public void runIssueActionWithParams(JiraIssue issue, JiraNamedEntity action, ICollection <JiraField> fields, string comment) { object data; var fldsObj = new Dictionary <string, object>(); foreach (var field in from field in fields let ops = field.FieldDefinition["operations"] where ops != null && ops.Values().Any(op => "set".Equals(op.Value <string>())) select field) { fldsObj[field.Id] = field.getJsonValue(); } if (comment != null) { var commentObj = new List <object> { new { add = new { body = comment } } }; data = new { update = new { comment = commentObj }, transition = new { id = action.Id }, fields = fldsObj }; } else { data = new { transition = new { id = action.Id }, fields = fldsObj }; } postJson(BaseUrl + REST + "issue/" + issue.Key + "/transitions", data); }
public void runIssueActionWithoutParams(JiraIssue issue, JiraNamedEntity action) { var data = new { transition = new { id = action.Id } }; postJson(BaseUrl + REST + "issue/" + issue.Key + "/transitions", data); }
public List <JiraField> getFieldsForAction(JiraIssue issue, int actionId) { var res = getJson(BaseUrl + REST + "issue/" + issue.Key + "/transitions?expand=transitions.fields"); return(( from tr in res["transitions"] where tr["id"].Value <int>() == actionId select tr["fields"].Select(fld => new JiraField(tr["fields"], ((JProperty)fld).Name)).ToList() ).FirstOrDefault()); }
private void fixOriginalEstimate(JiraIssue issue, string originalEstimate) { #if false if (originalEstimate == null) { return; } var data = new { fields = new { timetracking = new { originalEstimate = TimeTrackingFiller.translate(originalEstimate) } } }; putJson(BaseUrl + REST + "issue/" + issue.Key, data); #endif }
public JiraNamedEntity getSecurityLevel(JiraIssue issue) { var i = getJson(BaseUrl + REST + "issue/" + issue.Key); var sec = i["security"]; if (sec == null || !sec.HasValues) { return(null); } return(new JiraNamedEntity(sec)); }
public string createIssue(JiraIssue issue) { var meta = getJson(BaseUrl + REST + "issue/createmeta?projectKeys=" + issue.ProjectKey + "&issuetypeIds=" + issue.IssueTypeId + "&expand=projects.issuetypes.fields"); var projects = meta["projects"]; var types = projects.Children()["issuetypes"]; var fieldsMeta = types.Children()["fields"]; var assignee = issue.Assignee != null ? new { name = issue.Assignee } : null; var fixVersions = issue.FixVersions != null ? (object)issue.FixVersions.Select(fv => new { name = fv }).ToList() : new List <object>(); var versions = issue.Versions != null ? (object)issue.Versions.Select(v => new { name = v }).ToList() : new List <object>(); var components = issue.Components != null ? (object)issue.Components.Select(c => new { name = c }).ToList() : new List <object>(); var fields = new Dictionary <string, object>(); fields["issuetype"] = new { id = issue.IssueTypeId.ToString() }; if (issue.IsSubtask) { fields["parent"] = new { key = issue.ParentKey }; } maybeSetField(fieldsMeta, fields, "project", new { key = issue.ProjectKey }); maybeSetField(fieldsMeta, fields, "summary", issue.Summary); maybeSetField(fieldsMeta, fields, "description", issue.Description); maybeSetField(fieldsMeta, fields, "priority", new { id = issue.PriorityId.ToString() }); maybeSetField(fieldsMeta, fields, "assignee", assignee); maybeSetField(fieldsMeta, fields, "fixVersions", fixVersions); maybeSetField(fieldsMeta, fields, "versions", versions); maybeSetField(fieldsMeta, fields, "components", components); var data = new { fields = fields }; // new { // project = new { key = issue.ProjectKey }, // summary = issue.Summary, // description = issue.Description, // issuetype = new { id = issue.IssueTypeId.ToString() }, // priority = new { id = issue.PriorityId.ToString() }, // assignee = assignee, // fixVersions = fixVersions, // versions = versions, // components = components // } // }; var result = postJson(BaseUrl + REST + "issue", data, HttpStatusCode.Created); return(result["key"].Value <string>()); }
public bool Equals(JiraIssue other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } bool eq = true; eq &= other.Server.GUID.Equals(Server.GUID); eq &= other.IssueType.Equals(IssueType); eq &= other.IssueTypeId.Equals(IssueTypeId); eq &= other.IssueTypeIconUrl.Equals(IssueTypeIconUrl); eq &= string.Equals(other.Description, Description); eq &= other.Id == Id; eq &= other.Key.Equals(Key); eq &= string.Equals(other.Summary, Summary); eq &= other.Status.Equals(Status); eq &= other.StatusIconUrl.Equals(StatusIconUrl); eq &= Equals(other.Priority, Priority); eq &= string.Equals(other.Resolution, Resolution); eq &= other.Reporter.Equals(Reporter); eq &= string.Equals(other.Assignee, Assignee); eq &= other.CreationDate.Equals(CreationDate); eq &= other.UpdateDate.Equals(UpdateDate); eq &= other.ProjectKey.Equals(ProjectKey); eq &= string.Equals(other.Environment, Environment); eq &= string.Equals(other.OriginalEstimate, OriginalEstimate); eq &= string.Equals(other.RemainingEstimate, RemainingEstimate); eq &= string.Equals(other.TimeSpent, TimeSpent); eq &= string.Equals(other.ParentKey, ParentKey); eq &= Equals(other.PriorityIconUrl, PriorityIconUrl); eq &= other.StatusId == StatusId; eq &= other.PriorityId == PriorityId; eq &= PlvsUtils.compareLists(other.comments, comments); eq &= PlvsUtils.compareLists(other.versions, versions); eq &= PlvsUtils.compareLists(other.fixVersions, fixVersions); eq &= PlvsUtils.compareLists(other.components, components); eq &= PlvsUtils.compareLists(other.SubtaskKeys, SubtaskKeys); eq &= PlvsUtils.compareLists(other.Attachments, Attachments); eq &= PlvsUtils.compareLists(other.IssueLinks, IssueLinks); return(eq); }
public void updateIssue(JiraIssue issue, ICollection <JiraField> fields) { #if false var needAdjustOriginalEstimate = fields.Any(field => "remainingEstimate".Equals(field.SettablePropertyName)); var originalEstimate = needAdjustOriginalEstimate && issue.TimeSpent != null ? issue.OriginalEstimate : null; #endif var fldsObj = new Dictionary <string, object>(); foreach (var field in fields) { fldsObj[field.Id] = field.getJsonValue(); } object data = new { fields = fldsObj }; putJson(BaseUrl + REST + "issue/" + issue.Key, data); #if false fixOriginalEstimate(issue, originalEstimate); #endif }
public void uploadAttachment(JiraIssue issue, string name, byte[] attachment) { var file = saveAttachmentContents(name, attachment); try { var url = BaseUrl + REST + "issue/" + issue.Key + "/attachments"; if (server.OldSkoolAuth) { url = url + appendAuthentication(url); } HttpWebRequest request = null; using (var response = FormUpload.multipartFormDataPost(url, req => { // setBasicAuthHeader(req); request = req; loadLoginSessionCookies(req); req.Headers["X-Atlassian-Token"] = "nocheck"; }, new Dictionary <string, string> { { "file", "file://" + file } })) { storeLoginSessionCookies(request); if (response.StatusCode != HttpStatusCode.OK) { throw new WebException("Failed to upload attachment, error code: " + response.StatusCode); } using (var responseStream = response.GetResponseStream()) { if (responseStream != null) { using (var responseReader = new StreamReader(responseStream)) { responseReader.ReadToEnd(); } } } } } finally { File.Delete(file); } }
public void logWorkAndAutoUpdateRemaining(JiraIssue issue, string timeSpent, DateTime startDate, string comment) { logWorkAtUrl(BaseUrl + REST + "issue/" + issue.Key + "/worklog?adjustEstimate=auto", timeSpent, startDate, comment); }
public void logWorkAndLeaveRemainingUnchanged(JiraIssue issue, string timeSpent, DateTime startDate, string comment) { logWorkAtUrl(BaseUrl + REST + "issue/" + issue.Key + "/worklog?adjustEstimate=leave", timeSpent, startDate, comment); }
public void logWorkAndUpdateRemainingManually(JiraIssue issue, string timeSpent, DateTime startDate, string remainingEstimate, string comment) { logWorkAtUrl(BaseUrl + REST + "issue/" + issue.Key + "/worklog?adjustEstimate=new&newEstimate=" + remainingEstimate, timeSpent, startDate, comment); }
public void addComment(JiraIssue issue, string comment) { var data = new { body = comment }; postJson(BaseUrl + REST + "issue/" + issue.Key + "/comment", data, HttpStatusCode.Created); }
public List <JiraNamedEntity> getActionsForIssue(JiraIssue issue) { var res = getJson(BaseUrl + REST + "issue/" + issue.Key + "/transitions"); return(res["transitions"].Select(t => new JiraNamedEntity(t)).ToList()); }