public static async Task <Issue> CreateDatabaseTask(IssueFields fields) { IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng"); var issue = jira.CreateIssue("DATABASE", "Task", fields); return(issue); }
public IssueResponse GetIssue(string IssueApiId, IssueFields IssueFields = IssueFields.ALL) { string _RequestResourceUrl = ApiResources.Issue.Resource + "/" + IssueApiId; Parameter _FieldsParam = null; if (IssueFields != IssueFields.ALL) { _FieldsParam = RestHelper.BuildParameter(ApiResources.Issue.Parameters.FieldList, EnumHelper.CleanEnumAndReturnAsLowercaseString(IssueFields), ParameterType.QueryString); } return(GetResource <IssueResponse>(_RequestResourceUrl, _FieldsParam)); }
public void Sort(IssueFields sortField, bool isAscending) { switch (sortField) { case IssueFields.Id: InnerList.Sort(new IdComparer()); break; case IssueFields.Title: InnerList.Sort(new TitleComparer()); break; case IssueFields.Category: InnerList.Sort(new CategoryComparer()); break; case IssueFields.Assigned: InnerList.Sort(new AssignedComparer()); break; case IssueFields.Creator: InnerList.Sort(new CreatorComparer()); break; case IssueFields.Owner: InnerList.Sort(new OwnerComparer()); break; case IssueFields.Priority: InnerList.Sort(new PriorityComparer()); break; case IssueFields.Status: InnerList.Sort(new StatusComparer()); break; case IssueFields.Milestone: InnerList.Sort(new MilestoneComparer()); break; case IssueFields.Created: InnerList.Sort(new CreatedComparer()); break; } if (!isAscending) { InnerList.Reverse(); } }
public void CreateNewIssue() { JiraClient client = new JiraClient("https://teamsupport.atlassian.net", "michael", "Welcome1"); IssueFields fields = new IssueFields(); fields.description = "This is a test description"; Comment comment = new Comment(); comment.body = "This is a test comment"; fields.comments.Add(comment); fields.summary = "This is a test summary"; var issue = client.CreateIssue("CON", "New Feature", fields); Assert.AreEqual("This is a test description", issue.fields.description); }
public static IssueNewFields Get(IssueFields ori) { return(new IssueNewFields() { assignee = new OnlyId(ori.assignee.accountId), issuetype = new OnlyId(ori.issuetype.id), components = ori.components.Select(p => new OnlyId(p.id)).ToList(), project = new OnlyId(ori.project.id), description = new CommentObjHeader() { type = "doc", version = 1, content = new Comments.IContent[] { new Comments.Paragraph(new Comments.Text("Clonacion de original")) }.ToList() }, priority = new OnlyId(ori.priority.id), summary = ori.summary }); }
public Issue AddIssue(IssueFields issueFields) { IRestRequest request = new RestRequest(string.Format("{0}/issue", JiraAPIServiceURI), Method.POST); request.RequestFormat = DataFormat.Json; Issue issue = new Issue() { Fields = issueFields }; List <Field> fields = GetFields(); //TODO //foreach (KeyValuePair<string, CustomField> customfield in issueFields.CustomFields) //{ // Field field = fields.Where(f => f.ID.Equals(customfield.Key)).FirstOrDefault(); // switch (field.Schema.Custom) // { // case "com.atlassian.jira.plugin.system.customfieldtypes:select": // tempjson.Add(customfield.Key.ToLower(), JToken.FromObject(new { value = customfield.Value.Value })); // break; // default: // tempjson.Add(customfield.Key.ToLower(), customfield.Value.Value); // break; // } //} request.RequestFormat = DataFormat.Json; request.AddBody(issue); IRestResponse <Issue> response = Client.Post <Issue>(request); if (response.ErrorException != null) { throw response.ErrorException; } if (response.ResponseStatus != ResponseStatus.Completed) { throw new Exception(response.ErrorMessage); } return(response.Data); }
public Issue AddIssue(IssueFields issueFields) { IRestRequest request = new RestRequest(String.Format("{0}/issue", JiraAPIServiceURI), Method.POST); request.RequestFormat = DataFormat.Json; JObject tempjson = JObject.FromObject(new { project = new { id = issueFields.Project.ID }, issuetype = new { id = issueFields.IssueType.ID }, summary = issueFields.Summary, //description = issueFields.Description, //User Reporter { get; set; } //User Assignee { get; set; } }); List <Field> fields = GetFields(); foreach (KeyValuePair <String, CustomField> customfield in issueFields.CustomFields) { Field field = fields.Where(f => f.ID.Equals(customfield.Key)).FirstOrDefault(); switch (field.Schema.Custom) { case "com.atlassian.jira.plugin.system.customfieldtypes:select": tempjson.Add(customfield.Key.ToLower(), JToken.FromObject(new { value = customfield.Value.Value })); break; default: tempjson.Add(customfield.Key.ToLower(), customfield.Value.Value); break; } } JObject json = new JObject(); json.Add("fields", tempjson.Root); request.AddParameter("Application/Json", json.ToString(), ParameterType.RequestBody); IRestResponse <Issue> response = Client.Post <Issue>(request); if (response.ErrorException != null) { throw response.ErrorException; } if (response.ResponseStatus != ResponseStatus.Completed) { throw new Exception(response.ErrorMessage); } return(response.Data); }
/// <summary> /// Update issue /// </summary> /// <param name="issueFields"></param> /// <returns></returns> public Issue UpdateIssue(IssueFields issueFields) { // TODO return(null); }
/// <summary> /// Add issue to project /// </summary> /// <param name="issueFields"></param> /// <returns></returns> public Issue AddIssue(IssueFields issueFields) { JObject json = new JObject(); JObject fieldsjson = new JObject(); json.Add("fields", fieldsjson); // Fill main fields if they are defined if (issueFields.Project != null) { fieldsjson.Add("project", new JObject(new JProperty("id", issueFields.Project.ID))); } if (issueFields.IssueType != null) { fieldsjson.Add("issuetype", new JObject(new JProperty("id", issueFields.IssueType.ID))); } if (issueFields.Reporter != null) { fieldsjson.Add("reporter", new JObject(new JProperty("name", issueFields.Reporter.Name))); } if (issueFields.Assignee != null) { fieldsjson.Add("assignee", new JObject(new JProperty("name", issueFields.Assignee.Name))); } if (issueFields.Priority != null) { fieldsjson.Add("priority", new JObject(new JProperty("name", issueFields.Priority.Name))); } if (issueFields.Summary != null) { fieldsjson.Add(new JProperty("summary", issueFields.Summary)); } if (issueFields.Description != null) { fieldsjson.Add(new JProperty("description", issueFields.Description)); } if (issueFields.AffectsVersions != null) { JArray affverjson = new JArray(); fieldsjson.Add("versions", affverjson); foreach (ProjectVersion version in issueFields.AffectsVersions) { affverjson.Add(new JObject(new JProperty("id", version.ID))); } } if (issueFields.FixVersions != null) { JArray fixverjson = new JArray(); fieldsjson.Add("fixVersions", fixverjson); foreach (ProjectVersion version in issueFields.FixVersions) { fixverjson.Add(new JObject(new JProperty("id", version.ID))); } } if (issueFields.Components != null) { JArray componentsjson = new JArray(); fieldsjson.Add("components", componentsjson); foreach (Component component in issueFields.Components) { componentsjson.Add(new JObject(new JProperty("id", component.ID.ToString()))); } } // TODO What is it ? List <Field> fields = GetFields(); foreach (KeyValuePair <String, CustomField> customfield in issueFields.CustomFields) { Field field = fields.Where(f => f.ID.Equals(customfield.Key)).FirstOrDefault(); switch (field.Schema.Custom) { case "com.atlassian.jira.plugin.system.customfieldtypes:select": fieldsjson.Add(customfield.Key.ToLower(), JToken.FromObject(new { value = customfield.Value.Value })); break; default: fieldsjson.Add(customfield.Key.ToLower(), customfield.Value.Value); break; } } // Create request IRestRequest request = new RestRequest(String.Format("{0}/issue", JiraAPIServiceURI), Method.POST); request.RequestFormat = DataFormat.Json; request.AddParameter("Application/Json", json.ToString(), ParameterType.RequestBody); // Get response IRestResponse <Issue> response = Client.Post <Issue>(request); if (response.ErrorException != null) { throw response.ErrorException; } if (response.ResponseStatus != ResponseStatus.Completed) { throw new Exception(response.ErrorMessage); } if (response.StatusCode != System.Net.HttpStatusCode.Created) { throw new Exception(response.StatusDescription, new Exception(response.Content)); } return(response.Data); }
private async void btnRequest_Click(object sender, EventArgs e) { // this.btnRequest.Enabled = false; string sfid = this.txtSFID.Text; string engsuppKey = this.txtEngsuppID.Text; string currentVersion = this.txtVersion.Text; string product = this.txtProduct.Text; string contact = this.txtCaseOwner.Text; string priority = this.txtPriority.Text; string siteUr = this.txtSiteUrl.Text; string issueSubject = this.txtIssueSubject.Text; string customerInfo = this.txtCustomerInfo.Text; string dbType = this.txtDBType.Text; string dbIP = this.txtDBServerIP.Text; string dbPort = this.txtDBServerPort.Text; string dbInstance = this.txtDBInstance.Text; string dbUserName = this.txtDBUser.Text; string dbUserPassword = this.txtDBPassword.Text; string dbVersion = this.txtDBVersion.Text; string dbRelatedCase = this.txtRelatedCase.Text; string enviroment = ""; string reviewer = this.txtReviewer.Text; if (this.txtSiteUrl.Text.Trim().IndexOf(".accela.com") == -1) { MessageBox.Show("Please specify the client's site url where this case could be recreated.\n For example: https://av.supp3.accela.com/ "); this.btnRequest.Enabled = true; return; } if (chbAccelaHostedFlag.Checked) { if (this.chbProductionFlag.Checked) { enviroment += "<<Production>>"; } if (this.chbSupportFlag.Checked) { enviroment += "<<Support>>"; } if (this.chbTestFlag.Checked) { enviroment += "<<Test>>"; } if (this.chbJetspeed.Checked) { enviroment += "<<Jetspeed>>"; } if (String.IsNullOrEmpty(enviroment)) { MessageBox.Show("Please specify which database enviroment you would request. For example, production, support or test or jetspped"); this.btnRequest.Enabled = true; return; } } else { MessageBox.Show("Please double check if this customer is Accela hosted. If yes, please tick the checkbox beside Accela Hosted field."); this.btnRequest.Enabled = true; return; } string summary = "Request one fresh database dump for [" + customerInfo + "] - " + sfid; string description1 = @" Hi [[email protected]], Please kindly help to get one fresh database dump pings to {0} for <<{1}>> which is Accela hosted, because we could not reproduce the problem on our local site. The problem might exists on their latest {2} enviroment. Custom Info: --------------------------------------------------------- Salesforce ID: {3} ENGSUPP Key: {4} Customer: {5} Current Version: {6} Product: {7} Contact:{8} Priority: {9} Issue Subject: {10} --------------------------------------------------------- After the fresh database dump is ready, please put it under Accela ftp server. The path should like ftp://ftp.accela.com/BIN/MISSIONSKY/XXXXX-XXXXX, and then re-assign this jira ticket to [~{11}] who will download it in Missionsky. Any further question, please let us know. Thanks you very much! CC [[email protected]] [[email protected]] [[email protected]] [~{11}]"; description1 = String.Format(description1, siteUr, customerInfo, enviroment, sfid, engsuppKey, customerInfo, currentVersion, product, contact, priority, issueSubject, reviewer ); IssueFields fields = new IssueFields(); fields.summary = summary; fields.description = description1; var GetDBTaskBySFID = JiraProxy.GetDatabaseTaskByCaseID("DATABASE", "Task", sfid); var GetDatabaseTaskByCustomerID = JiraProxy.GetDatabaseTaskByCustomerID("DATABASE", "Task", customerInfo); var taskInfoByCaseId = await GetDBTaskBySFID; var taskInfoByCustomerId = await GetDatabaseTaskByCustomerID; if (taskInfoByCaseId != null || taskInfoByCustomerId != null) { var taskInfo = taskInfoByCaseId; if (taskInfo == null) { taskInfo = taskInfoByCustomerId; } taskInfo.fields = fields; JiraProxy.UpdateDatabaseTask(taskInfo); this.txtDatabaseID.Text = taskInfo.key; MessageBox.Show("The database request ticket already exists, please refer to " + taskInfo.key); showCaseComment(engsuppKey, taskInfo.key); } else { var issue = await JiraProxy.CreateDatabaseTask(fields); this.txtDatabaseID.Text = issue.key; // 2 - Critical // 7 - High // 6 - Medium // 8 - Low issue.fields.Priority = new IssuePriority(); issue.fields.Priority.name = priority; JiraProxy.UpdateDatabaseTask(issue); showCaseComment(engsuppKey, issue.key); IssueRef engIssue = new IssueRef(); engIssue.key = engsuppKey; engIssue.id = engsuppKey; JiraProxy.CreateComment(engIssue, String.Format("One jira ticket is already submitted to Accela DBA for the most recent database dump, because the reported issue might be data-related based on the research. The ticket key is {0}. Thank you for your patience", issue.key)); } this.btnRequest.Enabled = true; }
public Issue CreateIssue(String projectKey, String issueType, IssueFields issueFields) { return(Issue.From(_client.CreateIssue(projectKey, issueType, issueFields))); }