private void getAttachments(XPathNavigator nav)
        {
            XPathExpression   expr = nav.Compile("attachment");
            XPathNodeIterator it   = nav.Select(expr);

            if (!nav.MoveToFirstChild())
            {
                return;
            }
            while (it.MoveNext())
            {
                JiraAttachment a = new JiraAttachment(
                    int.Parse(XPathUtils.getAttributeSafely(it.Current, "id", "0")),
                    XPathUtils.getAttributeSafely(it.Current, "name", "none"),
                    JiraIssueUtils.getDateTimeFromJiraTimeString(XPathUtils.getAttributeSafely(it.Current, "created", "none")),
                    XPathUtils.getAttributeSafely(it.Current, "author", "none"),
                    int.Parse(XPathUtils.getAttributeSafely(it.Current, "size", "0")));
                attachments.Add(a);
            }
            nav.MoveToParent();
        }
        public JiraIssue(JiraServer server, XPathNavigator nav)
        {
            Server = server;

            nav.MoveToFirstChild();
            do
            {
                switch (nav.Name)
                {
                case "key":
                    Key        = nav.Value;
                    Id         = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN);
                    ProjectKey = Key.Substring(0, Key.LastIndexOf('-'));
                    break;

                case "parent":
                    ParentKey = nav.Value;
                    break;

                case "subtasks":
                    getSubtasks(nav);
                    break;

                case "summary":
                    Summary = nav.Value;
                    break;

                case "attachments":
                    getAttachments(nav);
                    break;

                case "status":
                    Status        = nav.Value;
                    StatusIconUrl = XPathUtils.getAttributeSafely(nav, "iconUrl", null);
                    StatusId      = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN);
                    break;

                case "priority":
                    Priority        = nav.Value;
                    PriorityIconUrl = XPathUtils.getAttributeSafely(nav, "iconUrl", null);
                    PriorityId      = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN);
                    break;

                case "description":
                    Description = nav.Value;
                    break;

                case "type":
                    IssueType        = nav.Value;
                    IssueTypeIconUrl = XPathUtils.getAttributeSafely(nav, "iconUrl", null);
                    IssueTypeId      = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN);
                    break;

                case "assignee":
                    Assignee = XPathUtils.getAttributeSafely(nav, "username", "Unknown");
                    string assigneName = nav.Value;
                    break;

                case "reporter":
                    Reporter = XPathUtils.getAttributeSafely(nav, "username", "Unknown");
                    string reporterName = nav.Value;
                    break;

                case "created":
                    CreationDate = JiraIssueUtils.getDateTimeFromJiraTimeString(nav.Value);
                    break;

                case "updated":
                    UpdateDate = JiraIssueUtils.getDateTimeFromJiraTimeString(nav.Value);
                    break;

                case "resolution":
                    Resolution   = nav.Value;
                    ResolutionId = XPathUtils.getAttributeSafely(nav, "id", UNKNOWN);
                    break;

                case "timeestimate":
                    RemainingEstimate          = nav.Value;
                    RemainingEstimateInSeconds = XPathUtils.getAttributeSafely(nav, "seconds", UNKNOWN);
                    break;

                case "timeoriginalestimate":
                    OriginalEstimate          = nav.Value;
                    OriginalEstimateInSeconds = XPathUtils.getAttributeSafely(nav, "seconds", UNKNOWN);
                    break;

                case "timespent":
                    TimeSpent          = nav.Value;
                    TimeSpentInSeconds = XPathUtils.getAttributeSafely(nav, "seconds", UNKNOWN);
                    break;

                case "version":
                    versions.Add(nav.Value);
                    break;

                case "fixVersion":
                    fixVersions.Add(nav.Value);
                    break;

                case "component":
                    components.Add(nav.Value);
                    break;

                case "comments":
                    getComments(nav);
                    break;

                case "environment":
                    Environment = nav.Value;
                    break;

                case "issuelinks":
                    getIssueLinks(nav);
                    break;

                default:
                    break;
                }
            } while (nav.MoveToNext());
            if (Key == null || Summary == null)
            {
                throw new InvalidDataException();
            }
        }