TFS Api Create Build from Custom Process Template - tfs

I want to create gated.checkins programmatically.I have a custom build template.I can create build successfully but when I want to open created build definition from visual studio that time In Process tab selected template comes empty but if I go and selected my custom template that time I can see all my property's and configurations .
var newBuildDefinition =
buildServer.CreateBuildDefinition(TeamProject);
newBuildDefinition.Name = GatedName;
newBuildDefinition.Description = TFSConstantEnums.AutomaticGatedCreationDescription;
newBuildDefinition.ContinuousIntegrationType = ContinuousIntegrationType.All;
newBuildDefinition.QueueStatus = DefinitionQueueStatus.Enabled;
newBuildDefinition.TriggerType = triggerType;
// ..........................
newBuildDefinition.BuildController = Controllers(buildServer).FirstOrDefault();
var GatedTemplate = buildServer.QueryProcessTemplates(ConstantEnums.BuildProcessTemplateTeamProject).Where(p
=> p.ServerPath.Contains(ProcessTemplateName)).First();
newBuildDefinition.Process = GatedTemplate; //In here my custom template come and I can set it

Related

How to pass parameter to the table's datasource with Telerik Reporting?

I have a table on my Telerik report where I want to pass parameters with the table's data source. I also have a report datasource with parameter but this does not help with the table's datasource and its parameter. Any help would be appreciated.
this.table1.DataSource = "GetLocationsData";
You have to set the available values source and most probably filters:
Telerik.Reporting.ReportParameter reportParameter1 = new Telerik.Reporting.ReportParameter();
this.csvDataSource1 = new Telerik.Reporting.CsvDataSource();
this.table1 = new Telerik.Reporting.Table();
this.csvDataSource1.Source = "id,text\r\n1,a\r\n2,b\r\n3,c";
this.table1.DataSource = this.csvDataSource1;
this.table1.Filters.Add(new Telerik.Reporting.Filter("= Fields.text", Telerik.Reporting.FilterOperator.Equal, "= Parameters.paramString.Value"));
reportParameter1.AvailableValues.DataSource = this.csvDataSource1;
reportParameter1.AvailableValues.ValueMember = "=Fields.Text";
reportParameter1.Name = "paramString";
reportParameter1.Text = "String";
reportParameter1.Value = "a";
reportParameter1.Visible = true;
this.ReportParameters.Add(reportParameter1);
If this does not help you, you can have a look at the available reports that come with the installation - replace in the path below your Telerik Reporting version, mine is R3 2022. View Code (F7) on the report's designer.cs file:
C:\Program Files (x86)\Progress\Telerik Reporting R3 2022\Examples\CSharp\.NET Framework\ReportLibrary
Another option if you are stuck, is to create the report in the Visual Studio Designer and View the generated code (F7) on the yourreportname.designer.cs file.
If the report was created using the web report or standalone report designer you can import the report definition file (trdp, trdx, trbp) into Visual Studio (will be converted to type definition .cs file) first.
Reference:
https://docs.telerik.com/reporting/designing-reports/connecting-to-data/report-parameters/how-to-add-report-parameters
https://docs.telerik.com/reporting/designing-reports/connecting-to-data/report-parameters/overview

Can't preserve document core metadata (Created By, Modified By) when I import documents to SharePoint Document Library

I'm currently building a tool to migrate from a document management system to use SharePoint Online. The main challenge I'm facing is to preserve the details of document authors and creating time. I have checked bunch of of code online but I didn't get success with any of them.
Here are the approaches I used
SharePoint Rest API
Microsoft Graph API
CSOM (using console application)
Here is the code I have so far in CSOM but I'm still not able to update the Author field
li["Title"] = "Update from CSOM";
li["Created"] = DateTime.Now.AddYears(-5);
li["Author"] = author.Id;
li.UpdateOverwriteVersion();
clientContext.ExecuteQuery();
Any idea for how to do this, or if there is any other approach to achieve my goal?
The code works when I did test in my environment.
using (ClientContext context = new ClientContext("https://xxx.sharepoint.com/sites/lee"))
{
string s = "password";
SecureString passWord = new SecureString();
foreach (var c in s)
passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials("admin#xxx.onmicrosoft.com", passWord);
var author = context.Web.EnsureUser("Lee#xxx.onmicrosoft.com");
context.Load(author);
context.ExecuteQuery();
var _List = context.Web.Lists.GetByTitle("List1");
var li = _List.GetItemById(1);
li["Title"] = "Update from CSOM";
li["Created"] = DateTime.Now.AddYears(-5);
li["Author"] = author.Id;
li.UpdateOverwriteVersion();
context.ExecuteQuery();
}
You will need to update the Author and Editor fields at the same time in order to update the CreatedBy field. If you wish to update additional fields at the same time you can. Using SystemUpdate() does not update the Modified date whereas Update() does update the Modified date. See abbreviated sample below.
FieldUserValue userValue = new FieldUserValue();
User newUser = cc.Web.EnsureUser("newAuthor#xxx.onmicrosoft.com");
cc.Load(newUser);
cc.ExecuteQuery();
userValue.LookupId = newUser.Id;
item["Author"] = userValue;
item["Editor"] = userValue;
item.SystemUpdate();
cc.ExecuteQuery();

