A container class for a FogBugz case.
Beispiel #1
0
        /// <summary>
        /// Updates the internal working case record.
        /// </summary>
        private Boolean UpdateWorkingCase()
        {
            if (IsLoggedIn)
             {
            XDocument doc = LoadDoc(GetCommandUrlWithToken("cmd=listIntervals"));
            XDocumentDescendantsResult result;
            if (doc.TryGetDescendants("interval", out result))
            {
               // Get the current working case
               IEnumerable<FogBugzCase> cases = (
                   from c in result.Descendants
                   where c.Element("dtEnd").Value == ""
                   select new FogBugzCase
                   {
                      Id = Int32.Parse(c.Element("ixBug").Value),
                      Title = c.Element("sTitle").Value
                   });
               if (cases.Count() > 0) workingCase = cases.First();
               else workingCase = null;

               // Get the most recently worked on case
               cases = (
                   from c in result.Descendants
                   orderby c.Element("dtEnd").Value == "" ? DateTime.MinValue : DateTime.Parse(c.Element("dtEnd").Value) descending
                   select new FogBugzCase
                   {
                      Id = Int32.Parse(c.Element("ixBug").Value),
                      Title = c.Element("sTitle").Value
                   });
               if (cases.Count() > 0) lastWorkedCase = cases.First();
               else lastWorkedCase = null;

               if (workingCase == null)
               {
                  tray.Text = "Not working on anything.";
                  if (lastWorkedCase == null)
                  {
                     stopWorkToolStripMenuItem.Text = "&Stop Work";
                     stopWorkToolStripMenuItem.Enabled = false;
                  }
                  else
                  {
                     stopWorkToolStripMenuItem.Text = String.Format("&Resume Work on Case {0}", lastWorkedCase.Id);
                     stopWorkToolStripMenuItem.Enabled = true;
                  }
               }
               else
               {
                  tray.Text = String.Format("Working on Case {0} - {1}.", workingCase.Id, workingCase.Title).TruncateByLetters(64);
                  stopWorkToolStripMenuItem.Text = String.Format("&Stop Work on Case {0}", workingCase.Id);
                  stopWorkToolStripMenuItem.Enabled = true;
               }
               return true;
            }
            else if (result.IsFogBugzError) result.FogBugzError.Show(this);
            else if (result.IsWebException) result.ShowException(this, String.Format("An error occurred while attempting to contact {0}", Settings.Default.Server));
            else if (result.IsException) result.ShowException(this, "An error occurred");
             }
             return false;
        }
Beispiel #2
0
        /// <summary>
        /// Updates the internal working case record.
        /// </summary>
        private Boolean UpdateWorkingCase()
        {
            if (IsLoggedIn)
            {
                XDocument doc = LoadDoc(GetCommandUrlWithToken("cmd=listIntervals"));
                XDocumentDescendantsResult result;
                if (doc.TryGetDescendants("interval", out result))
                {
                    // Get the current working case
                    IEnumerable <FogBugzCase> cases = (
                        from c in result.Descendants
                        where c.Element("dtEnd").Value == ""
                        select new FogBugzCase
                    {
                        Id = Int32.Parse(c.Element("ixBug").Value),
                        Title = c.Element("sTitle").Value
                    });
                    if (cases.Count() > 0)
                    {
                        workingCase = cases.First();
                    }
                    else
                    {
                        workingCase = null;
                    }

                    // Get the most recently worked on case
                    cases = (
                        from c in result.Descendants
                        orderby c.Element("dtEnd").Value == "" ? DateTime.MinValue : DateTime.Parse(c.Element("dtEnd").Value) descending
                        select new FogBugzCase
                    {
                        Id = Int32.Parse(c.Element("ixBug").Value),
                        Title = c.Element("sTitle").Value
                    });
                    if (cases.Count() > 0)
                    {
                        lastWorkedCase = cases.First();
                    }
                    else
                    {
                        lastWorkedCase = null;
                    }

                    if (workingCase == null)
                    {
                        tray.Text = "Not working on anything.";
                        if (lastWorkedCase == null)
                        {
                            stopWorkToolStripMenuItem.Text    = "&Stop Work";
                            stopWorkToolStripMenuItem.Enabled = false;
                        }
                        else
                        {
                            stopWorkToolStripMenuItem.Text    = String.Format("&Resume Work on Case {0}", lastWorkedCase.Id);
                            stopWorkToolStripMenuItem.Enabled = true;
                        }
                    }
                    else
                    {
                        tray.Text = String.Format("Working on Case {0} - {1}.", workingCase.Id, workingCase.Title).TruncateByLetters(64);
                        stopWorkToolStripMenuItem.Text    = String.Format("&Stop Work on Case {0}", workingCase.Id);
                        stopWorkToolStripMenuItem.Enabled = true;
                    }
                    return(true);
                }
                else if (result.IsFogBugzError)
                {
                    result.FogBugzError.Show(this);
                }
                else if (result.IsWebException)
                {
                    result.ShowException(this, String.Format("An error occurred while attempting to contact {0}", Settings.Default.Server));
                }
                else if (result.IsException)
                {
                    result.ShowException(this, "An error occurred");
                }
            }
            return(false);
        }