const int NumThreadsToRunInParallel = 8; // Tune this for your DB server performance characteristics public static void FillDataSet(ref DataSet Source) { WorkItemDefinition Work; foreach (DataRow r in Source.Tables["queries"].Rows) { Work = new WorkItemDefinition(); Work.Query = r["QueryStatement"].ToString(); Work.QSource = r["QuerySource"].ToString(); Work.TableName = r["TableName"].ToString(); EnQueueWork(Work); } System.Threading.ThreadStart NewThreadStart; NewThreadStart = new System.Threading.ThreadStart(ProcessPendingWork); for (int I = 0; I < NumThreadsToRunInParallel; I++) { System.Threading.Thread NewThread; NewThread = new System.Threading.Thread(NewThreadStart); //NewThread.IsBackground = true; //Do this if you want to allow the application to quit before these threads finish all their work and exit ThreadCounterInc(); NewThread.Start(); } while (ThreadCounterValue > 0) { System.Threading.Thread.Sleep(1000); } }
private static void EnQueueWork(WorkItemDefinition Work) { lock (SyncRoot) { PendingWork.Enqueue(Work); } }
private static void FeedWorkItemData(ICollection <WorkItemDefinition> workItemDefinitionCollection, TfsTeamProjectCollection tpc, string projectName) { WorkItemStore wis = tpc.GetService <WorkItemStore>(); Microsoft.TeamFoundation.WorkItemTracking.Client.Project project = wis.Projects[projectName]; foreach (WorkItemType wit in project.WorkItemTypes) { WorkItemDefinition witDefinition = new WorkItemDefinition() { Name = wit.Name, Description = wit.Description }; IEnumerable <Category> categories = project.Categories.Where(x => x.WorkItemTypes.Contains(wit)); foreach (Category item in categories) { witDefinition.Categories.Add(item.Name); } FieldDefinition systemState = wit.FieldDefinitions.TryGetByName("System.State"); foreach (string allowedValue in systemState.AllowedValues) { int stateCount = wis.QueryCount("Select System.Id From WorkItems Where System.TeamProject = '" + projectName + "' And System.WorkItemType = '" + witDefinition.Name + "' And System.State = '" + allowedValue + "'"); witDefinition.StateCollection.Add(allowedValue, stateCount); } workItemDefinitionCollection.Add(witDefinition); } }
public void Init() { instance = new WorkItemDefinition(); }