//------------------------------------------------------------------------------------ /// <summary> /// Background worker for the ProductGroup query. /// </summary> //------------------------------------------------------------------------------------ void ProductGroupQuery_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { BackgroundTask taskWorker = e.Argument as BackgroundTask; taskWorker.ReportProgress(0, "", "Loading Product Groups..."); try { List <ItemTypeID> typeList = new List <ItemTypeID>(); typeList.Add(ItemTypeID.ProductGroup); typeList.Add(ItemTypeID.HelpContent); ActiveItemTypeQuery query = new ActiveItemTypeQuery(ScheduleStore.Instance, null, typeList, ShouldRefresh.No); BackgroundTaskResult queryResult = ScheduleStore.Instance.ExecuteQuery(this, query, ShouldRefresh, taskWorker, false); if (!CheckResults(taskWorker, e, queryResult)) { return; } e.Result = new BackgroundTaskResult { ResultType = ResultType.Completed }; } catch (Exception exception) { Planner.Instance.WriteToEventLog(exception.Message); Planner.Instance.WriteToEventLog(exception.StackTrace); e.Result = new BackgroundTaskResult { ResultType = ResultType.Failed, ResultMessage = exception.Message }; return; } }
//------------------------------------------------------------------------------------ /// <summary> /// Background worker that executes all planner store queries. /// </summary> //------------------------------------------------------------------------------------ void PlannerQueryTask_DoWork(object sender, DoWorkEventArgs e) { BackgroundTask taskWorker = e.Argument as BackgroundTask; const int totalTasks = 4; int currentTask = 1; { // First query for the items that are global to all product groups. taskWorker.ReportProgress((currentTask * 100) / totalTasks, "", "Looking for your product group..."); List <ItemTypeID> typeList = new List <ItemTypeID>(); typeList.Add(ItemTypeID.ProductGroup); typeList.Add(ItemTypeID.Train); typeList.Add(ItemTypeID.Persona); typeList.Add(ItemTypeID.HelpContent); //// ActiveItemTypeQuery query = new ActiveItemTypeQuery(ScheduleStore.Instance, null, typeList, ShouldRefresh); bool deferItemCreationforScheduleItems = ShouldRefresh == ShouldRefresh.Yes ? true : false; BackgroundTaskResult queryResult = ScheduleStore.Instance.ExecuteQuery(this, query, ShouldRefresh, taskWorker, deferItemCreationforScheduleItems); if (!CheckResults(taskWorker, e, queryResult)) { return; } // Query for bugs that users have filed against OPlanner //OPlannerBugsQuery bugsQuery = new OPlannerBugsQuery(ScheduleStore.Instance, ShouldRefresh); //queryResult = ScheduleStore.Instance.ExecuteQuery(this, bugsQuery, ShouldRefresh, taskWorker, deferItemCreationforScheduleItems); //if (!CheckResults(taskWorker, e, queryResult)) //{ // return; //} CurrentProductGroup = GetItem <ProductGroupItem>(m_currentProductGroupKey); if (CurrentProductGroup != null) { CurrentProductGroup.EnsureProductGroupMembers(); } currentTask++; // Query for all pillars first taskWorker.ReportProgress((currentTask * 100) / totalTasks, "", "Opening the plan for your product group..."); typeList.Clear(); typeList.Add(ItemTypeID.Pillar); query = new ActiveItemTypeQuery(ScheduleStore.Instance, m_currentProductGroupKey, typeList, ShouldRefresh); queryResult = ScheduleStore.Instance.ExecuteQuery(this, query, ShouldRefresh, taskWorker, deferItemCreationforScheduleItems); if (!CheckResults(taskWorker, e, queryResult)) { return; } // Next query for all the planner items associated with this product group taskWorker.ReportProgress((currentTask * 100) / totalTasks, "", "Loading team member information..."); typeList.Clear(); typeList.Add(ItemTypeID.GroupMember); typeList.Add(ItemTypeID.ScrumTeam); typeList.Add(ItemTypeID.OffTime); query = new ActiveItemTypeQuery(ScheduleStore.Instance, m_currentProductGroupKey, typeList, ShouldRefresh); queryResult = ScheduleStore.Instance.ExecuteQuery(this, query, ShouldRefresh, taskWorker, deferItemCreationforScheduleItems); if (!CheckResults(taskWorker, e, queryResult)) { return; } currentTask++; OnScheduleMetadataReady(); // Next, query for all Experiences, Features, and workItems owned by the product group List <string> groupMembers = Planner.Instance.GetMemberAliases(); if (groupMembers.Count > 0) { AsyncObservableCollection <TrainItem> currentTrains = GetQueryableTrains(); List <int> pillarPathIDs = GetAllPillarPathIDs(); // Get all experience items first, so they'll all be available once we query for features and // attempt to associate them with their experiences. taskWorker.ReportProgress((currentTask * 100) / totalTasks, "", "Loading your team's experiences..."); typeList.Clear(); typeList.Add(ItemTypeID.Experience); List <int> treeIds = new List <int>(); foreach (int pathID in pillarPathIDs) { treeIds.Add(pathID); } bool deferItemCreationForHostItems = DeferItemCreationForHostItems; HostItemQuery hostQuery = new HostItemQuery(HostItemStore.Instance, typeList, groupMembers, treeIds, currentTrains, ShouldRefresh, RefreshType); queryResult = HostItemStore.Instance.ExecuteQuery(this, hostQuery, ShouldRefresh, taskWorker, deferItemCreationForHostItems); if (!CheckResults(taskWorker, e, queryResult)) { return; } // Get all features next, so they'll all be available once we query for work items and // attempt to associate them with their parent features. taskWorker.ReportProgress((currentTask * 100) / totalTasks, "", "Loading your team's features..."); typeList.Clear(); typeList.Add(ItemTypeID.BacklogItem); hostQuery = new HostItemQuery(HostItemStore.Instance, typeList, groupMembers, treeIds, currentTrains, ShouldRefresh, RefreshType); queryResult = HostItemStore.Instance.ExecuteQuery(this, hostQuery, ShouldRefresh, taskWorker, deferItemCreationForHostItems); if (!CheckResults(taskWorker, e, queryResult)) { return; } // Then get the work items. taskWorker.ReportProgress((currentTask * 100) / totalTasks, "", "Loading your team's work items..."); typeList.Clear(); typeList.Add(ItemTypeID.WorkItem); hostQuery = new HostItemQuery(HostItemStore.Instance, typeList, groupMembers, treeIds, currentTrains, ShouldRefresh, RefreshType); queryResult = HostItemStore.Instance.ExecuteQuery(this, hostQuery, ShouldRefresh, taskWorker, deferItemCreationForHostItems); if (!CheckResults(taskWorker, e, queryResult)) { return; } } e.Result = new BackgroundTaskResult { ResultType = ResultType.Completed }; } }