Пример #1
0
        public Expand GetIssueDetails(string issues, int startAt = 0, int maxResults = 50)
        {
            List <string> fields = new List <string> {
                "issuetype", "project", "key", "summary", "assignee", "status", "fixVersions", "created", "reporter", "updated", "customfield_10200", "customfield_10101"
            };

            string jql = "issue in (" + issues + ")";

            SearchRequest request = new SearchRequest
            {
                Fields     = fields,
                Jql        = jql,
                MaxResults = maxResults,
                StartAt    = startAt
            };

            string data = JsonConvert.SerializeObject(request);

            string result = RunQuery(JiraResource.search, data: data, method: "POST");

            Expand response = JsonConvert.DeserializeObject <Expand>(result);

            return(response);
        }
Пример #2
0
        // Process issue details and its worlogs
        public List <JiraTimeSheet> ProcessIssueWorkLogs(string issues, DateTime startDate, DateTime endDate)
        {
            List <JiraTimeSheet> jiraTimeSheetList = new List <JiraTimeSheet>();
            JiraManager          manager           = new JiraManager();

            int startAt = 0;
            int total;

            do
            {
                Expand keyDetailsList = manager.GetIssueDetails(issues, startAt);
                foreach (Issue keyDetails in keyDetailsList.IssueList)
                {
                    //Call jira rest api to get all worklogs for a issue
                    WorklogOfIssue workLogs   = manager.GetWorkLogsForIssue(keyDetails.Key);
                    IssueWorklog   objWorklog = GetIssueTimeSpent(workLogs, startDate, endDate);
                    if (objWorklog.TimeSpentSeconds > 0)
                    {
                        JiraTimeSheet jiraTimeSheet = new JiraTimeSheet();
                        foreach (FixVersion fixVersion in keyDetails.Fields.FixVersions)
                        {
                            if (!string.IsNullOrEmpty(jiraTimeSheet.FixVersions))
                            {
                                jiraTimeSheet.FixVersions += fixVersion.Version;
                            }
                            else
                            {
                                jiraTimeSheet.FixVersions = fixVersion.Version;
                            }
                        }
                        if (keyDetails.Fields.AssigneeName != null)
                        {
                            jiraTimeSheet.Assignee = keyDetails.Fields.AssigneeName.Name;
                        }
                        if (keyDetails.Fields.OriginalAssignee != null)
                        {
                            jiraTimeSheet.OriginalAssignee = keyDetails.Fields.OriginalAssignee.Originalassignee;
                        }

                        jiraTimeSheet.Created        = keyDetails.Fields.CreatedDate.DateTime;
                        jiraTimeSheet.IssueType      = keyDetails.Fields.IssueType.Name;
                        jiraTimeSheet.Key            = keyDetails.Key;
                        jiraTimeSheet.Project        = keyDetails.Fields.Project.Name;
                        jiraTimeSheet.Reporter       = keyDetails.Fields.Reporter.reporter;
                        jiraTimeSheet.Status         = keyDetails.Fields.Status.Name;
                        jiraTimeSheet.Summary        = keyDetails.Fields.Summary;
                        jiraTimeSheet.TimeLoggedBy   = objWorklog.LoggedInPerson;
                        jiraTimeSheet.TimeSpent      = objWorklog.TimeSpent;
                        jiraTimeSheet.TotalTimeSpent = objWorklog.TimeSpentSeconds;
                        jiraTimeSheet.Updated        = keyDetails.Fields.UpdatedDate.DateTime;

                        if (keyDetails.Fields.Website != null)
                        {
                            jiraTimeSheet.Website = keyDetails.Fields.Website.WebSite;
                        }
                        jiraTimeSheetList.Add(jiraTimeSheet);
                    }
                }
                total   = keyDetailsList.Total;
                startAt = startAt + 50;
            } while (startAt < total);
            if (jiraTimeSheetList.Count > 0)
            {
                jiraTimeSheetList = jiraTimeSheetList.OrderBy(o => o.Updated).ThenBy(o => o.Created).ThenBy(o => o.FixVersions).ToList();
            }
            return(jiraTimeSheetList);
        }