We've moved to the "Single Team Project" way of working, and thus our different teams are split up into different areas (because that works for us).
Our URLs are http://tfsserver/ProjectA, http://tfsserver//ProjectB etc.. etc.. which auto populates the Area, and thus makes sure all the work items go into the correct place.
However, all our queries are very simple for each team. This has led us to have query folders which duplicate many of the queries, but scope down to single areas, to make sure that query only targets the right work items.
Is there a #CurrentTeam macro which we can apply to our queries to prevent duplicating all our queries?
We can't be the only people with this problem can we - or we're doing it wrong.
No, there's no such thing right now in TFS. The only predefined macros are: #project, #me and #today. You can create your own macros when using TFS object model for running queries but there's no way to do it in the UI.
Sample code:
var tpc = new TfsTeamProjectCollection(new Uri("http://localhost:8080/tfs/DefaultCollection"));
var store = tpc.GetService<WorkItemStore>();
Query query = new Query(store, "select * from workitems where System.AreaPath = #TeamArea", new Dictionary<string, string>() { { "TeamArea", "<Team area path>" } });
query.RunQuery();
Related
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
I'm using a split app layout for editing and creating new employees. Therefore I do have a button "Add employee". After submitChanges is done, I want to find this new employee in the master list and select it.
I am using an event-bus for the communication between detail-controller and master-controller.
fnAfterSubmitChangesSuccess: function(sChanel, sEvent, oData) {
var oResponseData = oData.__batchResponses[0].__changeResponses[0].data;
var sBindingPath = oModel.createKey("/EmployeeSet", {Begda: oData.Begda, Endda: oData.Endda, Pernr: oData.Pernr}).replace(/:\s*/g, "%3A");
},
Is there a way to find the index of a specific listitem by the using binding-path. Or is there another way to solve this problem, instead of looping over the whole list a do a comparison?
I'm afraid the only way to find the index of a specific listItems by binding-path is to walk through the collection of list items. So, I'm afraid that a very plain and short answer would be "No".
It's quite easy though, code is not that lengthy, and it also shouldn't cost to much performance if you're not talking about humongous lists. You will have to walk through the list of items though. Once you have found the item with a binding to the context path you're looking for, you can select it using setSelectedItem, like so:
var list = this.getView().byId("list");
jQuery.each(list.getList(), function(idx, item) {
if (items.getBindingContext().getPath = sBindingPath) {
list.setSelectedItem(item);
}
});
Note: Do keep in mind that if you're working with OData services and are working with a so-called 'growing list', the entry you're looking for may not necessarily be in the list.
Apologies, wish I could give you a more pleasant answer.
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 know this has been asked before in several ways but none of the answers seem applicable to me - or correct - or current, so I'll try again.
I have a large model with several intstances of inherited entities. One example is a Timetable that contains a collection of TimetableEvents. There are several sub-types of TimetableEvent, such as an InterviewTimetableEvent, BreakTimetableEvent and an ExercisetimeTableEvent. ExerciseTimetableEvent has a relationship to an Exercise entity.
I need to use self-tracking entities as I'm using a WCF back end to serve up data to several WPF clients in a stateless fashion.
So, I need to eager load everything and I thought that self-tracking entities would automatically do this but it appears they dont.
So, to get a timetable I need to do something like this:
var tt = (from s in ESSDataContainer.Timetables
.Include("TimetableEvents")
where s.TimetableId == timetableid
select s).FirstOrDefault();
This will give me the TimetableEvents but not the Exercises that are related to the ExerciseTimetableEvents. Ive tried the following (and several other suggestions) without luck:
var tt = (from s in ESSDataContainer.Timetables
.Include("TimetableEvents")
.Include("ExerciseTimetableEvents.Exercise")
where s.TimetableId == timetableid
select s).FirstOrDefault();
Is there a solution to this?
If not I'll go back to normal context tracking and connect to the database from a local container rather than using WCF.
Cheers
It's a bit tricky, but possible:
var tt = (from s in ESSDataContainer.Timetables
where s.TimetableId == timetableid
select new
{
TimeTable = s,
Events = s.TimeTableEvents,
Exercise = s.TimeTableEvents.OfType<ExerciseTimetableEvents>()
.Select(ett => ett.Exercise)
}).Select(s => s.TimeTable)
.AsEnumerable()
.FirstOrDefault();
Clear as mud, but, hey: No magic strings! Also, it has the advantage that it actually works....
There is a Proposal for this issua at Microsoft Connect:. If you think this worthy you can vote for it.
I have coded three select statements in stored procedure in Microsoft SQL Server 2005. Both select statements return multiple number of records and table list for select statements is different. One select records from a master table and the other from a child table. In C# code I want to get all these records and put all the data in one object. I am using SqlDataReader. Is it possible with it or should i do something else.
You use the NextResult method on the datareader to navigate with multiple results from a query.
To loop through all data you would do something like this:
var moreResults = true;
while (moreResults)
{
while (reader.Read())
{
...
}
moreResults = reader.NextResult();
}
So with that as a background, and assuming the master resultset comes first, populating master and detail objects could be done like this:
First, build up a dictionary of the Master records:
var masters = new Dictionary<int, Master>();
var idOrdinal = reader.GetOrdinal("id");
while (reader.Read())
{
var id = reader.GetInt32(idOrdinal);
masters.Add(id, new Master{Id=id, ....});
}
Next, move on to detail records and add those to their corresponding master:
reader.NextResult();
var masterIdOrdinal = reader.GetOrdinal("masterId");
while (reader.Read())
{
var masterId = reader.GetInt32(masterIdOrdinal);
var master = masters[masterId];
master.Details.Add(new Detail{....});
}
You should obviously replace column names with what you have in your data as well as supply the full initialization of Master and Detail objects.
If the detail resultset is sorted on master id, the last loop could be optimized to only lookup each master once from the dictionary. If the resultsets are small though, the gain would not be that huge.
...one select records from master table
and other from child table .in c# code
i want to get all this record and put
all this data in one object...
Peter's solution works to solve the basic problem of retrieving multiple results with a single DataReader. However, If you want to save your data to an object which replicates the relationship between the Master-Details tables, you should be using a DataSet instead.
DataSets can contain multiple DataTables and provide full support for inherent relationships between the tables by allowing creation of DataRelations between the tables. Then you can get related records for each scenario by calling GetChildRows() or GetParentRows() from the Master or Details tables respectively.
There are probably many samples online that illustrate how to do this. Here's one discussion thread from my Group where I have listed the steps and provided some code to demonstrate the procedure.