Creating default Userstorie or Tasks on creating a new iteration (TFS2013)

We work with TFS 2013 and every month we create a new iteration (vx.x.x.x etc). Every iteration has a standard set of Userstory's / tasks that need to be done to complete the iteration. Currently we need to create these workitems every month with the same data in them. Is there a way to automate this process? I was thinking about "Default work items" for an iteration, is that possible in TFS 2013?
Thanks in advance,
Tim
I don't think you can do it without writing some code. I suggest using TFS API and create some kind of tool which will create new iteration and required work items. E.g.
var tpc = new TfsTeamProjectCollection(new Uri("collection url, e.g. http://localhost:8080/tfs/DefaultCollection"));
var css = tpc.GetService<ICommonStructureService4>();
var store = tpc.GetService<WorkItemStore>();
var server = tpc.GetService<WorkItemServer>();
var project = store.Projects["MyProject"];
/*get root iteration node*/
NodeInfo rootIteration = css.ListStructures(project.Uri.ToString()).First(n => n.StructureType == "ProjectLifecycle");
/*create new iteration*/
css.CreateNode("TestIteration", rootIteration.Uri.ToString());
/*sync changes*/
server.SyncExternalStructures(WorkItemServer.NewRequestId(), project.Uri.ToString());
project.Store.RefreshCache();
/*create new bug in the new iteration*/
var bug = project.WorkItemTypes["Bug"].NewWorkItem();
bug.Title = "Test";
bug.AreaPath = "MyProject\\TestIteration";
bug.Save();

TFS Custom Field Reporting on Historical Value

Using Agile template on with some customized fields.
Custom-Field-X is a Drop Down List with allowed value set 0, 1, 2, 3 - this value could change daily.
Need a way to check if Custom-Field-X was ever set to 0 during its life time.
Using TFS2010.
Thanks!
I assume you are talking about a custom field you added for TFS workitems. You can use following code to find out whether the value was set to 0 or not. Alternately you can also use workItemStore.GetWorkItem(id) to get specific workitem by Id. You can find details about retrieving work items # http://pwee167.wordpress.com/2012/09/18/retrieving-work-items-using-the-team-foundation-server-api/.
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client; // You need to add reference to both these assemblies in your project
var collectionUri = new Uri("<TfsUrl>/<CollectionName>"); // For e.g. "http://tfs:8080/DefaultCollection"
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = projectCollection.GetService<WorkItemStore>();
var results = workItemStore.Query("SELECT * FROM WORKITEMS");
WorkItem workItem = results[0];
foreach (Revision revision in workItem.Revisions)
{
var originalValue = revision.Fields["Custom-Field-X"].OriginalValue;
var curretValue = revision.Fields["Custom-Field-X"].Value;
}

ZendAMF 1.11 and the missing source

We are trying to upgrade from an older version of Zend Framework to the most recent one (1.11).
We have to send some ArrayCollections to a Flex-app that I can not access. Previous versions of ZF's Zend_Amf_Value_Messaging_ArrayCollection have a source attribute which the newer versions don't have.
I have tried editing the Zend_Amf_Value_Messaging_ArrayCollection class to have that source property, but it seems like ZF doesn't send objects to the Flex-app (I've noticed that via a debugging proxy). The ArrayCollection still has the correct keys (AFAIK, going from 0 -> 3), but the values are NULL.
This is from a small test-file:
$c = new RoomCategoryVO();
$c->name = 'root';
$c->childCategories = new Zend_Amf_Value_Messaging_ArrayCollection();
$cc1 = new RoomCategoryVO();
$cc1->sortPriority = 2;
$cc1->name = $this->xml->roomService->windows;
$cc1->parentCategory = $c;
$cc1->childItems = new Zend_Amf_Value_Messaging_ArrayCollection();
$re11 = new ElementVO();
$re11->id = "simpleWindow";
$re11->name = $this->xml->roomService->window;
$re11->type = 'SIMPLE_WINDOW';
$re11->icon = 'assets/runtime/images/schemeIcons/simpleWindow.png';
//$cc1->childItems->source[] = $re11;
$cc1->childItems[] = $re11;
//$c->childCategories->source[] = $cc1;
$c->childCategories->append($cc1);
In comments you see the 'old' way of ZendAMF, below them the new way.
Is there any way to get ZendAMF use the source property again without going back to an older version of ZF?
We finally settled on using ZendAMF, with only the Zend_Amf_Value_Messaging_ArrayCollection from the previous version being:
class Zend_Amf_Value_Messaging_ArrayCollection
{
public $source;
}
This allows us still using the source property.

Resources