예제 #1
0
        private async void OnAddButtonTapped(object obj)
        {
            try
            {
                var issue = new Models.Issues
                {
                    AttachmentsView = new List <Models.Attachments>(),

                    IssueCategoriesTitle   = this.CategoryTitle,
                    IssuesCategoriesId     = GetIssueCategoryId(this.CategoryTitle),
                    IssuesProjectsTitle    = this.ProjectTitle,
                    IssuesProjectsId       = GetIssueProjectId(this.ProjectTitle),
                    IssuesSeverityTitle    = this.SeverityTitle,
                    IssuesSeverityId       = GetIssueSeverityId(this.SeverityTitle),
                    IssuesCreatedBy        = Application.Current.Properties["Username"].ToString(),
                    IssuesCreatedDate      = DateTime.UtcNow,
                    IssuesDescription      = this.IssuesDescription,
                    IssuesExpectedBehavior = this.IssuesExpectedBehavior,
                    IssuesTitle            = this.IssuesTitle,
                    IssuesPriorityTitle    = " ",
                    IssuesStatusesTitle    = " ",
                    IssuesLastModifiedBy   = Application.Current.Properties["Username"].ToString(),
                    IssuesLastModifiedDate = DateTime.UtcNow,
                    IssuesProjectsIsActive = true,
                    IssuesStatusesId       = 2
                };
                if (CommentsComment != null || CommentsComment.Length != 0)
                {
                    var comments = new List <Models.Comments>
                    {
                        new Models.Comments
                        {
                            CommentedDate     = DateTime.UtcNow,
                            CommentsComment   = this.CommentsComment,
                            CommenterUserId   = new Guid(),
                            CommenterUserName = Application.Current.Properties["Username"].ToString()
                        }
                    };
                    issue.Comments = comments;
                }
                decimal issueId = await _issuesAPI.AddIssue(Xamarin.Forms.Application.Current.Properties["token"].ToString(), issue);

                if (AttachmentsImages != null || AttachmentsImages.Count != 0)
                {
                    foreach (var item in AttachmentsImages)
                    {
                        await SentAttachments(issueId, item);
                    }
                }
            }
            catch (NullReferenceException ex)
            {
                await MainPage.DisplayAlert(" ", "You need to fill all necessary fields", "Ok");
            }
            catch (Exception)
            {
                await MainPage.DisplayAlert(" ", "Can't Add Issue", "Ok");
            }
        }
예제 #2
0
 public ActionResult queryJiraIssues(List <string> project, List <string> sprint, string login, string password)
 {
     Models.Issues jiraI = new Models.Issues();
     jiraI.message = "";
     try
     {
         var          jira = Jira.CreateRestClient("https://jirabancobbm.atlassian.net", login, password);
         List <Issue> a    = jira.Issues.Queryable.ToList();
     }
     catch (Exception ex)
     {
         if (ex.Message.Contains("Unauthorized") || ex.InnerException.Message.Contains("Unauthorized"))
         {
             jiraI.message += "Your jira credentials do not match.\n";
         }
         else
         {
             jiraI.message += "There was some unknown error. Please try again later.\n";
         }
         return(View(jiraI));
     }
     if (project != null && sprint != null)
     {
         for (int i = 0; i < project.Count; i++)
         {
             if (project[i] == "" || sprint[i] == "")
             {
                 project.RemoveAt(i);
                 sprint.RemoveAt(i);
                 jiraI.message += "Issue at position " + (i + 1).ToString() + " left in blank.\n";
             }
         }
         if (project.Count > 0)
         {
             List <List <String> > allLists = queryJiraIssuesInfo(project, sprint, jiraI, login, password);
             jiraI.keys        = allLists[0];
             jiraI.labels      = allLists[1];
             jiraI.summaries   = allLists[2];
             jiraI.storypoints = allLists[3];
         }
     }
     else
     {
         jiraI.message += "Null parameters passed.";
     }
     return(View(jiraI));
 }
