/// <summary> /// Retreive the worklog from a specific issue /// </summary> /// <param name="issue">Issue key or id</param> /// <returns>A worklog containing all the work registered in the issue</returns> public JiraWorklog GetIssueWorklog(string issue) { JiraWorklog worklog = null; Logger.DebugFormat("Getting worklog for {0}", issue); HttpWebRequest request = GetRequest(string.Format(GetWorklogUrl, issue), true); request.Method = "GET"; try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) { if (response.StatusCode == HttpStatusCode.OK) { Logger.Debug("Got an OK from Jira when fetching worklog"); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(JiraWorklog)); if (stream != null) { worklog = serializer.ReadObject(stream) as JiraWorklog; } if (worklog != null) { Logger.Debug("Jira worklog serialzed"); } } else { Logger.WarnFormat("Didn't get an OK from Jira when fetching worklog for {0}, got {1}.", issue, response.StatusCode); } } } catch (WebException we) { Logger.Error("Unable to get worklog", we); worklog = null; } EncounteredError = worklog == null; return(worklog); }
/// <summary> /// Retreive the worklog from a specific issue /// </summary> /// <param name="issue">Issue key or id</param> /// <returns>A worklog containing all the work registered in the issue</returns> public JiraWorklog GetIssueWorklog(string issue) { JiraWorklog worklog = null; Logger.DebugFormat("Getting worklog for {0}", issue); try { using (IHttpResponse response = GetResponse(() => GetIssueWorklogRequest(issue))) { if (response.StatusCode == HttpStatusCode.OK) { Logger.Debug("Got an OK from Jira when fetching worklog"); worklog = response.GetResponseData <JiraWorklog>(); if (worklog != null) { Logger.Debug("Jira worklog serialzed"); } } else { Logger.WarnFormat("Didn't get an OK from Jira when fetching worklog for {0}, got {1}.", issue, response.StatusCode); } } } catch (WebException we) { Logger.Error("Unable to get worklog", we); worklog = null; } EncounteredError = worklog == null; return(worklog); }