public async Task <IStandardViewpoint> CreateViewpointAsync(IStandardViewpoint instance) { var jiraIssue = await _resourceClient.RestClient.Issues.GetIssueAsync(instance.Identifiers[InstanceKeyNames.JIRA_ISSUE].Id); using (WebClient client = new WebClient()) { try { byte[] img = client.DownloadData(new Uri(instance.Url)); UploadAttachmentInfo[] info = new UploadAttachmentInfo[1] { new UploadAttachmentInfo("viewpoint_" + instance.ViewpointId + ".png", img) }; await jiraIssue.AddAttachmentAsync(info); } catch (Exception e) { Debug.WriteLine("Failed to upload viewpoint attachment."); } } return(instance); }
public async Task <string> CreateNewItem(WorkItem wi) { var user = AuthHelper.GetCurrentUser(); try { //Create an epic in JIRA var jira = Jira.CreateRestClient(JIRAUrl, JIRAUserName, JIRAPassword); var issue = jira.CreateIssue("QSPEAR"); issue.Type = "Task"; issue.Priority = "Medium"; issue.Summary = wi.Title; issue.Description = wi.Description; issue["Epic Link"] = user.JIRAEpicId; await issue.SaveChangesAsync(); if (!string.IsNullOrEmpty(wi.FileName)) { UploadAttachmentInfo ai = new UploadAttachmentInfo(wi.FileName, Convert.FromBase64String(wi.Attachment.Replace("data:text/plain;base64,", ""))); await issue.AddAttachmentAsync(new UploadAttachmentInfo[] { ai }); } return(issue.Key.Value); } catch (Exception ex) { throw ex; } }
private static async void AddAttachmentsAsync(Issue issue, string path) { byte[] data = File.ReadAllBytes("files\\" + path); UploadAttachmentInfo info = new UploadAttachmentInfo(path, data); await issue.AddAttachmentAsync(new UploadAttachmentInfo [] { info }); }