Exemplo n.º 1
0
        public /*string*/ void JiraInfo(string jira, string va, string auth, string UField)
        {
            var j = new Get();
            //parse response to JTOKEN which allows to extract ids until a certain level
            var jsonResponse = j.Jrequest(jira, "issue/", va, auth);

            if (jsonResponse.Contains("errorMessages") == false)
            {
                //var help = JToken.Parse(jsonResponse);
                var objectparsejson = JObject.Parse(jsonResponse);


                if ((jirainfo.Exists(x => x.Jiraid == va) == false))
                {//adding defect information to jirainfo object list
                    jirainfo.Add(new Jiras()
                    {
                        Jiraid      = va,
                        Jirasummary = objectparsejson["fields"]["summary"].ToString(),
                        UbiPrio     = FormattingActions.UbiPrioP(jsonResponse, UField),
                        //Priority = Prio(jsonResponse),
                        Priority   = objectparsejson["fields"]["priority"]["name"].ToString(),
                        IssueType  = objectparsejson["fields"]["issuetype"]["name"].ToString(),
                        Status     = objectparsejson["fields"]["status"]["name"].ToString(),
                        id_link    = "<a href=\"https://mdc-tomcat-jira" + jira + ".ubisoft.org/jira/browse/" + objectparsejson["key"] + "\">" + objectparsejson["key"] + "</a>",
                        Regression = FormattingActions.RegressionP(jsonResponse)
                    });
                }
            }
        }
Exemplo n.º 2
0
        public void PlanReport(string name, int index, int sort_index, string jiraValue)
        {
            //button for plan generations
            string Jauth; string[] runs_id, defect_id; int a;

            //gets the selected testplan

            //calculate key for jira authentication
            Jauth = Gen_Authen(jiraLogin, pass);
            //get the jira entered by the user

            //gets the runs for the selected test plan
            string runId = GetPlan(_testrailId[index], testrailLogin, pass);

            //ze runs are split
            runs_id = runId.Split('\n').ToArray();

            //var myList = new List<string>();
            //for (int i = 0; i < d.Length - 1; i++)
            //    myList.Add(d[i]);
            ////this contains all the runs extracted from testplan
            //df = myList.ToArray();


            //retrieve the id for Ubi Priority fiels. differs between jira instances
            string UField = GetUbiPrioId(jiraValue, Jauth);

            //        getting runs from each plan
            //List<string> items = new List<string>();
            //Thread mth = new Thread(() => PlanThreads(uj, ut, Password.Text, j, name, df));
            //mth.Start();

            string defects = "";

            //Building the email report header
            string resort = "Your Text Goes Here\n<table border=1><tr><th bgcolor=#3A5DAD><font color=#FFFFFF>Jira Id</font></th><th width=\"250\" bgcolor=#3A5DAD><font color=#FFFFFF>Summary</font></th>";

            //if fields are checked they are added
            if (issueType)
            {
                resort += "<th width =\"50\" bgcolor=#3A5DAD><font color=#FFFFFF>Issue Type</font></th>";
            }
            if (ubiPriority)
            {
                resort += "<th bgcolor =#3A5DAD><font color=#FFFFFF>UbiPrio</font></th>";
            }
            if (priority)
            {
                resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Priority</font></th>";
            }
            if (status)
            {
                resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Status</font></th>";
            }

            resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Regression</font></th><th bgcolor=#3A5DAD><font color=#FFFFFF>Comments</font></th></tr>";

            for (int o = 0; o < runs_id.Length; o++)
            {
                // get testid for each of the runs in plan
                if (runs_id[o] != "")
                {
                    string   testId = GetTestId(runs_id[o], testrailLogin, pass);
                    string[] tr     = testId.Split(',');
                    //int n = tr.Length;

                    //Getting the defects from test ids
                    for (int i = 0; i < tr.Length - 1; i++)
                    {
                        if (tr[i] != null)
                        {
                            defects = GetResults(tr[i], testrailLogin, pass) + defects + ",";
                        }
                    }
                    //distinct defects moved to string array
                    defect_id = defects.Split(',').Distinct().ToArray();

                    //get Jira information for each of the defects
                    for (int i = 0; i < defect_id.Length; i++)
                    {
                        if (defect_id[i] != null && defect_id[i] != "")
                        {
                            //d[i].TrimStart(' ');
                            var parsedIssue = defect_id[i].TrimStart(' ');
                            //add information into the table string
                            JiraInfo(jiraValue, parsedIssue, Jauth, UField);
                        }
                    }
                }
            }

            //creating the sorting
            switch (sort_index)
            {
            case 0:
                jirainfo.Sort((x, y) => x.UbiPrio.CompareTo(y.UbiPrio));
                break;

            //to enable uncomment
            //case 1:
            //    jirainfo.Sort((x, y) => y.UbiPrio.CompareTo(x.UbiPrio));
            //    break;
            case 2:
                jirainfo.Sort((x, y) => y.Jiraid.CompareTo(x.Jiraid));
                break;

            case 3:
                jirainfo.Sort((x, y) => x.Jiraid.CompareTo(y.Jiraid));
                break;

            default:
                break;
            }

            //adding the issues into the table in html code
            foreach (Jiras jira_variab in jirainfo)
            {
                resort += "<tr><td>" + jira_variab.id_link + "</td><td>" + jira_variab.Jirasummary + "</td>";

                if (issueType)
                {
                    resort += "<td>" + jira_variab.IssueType + "</td>";
                }
                if (ubiPriority)
                {
                    resort += FormattingActions.FormatUp(jira_variab.UbiPrio) + "</td>";
                }
                if (priority)
                {
                    resort += "<td>" + FormattingActions.Prio(jira_variab.Priority) + " </td>";
                }
                if (status)
                {
                    resort += "<td>" + jira_variab.Status + " </td>";
                }

                resort += "<td>" + jira_variab.Regression + "</td><td>" + jira_variab.Comment + "</td></tr>";
            }
            //starts the email preparation
            Thread mth = new Thread(() => PlanThreads(name, resort));

            mth.Start();
        }
