예제 #1
0
파일: Submission.cs 프로젝트: mo5h/omeo
        /// <summary>
        /// Adds the <see cref="Attachments"/> to the <see cref="Issue"/>.
        /// </summary>
        protected void AddAttachmentsToIssue()
        {
            if (Attachments.Count == 0)
            {
                return;
            }

            SetStatus("Preparing the list of attachments");
            foreach (KeyValuePair <string, byte[]> pair in Attachments)
            {
                try
                {
                    // Due to an error in WSDL, convert the data to s-bytes from bytes
                    SetStatus(string.Format("Adding attachments — {0} — {1}", pair.Key, "Copying"));
                    sbyte[] datatemp = new sbyte[pair.Value.Length];
                    for (int a = 0; a < pair.Value.Length; a++)
                    {
                        datatemp[a] = unchecked ((sbyte)pair.Value[a]);
                    }

                    SetStatus(string.Format("Adding attachments — {0} — {1}", pair.Key, "Sending"));
                    Project.Server.Service.addAttachmentsToIssue(Project.Server.GetSignInToken(), Issue.key, new string[] { pair.Key }, datatemp);
                }
                catch (Exception ex)
                {
                    ErrorLog.AppendFormat("Could not add the “{0}” attachment to the issue. {1}", pair.Key, ex.Message);
                    ErrorLog.AppendLine();
                }
            }
        }
예제 #2
0
파일: Submission.cs 프로젝트: mo5h/omeo
        /// <summary>
        /// Implements the submission on the network thread.
        /// </summary>
        protected void Submit_Run()
        {
            if (!Core.NetworkAP.IsOwnerThread)
            {
                throw new InvalidOperationException("The submission impl must be run on the network thread.");
            }

            try
            {
                SetStatus("Collecting initial parameters");

                RemoteIssue issue = new RemoteIssue();
                issue.project     = Project.Key;
                issue.reporter    = Project.Server.Username;
                issue.type        = IssueType.JiraId.ToString();
                issue.summary     = Title;
                issue.description = Body;

                if (Priority != null)
                {
                    issue.priority = Priority.JiraId.ToString();
                }

                if (Component != null)
                {
                    RemoteComponent rc = new RemoteComponent();
                    rc.id            = Component.JiraId;
                    issue.components = new RemoteComponent[] { rc };
                }

                if (Status != null)
                {
                    issue.status = Status.JiraId;
                }

                issue.assignee = Assignee;

                // Create the issue!
                SetStatus("Creating issue carcass");
                _issue = Project.Server.Service.createIssue(Project.Server.GetSignInToken(), issue);

                // In case JIRA rejects some of the issue params at the creation time, set them one-by-one
                Submit_Run_UpdateIssue();

                // Submit the attachments
                AddAttachmentsToIssue();

                SetStatus("Done");
            }
            catch (Exception ex)
            {
                ErrorLog.AppendFormat("FATAL ERROR. {0}", ex.Message);
            }
            finally
            {
                Core.UserInterfaceAP.QueueJob("JIRA Issue Submission Done.", (MethodInvoker)Submit_Done);
            }
        }
예제 #3
0
파일: Submission.cs 프로젝트: mo5h/omeo
        /// <summary>
        /// In case JIRA rejects some of the issue params at the creation time, set them one-by-one
        /// Uses the <see cref="Project"/> for project and JIRA server, and <see cref="Issue"/> for the issue-key to update.
        /// </summary>
        protected void Submit_Run_UpdateIssue()
        {
            SetStatus("Preparing fields for the issue update");
            List <RemoteFieldValue> arValues = new List <RemoteFieldValue>();

            // Generic fields
            if (Component != null)
            {
                arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.components, Component.JiraId));
            }
            if (Priority != null)
            {
                arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.priority, Priority.JiraId));
            }
            //arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.reporter, Project.Server.Username));
            arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.type, IssueType.JiraId));
            arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.summary, Title));
            arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.description, Body));
            if (Status != null)
            {
                arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.status, Status.JiraId));
            }
            arValues.Add(CreateFieldValue(JiraIssueType.JiraIssueKeys.assignee, Assignee));

            // Custom fields
            UpdateIssue_SetCustomFields(arValues);

            // Submit the values to the server
            SetStatus("Updating issue fields");
            foreach (RemoteFieldValue value in arValues)
            {
                try
                {
                    SetStatus("Updating issue fields — " + value.id);
                    Project.Server.Service.updateIssue(Project.Server.GetSignInToken(), Issue.key, new RemoteFieldValue[] { value });
                }
                catch (Exception ex)
                {
                    ErrorLog.AppendFormat("Could not set the “{0}” field on the issue. {1}", value.id, ex.Message);
                    ErrorLog.AppendLine();
                }
            }

            // Dirty hack: try opening the issue
            if (Status.Name == "Open")
            {
                try
                {
                    SetStatus("Updating issue fields — Opening issue");
                    Project.Server.Service.progressWorkflowAction(Project.Server.GetSignInToken(), Issue.key, "Open", new RemoteFieldValue[] {});
                }
                catch (Exception ex)
                {
                    ErrorLog.AppendFormat("Could not open the issue. {0}", ex.Message);
                    ErrorLog.AppendLine();
                }
            }
        }
예제 #4
0
파일: Submission.cs 프로젝트: mo5h/omeo
        /// <summary>
        /// Adds one single custom field for the <see cref="UpdateIssue_SetCustomFields"/> function.
        /// </summary>
        protected void UpdateIssue_SetCustomFields_Add(List <RemoteFieldValue> arValues, Dictionary <string, string> mapFieldNameToId, string sFieldName, string sFieldValue)
        {
            if (string.IsNullOrEmpty(sFieldName))
            {
                return;
            }
            if (string.IsNullOrEmpty(sFieldValue))
            {
                return;
            }

            // Lookup ID by the name
            string sFieldId;

            if (!mapFieldNameToId.TryGetValue(sFieldName, out sFieldId))
            {
                ErrorLog.AppendFormat("Could not find a custom field named “{0}” on the “{1}” JIRA server.", sFieldName, Project.Server.Name);
                ErrorLog.AppendLine();
                return;
            }

            // Add to the submit-list
            arValues.Add(CreateFieldValue(sFieldId, sFieldValue));
        }
예제 #5
0
 // Display any validation errors.
 private void ValidationCallBack(object sender, ValidationEventArgs e)
 {
     ErrorLog.AppendFormat("Validation Error: {0}", e.Message ?? "Random fail").AppendLine();
 }