I have next situation and I am stack.
I am using Microsoft.TeamFoundation classes to get workitems from stored query with c#. I know server name, project name and stored query name. So I can execute stored query and receive all WorkItems.
But than I have to create a direct link to this item. According to the documentation, this link should be like
http:// ServerName:8080/tfs/CollectionName/ProjectName/_workitems/edit/Id
So, before executing query I know ServerName, ProjectName and work item's Id. But I cant find ProjectName anywhere.
So my question is. How, knowing ServerName, ProjectName, WorkItemId and Stored Query name get CollectionName?
Or. How to create link to the work item knowing ItemsId?
P.S. GetArtifactUrl is not the right way.
Thanks for help!
Afraid there is no such API to achieve this. However, as a workaround, you can list all collection's name through client API such as below:
Uri configurationServerUri = new Uri(URL);
TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(configurationServerUri);
ITeamProjectCollectionService tpcService = configurationServer.GetService<ITeamProjectCollectionService>();
foreach (TeamProjectCollection tpc in tpcService.GetCollections())
{
ListCollection.Add(tpc.Name);
}
More ways for your reference:
How to get all collections from TFS
Retrieve the List of Team Project Collections from TFS 2010 Client APIs
Related
I am using below flat query to get bug details for array of work item ids passed as argument.
Below query works perfectly fine, but it throws error in some cases "TF26180: An item with this ID already exists in the input Array"
Reason is, ids array has duplicate ids, which is expected in my case. Is there any way to ignore this check or by pass this ?
var flatQuery = new Query(_store, detailsWiql.ToString(), ids);
WorkItemCollection workitems = flatQuery.RunQuery();
foreach (WorkItem wi in workitems)
{
WorkItemType worktype = wi.Type;
worktypename = worktype.Name;
}
Thanks in advance
I don't think we can ignore or by pass this check, the exception is defined in Microsoft.TeamFoundation.WorkItemTracking.Common assembly. See https://www.powershellgallery.com/packages/PSPlus.Tfs/0.0.1.104/Content/Microsoft.TeamFoundation.WorkItemTracking.Common.xml
There is a doubt here, why you have duplicated work items?
Generally, the work item ID is unique in TFS server.
I suggest you delete the duplicated work items first, backup them if needed, then create new work items to track the related tasks/features.
UPDATE:
As a workaround, you can try using the WIQL query with REST API to get the IDs first, See A flat query. The write code to serach work item details with ID in loop. See Get a workitem with REST API.
Besides, you can have a try with the Wiql Editor, it can query the basic work item information directly.
I had a similar issue, so when I was creating the ids array, I just ensured it was distinct:
// Capture ids of results in an array
var ids = (from WorkItemLinkInfo info in result select info.TargetId).Distinct().ToArray();
// Query a list of WorkItem IDs we want more info about
wiql = #"SELECT * FROM WorkItems";
q = new Query(App.workItemStore, wiql, ids);
var workItems = q.RunQuery();
Hopefully the title says it all. I've retrieved the results of adhoc queries using the WorkItemStore.Query() method and created Query objects via the new syntax. However after examining the object model for Query objects, QueryFolders, QueryItems and the WorkItemStore I can't find a way to create and save a WIQL query to the store/TFS Server.
Any suggestions?
You can use QueryHierarchy.Save Method to save the query. For example:
QueryDefinition query = new QueryDefinition("My Query", "Select * from WorkItems Where [System.AssignedTo] = #me", parentFolder);
myproject.QueryHierarchy.Save();
Check blog for more information: http://blogs.msdn.com/b/team_foundation/archive/2010/06/16/work-item-tracking-queries-object-model-in-2010.aspx
Since Intuit has broken the QBFC reference today, I have to ask a question that I could normally look up. (I do not know who to complain to).
I normally query by list_id like so:
ICustomerQuery CustomerQueryRq = requestMsgSet.AppendCustomerQueryRq();
CustomerQueryRq.ORCustomerListQuery.ListIDList.Add(qb_list_id);
Is there a way to query by AccountNumber?
Thanks!
No, QuickBooks does not support querying by the AccountNumber field.
This is old, but maybe worth adding.
Create a temp "cached" object, containing all the properties you want to search for. Them when launching, and whenever customer changes are made, cache a list of custom QBcustomersForSearch objects with only the properties that you would want to use for the search.
class qbCustomerForSearch
property email as string
property accountnumber as string
property whatever as string
property QBListId as string
end class
Cache / create a list of these objects when and as needed, and search your list. Once located in your list, use the listID to identify the QB customer.
Cheers
I'd like to pass in parameters into a query so that I can use relationship properties in CreateUnique. I'd prefer to use the parameters rather than just doing a string format so that it can protect (Am I right in aassuming parameters are cypher injeciton protected?) against cypher injection.
var query = client.Cypher.Start(
new CypherStartBitWithNodeIndexLookup("left", AUTOINDEX, PrimaryIndexKey, uname),
new CypherStartBitWithNodeIndexLookupWithSingleParameter("right", AUTOINDEX, luceneQuery)
).CreateUnique("left-[r:Installed {DeviceId:{DeviceId},OS:{OS}}]->right").Return<Software>("right");
Update: It was a simple addition in the end so I just went ahead and added it. As of 1.0.0.517, the proposal linked to below is now implemented and available on NuGet.
Your query can be:
var query = client
.Cypher
.Start(
new CypherStartBitWithNodeIndexLookup("left", AUTOINDEX, PrimaryIndexKey, uname),
new CypherStartBitWithNodeIndexLookupWithSingleParameter("right", AUTOINDEX, luceneQuery)
)
.CreateUnique("left-[r:Installed {DeviceId:{DeviceId},OS:{OS}}]->right")
.WithParam("DeviceId", 123)
.WithParam("OS", "Windows 8")
.Return<Software>("right");
You can't do this in a nice way right now.
Yes, Cypher parameters are all safe from injection. We pass them across the wire in an entirely different construct that keeps them separate from the query text. In Neo4j, they are stored independently of the query's execution plan.
I've opened an issue at https://bitbucket.org/Readify/neo4jclient/issue/66/support-custom-parameters-in-cypher-fluent, with a proposed syntax, so that we can implement it. If you review the proposal and collaborate over there, we can get this in pretty quickly.
As a workaround, you could probably do:
var query = client
.Cypher
.Start(
new CypherStartBitWithNodeIndexLookup("left", AUTOINDEX, PrimaryIndexKey, uname),
new CypherStartBitWithNodeIndexLookupWithSingleParameter("right", AUTOINDEX, luceneQuery)
)
.CreateUnique("left-[r:Installed {DeviceId:{DeviceId},OS:{OS}}]->right")
.Return<Software>("right")
.Query;
query.QueryParameters.Add("DeviceId", 123);
query.QueryParameters.Add("OS", "Windows 8");
var results = client.ExecuteGetCypherResults<Software>(query);
I wrote that code right here in the answer box though, and haven't tested it, and it's horrible, and ugly, and I'd kind of like you to not use it.
I am writing a tool that needs to access all the revisions of a TFS workitem template.
The Workitem has a Revisons collection, and Rev property that returns the number of revisions.
When I try and do a foreach through the collection, even though it contains 6 "entries" in my test workitem, the collection is empty.
To work around this I am using the GetWorkItem(WorkItemID, RevisionID), incrementing the revision ID in a for loop to get the revisions. It seems crazy taht I have to do this and there collection that doesn't contain what it is supposed to.
Am I missing something here, or is this simply a bug in the TFS client API.
After much digging, it is quite clear to me now that if you want to get all the revisions of a work item, you must explicitly load the revision(2) that you want, and this makes the revisions collection pretty much useless.
Depending on how your retrieving the work item it may only be partially loaded. Try calling the Open method on the work item before accessing the Revisions collection.
Where are you getting the workitem? I know when I was getting version history of files with sourceControl.QueryHistory I had to set one of my parameters (bool include Changes) to true in order to get the changes in the changeset.
I'm using the Microsoft.TeamFoundation.Controls.PickWorkItemsControl to select the work items I need. After that the revsionsCollectoin is compleet. Maybe this helps:
// select the workitems using the picker
ArrayList workItems = _workItemPicker.Control.SelectedWorkItems();
// after that use a foreach and output all history included in each revision
private void PrintHistory(WorkItem workitem)
{
RevisionCollection revisions = workitem.Revisions;
foreach (Revision revision in revisions)
{
String history = (String) revision.Fields["History"].Value;
Console.WriteLine("**** Revision {0}", revision.Fields["Title"], revision.Fields["Changed Date"]);
foreach (Field field in revision.Fields)
{
Console.WriteLine("* field {0}:{1} ", field.Name, field.Value);
}
Console.WriteLine("****");
Console.WriteLine();
}
}