Exemplo n.º 3
0
        public void RunReport(string name, int runs_index, int sort_index, string jiravalue)
        {
            //initialization
            string defects = ""; string[] defect_id;
            // pass the jira instance

            //Building the email report header
            string resort = "Your Text Goes Here\n<table border=1><tr><th bgcolor=#3A5DAD><font color=#FFFFFF>Jira Id</font></th><th width=\"250\" bgcolor=#3A5DAD><font color=#FFFFFF>Summary</font></th>";

            //based on the which field is checked, info is added to the header
            if (issueType)
            {
                resort += "<th width =\"70\" bgcolor=#3A5DAD><font color=#FFFFFF>Issue Type</font></th>";
            }
            if (ubiPriority)
            {
                resort += "<th bgcolor =#3A5DAD><font color=#FFFFFF>UbiPrio</font></th>";
            }
            if (priority)
            {
                resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Priority</font></th>";
            }
            if (status)
            {
                resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Status</font></th>";
            }

            resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Regression</font></th><th bgcolor=#3A5DAD><font color=#FFFFFF>Comments</font></th></tr>";

            //generate the authentication string
            string Jauth = Gen_Authen(jiraLogin, pass);

            // Test id's for said run
            string ds = GetTestId(_runsId[runs_index], testrailLogin, pass);

            //splitting the test id's
            string[] tr     = ds.Split(',');
            string   UField = GetUbiPrioId(jiravalue, Jauth);

            //Getting the defects from test ids
            for (int i = 0; i < tr.Length - 1; i++)
            {
                if (tr[i] != null)
                {
                    defects = GetResults(tr[i], testrailLogin, pass) + defects + ",";
                }
                //jirainfo.Add(jirainfo)
            }
            //distinct defects moved to string array

            defect_id = defects.Split(',').Distinct().ToArray();
            //parsing the defects, triming if necessary, adding them to JiraInfo list
            for (int i = 0; i < defect_id.Length; i++)
            {
                if (defect_id[i] != null && defect_id[i] != "")
                {
                    var parsedissue = defect_id[i].TrimStart(' ');
                    JiraInfo(jiravalue, parsedissue, Jauth, UField);
                }
            }

            //creating the sorting
            switch (sort_index)
            {
            case 0:
                jirainfo.Sort((x, y) => x.UbiPrio.CompareTo(y.UbiPrio));
                break;

            //to enable uncomment
            //case 1:
            //    jirainfo.Sort((x, y) => y.UbiPrio.CompareTo(x.UbiPrio));
            //    break;
            case 2:
                jirainfo.Sort((x, y) => y.Jiraid.CompareTo(x.Jiraid));
                break;

            case 3:
                jirainfo.Sort((x, y) => x.Jiraid.CompareTo(y.Jiraid));
                break;

            default:
                break;
            }

            //adding the information to the resort string
            foreach (Jiras jira_variab in jirainfo)
            {
                resort += "<tr><td>" + jira_variab.id_link + "</td><td>" + jira_variab.Jirasummary + "</td>";

                if (issueType)
                {
                    resort += "<td>" + jira_variab.IssueType + "</td>";
                }
                if (ubiPriority)
                {
                    resort += FormattingActions.FormatUp(jira_variab.UbiPrio) + "</td>";
                }
                if (priority)
                {
                    resort += "<td>" + FormattingActions.Prio(jira_variab.Priority) + "</td>";
                }
                if (status)
                {
                    resort += "<td>" + jira_variab.Status + "</td>";
                }

                resort += "<td>" + jira_variab.Regression + "</td><td>" + jira_variab.Comment + "</td></tr>";
            }


            //complete the string to define table
            resort = resort + "</table>";

            //Thread mth = new Thread(() => RunsThread(uj, ut, Password.Text, _runsId[b], j, name));
            //mth.Start();
            Thread mth = new Thread(() => RunsThread(resort, name));

            mth.Start();
        }
