/// <summary> /// The on associate command. /// </summary> private void OnPlanCommand() { try { if (this.CommandText.Equals("Associate to new plan")) { var availablePlans = this.rest.GetAvailableActionPlan(this.config, this.associatedProject.Key); var newPlan = PromptUserForNewPlan.Prompt(availablePlans); if (newPlan == null) { return; } foreach (var existentPlan in availablePlans) { if (existentPlan.Name.Equals(newPlan)) { var associatedWithExistent = QuestionUser.GetInput("Plan exists already, do you want to associate with current plan?"); if (associatedWithExistent) { var replies = this.rest.PlanIssues(this.config, this.model.SelectedItems, existentPlan.Key.ToString()); foreach (var itemreply in replies) { this.manager.ReportMessage(new Message() { Data = "Plan Operation Result: " + itemreply.Key + " : " + itemreply.Value }); } } return; } } try { var plan = this.rest.CreateNewPlan(this.config, this.associatedProject.Key, newPlan); var replies = this.rest.PlanIssues(this.config, this.model.SelectedItems, plan.Key.ToString()); foreach (var itemreply in replies) { manager.ReportMessage(new Message() { Data = "Plan Operation Result: " + itemreply.Key + " : " + itemreply.Value }); } } catch (Exception ex) { UserExceptionMessageBox.ShowException("Cannot Create Plan, Make sure you have permissions", ex); } } else { if (this.CommandText.Equals("Unplan")) { var replies = this.rest.UnPlanIssues(this.config, this.model.SelectedItems); foreach (var itemreply in replies) { this.manager.ReportMessage(new Message() { Data = "Unplan Operation Result: " + itemreply.Key + " : " + itemreply.Value }); } } else { var plans = this.rest.GetAvailableActionPlan(this.config, this.associatedProject.Key); foreach (var plan in plans) { if (plan.Name.Equals(this.CommandText)) { var replies = this.rest.PlanIssues(this.config, this.model.SelectedItems, plan.Key.ToString()); foreach (var itemreply in replies) { this.manager.ReportMessage(new Message() { Data = "Plan Operation Result: " + itemreply.Key + " : " + itemreply.Value }); } return; } } } } } catch (Exception ex) { UserExceptionMessageBox.ShowException("Cannot Perform Operation in Plan: " + ex.Message + " please check vs output log for detailed information", ex); } }
/// <summary> /// The on associate command. /// </summary> private void OnPlanCommand() { try { if (this.CommandText.Equals("Associate to new plan")) { var availablePlans = this.rest.GetAvailableActionPlan(this.config, this.associatedProject.Key); var newPlan = PromptUserForNewPlan.Prompt(availablePlans); if (newPlan == null) { return; } this.AssociateToNewPlan(availablePlans, newPlan); foreach (var issue in this.model.SelectedItems) { var issueData = issue as Issue; issueData.ActionPlanName = newPlan.Name; issueData.ActionPlan = newPlan.Key; } this.ReloadPlanData(this.parent); } else { if (this.CommandText.Equals("Unplan")) { this.UnPlanIssues(); foreach (var issue in this.model.SelectedItems) { (issue as Issue).ActionPlanName = string.Empty; (issue as Issue).ActionPlan = Guid.Empty; } } else { var plans = this.rest.GetAvailableActionPlan(this.config, this.associatedProject.Key); foreach (var plan in plans) { if (plan.Name.Equals(this.CommandText)) { this.AttachToExistentPlan(plan); foreach (var issue in this.model.SelectedItems) { (issue as Issue).ActionPlanName = plan.Name; (issue as Issue).ActionPlan = plan.Key; } return; } } } } } catch (Exception ex) { UserExceptionMessageBox.ShowException("Cannot Perform Operation in Plan: " + ex.Message + " please check vs output log for detailed information", ex); } }