예제 #1
0
파일: Jira.cs 프로젝트: Celdorfpwn/ASAP
        /// <summary>
        /// Adds the jira attachments to the given issue
        /// </summary>
        /// <param name="issue">Issue to add attachments to </param>
        /// <returns>Jira attachments for the given issue</returns>
        public Attachment[] AppendAttachmentForIssue(Issue issue)
        {
            Issue i = GetIssue(issue.Key);

            issue.Field.Attachment = i.Field.Attachment;

            return issue.Field.Attachment;
        }
예제 #2
0
파일: Jira.cs 프로젝트: Celdorfpwn/ASAP
 public void AddMessage(Issue issue, string message)
 {
     string query = String.Format("issue/{0}", issue.Key);
     string data = "{\"update\" : {\"comment\" : [{\"add\" : {\"body\" : \"" + message + "\"}}]}}";
     string response = RunQuery(query, data, "POST");
 }
예제 #3
0
파일: Jira.cs 프로젝트: Celdorfpwn/ASAP
        /// <summary>
        /// Set the next status
        /// </summary>
        /// <param name="issue">The issue to change the status for</param>
        /// <param name="newStatus">The new status (transition)</param>
        /// <param name="message">Message to add</param>
        public void SetStatus(Issue issue, JiraTransition newStatus, string message, ItVersion fixVersion = null)
        {
            string query = String.Format("issue/{0}", issue.Key);
            string data = "{\"transition\" : {\"id\" : \"" + (int)newStatus + "\"}}";
            if (!String.IsNullOrWhiteSpace(message))
            {
                data = "{\"update\" : {\"comment\" : [{\"add\" : {\"body\" : \"" + message + "\"}}]}, \"transition\": {\"id\": \"" + (int)newStatus + "\"}}";
            }

            // Set the new status and comment
            string response = RunQuery(query, data, "POST");

            if (!String.IsNullOrEmpty(response))
            {
                throw new InvalidDataException("Set status return not expected data");
            }

            // Set the fix Version
            if (fixVersion != null)
            {
                data = "{\"update\" : {\"fixVersions\" : [{\"set\" : [{\"name\" : \"" + fixVersion.Name + "\"}]}]} }";

                response = RunQuery(query, data, "POST");

                if (!String.IsNullOrEmpty(response))
                {
                    throw new InvalidDataException("Set fix version return not expected data");
                }
            }
            string logMsg = String.Format("{0} changed into {1}", issue.Key, newStatus);
            LoggerService.Log.Instance.AddLog(new LoggerService.LogEntry(LoggerService.LogType.Info, logMsg));
        }
예제 #4
0
파일: Jira.cs 프로젝트: Celdorfpwn/ASAP
        /// <summary>
        /// Creates the Jira issue.
        /// </summary>
        /// <param name="issue">The issue.</param>
        /// <param name="project">The project.</param>
        /// <returns>CreateResult object</returns>
        /// <exception cref="InvalidDataException">Create item return not expected data</exception>
        public CreateResult CreateIssue(Issue issue)
        {
            issue.Field.Assignee = new Person();
            issue.Field.Assignee.Name = "valentin.mitaru";
            string query = String.Format("issue/");
            string data = "{\"fields\" : {\"project\" : {\"key\" : \"" + Config.Project + "\"}, \"summary\":\"" + issue.Field.Summary + "\", \"description\":\"" + issue.Field.Description + "\", \"issuetype\": {\"name\":\"" + issue.Field.IssueType.Name + "\"}, \"assignee\": {\"name\":\"" + issue.Field.Assignee.Name + "\"}}}";
            string response = RunQuery(query, data, create:true);
            if (String.IsNullOrEmpty(response))
            {
                throw new InvalidDataException("Create item return not expected data");
            }

            DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(CreateResult));
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(response));
            CreateResult createdItem = (CreateResult)jsonSerializer.ReadObject(stream);
            return createdItem;
        }
예제 #5
0
파일: Jira.cs 프로젝트: Celdorfpwn/ASAP
        /// <summary>
        /// Assign the given issue to the specified name
        /// </summary>
        /// <param name="issue">Issue to be assigned to newName</param>
        /// <param name="newName">The person that gets the Issue</param>
        public void AssignIssue(Issue issue, string newName)
        {
            string query = String.Format("issue/{0}", issue.Key);
            //string data = "{\"update\" : {\"components\" : [{\"set\" : [{\"assignee\" : \"" + email + "\"}]}]}}";
            //string data = "{\"update\" : {\"assignee\" :[\"set\" : {\"name\" : \"" + email + "\"}]}}";
            string data = "{\"fields\" : {\"assignee\" : {\"name\" : \"" + newName + "\"}}}";
            //string data = String.Format("{\"update\":{\"components\":[{\"set\":[{\"assignee\":\"{0}\"}]]}}",email);
            string response = RunQuery(query, data);
            if (!String.IsNullOrEmpty(response))
            {
                throw new InvalidDataException("Reassign flow return not expected data");
            }

            string logMsg = String.Format("{0} assigned to {1}", issue.Key, newName);
            LoggerService.Log.Instance.AddLog(new LoggerService.LogEntry(LoggerService.LogType.Info, logMsg));
        }
예제 #6
0
파일: Jira.cs 프로젝트: Celdorfpwn/ASAP
        /// <summary>
        /// Adds the jira comments to the given issue
        /// </summary>
        /// <param name="issue">Issue to add comments to</param>
        /// <returns>Comments for the given issue</returns>
        public Comment AppendCommentsForIssue(Issue issue)
        {
            issue.Field.Comment = GetIssue(issue.Key).Field.Comment;

            return issue.Field.Comment;
        }