static void Main(string[] args) { string connectionUrl = null, token = null, project = null; //args = new string[] { "/url:http://cmp02-app05:8080/tfs/DefaultCollection/", "/project:WebSphere" }; args = new string[] { "/url:https://kanchansharmaqa.visualstudio.com/DefaultCollection/", "/project:Training" }; try { CheckArguments(args, out connectionUrl, out project); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } Console.WriteLine("Executing quick start sample to create a Bug..."); Console.WriteLine(""); string BugTitle = "Demo bug title TFS API"; string Description = "This is a demo 1 bug description"; int Priority = 3; string Area = @"Training"; string Iteration = @"Training\Release 1\Sprint 1"; string ReproSteps = "Click the screen"; string Assignee = "Kanchan Sharma"; //todo: Create a new bug using TFS API. TfsUtility tfsUtility = new TfsUtility(); //Project tfsProject = tfsUtility.GetTeamProject(connectionUrl, project); var result = tfsUtility.CreateBug(connectionUrl, project, BugTitle, Description, Area, Iteration, Assignee, ReproSteps); }
/// <summary> /// Create work item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void workItemCreateBtn_Click(object sender, EventArgs e) { if (Settings.settings.Validate() && ValidateWorkItemFields()) { try { _syncContext.Send(new SendOrPostCallback((state) => ChangeEnabledStateOfControls(false)), null); var category = categoriesComboBox.Text; var title = titleTextBox.Text; var description = descriptionTextBox.DocumentText; var withAttachments = includeAttachmentsCheckBox.Checked; var createdWorkItem = await TfsUtility.CreateWorkItem(title, description, category, _outlookItem.Attachments, withAttachments); _syncContext.Send(new SendOrPostCallback((state) => { var workItemCreatedForm = new WorkItemCreated(createdWorkItem.Id.Value); workItemCreatedForm.StartPosition = FormStartPosition.CenterParent; workItemCreatedForm.ShowDialog(); this.Close(); }), null); } catch (System.Exception ex) { _syncContext.Send(new SendOrPostCallback((state) => MessageBox.Show(TfsUtility.ProcessException(ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)), null); } finally { _syncContext.Send(new SendOrPostCallback((state) => { Globals.ThisAddIn.ChangeTaskPaneVisibility(false); ChangeEnabledStateOfControls(true); }), null); } } }
private async void addCommentButton_Click(object sender, EventArgs e) { if (ValidateCommentFields()) { try { _syncContext.Send(new SendOrPostCallback((state) => ChangeEnabledStateOfControls(false)), null); var complexity = _resolvedStateChosen ? (string)complexityComboBox.SelectedItem : null; var comment = commentTextBox.DocumentText; var withAttachments = includeAttachmentsCheckBox.Checked; var commentEntity = await TfsUtility.AddCommentToWorkItem(_workItem.Id, (string)statesComboBox.SelectedItem, comment, _mailItem.Attachments, withAttachments, complexity); _syncContext.Send(new SendOrPostCallback((state) => this.Close()), null); } catch (System.Exception ex) { MessageBox.Show(TfsUtility.ProcessException(ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { _syncContext.Send(new SendOrPostCallback((state) => { Globals.ThisAddIn.ChangeTaskPaneVisibility(false); ChangeEnabledStateOfControls(true); }), null); } } }
public async Task CreateWorkItem(Office.IRibbonControl control) { Globals.ThisAddIn.ChangeTaskPaneVisibility(false); // Determine subject of selected item if (_explorer?.Selection?.Count > 0) { var mailItem = _explorer.Selection[1] as MailItem; if (mailItem == null) { return; } _createWorkItemButtonEnabled = false; ribbon.InvalidateControl("CreateWorkItem"); try { if ((Models.WorkItem.CategoriesBySource?.Count > 0 && Models.WorkItem.CategoriesByComplexity?.Count > 0) || await TfsUtility.ValidateVssSettings()) { var workItems = await TfsUtility.FindWorkItemsByTitle(HtmlUtility.RemoveSubjectAbbreviationsFromSubject(mailItem.Subject)); synchronizationContext.Send(new SendOrPostCallback(o => Globals.ThisAddIn.FillTaskPane(workItems, mailItem)), null); } } catch (System.Exception ex) { MessageBox.Show(TfsUtility.ProcessException(ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { synchronizationContext.Send(new SendOrPostCallback(o => EnableCreateNewWorkItemButton()), null); } } }
public void OpenDocumentation(Office.IRibbonControl control) { try { System.Diagnostics.Process.Start(Settings.settings.ProjectURL); } catch (System.Exception ex) { TfsUtility.ProcessException(ex); } }
private async Task <bool> Validate(bool showMessage = true) { var orgName = orgNameTextBox.Text != null?orgNameTextBox.Text.Trim() : null; var projectName = projectNameTextBox.Text != null?projectNameTextBox.Text.Trim() : null; var patToken = patTokenTextBox.Text != null?patTokenTextBox.Text.Trim() : null; var categoryBySource = categoryBySourceFieldTextBox.Text != null?categoryBySourceFieldTextBox.Text.Trim() : null; var categoryByComplexity = categoryByComplexityTextBox.Text != null?categoryByComplexityTextBox.Text.Trim() : null; var workItemType = workItemTypeTextBox.Text != null?workItemTypeTextBox.Text.Trim() : null; var errorMessage = ""; if (string.IsNullOrEmpty(orgName)) { errorMessage += "organization name field is empty\n"; } if (string.IsNullOrEmpty(projectName)) { errorMessage += "project name field is empty\n"; } if (string.IsNullOrEmpty(patToken)) { errorMessage += "PAT token field is empty\n"; } if (string.IsNullOrEmpty(workItemTypeTextBox.Text)) { errorMessage += "work Item type field is empty\n"; } if (string.IsNullOrEmpty(categoryBySource)) { errorMessage += "categoryBySource field is empty\n"; } if (string.IsNullOrEmpty(categoryByComplexity)) { errorMessage += "categoryByComplexity field is empty\n"; } if (categoryByComplexity == categoryBySource) { errorMessage += "categoryByComplexity and categoryBySource should not be equal\n"; } if (showMessage && !string.IsNullOrEmpty(errorMessage)) { MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { await TfsUtility.ValidateVssSettings(workItemType, projectName, categoryBySource, categoryByComplexity, orgName, patToken); return(true); } catch (System.Exception ex) { if (showMessage) { MessageBox.Show(TfsUtility.ProcessException(ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } return(false); }