Exemplo n.º 4
0
        public async Task JiraReport(string name, int a, string j, int sort_index)
        {
            //the object list is cleared
            jirainfo.Clear();
            //generate the authentication string
            string auth = Gen_Authen(jiraLogin, pass);

            //Building the email report header
            string resort = "Your Text Goes Here\n<table border=1><tr><th bgcolor=#3A5DAD><font color=#FFFFFF>Jira Id</font></th><th width=\"250\" bgcolor=#3A5DAD><font color=#FFFFFF>Summary</font></th>";

            //checked fields are added to the header
            if (issueType)
            {
                resort += "<th width =\"70\" bgcolor=#3A5DAD><font color=#FFFFFF>Issue Type</font></th>";
            }
            if (ubiPriority)
            {
                resort += "<th bgcolor =#3A5DAD><font color=#FFFFFF>UbiPrio</font></th>";
            }
            if (priority)
            {
                resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Priority</font></th>";
            }
            if (status)
            {
                resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Status</font></th>";
            }

            resort += "<th bgcolor=#3A5DAD><font color=#FFFFFF>Regression</font></th><th bgcolor=#3A5DAD><font color=#FFFFFF>Comments</font></th></tr>";

            //jiras except 19have a different field id
            string UField = GetUbiPrioId(j, auth);

            //a jira filter will only show the first 50 issues so a bypass using MaxRes argument
            // verification for total number of issues in filter to know if MaxRes bypass is needed
            var help = JToken.Parse(MaxRes(links[a], auth));

            int total = Int32.Parse(help["total"].ToString());
            int max   = Int32.Parse(help["maxResults"].ToString());

            var call = new Get();

            //if nr of issues in filter >50, we need to have a modified get
            if (total > max)
            {
                var helps = JToken.Parse(call.Jrequest(j, links[a], "&maxResults=" + total.ToString(), auth));

                //get Jira information for each of the defects
                for (int i = 0; i < total; i++)
                {
                    JiraInfo(j, helps["issues"][i]["key"].ToString(), auth, UField);
                }
            }
            else
            {
                //get jira information for each of the defects
                for (int i = 0; i < total; i++)
                {
                    JiraInfo(j, help["issues"][i]["key"].ToString(), auth, UField);
                }
            }


            //jira issues loaded in jirainfo are sorted based on the index of the users list selection
            switch (sort_index)
            {
            case 0:
                jirainfo.Sort((x, y) => x.UbiPrio.CompareTo(y.UbiPrio));
                break;

            //to enable the scenario uncomment
            //case 1:
            //    jirainfo.Sort((x, y) => y.UbiPrio.CompareTo(x.UbiPrio));
            //    break;
            case 2:
                jirainfo.Sort((x, y) => y.Jiraid.CompareTo(x.Jiraid));
                break;

            case 3:
                jirainfo.Sort((x, y) => x.Jiraid.CompareTo(y.Jiraid));
                break;

            default:
                break;
            }
            //adding the defects to the report in html format
            foreach (Jiras jira_variab in jirainfo)
            {
                resort += "<tr><td>" + jira_variab.id_link + "</td><td>" + jira_variab.Jirasummary + "</td>";

                if (issueType)
                {
                    resort += "<td>" + jira_variab.IssueType + "</td>";
                }
                if (ubiPriority)
                {
                    resort += FormattingActions.FormatUp(jira_variab.UbiPrio) + "</td>";
                }
                if (priority)
                {
                    resort += "<td>" + FormattingActions.Prio(jira_variab.Priority) + " </td>";
                }
                if (status)
                {
                    resort += "<td>" + jira_variab.Status + "</td>";
                }

                resort += "<td>" + jira_variab.Regression + "</td><td>" + jira_variab.Comment + "</td></tr>";
            }



            resort = resort + "</table>";
            //starting the mail thread
            Thread mth = new Thread(() => JiraFilterThread(name, j, resort));

            mth.Start();
        }