예제 #3
0
        // GET: Jira
        public ActionResult getJiraIssues(string project, string sprint, string login, string password)
        {
            Models.Issues jiraI = new Models.Issues();

            try
            {
                var          jira = Jira.CreateRestClient("https://jirabancobbm.atlassian.net", login, password);
                List <Issue> a    = jira.Issues.Queryable.ToList();
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Unauthorized") || ex.InnerException.Message.Contains("Unauthorized"))
                {
                    jiraI.message += "Your jira credentials do not match.\n";
                }
                else
                {
                    jiraI.message += "There was some unknown error. Please try again later.\n";
                }
                return(View(jiraI));
            }
            if (project != null && sprint != null)
            {
                if (project != "" && sprint != "")
                {
                    List <List <String> > allLists = getJiraIssuesInfo(project, sprint, login, password);
                    jiraI.keys        = allLists[0];
                    jiraI.labels      = allLists[1];
                    jiraI.summaries   = allLists[2];
                    jiraI.storypoints = allLists[3];
                    if (jiraI.keys.Count == 0)
                    {
                        jiraI.message += "No issues found for this sprint in this project.\n";
                    }
                }
                else
                {
                    jiraI.message += "Either the project or the sprint was left in blank.\n";
                }
            }
            else
            {
                jiraI.message += "Null parameters passed.";
            }
            return(View(jiraI));
        }
예제 #4
0
        private List <List <String> > queryJiraIssuesInfo(List <string> projects, List <string> keysQuery, Models.Issues jiraI, string login, string password)
        {
            var jira = Jira.CreateRestClient("https://jirabancobbm.atlassian.net", login, password);

            jira.Issues.ValidateQuery = false;

            jira.Issues.MaxIssuesPerRequest = 2000;
            List <String> keys        = new List <String>();
            List <String> labels      = new List <String>();
            List <String> summaries   = new List <String>();
            List <String> storypoints = new List <String>();
            List <String> ranks       = new List <String>();

            List <Issue> all_issues = new List <Issue>();

            for (int i = 0; i < projects.Count(); i++)
            {
                string project  = projects[i];
                string keyQuery = project + "-" + keysQuery[i];


                Issue issue = jira.Issues.Queryable.Where(j => j.Project == project && j.Type == "Story" && j.Key == keyQuery).FirstOrDefault();
                if (issue != null)
                {
                    keys.Add(issue.Key.Value.Replace("TARGARYENS", "T").Replace("STARKS", "S").Replace("TA", "A").Replace("TTDE", "TE").Replace("TB", "B").Replace("TD", "D"));

                    if (issue.Labels.Count() > 0)
                    {
                        labels.Add(issue.Labels[0]);
                    }
                    else
                    {
                        labels.Add("");
                    }

                    if (issue.CustomFields["Story Points"] != null && issue.CustomFields["Story Points"].Values != null && issue.CustomFields["Story Points"].Values.Count() > 0)
                    {
                        storypoints.Add(issue.CustomFields["Story Points"].Values[0]);
                    }
                    else
                    {
                        storypoints.Add("");
                    }
                    if (issue.Summary.Contains("[") && issue.Summary.Contains("]"))
                    {
                        String[] auxiliar = issue.Summary.Split(']');
                        summaries.Add(auxiliar[1].Substring(1));
                    }
                    else
                    {
                        summaries.Add(issue.Summary);
                    }

                    ranks.Add(issue.CustomFields["Rank"].Values[0]);
                }
                else
                {
                    jiraI.message += "Issue " + keyQuery + " was not found in Jira.\n";
                }
            }
            List <List <String> > allLists = new List <List <String> >();

            orderLists(ref ranks, ref keys, ref summaries, ref storypoints, ref labels);
            allLists.Add(keys);
            allLists.Add(labels);
            allLists.Add(summaries);
            allLists.Add(storypoints);
            return(allLists);
        }