Esempio n. 1
0
        /// <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));
        }
Esempio n. 2
0
        /// <summary>
        /// Search the Jira for issues that were fixed in the given version
        /// </summary>
        /// <param name="version">The version used to search for FixVersion</param>
        public SearchResult SearchIssues(ItVersion version)
        {
            string query = String.Format("search?jql=FixVersion='{0}'+order+by+priority", version.Name);
            string response = RunQuery(query);

            DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(SearchResult));
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(response));
            SearchResult vers = (SearchResult)jsonSerializer.ReadObject(stream);

            // Fill-up URL property
            foreach (Issue issue in vers.Issues)
            {
                issue.URL = Config.BrowserUrl + issue.Key;
                issue.Field.Severity = ParseSeverityFromTheme(issue.Field.Labels);
            }
            return vers;
        }