Exemple #1
0
        private void addToSprint(string sprintData, TaskModel tm)
        {
            string name = sprintData == null ? "Unassigned" : getSprintName(sprintData);

            //A new sprint may need to be created
            if (sprintData == null && !Sprints.ContainsKey(name)) {
                Sprints[name] = new SprintModel();
                Sprints[name].CompleteDate = Epoch;
                Sprints[name].EndDate = Epoch;
                Sprints[name].Name = name;
                Sprints[name].StartDate = Epoch;
                Sprints[name].State = "FUTURE";
                Sprints[name].Tasks = new List<TaskModel>();
            } else if (!Sprints.ContainsKey(name)) {
                Sprints[name] = createSprint(sprintData);
            }

            Sprints[name].Tasks.Add(tm);
        }
Exemple #2
0
        private void fetchTasks(string projectKey)
        {
            //Find the Epic and Sprint field IDs
            string epicField, sprintField;

            if (Fields.List[0].Name == EPIC_FIELD_NAME) {
                epicField = Fields.List[0].ID;
                sprintField = Fields.List[1].ID;
            } else {
                epicField = Fields.List[1].ID;
                sprintField = Fields.List[0].ID;
            }

            //Fetch all of the tasks for a particular project
            Issues = Jira.RPC(API_ISSUES_LIST + HttpUtility.UrlEncode("\"" + projectKey + "\""));
            Dictionary<String, Object> parent = Issues as Dictionary<String, Object>;

            //Iterate over all of the issues
            IEnumerable<Object> issueList = parent["issues"] as IEnumerable<Object>;

            foreach(Dictionary<String, Object> issue in issueList) {
                TaskModel tm = new TaskModel();

            //Parse the data from each of the Jira fields, as supplied by the API
                Dictionary<String, Object> fields = issue["fields"] as Dictionary<String, Object>;

            //Creation date
                string created = fields["created"] as string;

                if (created == null) {
                    tm.Created = Epoch;
                } else {
                    tm.Created = DateTime.Parse(fields["created"] as string);
                }

            //Description
                tm.Description = fields["description"] as string;

            //Due date
                string due = fields["duedate"] as string;

                if (due == null) {
                    tm.DueDate = Epoch;
                } else {
                    tm.DueDate = DateTime.Parse(fields["duedate"] as string);
                }

            //Epic
                tm.Epic = fields[epicField] as string;

            //Issue
                Dictionary<String, Object> issueDetails = fields["issuetype"] as Dictionary<String, Object>;
                tm.Issue = issueDetails["name"] as string;

            //Name
                tm.Name = fields["summary"] as string;

            //Priority
                Dictionary<String, Object> priorityDetails = fields["priority"] as Dictionary<String, Object>;
                tm.Priority = priorityDetails["name"] as string;

            //Progress
                Dictionary<String, Object> progressDetails = fields["progress"] as Dictionary<String, Object>;
                tm.Progress = new ProgressModel();
                tm.Progress.Committed = (int)progressDetails["progress"];
                tm.Progress.Expected = (int)progressDetails["total"];

                if (progressDetails.ContainsKey("percent")) {
                    tm.Progress.Percent = (int)progressDetails["percent"];

                    if (tm.Progress.Percent > 100) { // If Committed > Expected, may be greater than 100%
                        tm.Progress.Percent = 100;
                    }
                } else {
                    if (tm.Progress.Expected > 0) {
                        tm.Progress.Percent = Convert.ToInt32(tm.Progress.Committed / tm.Progress.Expected);
                    } else {
                        tm.Progress.Percent = 0;
                    }
                }

            //Resolution
                if (fields["resolution"] == null) {
                    fields["resolution"] = null;
                } else {
                    Dictionary<String, Object> resolutionDetails = fields["resolution"] as Dictionary<String, Object>;
                    tm.Resolution = resolutionDetails["name"] as string;
                }

            //Resolution date
                string resolution = fields["resolutiondate"] as string;

                if(resolution == null) {
                    tm.ResolutionDate = Epoch;
                } else {
                    tm.ResolutionDate = DateTime.Parse(fields["resolutiondate"] as string);
                }

            //Status
                Dictionary<String, Object> statusDetails = fields["status"] as Dictionary<String, Object>;
                tm.Status = statusDetails["name"] as string;

            //Add this task to the appropriate sprint
                object[] sprint = fields[sprintField] as object[];

                if (sprint == null) {
                    addToSprint(null, tm);
                } else {
                    addToSprint(sprint[0] as string, tm);
                }

            //Add the tasks to a flat array of tasks
                Tasks.Add(tm);
            }

            //Sort the tasks
            foreach (SprintModel sm in List) {
                sm.Tasks.Sort((x, y) => x.Created.CompareTo(y.Created));
                Tasks.Sort((x, y) => x.Created.CompareTo(y.Created));
            }
        }