Exemple #1
0
        /// <summary>
        /// Adds attachments to a given issue.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="remoteIssue"></param>
        /// <param name="remoteAttachments">A tuple where the first string array is a list of names, the second array a base64 encoded list of files corresponding to the names.</param>
        internal static void AddAttachments(string token, RemoteIssue remoteIssue, Tuple <string[], string[]> remoteAttachments)
        {
            if (!IsConfigured)
            {
                throw new InvalidOperationException("JIRA is not configured");
            }

            if (Log.IsDebugEnabled)
            {
                Log.DebugFormat("Adding attachments to issue {0}: {1}", remoteIssue.key, remoteAttachments.Item1.Join());
            }

            Service.addBase64EncodedAttachmentsToIssue(token, remoteIssue.key, remoteAttachments.Item1, remoteAttachments.Item2);
        }
Exemple #2
0
 public void addAttachment(string issueKey, string filename, IBinaryContainer attachment)
 {
     checkCredentials();
     try {
         jira.addBase64EncodedAttachmentsToIssue(credentials, issueKey, new string[] { filename }, new string[] { attachment.ToBase64String(Base64FormattingOptions.InsertLineBreaks) });
     } catch (Exception ex1) {
         LOG.WarnFormat("Failed to upload by using method addBase64EncodedAttachmentsToIssue, error was {0}", ex1.Message);
         try {
             LOG.Warn("Trying addAttachmentsToIssue instead");
             jira.addAttachmentsToIssue(credentials, issueKey, new string[] { filename }, (sbyte[])(Array)attachment.ToByteArray());
         } catch (Exception ex2) {
             LOG.WarnFormat("Failed to use alternative method, error was: {0}", ex2.Message);
             throw;
         }
     }
 }
Exemple #3
0
        private void jiraUploadBySoapWithToken()
        {
            try {
                JiraSoapServiceService service = new JiraSoapServiceService {
                    Url = serverUrl + "/rpc/soap/jirasoapservice-v2"
                };

                string[] fileNames = new[] { name };
                byte[]   bytes     = File.ReadAllBytes(path);

                service.addBase64EncodedAttachmentsToIssue(token, issueKey, fileNames, new[] { Convert.ToBase64String(bytes) });
                if (!string.IsNullOrEmpty(comment) && comment.Trim().Length > 0)
                {
                    RemoteComment c = new RemoteComment {
                        body = comment
                    };
                    service.addComment(token, issueKey, c);
                }

                Invoke(new MethodInvoker(delegate
                {
                    uploadLog.Text += "Done. See " + serverUrl + "/browse/" + issueKey + "\r\n";
                }));
            } catch (Exception e) {
                Debug.Write(e.StackTrace);
                Invoke(new MethodInvoker(delegate
                {
                    uploadLog.Text += "Failed: " + e.Message + "\r\n";
                }));
            }

            done = true;

            Invoke(new MethodInvoker(delegate
            {
                saveLastUsed();
                buttonCancel.Enabled = true;
                buttonCancel.Text    = "Close";
            }));
        }
 public void uploadAttachment(string key, string name, byte[] attachment)
 {
     service.addBase64EncodedAttachmentsToIssue(Token, key, new[] { name }, new[] { Convert.ToBase64String(attachment) });
 }