/// <summary> /// Attempts to start the time tracking timer for the specified case. /// </summary> /// <param name="caseId">The FogBugz ID of the case to start work on.</param> /// <param name="error">The FogBugz error, if any occurs.</param> /// <returns>A Boolean value specifying whether the API call to start the time tracking timer succeeded.</returns> private Boolean TryStartWork(Int32 caseId, out FogBugzApiError error) { if (IsLoggedIn) { XDocument doc = LoadDoc(GetCommandUrlWithToken(String.Format("cmd=startWork&ixBug={0}", caseId))); if (doc.IsFogBugzError(out error)) { startedOn = DateTime.MinValue; if (error.Code == 7) { this.OpenUrl(String.Format("{0}/?pg=pgEditBug&ixBug={1}&command=edit", serverUrl, caseId)); } return(false); } else { startedOn = DateTime.Now; UpdateFogBugzData(); tray.ShowBalloonTip(0, String.Format("Work started on Case {0}", caseId), workingCase.Title, ToolTipIcon.Info); return(true); } } else { error = null; return(false); } }
/// <summary> /// Evaluates the result of a FogBugz API call and determines if the result is an error. /// </summary> /// <param name="error">The resulting FogBugz error, if any.</param> /// <returns>A boolean value representing whether the FogBugz API call was an error</returns> public static Boolean IsFogBugzError(this XDocument doc, out FogBugzApiError error) { if (doc.Descendants("error").Count() == 1) { error = ( from c in doc.Descendants("error") select new FogBugzApiError { Code = (int)c.Attribute("code"), Message = c.Value } ).First(); return(true); } else { error = null; return(false); } }
/// <summary> /// Attempts to start the time tracking timer for the specified case. /// </summary> /// <param name="caseId">The FogBugz ID of the case to start work on.</param> /// <param name="error">The FogBugz error, if any occurs.</param> /// <returns>A Boolean value specifying whether the API call to start the time tracking timer succeeded.</returns> private Boolean TryStartWork(Int32 caseId, out FogBugzApiError error) { if (IsLoggedIn) { XDocument doc = LoadDoc(GetCommandUrlWithToken(String.Format("cmd=startWork&ixBug={0}", caseId))); if (doc.IsFogBugzError(out error)) { startedOn = DateTime.MinValue; if (error.Code == 7) { this.OpenUrl(String.Format("{0}/?pg=pgEditBug&ixBug={1}&command=edit", serverUrl, caseId)); } return false; } else { startedOn = DateTime.Now; UpdateFogBugzData(); tray.ShowBalloonTip(0, String.Format("Work started on Case {0}", caseId), workingCase.Title, ToolTipIcon.Info); return true; } } else { error = null; return false; } }