private async void btnLookUpInJiraAndSF_Click(object sender, EventArgs e)
        {
            this.btnLookUpInJiraAndSF.Enabled = false;

            string emailAddress = this.ddlReviewerEmailAddress.SelectedValue as string;

            if ("*****@*****.**" == emailAddress)
            {
                emailAddress = emailAddress.Replace("@missionsky.com", "");
            }

            var issues = await JiraProxy.GetIssueList(emailAddress);

            List <string> caseList = new List <string>();
            Dictionary <string, AccelaIssueCaseMapper> JiraMapping = new Dictionary <string, AccelaIssueCaseMapper>();

            foreach (var issue in issues)
            {
                AccelaIssueCaseMapper accelaIssueCaseMapper = new AccelaIssueCaseMapper();
                accelaIssueCaseMapper.CaseNumber = issue.fields.customfield_10600;
                accelaIssueCaseMapper.Assignee   = (issue.fields.assignee == null ? "" : issue.fields.assignee.displayName);
                accelaIssueCaseMapper.JiraKey    = issue.key;
                accelaIssueCaseMapper.JiraId     = issue.id;
                accelaIssueCaseMapper.Status     = issue.fields.status.name;
                accelaIssueCaseMapper.HotCase    = issue.fields.labels.Contains("HotCase");

                if (String.IsNullOrEmpty(accelaIssueCaseMapper.CaseNumber))
                {
                    continue;
                }

                if (!JiraMapping.ContainsKey(accelaIssueCaseMapper.CaseNumber))
                {
                    JiraMapping.Add(accelaIssueCaseMapper.CaseNumber, accelaIssueCaseMapper);
                }
                else
                {
                    System.Console.WriteLine("Duplicated Case: " + accelaIssueCaseMapper.CaseNumber);
                    if ("CLOSED".Equals(JiraMapping[accelaIssueCaseMapper.CaseNumber].Status, StringComparison.CurrentCultureIgnoreCase))
                    {
                        JiraMapping[accelaIssueCaseMapper.CaseNumber] = accelaIssueCaseMapper;
                    }
                }
                caseList.Add(accelaIssueCaseMapper.CaseNumber);
            }

            DataTable table = new DataTable("CaseList");

            table.Columns.Add("ID", typeof(string));
            table.Columns.Add("No", typeof(int));
            table.Columns.Add("Product", typeof(string));
            table.Columns.Add("SalesforceID", typeof(string));
            table.Columns.Add("JiraKey", typeof(string));
            table.Columns.Add("JiraID", typeof(string));
            table.Columns.Add("Type", typeof(string));
            table.Columns.Add("Version", typeof(string));
            table.Columns.Add("Priority", typeof(string));
            table.Columns.Add("Customer", typeof(string));
            table.Columns.Add("Summary", typeof(string));
            table.Columns.Add("Reviewer", typeof(string));
            table.Columns.Add("ReopenedCount", typeof(string));
            table.Columns.Add("SFQueue", typeof(string));
            table.Columns.Add("SFStatus", typeof(string));
            table.Columns.Add("JiraStatus", typeof(string));
            table.Columns.Add("JiraNextStatus", typeof(string));

            if (caseList.Count == 0)
            {
                this.grdCaseList.DataSource          = table;
                this.grdCaseList.AutoGenerateColumns = false;
                this.btnLookUpInJiraAndSF.Enabled    = true;
                return;
            }

            Dictionary <string, string> Reviewers = new Dictionary <string, string>();

            Reviewers.Add("Jessy", "Jessy.Zhang");
            Reviewers.Add("Adger", "Adger.Chen");
            Reviewers.Add("Tim", "Tim.Liu");

            Reviewers.Add("Mia", "Mia.Huang");
            Reviewers.Add("Alvin", "Alvin.Li");
            Reviewers.Add("Mina", "Mina.Xiong");

            Reviewers.Add("Peter", "Peter.Peng");
            Reviewers.Add("John", "John.Huang");
            Reviewers.Add("Bass", "Bass.Yang");
            Reviewers.Add("Star", "Star.Li");
            Reviewers.Add("Shaun", "Shaun.Qiu");
            Reviewers.Add("Lex", "Lex.Wu");
            Reviewers.Add("Louis", "Louis.He");
            Reviewers.Add("Likko", "Likko.Zhang");
            Reviewers.Add("Sandy", "Sandy.Zheng");
            Reviewers.Add("Weber", "Weber.Yan");
            Reviewers.Add("Rick", "Rick.Liu");
            Reviewers.Add("Matt", "Matt.Ao");
            Reviewers.Add("Hyman", "Hyman.Zhang");
            Reviewers.Add("Feng", "Feng.Xuan");
            Reviewers.Add("Cheng", "Cheng.Xu");
            Reviewers.Add("Alex", "Alex.Li");

            Reviewers.Add("Mandy", "Mandy.Zhou");
            Reviewers.Add("Linda", "Linda.Xiao");
            Reviewers.Add("Leo", "Leo.Liu");
            Reviewers.Add("Abel", "Abel.Yu");
            Reviewers.Add("Claire", "Claire.Cao");
            Reviewers.Add("Viola", "Viola.Shi");
            Reviewers.Add("Larry", "Larry.Francisco");

            Reviewers.Add("Gordon", "Gordon.Chen");
            Reviewers.Add("Tracy", "Tracy.Xiang");

            Reviewers.Add("Jessie", "Jessie.Zhang");
            Reviewers.Add("William", "William.Wang");

            Reviewers.Add("Carly", "Carly.Xu");
            Reviewers.Add("Janice", "Janice.Zhong");
            Reviewers.Add("Jane", "Jane.Hu");
            Reviewers.Add("Amy", "Amy.Bao");
            Reviewers.Add("Iris", "Iris.Wang");
            Reviewers.Add("Grace", "Grace.Tang");
            Reviewers.Add("Cloud", "Clouid.Qi");
            Reviewers.Add("Carol", "Carol.Gong");

            Reviewers.Add("Manasi", "*****@*****.**");
            Reviewers.Add("Sasirekha", "*****@*****.**");
            Reviewers.Add("Jerry", "Jerry.Lu");

            var  jiraId                     = "";
            var  jiraKey                    = "";
            var  customer                   = "";
            var  assignee                   = "";
            var  jiaStstus                  = "";
            var  reopenCount                = 0;
            bool isCommentedToday           = false;
            int  index                      = 1;
            AccelaIssueCaseMapper tempIssue = null;
            var cases = await SalesforceProxy.GetCaseList(caseList);

            foreach (var caseinfo in cases)
            {
                tempIssue = null;
                if (JiraMapping.ContainsKey(caseinfo.CaseNumber))
                {
                    tempIssue = JiraMapping[caseinfo.CaseNumber];
                }

                DataRow row = table.NewRow();
                row["ID"]           = caseinfo.Id;
                row["No"]           = index;
                row["Product"]      = AccelaCaseUtil.AdjustProductName(caseinfo.Product, caseinfo.Solution, caseinfo.Subject, caseinfo.Description);
                row["SalesforceID"] = caseinfo.CaseNumber;
                jiraId         = (tempIssue != null ? tempIssue.JiraId : "");
                row["JiraID"]  = jiraId;
                jiraKey        = (tempIssue != null ? tempIssue.JiraKey : "");
                row["JiraKey"] = jiraKey;
                row["Type"]    = caseinfo.Type;
                row["Version"] = caseinfo.CurrentVersion;
                string[] severity = caseinfo.Priority.Split(' ');
                row["Priority"]      = severity[1];
                customer             = (caseinfo.Customer != null && !String.IsNullOrEmpty(caseinfo.Customer.Name) ? caseinfo.Customer.Name : (caseinfo.Account != null ? caseinfo.Account.Name : ""));
                row["Customer"]      = customer;
                row["Summary"]       = caseinfo.Subject;
                reopenCount          = (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null ? caseinfo.CaseComments.Records.Count - 1 : 0);
                row["ReopenedCount"] = reopenCount;
                row["SFQueue"]       = caseinfo.Owner.Name;
                row["SFStatus"]      = caseinfo.Status;
                jiaStstus            = (tempIssue != null ? tempIssue.Status : "");
                row["JiraStatus"]    = jiaStstus;

                assignee = (tempIssue != null ? tempIssue.Assignee : "");

                isCommentedToday = false;
                if (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null)
                {
                    CaseComment comment = caseinfo.CaseComments.Records[0];

                    isCommentedToday = (comment.CreatedDate.Year == DateTime.Now.Year && comment.CreatedDate.Month == DateTime.Now.Month && comment.CreatedDate.Day == DateTime.Now.Day ? true : false);
                    if (!String.IsNullOrEmpty(assignee) && comment.CommentBody.ToUpper().Contains(assignee.ToUpper()))
                    {
                    }
                    else
                    {
                        foreach (var key in Reviewers.Keys)
                        {
                            string value  = Reviewers[key];
                            string value1 = value.Replace('.', ' ');
                            if (comment.CommentBody.ToUpper().EndsWith(key.ToUpper()) ||
                                comment.CommentBody.ToUpper().EndsWith(value.ToUpper()) ||
                                comment.CommentBody.ToUpper().EndsWith(value1.ToUpper()))
                            {
                                assignee = Reviewers[key];
                                break;
                            }
                        }
                    }
                }

                /*
                 * if ("CLOSED".Equals(caseinfo.Status, StringComparison.InvariantCultureIgnoreCase)
                 *  && !"CLOSED".Equals(jiaStstus, StringComparison.InvariantCultureIgnoreCase))
                 * {
                 *  row["JiraNextStatus"] = "Closed";
                 * }
                 *
                 * if ("engineering".Equals(caseinfo.Owner.Name, StringComparison.InvariantCultureIgnoreCase)
                 *  && "eng new".Equals(caseinfo.Status, StringComparison.InvariantCultureIgnoreCase))
                 * {
                 *  if (isCommentedToday)
                 *  {
                 *      row["JiraNextStatus"] = "Pending";
                 *  }
                 *  else
                 *  {
                 *      if (!"Open".Equals(jiaStstus, StringComparison.InvariantCultureIgnoreCase)
                 *          && !"In Progress".Equals(jiaStstus, StringComparison.InvariantCultureIgnoreCase))
                 *      {
                 *          row["JiraNextStatus"] = "In Progress";
                 *      }
                 *  }
                 * }
                 *
                 * if (isCommentedToday && !"Pending".Equals(jiaStstus, StringComparison.InvariantCultureIgnoreCase))
                 * {
                 *  row["JiraNextStatus"] = "Pending";
                 * }
                 * */
                row["JiraNextStatus"] = AccelaCaseUtil.GetNextJIRAStatus(caseinfo.Owner.Name, caseinfo.Status, jiaStstus, isCommentedToday);

                row["Reviewer"] = assignee;

                table.Rows.Add(row);
                index++;
            }

            this.grdCaseList.AutoGenerateColumns = false;
            this.grdCaseList.DataSource          = table;

            this.btnLookUpInJiraAndSF.Enabled = true;
        }
示例#2
0
        private async void btnSyncWithJiraAndSF_Click(object sender, EventArgs e)
        {
            this.btnSendSummaryReport.Enabled = false;
            this.btnSyncWithJiraAndSF.Enabled = false;

            List <string> problemCaseIDList = new List <string>();

            // 1, Construct one case list from the specified case list
            // 1.1 Check if the case list formate is valid or not
            // 1.2 Construct one case list
            string        caseIDs    = this.txtCaseIDList.Text;
            List <string> caseIdList = new List <string>();

            if (String.IsNullOrEmpty(caseIDs) || caseIDs.Trim().Length == 0)
            {
                // Show one error message "ERROR: Please enter case id"
                (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Please enter case id");

                this.btnSendSummaryReport.Enabled = true;
                this.btnSyncWithJiraAndSF.Enabled = true;

                return;
            }
            else
            {
                (this.MdiParent as MainForm).ShowStatusMessage("");

                string[] caseIDArray = caseIDs.Split(',');
                Regex    reg         = new Regex(@"\d{2}ACC-\d{5}");
                foreach (string caseId in caseIDArray)
                {
                    if (reg.IsMatch(caseId))
                    {
                        if (!caseIdList.Contains(caseId.Trim()))
                        {
                            caseIdList.Add(caseId.Trim());
                        }
                    }
                    else
                    {
                        // Show one error message "ERROR: Invalid Format for XXXX"
                        (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Invalid Format for " + caseId);

                        this.btnSendSummaryReport.Enabled = true;
                        this.btnSyncWithJiraAndSF.Enabled = true;

                        return;
                    }
                }
            }

            var caseList  = new List <AccelaCase>();
            var issueList = new List <Issue>();

            int N = 1;

            for (int i = 0; i < caseIdList.Count;)
            {
                List <string> caseIdListTemp = new List <string>();
                for (; i < N * 50 && i < caseIdList.Count; i++)
                {
                    caseIdListTemp.Add(caseIdList[i]);
                }

                N = N + 1;

                var GetCaseList  = SalesforceProxy.GetCaseList(caseIdListTemp);
                var GetIssueList = JiraProxy.GetIssueList(caseIdListTemp);

                var caseListTmp  = await GetCaseList;
                var issueListTmp = await GetIssueList;

                if (caseIdListTemp.Count != caseListTmp.Count)
                {
                    foreach (var tempCase in caseListTmp)
                    {
                        string caseID = tempCase.CaseNumber;
                        if (caseIdListTemp.Contains(caseID))
                        {
                            caseIdListTemp.Remove(caseID);
                        }
                    }

                    problemCaseIDList.AddRange(caseIdListTemp);
                }
                caseList.AddRange(caseListTmp);
                issueList.AddRange(issueListTmp);
            }

            if (problemCaseIDList != null && problemCaseIDList.Count > 0)
            {
                System.Console.WriteLine("Below case id are lost.");
                foreach (string lostCaseId in problemCaseIDList)
                {
                    System.Console.WriteLine(lostCaseId);
                }
            }

            Dictionary <string, AccelaIssueCaseMapper> JiraMapping = new Dictionary <string, AccelaIssueCaseMapper>();

            foreach (var issue in issueList)
            {
                if (!JiraMapping.ContainsKey(issue.fields.customfield_10600))
                {
                    AccelaIssueCaseMapper accelaIssueCaseMapper = new AccelaIssueCaseMapper();
                    accelaIssueCaseMapper.CaseNumber    = issue.fields.customfield_10600;
                    accelaIssueCaseMapper.Assignee      = (issue.fields.assignee == null ? "" : issue.fields.assignee.displayName);
                    accelaIssueCaseMapper.AssigneeQA    = (issue.fields.customfield_11702 == null ? "" : issue.fields.customfield_11702.displayName);
                    accelaIssueCaseMapper.JiraId        = issue.id;
                    accelaIssueCaseMapper.JiraKey       = issue.key;
                    accelaIssueCaseMapper.IssueCategory = (issue.fields.customfield_11502 != null && issue.fields.customfield_11502.Count > 0 ? issue.fields.customfield_11502[0].value : "--NONE--");
                    accelaIssueCaseMapper.LastModified  = issue.fields.customfield_10903;
                    accelaIssueCaseMapper.Status        = issue.fields.status.name;
                    accelaIssueCaseMapper.HotCase       = issue.fields.labels.Contains("HotCase");
                    accelaIssueCaseMapper.Missionsky    = issue.fields.labels.Contains("Missionsky");
                    accelaIssueCaseMapper.JiraLabels    = issue.fields.labels;
                    accelaIssueCaseMapper.FixVersions   = new List <string>();

                    if (issue.fields.fixVersions != null)
                    {
                        foreach (var fixVersion in issue.fields.fixVersions)
                        {
                            accelaIssueCaseMapper.FixVersions.Add(fixVersion.name);
                        }
                    }

                    JiraMapping.Add(accelaIssueCaseMapper.CaseNumber, accelaIssueCaseMapper);
                }
            }

            DataTable table = new DataTable("Daily Report");

            table.Columns.Add("ID", typeof(string));
            table.Columns.Add("No", typeof(int));
            table.Columns.Add("HotCase", typeof(bool));
            table.Columns.Add("Missionsky", typeof(bool));
            table.Columns.Add("JiraLabels", typeof(List <string>));
            table.Columns.Add("ProductForUI", typeof(string));
            table.Columns.Add("Product", typeof(string));
            table.Columns.Add("Solution", typeof(string));
            table.Columns.Add("Orgin", typeof(string));
            table.Columns.Add("OpenDate", typeof(string));
            table.Columns.Add("Severity", typeof(string));
            table.Columns.Add("Rank", typeof(int));
            table.Columns.Add("SalesforceID", typeof(string));
            table.Columns.Add("JiraID", typeof(string));
            table.Columns.Add("JiraKey", typeof(string));
            table.Columns.Add("Type", typeof(string));
            table.Columns.Add("Version", typeof(string));
            table.Columns.Add("Customer", typeof(string));
            table.Columns.Add("Summary", typeof(string));
            table.Columns.Add("Description", typeof(string));
            table.Columns.Add("Reviewer", typeof(string));
            table.Columns.Add("Comments", typeof(string));
            table.Columns.Add("ReopenedCount", typeof(string));
            table.Columns.Add("JiraStatus", typeof(string));
            table.Columns.Add("NextJiraStatus", typeof(string));
            table.Columns.Add("SFQueue", typeof(string));
            table.Columns.Add("SFStatus", typeof(string));
            table.Columns.Add("SFLastModified", typeof(string));
            table.Columns.Add("CaseComment", typeof(CaseComment));
            table.Columns.Add("FixVersions", typeof(string));
            table.Columns.Add("ReleaseInfo", typeof(string));
            table.Columns.Add("TargetedRelease", typeof(string));
            table.Columns.Add("InternalType", typeof(string));
            table.Columns.Add("EngineeringStatus", typeof(string));
            table.Columns.Add("BZID", typeof(string));
            table.Columns.Add("IssueCategory", typeof(string));
            table.Columns.Add("Assignee", typeof(string));
            table.Columns.Add("AssigneeQA", typeof(string));
            table.Columns.Add("CaseComments", typeof(List <CaseComment>));

            Dictionary <string, string> Reviewers = SalesforceProxy.GetReviewerNamesList();

            int index = 1;
            AccelaIssueCaseMapper tempIssue = null;
            string openDate    = "";
            string jiraKey     = "";
            string jiraId      = "";
            string customer    = "";
            string assignee    = "";
            int    reopenCount = 0;
            string jiaStstus   = "";

            string[] Severity         = null;
            string   temComment       = "";
            string   lastModifiedDate = "";

            int rank = 0;

            foreach (var caseinfo in caseList)
            {
                tempIssue = null;
                if (JiraMapping.ContainsKey(caseinfo.CaseNumber))
                {
                    tempIssue = JiraMapping[caseinfo.CaseNumber];
                }

                if (caseinfo.ReleaseInfo != null)
                {
                    //SalesforceProxy.GetReleaseInfoById(caseinfo.ReleaseInfo);
                }

                DataRow row = table.NewRow();
                row["ID"]            = caseinfo.Id;
                row["No"]            = index;
                row["HotCase"]       = (tempIssue != null && tempIssue.HotCase);
                row["Missionsky"]    = (tempIssue != null && tempIssue.Missionsky);
                row["JiraLabels"]    = (tempIssue != null ? tempIssue.JiraLabels : null);
                row["IssueCategory"] = (tempIssue != null ? tempIssue.IssueCategory : null);
                row["Assignee"]      = (tempIssue != null ? tempIssue.Assignee : null);
                row["AssigneeQA"]    = (tempIssue != null ? tempIssue.AssigneeQA : null);
                //row["HotCase"] = true;
                row["ProductForUI"] = AccelaCaseUtil.AdjustProductName(caseinfo.Product, caseinfo.Solution, caseinfo.Subject, caseinfo.Description);
                row["Product"]      = caseinfo.Product;
                row["Solution"]     = caseinfo.Solution;
                row["Orgin"]        = caseinfo.Origin;
                //openDate = caseinfo.CreatedDate.ToShortDateString();
                openDate = (caseinfo.CreatedDate.Month < 10 ? "0" + caseinfo.CreatedDate.Month : "" + caseinfo.CreatedDate.Month)
                           + "/" + (caseinfo.CreatedDate.Day < 10 ? "0" + caseinfo.CreatedDate.Day : "" + caseinfo.CreatedDate.Day)
                           + "/" + ("" + caseinfo.CreatedDate.Year);

                row["OpenDate"] = openDate;
                Severity        = caseinfo.Priority.Split(' ');
                row["Severity"] = Severity[1];

                rank = 0;
                if (!String.IsNullOrEmpty(caseinfo.RankOrder))
                {
                    rank = int.Parse(caseinfo.RankOrder);
                }
                else if (!String.IsNullOrEmpty(caseinfo.ServicesRank))
                {
                    rank = int.Parse(caseinfo.ServicesRank);
                }
                else
                {
                    rank = 0;
                }

                row["Rank"] = rank;

                row["SalesforceID"] = caseinfo.CaseNumber;
                jiraKey             = (tempIssue != null ? tempIssue.JiraKey : "");
                jiraId         = (tempIssue != null ? tempIssue.JiraId : "");
                row["JiraKey"] = jiraKey;
                row["JiraID"]  = jiraId;
                row["Type"]    = (String.IsNullOrEmpty(caseinfo.InternalType) ? caseinfo.Type : "Production " + caseinfo.InternalType);
                row["Version"] = caseinfo.CurrentVersion;
                customer       = (caseinfo.Customer != null && !String.IsNullOrEmpty(caseinfo.Customer.Name) ? caseinfo.Customer.Name : (caseinfo.Account != null ? caseinfo.Account.Name : ""));
                if (customer.IndexOf("Accela") >= 0 && caseinfo.Account != null && !String.IsNullOrEmpty(caseinfo.Account.Name))
                {
                    customer = caseinfo.Account.Name;
                }

                row["Customer"]    = customer;
                row["Summary"]     = caseinfo.Subject;
                row["Description"] = caseinfo.Description;
                assignee           = (tempIssue != null ? tempIssue.Assignee : "");

                temComment = "";

                //lastModifiedDate = DateTime.Now.Year + "-" + (DateTime.Now.Month < 10 ? "0" + DateTime.Now.Month : "" + DateTime.Now.Month) + "-" + (DateTime.Now.Day < 10 ? "0" + DateTime.Now.Day : "" + DateTime.Now.Day);
                DateTime Yesterday = DateTime.Now.AddDays(-1);
                lastModifiedDate = Yesterday.Year + "-" + Yesterday.Month + "-" + Yesterday.Day;
                if (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null)
                {
                    row["CaseComments"] = caseinfo.CaseComments.Records;

                    CaseComment comment = caseinfo.CaseComments.Records[0];
                    //lastModifiedDate = comment.CreatedDate.Year + "-" + (comment.CreatedDate.Month < 10 ? "0" + comment.CreatedDate.Month : "" + comment.CreatedDate.Month) + "-" + (comment.CreatedDate.Day < 10 ? "0" + comment.CreatedDate.Day : "" + comment.CreatedDate.Day);
                    if (DateTime.Now.Year != comment.CreatedDate.Year &&
                        DateTime.Now.Month != comment.CreatedDate.Month &&
                        DateTime.Now.Day != comment.CreatedDate.Day)
                    {
                        lastModifiedDate = comment.CreatedDate.Year + "-" + comment.CreatedDate.Month + "-" + comment.CreatedDate.Day;
                    }

                    row["CaseComment"] = comment;

                    if (!String.IsNullOrEmpty(comment.CommentBody))
                    {
                        if (comment.CommentBody.ToUpper().IndexOf("BUB") > 0)
                        {
                            temComment += "This is a bug.<br>";
                        }

                        if (comment.CommentBody.ToUpper().IndexOf("DEFECT") > 0)
                        {
                            temComment += "This is a defect.<br>";
                        }
                    }

                    if (!String.IsNullOrEmpty(assignee) && comment.CommentBody.ToUpper().Contains(assignee.ToUpper()))
                    {
                    }
                    else
                    {
                        foreach (var key in Reviewers.Keys)
                        {
                            string value  = Reviewers[key];
                            string value1 = value.Replace('.', ' ');
                            if (comment.CommentBody.ToUpper().EndsWith(key.ToUpper()) ||
                                comment.CommentBody.ToUpper().EndsWith(value.ToUpper()) ||
                                comment.CommentBody.ToUpper().EndsWith(value1.ToUpper()))
                            {
                                assignee = Reviewers[key];
                                break;
                            }
                        }
                    }
                }

                row["Reviewer"]      = assignee;
                row["Comments"]      = temComment;
                reopenCount          = (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null ? caseinfo.CaseComments.Records.Count - 1 : 0);
                row["ReopenedCount"] = reopenCount;
                jiaStstus            = (tempIssue != null ? tempIssue.Status : "");
                row["JiraStatus"]    = jiaStstus;
                row["SFQueue"]       = caseinfo.Owner.Name;
                row["SFStatus"]      = caseinfo.Status;

                bool isCommentedToday = false;
                if (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null)
                {
                    CaseComment comment = caseinfo.CaseComments.Records[0];

                    isCommentedToday = (comment.CreatedDate.Year == DateTime.Now.Year && comment.CreatedDate.Month == DateTime.Now.Month && comment.CreatedDate.Day == DateTime.Now.Day ? true : false);
                }

                row["NextJiraStatus"] = AccelaCaseUtil.GetNextJIRAStatus(caseinfo.Owner.Name, caseinfo.Status, jiaStstus, isCommentedToday);
                row["SFLastModified"] = lastModifiedDate;
                if (tempIssue != null && String.IsNullOrEmpty(tempIssue.LastModified))
                {
                    System.Console.WriteLine("Last Modified Date is empty");
                }

                if (tempIssue != null && tempIssue.FixVersions != null)
                {
                    bool isFirst = true;
                    foreach (var fixVersion in tempIssue.FixVersions)
                    {
                        if (isFirst)
                        {
                            row["FixVersions"] = fixVersion;
                            isFirst            = false;
                        }
                        else
                        {
                            row["FixVersions"] += "," + fixVersion;
                        }
                    }
                }

                row["ReleaseInfo"]       = caseinfo.ReleaseInfo;
                row["TargetedRelease"]   = caseinfo.TargetedRelease;
                row["BZID"]              = caseinfo.BZID;
                row["InternalType"]      = caseinfo.InternalType;
                row["EngineeringStatus"] = caseinfo.EngineeringStatus;

                table.Rows.Add(row);
                index++;
            }

            grdCaseList.AutoGenerateColumns = false;
            grdCaseList.DataSource          = table;



            this.btnSendSummaryReport.Enabled = true;
            this.btnSyncWithJiraAndSF.Enabled = true;
        }
示例#3
0
        private async void btnSyncWithJIRA_Click(object sender, EventArgs e)
        {
            this.btnSendNotificationEmail.Enabled = false;
            this.btnSyncWithJIRA.Enabled          = false;

            // 1, Construct one case list from the specified case list
            // 1.1 Check if the case list formate is valid or not
            // 1.2 Construct one case list
            string        caseIDs    = this.txtCaseIDList.Text;
            List <string> caseIdList = new List <string>();

            if (String.IsNullOrEmpty(caseIDs) || caseIDs.Trim().Length == 0)
            {
                // Show one error message "ERROR: Please enter case id"
                (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Please enter case id");
                return;
            }
            else
            {
                (this.MdiParent as MainForm).ShowStatusMessage("");

                string[] caseIDArray = caseIDs.Split(',');
                Regex    reg         = new Regex(@"\d{2}ACC-\d{5}");
                foreach (string caseId in caseIDArray)
                {
                    if (reg.IsMatch(caseId))
                    {
                        caseIdList.Add(caseId.Trim());
                    }
                    else
                    {
                        // Show one error message "ERROR: Invalid Format for XXXX"
                        (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Invalid Format for " + caseId);
                        return;
                    }
                }
            }

            var GetCaseList  = SalesforceProxy.GetCaseList(caseIdList);
            var GetIssueList = JiraProxy.GetIssueList(caseIdList);

            var caseList  = await GetCaseList;
            var issueList = await GetIssueList;

            Dictionary <string, AccelaIssueCaseMapper> JiraMapping = new Dictionary <string, AccelaIssueCaseMapper>();

            foreach (var issue in issueList)
            {
                if (!JiraMapping.ContainsKey(issue.fields.customfield_10600))
                {
                    AccelaIssueCaseMapper accelaIssueCaseMapper = new AccelaIssueCaseMapper();
                    accelaIssueCaseMapper.CaseNumber   = issue.fields.customfield_10600;
                    accelaIssueCaseMapper.Assignee     = (issue.fields.assignee == null ? "" : issue.fields.assignee.displayName);
                    accelaIssueCaseMapper.JiraId       = issue.id;
                    accelaIssueCaseMapper.JiraKey      = issue.key;
                    accelaIssueCaseMapper.LastModified = issue.fields.customfield_10903;
                    accelaIssueCaseMapper.Status       = issue.fields.status.name;
                    accelaIssueCaseMapper.HotCase      = issue.fields.labels.Contains("HotCase");
                    accelaIssueCaseMapper.JiraLabels   = issue.fields.labels;

                    JiraMapping.Add(accelaIssueCaseMapper.CaseNumber, accelaIssueCaseMapper);
                }
            }

            DataTable table = new DataTable("Daily Report");

            table.Columns.Add("ID", typeof(string));
            table.Columns.Add("No", typeof(int));
            table.Columns.Add("HotCase", typeof(bool));
            table.Columns.Add("JiraLabels", typeof(List <string>));
            table.Columns.Add("ProductForUI", typeof(string));
            table.Columns.Add("Product", typeof(string));
            table.Columns.Add("Solution", typeof(string));
            table.Columns.Add("Orgin", typeof(string));
            table.Columns.Add("OpenDate", typeof(string));
            table.Columns.Add("Severity", typeof(string));
            table.Columns.Add("SalesforceID", typeof(string));
            table.Columns.Add("JiraID", typeof(string));
            table.Columns.Add("JiraKey", typeof(string));
            table.Columns.Add("Type", typeof(string));
            table.Columns.Add("Version", typeof(string));
            table.Columns.Add("Customer", typeof(string));
            table.Columns.Add("Summary", typeof(string));
            table.Columns.Add("Description", typeof(string));
            table.Columns.Add("Reviewer", typeof(string));
            table.Columns.Add("Comments", typeof(string));
            table.Columns.Add("ReopenedCount", typeof(string));
            table.Columns.Add("JiraStatus", typeof(string));
            table.Columns.Add("NextJiraStatus", typeof(string));
            table.Columns.Add("SFQueue", typeof(string));
            table.Columns.Add("SFStatus", typeof(string));
            table.Columns.Add("SFLastModified", typeof(string));
            table.Columns.Add("CaseComment", typeof(CaseComment));

            Dictionary <string, string> Reviewers = new Dictionary <string, string>();

            Reviewers.Add("Alvin", "Alvin.Li");
            Reviewers.Add("Rick", "Rick.Liu");
            Reviewers.Add("Weber", "Weber.Yan");
            Reviewers.Add("John", "John.Huang");
            Reviewers.Add("Hyman", "Hyman.Zhang");
            Reviewers.Add("Star", "Star.Li");
            Reviewers.Add("Lex", "Lex.Wu");
            Reviewers.Add("Bass", "Bass.Yang");
            Reviewers.Add("Mandy", "Mandy.Zhou");
            Reviewers.Add("Linda", "Linda.Xiao");
            Reviewers.Add("Abel", "Abel.Yu");
            Reviewers.Add("Matt", "Matt.Ao");
            Reviewers.Add("Peter", "Peter.Peng");
            Reviewers.Add("Sandy", "Sandy.Zheng");
            Reviewers.Add("Likko", "Likko.Zhang");
            Reviewers.Add("Mina", "Mina.Xiong");
            Reviewers.Add("Jessy", "Jessy.Zhang");
            Reviewers.Add("Louis", "Louis.He");
            Reviewers.Add("Leo", "Leo.Liu");
            Reviewers.Add("Adger", "Adger.Chen");
            Reviewers.Add("Tim", "Tim.Liu");
            Reviewers.Add("Mia", "Mia.Huang");
            Reviewers.Add("Jessie", "Jessie.Zhang");
            Reviewers.Add("William", "William.Wang");
            Reviewers.Add("Cheng", "Cheng.Xu");
            Reviewers.Add("Gordon", "Gordon.Chen");
            Reviewers.Add("Tracy", "Tracy.Xiang");

            int index = 1;
            AccelaIssueCaseMapper tempIssue = null;
            string openDate    = "";
            string jiraKey     = "";
            string jiraId      = "";
            string customer    = "";
            string assignee    = "";
            int    reopenCount = 0;
            string jiaStstus   = "";

            string[] Severity   = null;
            string   temComment = "";

            foreach (var caseinfo in caseList)
            {
                tempIssue = null;
                if (JiraMapping.ContainsKey(caseinfo.CaseNumber))
                {
                    tempIssue = JiraMapping[caseinfo.CaseNumber];
                }

                DataRow row = table.NewRow();
                row["ID"]         = caseinfo.Id;
                row["No"]         = index;
                row["HotCase"]    = (tempIssue != null && tempIssue.HotCase);
                row["JiraLabels"] = (tempIssue != null ? tempIssue.JiraLabels : null);
                //row["HotCase"] = true;
                row["ProductForUI"] = AccelaCaseUtil.AdjustProductName(caseinfo.Product, caseinfo.Solution, caseinfo.Subject, caseinfo.Description);
                row["Product"]      = caseinfo.Product;
                row["Solution"]     = caseinfo.Solution;
                row["Orgin"]        = caseinfo.Origin;
                //openDate = caseinfo.CreatedDate.ToShortDateString();
                openDate = (caseinfo.CreatedDate.Month < 10 ? "0" + caseinfo.CreatedDate.Month : "" + caseinfo.CreatedDate.Month)
                           + "/" + (caseinfo.CreatedDate.Day < 10 ? "0" + caseinfo.CreatedDate.Day : "" + caseinfo.CreatedDate.Day)
                           + "/" + ("" + caseinfo.CreatedDate.Year);

                row["OpenDate"]     = openDate;
                Severity            = caseinfo.Priority.Split(' ');
                row["Severity"]     = Severity[1];
                row["SalesforceID"] = caseinfo.CaseNumber;
                jiraKey             = (tempIssue != null ? tempIssue.JiraKey : "");
                jiraId             = (tempIssue != null ? tempIssue.JiraId : "");
                row["JiraKey"]     = jiraKey;
                row["JiraID"]      = jiraId;
                row["Type"]        = caseinfo.Type;
                row["Version"]     = caseinfo.CurrentVersion;
                customer           = (caseinfo.Customer != null && !String.IsNullOrEmpty(caseinfo.Customer.Name) ? caseinfo.Customer.Name : caseinfo.Account.Name);
                row["Customer"]    = customer;
                row["Summary"]     = caseinfo.Subject;
                row["Description"] = caseinfo.Description;
                assignee           = (tempIssue != null ? tempIssue.Assignee : "");

                temComment = "";

                if (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null)
                {
                    CaseComment comment = caseinfo.CaseComments.Records[0];
                    row["CaseComment"] = comment;

                    if (!String.IsNullOrEmpty(comment.CommentBody))
                    {
                        if (comment.CommentBody.ToUpper().IndexOf("BUB") > 0)
                        {
                            temComment += "This is a bug.<br>";
                        }

                        if (comment.CommentBody.ToUpper().IndexOf("DEFECT") > 0)
                        {
                            temComment += "This is a defect.<br>";
                        }
                    }

                    if (!String.IsNullOrEmpty(assignee) && comment.CommentBody.ToUpper().Contains(assignee.ToUpper()))
                    {
                    }
                    else
                    {
                        foreach (var key in Reviewers.Keys)
                        {
                            string value  = Reviewers[key];
                            string value1 = value.Replace('.', ' ');
                            if (comment.CommentBody.ToUpper().EndsWith(key.ToUpper()) ||
                                comment.CommentBody.ToUpper().EndsWith(value.ToUpper()) ||
                                comment.CommentBody.ToUpper().EndsWith(value1.ToUpper()))
                            {
                                assignee = Reviewers[key];
                                break;
                            }
                        }
                    }
                }

                row["Reviewer"]      = assignee;
                row["Comments"]      = temComment;
                reopenCount          = (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null ? caseinfo.CaseComments.Records.Count - 1 : 0);
                row["ReopenedCount"] = reopenCount;
                jiaStstus            = (tempIssue != null ? tempIssue.Status : "");
                row["JiraStatus"]    = jiaStstus;
                row["SFQueue"]       = caseinfo.Owner.Name;
                row["SFStatus"]      = caseinfo.Status;

                bool isCommentedToday = false;
                if (caseinfo.CaseComments != null && caseinfo.CaseComments.Records != null)
                {
                    CaseComment comment = caseinfo.CaseComments.Records[0];

                    isCommentedToday = (comment.CreatedDate.Year == DateTime.Now.Year && comment.CreatedDate.Month == DateTime.Now.Month && comment.CreatedDate.Day == DateTime.Now.Day ? true : false);
                }

                row["NextJiraStatus"] = AccelaCaseUtil.GetNextJIRAStatus(caseinfo.Owner.Name, caseinfo.Status, jiaStstus, isCommentedToday);
                row["SFLastModified"] = (tempIssue != null ? tempIssue.LastModified : "");

                table.Rows.Add(row);
                index++;
            }

            grdCaseList.AutoGenerateColumns = false;
            grdCaseList.DataSource          = table;

            this.btnSendNotificationEmail.Enabled = true;
            this.btnSyncWithJIRA.Enabled          = true;
        }
示例#4
0
        private async void btnSync_Click(object sender, EventArgs e)
        {
            this.btnSync.Enabled  = false;
            this.btnMerge.Enabled = false;

            // 1, Construct one case list from the specified case list
            // 1.1 Check if the case list formate is valid or not
            // 1.2 Construct one case list
            string        caseIDs    = this.txtInputCaseList.Text;
            List <string> caseIdList = new List <string>();

            if (String.IsNullOrEmpty(caseIDs) || caseIDs.Trim().Length == 0)
            {
                // Show one error message "ERROR: Please enter case id"
                (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Please enter case id");

                this.btnSync.Enabled  = true;
                this.btnMerge.Enabled = false;

                return;
            }
            else
            {
                (this.MdiParent as MainForm).ShowStatusMessage("");

                string[] caseIDArray = caseIDs.Split(',');
                Regex    reg         = new Regex(@"\d{2}ACC-\d{5}");
                foreach (string caseId in caseIDArray)
                {
                    if (reg.IsMatch(caseId))
                    {
                        if (!caseIdList.Contains(caseId.Trim()))
                        {
                            caseIdList.Add(caseId.Trim());
                        }
                    }
                    else
                    {
                        // Show one error message "ERROR: Invalid Format for XXXX"
                        (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Invalid Format for " + caseId);

                        this.btnSync.Enabled  = true;
                        this.btnMerge.Enabled = false;

                        return;
                    }
                }
            }

            if (caseIdList.Count == 0)
            {
                // Show one error message "ERROR: Please enter case id"
                (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Please enter case id");

                this.btnSync.Enabled  = true;
                this.btnMerge.Enabled = false;

                return;
            }

            Dictionary <string, Dictionary <string, AccelaAttachmentMapper> > AttachmentMapper = new Dictionary <string, Dictionary <string, AccelaAttachmentMapper> >();
            var GetCaseAttachmentInfoByID = SalesforceProxy.GetCaseAttachmentInfoByID(caseIdList);
            var GetJiraIssueList          = JiraProxy.GetIssueList(caseIdList);

            var CaseAttachments = await GetCaseAttachmentInfoByID;

            foreach (AccelaCase accelaCase in CaseAttachments)
            {
                string caseId     = accelaCase.Id;
                string caseNumber = accelaCase.CaseNumber;

                if (!AttachmentMapper.ContainsKey(caseNumber))
                {
                    AttachmentMapper.Add(caseNumber, new Dictionary <string, AccelaAttachmentMapper>());
                }

                if (accelaCase.CaseAttachments != null && accelaCase.CaseAttachments.Records.Count > 0)
                {
                    Dictionary <string, AccelaAttachmentMapper> CaseAttachmentDic = AttachmentMapper[caseNumber];

                    foreach (CaseAttachment caseAttachment in accelaCase.CaseAttachments.Records)
                    {
                        string fileName = caseAttachment.Name;

                        var GetUserInfoById = SalesforceProxy.GetUserInfoById(caseAttachment.LastModifiedById);
                        var UserInfo        = await GetUserInfoById;

                        if (!CaseAttachmentDic.ContainsKey(fileName))
                        {
                            AccelaAttachmentMapper accelaAttachmentMapper = new AccelaAttachmentMapper();

                            accelaAttachmentMapper.IsMerged           = true;
                            accelaAttachmentMapper.CaseId             = caseId;
                            accelaAttachmentMapper.CaseNumber         = caseNumber;
                            accelaAttachmentMapper.CaseFileName       = fileName;
                            accelaAttachmentMapper.CaseAttchmentId    = caseAttachment.Id;
                            accelaAttachmentMapper.CaseAttachmentType = caseAttachment.ContentType;
                            accelaAttachmentMapper.CaseIsPrivate      = caseAttachment.IsPrivate;
                            accelaAttachmentMapper.UploadedBy         = UserInfo.Name;
                            accelaAttachmentMapper.UploadDate         = caseAttachment.LastModifiedDate;

                            CaseAttachmentDic.Add(fileName, accelaAttachmentMapper);
                        }
                    }
                }
            }

            var JiraIssueList = await GetJiraIssueList;

            foreach (Issue issue in JiraIssueList)
            {
                IssueRef issueRef = new IssueRef();
                issueRef.id  = issue.id;
                issueRef.key = issue.key;

                string caseNumber = issue.fields.customfield_10600;
                if (!AttachmentMapper.ContainsKey(caseNumber))
                {
                    AttachmentMapper.Add(caseNumber, new Dictionary <string, AccelaAttachmentMapper>());
                }

                Dictionary <string, AccelaAttachmentMapper> CaseAttachmentDic = AttachmentMapper[caseNumber];
                if (CaseAttachmentDic != null)
                {
                    foreach (AccelaAttachmentMapper accelaAttachmentMapper in CaseAttachmentDic.Values)
                    {
                        accelaAttachmentMapper.JiraId  = issue.id;
                        accelaAttachmentMapper.JiraKey = issue.key;
                    }
                }

                var GetAttachments     = JiraProxy.GetAttachments(issueRef);
                var JiraAttachmentList = await GetAttachments;

                if (JiraAttachmentList != null && JiraAttachmentList.Count > 0)
                {
                    foreach (Attachment attachment in JiraAttachmentList)
                    {
                        string fileName = attachment.filename;
                        AccelaAttachmentMapper accelaAttachmentMapper = null;
                        if (CaseAttachmentDic.ContainsKey(fileName))
                        {
                            accelaAttachmentMapper          = CaseAttachmentDic[fileName];
                            accelaAttachmentMapper.IsMerged = false;
                        }
                        else
                        {
                            accelaAttachmentMapper = new AccelaAttachmentMapper();
                            //accelaAttachmentMapper.CaseId = caseId;
                            accelaAttachmentMapper.CaseNumber = caseNumber;
                        }

                        accelaAttachmentMapper.JiraId           = issue.id;
                        accelaAttachmentMapper.JiraKey          = issue.key;
                        accelaAttachmentMapper.JiraFileName     = fileName;
                        accelaAttachmentMapper.JiraAttachmentId = attachment.id;
                        //CaseAttachmentDic.Add(fileName, accelaAttachmentMapper);
                        CaseAttachmentDic[fileName] = accelaAttachmentMapper;
                    }
                }
            }

            DataTable table = new DataTable("Merge Attachment");

            table.Columns.Add("IsMerged", typeof(bool));
            table.Columns.Add("CaseFileName", typeof(string));
            table.Columns.Add("CaseId", typeof(string));
            table.Columns.Add("CaseNumber", typeof(string));
            table.Columns.Add("CaseAttchmentId", typeof(string));
            table.Columns.Add("CaseAttachmentType", typeof(string));
            table.Columns.Add("CaseIsPrivate", typeof(bool));
            table.Columns.Add("UploadDate", typeof(string));
            table.Columns.Add("UploadedBy", typeof(string));
            table.Columns.Add("JiraFileName", typeof(string));
            table.Columns.Add("JiraId", typeof(string));
            table.Columns.Add("JiraKey", typeof(string));
            table.Columns.Add("JiraAttachmentId", typeof(string));

            foreach (string caseNumber in AttachmentMapper.Keys)
            {
                Dictionary <string, AccelaAttachmentMapper> CaseAttachmentDic = AttachmentMapper[caseNumber];
                foreach (AccelaAttachmentMapper accelaAttachMapper in CaseAttachmentDic.Values)
                {
                    DataRow row = table.NewRow();
                    row["IsMerged"]           = accelaAttachMapper.IsMerged;
                    row["CaseFileName"]       = accelaAttachMapper.CaseFileName;
                    row["CaseId"]             = accelaAttachMapper.CaseId;
                    row["CaseNumber"]         = accelaAttachMapper.CaseNumber;
                    row["CaseAttchmentId"]    = accelaAttachMapper.CaseAttchmentId;
                    row["CaseAttachmentType"] = accelaAttachMapper.CaseAttachmentType;
                    row["CaseIsPrivate"]      = accelaAttachMapper.CaseIsPrivate;
                    row["UploadDate"]         = accelaAttachMapper.UploadDate.ToShortDateString();
                    row["UploadedBy"]         = accelaAttachMapper.UploadedBy;
                    row["JiraFileName"]       = accelaAttachMapper.JiraFileName;
                    row["JiraId"]             = accelaAttachMapper.JiraId;
                    row["JiraKey"]            = accelaAttachMapper.JiraKey;
                    row["JiraAttachmentId"]   = accelaAttachMapper.JiraAttachmentId;

                    table.Rows.Add(row);
                }
            }

            DataView dataTableView = table.DefaultView;

            dataTableView.Sort = "CaseNumber ASC, UploadDate ASC";
            table = dataTableView.ToTable();

            this.dgdMergeFileList.AutoGenerateColumns = false;
            this.dgdMergeFileList.DataSource          = table;

            this.btnSync.Enabled  = true;
            this.btnMerge.Enabled = true;
        }
示例#5
0
        private async void btnSync_Click(object sender, EventArgs e)
        {
            this.btnSync.Enabled = false;
            this.btnSend.Enabled = false;

            // 1, Construct one case list from the specified case list
            // 1.1 Check if the case list formate is valid or not
            // 1.2 Construct one case list
            string        caseIDs    = this.txtInputCaseList.Text;
            List <string> caseIdList = new List <string>();

            if (String.IsNullOrEmpty(caseIDs) || caseIDs.Trim().Length == 0)
            {
                // Show one error message "ERROR: Please enter case id"
                (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Please enter case id");

                this.btnSync.Enabled = true;
                this.btnSend.Enabled = true;

                return;
            }
            else
            {
                (this.MdiParent as MainForm).ShowStatusMessage("");

                string[] caseIDArray = caseIDs.Split(',');
                Regex    reg         = new Regex(@"\d{2}ACC-\d{5}");
                foreach (string caseId in caseIDArray)
                {
                    if (reg.IsMatch(caseId))
                    {
                        if (!caseIdList.Contains(caseId.Trim()))
                        {
                            caseIdList.Add(caseId.Trim());
                        }
                    }
                    else
                    {
                        // Show one error message "ERROR: Invalid Format for XXXX"
                        (this.MdiParent as MainForm).ShowStatusMessage("ERROR: Invalid Format for " + caseId);

                        this.btnSync.Enabled = true;
                        this.btnSend.Enabled = true;

                        return;
                    }
                }
            }

            List <string> DevNameList = null;
            List <string> QANameList  = SalesforceProxy.GetQAReviewerNamesList();

            QANameList  = SalesforceProxy.GetSupportQAList(this.chkExcludeAccela.Checked);
            DevNameList = SalesforceProxy.GetSupportDevList(this.chkExcludeAccela.Checked);
            Dictionary <string, string> Reviewers = SalesforceProxy.GetReviewerNamesList(this.chkExcludeAccela.Checked);

            var caseList  = new List <CaseAnalysisInfo>();
            var issueList = new List <Issue>();

            int N      = 1;
            int index1 = 1;

            for (int i = 0; i < caseIdList.Count;)
            {
                List <string> caseIdListTemp = new List <string>();
                for (; i < N * 100 && i < caseIdList.Count; i++)
                {
                    caseIdListTemp.Add(caseIdList[i]);
                }

                N = N + 1;

                var GetCaseList  = SalesforceProxy.GetCaseList(caseIdListTemp, true);
                var GetIssueList = JiraProxy.GetIssueList(caseIdListTemp);

                var caseListTmp  = await GetCaseList;
                var issueListTmp = await GetIssueList;

                Dictionary <string, CaseAnalysisInfo> JIRAMapper = new Dictionary <string, CaseAnalysisInfo>();
                foreach (var issue in issueListTmp)
                {
                    CaseAnalysisInfo caseAnalysisInfo = new CaseAnalysisInfo();
                    caseAnalysisInfo.SFID          = issue.fields.customfield_10600;
                    caseAnalysisInfo.JiraKey       = issue.key;
                    caseAnalysisInfo.IssueCategory = (issue.fields.customfield_11502 != null && issue.fields.customfield_11502.Count > 0 ? issue.fields.customfield_11502[0].value : "NONE");
                    if (!JIRAMapper.ContainsKey(issue.fields.customfield_10600))
                    {
                        JIRAMapper.Add(issue.fields.customfield_10600, caseAnalysisInfo);
                    }
                }

                foreach (var caseInfo in caseListTmp)
                {
                    Dictionary <DateTime, string> CommentHistories = new Dictionary <DateTime, string>();
                    bool isFound           = false;
                    int  sfCommentCount    = 0;
                    int  sfDevCommentCount = 0;
                    int  sfQACommentCount  = 0;

                    System.Console.WriteLine("[" + (index1++) + "] " + caseInfo.CaseNumber);

                    if (caseInfo.CaseComments != null && caseInfo.CaseComments.Records != null && caseInfo.CaseComments.Records.Count > 0)
                    {
                        foreach (CaseComment comment in caseInfo.CaseComments.Records)
                        {
                            if (comment == null ||
                                comment.CommentBody == null ||
                                comment.CreatedDate.Year != this.dtpSpecifyDate.Value.Year ||
                                comment.CreatedDate.Month != this.dtpSpecifyDate.Value.Month)
                            {
                                continue;
                            }

                            if (this.chkSpecifyDate.Checked)
                            {
                                DateTime date = this.dtpSpecifyDate.Value;

                                if (comment == null ||
                                    comment.CommentBody == null ||
                                    comment.CreatedDate.Year != date.Year ||
                                    comment.CreatedDate.Month != date.Month ||
                                    comment.CreatedDate.Day != date.Day)
                                {
                                    continue;
                                }
                            }

                            string assignee = "";

                            foreach (var key in Reviewers.Keys)
                            {
                                string value  = Reviewers[key];
                                string value1 = value.Replace('.', ' ');
                                if (comment.CommentBody.ToUpper().EndsWith(key.ToUpper()) ||
                                    comment.CommentBody.ToUpper().EndsWith(value.ToUpper()) ||
                                    comment.CommentBody.ToUpper().EndsWith(value1.ToUpper()) ||
                                    comment.LastModifiedBy.Name.ToUpper().StartsWith(value.ToUpper()) ||
                                    comment.LastModifiedBy.Name.ToUpper().StartsWith(value1.ToUpper()))
                                {
                                    isFound = true;
                                    sfCommentCount++;
                                    assignee = Reviewers[key];
                                    if (QANameList.Contains(assignee))
                                    {
                                        sfQACommentCount++;
                                    }

                                    if (DevNameList.Contains(assignee))
                                    {
                                        sfDevCommentCount++;
                                    }

                                    CommentHistories.Add(comment.LastModifiedDate, assignee);
                                    break;
                                }
                            }
                        }
                    }

                    if (isFound)
                    {
                        CaseAnalysisInfo caseAnalysisInfo = ConstructCaseAnalysisInfoModel(caseInfo, sfCommentCount, sfDevCommentCount, sfQACommentCount, CommentHistories);

                        if (JIRAMapper.ContainsKey(caseAnalysisInfo.SFID))
                        {
                            CaseAnalysisInfo tempCaseAnalysisInfo = JIRAMapper[caseAnalysisInfo.SFID];
                            caseAnalysisInfo.JiraKey       = tempCaseAnalysisInfo.JiraKey;
                            caseAnalysisInfo.IssueCategory = tempCaseAnalysisInfo.IssueCategory;
                        }

                        System.Console.WriteLine("Add " + caseInfo.CaseNumber);
                        caseList.Add(caseAnalysisInfo);
                    }
                    else
                    {
                        System.Console.WriteLine("Skip " + caseInfo.CaseNumber);
                    }
                }

                //issueList.AddRange(issueListTmp);
            }

            DataTable table = new DataTable("Case Analysis Report");

            table.Columns.Add("No", typeof(int));
            table.Columns.Add("Product", typeof(string));
            table.Columns.Add("SalesforceID", typeof(string));
            table.Columns.Add("JiraKey", typeof(string));
            table.Columns.Add("SFCaseCommentCount", typeof(int));
            table.Columns.Add("SFDevCaseCommentCount", typeof(int));
            table.Columns.Add("SFQACaseCommentCount", typeof(int));
            table.Columns.Add("Customer", typeof(string));
            table.Columns.Add("Severity", typeof(string));
            table.Columns.Add("Version", typeof(string));
            table.Columns.Add("OpenDate", typeof(string));
            table.Columns.Add("Summary", typeof(string));
            table.Columns.Add("CommentHistories", typeof(Dictionary <DateTime, string>));
            table.Columns.Add("IssueCategory", typeof(string));
            table.Columns.Add("SFQueue", typeof(string));
            table.Columns.Add("SFStatus", typeof(string));

            int index = 1;

            foreach (CaseAnalysisInfo caseAnalysisInfo in caseList)
            {
                DataRow row = table.NewRow();
                row["No"]                    = index;
                row["Product"]               = caseAnalysisInfo.Product;
                row["SalesforceID"]          = caseAnalysisInfo.SFID;
                row["JiraKey"]               = caseAnalysisInfo.JiraKey;
                row["SFCaseCommentCount"]    = caseAnalysisInfo.SFCaseCommentCount;
                row["SFDevCaseCommentCount"] = caseAnalysisInfo.SFDevCaseCommentCount;
                row["SFQACaseCommentCount"]  = caseAnalysisInfo.SFQACaseCommentCount;
                row["Customer"]              = caseAnalysisInfo.Customer;
                row["Severity"]              = caseAnalysisInfo.Severity;
                row["Version"]               = caseAnalysisInfo.Version;
                row["OpenDate"]              = caseAnalysisInfo.OpenDate;
                row["Summary"]               = caseAnalysisInfo.Summary;
                row["CommentHistories"]      = caseAnalysisInfo.CommentHistories;
                row["IssueCategory"]         = caseAnalysisInfo.IssueCategory;
                row["SFQueue"]               = caseAnalysisInfo.SFQueue;
                row["SFStatus"]              = caseAnalysisInfo.SFStatus;

                table.Rows.Add(row);
                index++;
            }

            DataView dataTableView = table.DefaultView;

            dataTableView.Sort = "SalesforceID ASC";
            table = dataTableView.ToTable();

            grdCaseList.AutoGenerateColumns = false;
            grdCaseList.DataSource          = table;


            this.btnSync.Enabled = true;
            this.btnSend.Enabled = true;
        }
示例#6
0
        private async Task <List <SubTaskSuite> > GetSubTaskSuiteByCaseID(List <string> caseIDs)
        {
            List <SubTaskSuite> subTaskSuites = new List <SubTaskSuite>();

            var issueList = new List <Issue>();

            int N = 1;

            for (int i = 0; i < caseIDs.Count;)
            {
                List <string> caseIdListTemp = new List <string>();
                for (; i < N * 50 && i < caseIDs.Count; i++)
                {
                    caseIdListTemp.Add(caseIDs[i]);
                }

                N = N + 1;

                var GetIssueList = JiraProxy.GetIssueList(caseIdListTemp);

                var issueListTmp = await GetIssueList;

                issueList.AddRange(issueListTmp);
            }

            foreach (var issue in issueList)
            {
                SubTaskSuite subTaskSuite = new SubTaskSuite();

                // SF ID
                subTaskSuite.SFID = issue.fields.customfield_10600;
                // Jira Key
                subTaskSuite.JiraKey = issue.key;
                // Issue Type
                subTaskSuite.IssueType = issue.fields.issueType.name;
                // Status
                subTaskSuite.Status = issue.fields.status.name;
                // Assignee
                subTaskSuite.Assignee      = (issue.fields.assignee == null ? "" : issue.fields.assignee.displayName);
                subTaskSuite.AssigneeEmail = (issue.fields.assignee == null ? "" : issue.fields.assignee.name);
                // AssigneeQA
                subTaskSuite.AssigneeQA      = (issue.fields.customfield_11702 == null ? "" : issue.fields.customfield_11702.displayName);
                subTaskSuite.AssigneeQAEmail = (issue.fields.customfield_11702 == null ? "" : issue.fields.customfield_11702.name);

                Dictionary <string, string> SubTaskMaper = new Dictionary <string, string>();
                foreach (var subTask in issue.fields.subtasks)
                {
                    if (subTask != null && subTask.fields != null && subTask.fields.issuetype.subtask == true)
                    {
                        if (!SubTaskMaper.ContainsKey(subTask.fields.summary))
                        {
                            SubTaskMaper.Add(subTask.fields.summary, subTask.key);
                        }
                    }
                }

                // Review and Recreate(QA)
                if (SubTaskMaper.ContainsKey("Review and Recreate(QA)"))
                {
                    subTaskSuite.ReviewAndRecreateByQA = SubTaskMaper["Review and Recreate(QA)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.ReviewAndRecreateByQA);

                    subTaskSuite.Assignee1 = subTask.Assignee;
                    subTaskSuite.Status1   = subTask.Status;
                }

                // Review and Recreate(Dev)
                if (SubTaskMaper.ContainsKey("Review and Recreate(Dev)"))
                {
                    subTaskSuite.ReviewAndRecreateByDev = SubTaskMaper["Review and Recreate(Dev)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.ReviewAndRecreateByDev);

                    subTaskSuite.Assignee2 = subTask.Assignee;
                    subTaskSuite.Status2   = subTask.Status;
                }

                // Research Root Cause
                if (SubTaskMaper.ContainsKey("Research Root Cause"))
                {
                    subTaskSuite.ResearchRootCauseByDev = SubTaskMaper["Research Root Cause"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.ReviewAndRecreateByDev);

                    subTaskSuite.Assignee3 = subTask.Assignee;
                    subTaskSuite.Status3   = subTask.Status;
                }

                // Code Fix(Dev)
                if (SubTaskMaper.ContainsKey("Code Fix(Dev)"))
                {
                    subTaskSuite.CodeFixByDev = SubTaskMaper["Code Fix(Dev)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.CodeFixByDev);

                    subTaskSuite.Assignee4 = subTask.Assignee;
                    subTaskSuite.Status4   = subTask.Status;
                }

                // Write Test Case(QA)
                if (SubTaskMaper.ContainsKey("Write Test Case(QA)"))
                {
                    subTaskSuite.WriteTestCaseByQA = SubTaskMaper["Write Test Case(QA)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.WriteTestCaseByQA);

                    subTaskSuite.Assignee5 = subTask.Assignee;
                    subTaskSuite.Status5   = subTask.Status;
                }

                // Execute Test Case(QA)
                if (SubTaskMaper.ContainsKey("Execute Test Case(QA)"))
                {
                    subTaskSuite.WriteTestCaseByQA = SubTaskMaper["Execute Test Case(QA)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.WriteTestCaseByQA);

                    subTaskSuite.Assignee6 = subTask.Assignee;
                    subTaskSuite.Status6   = subTask.Status;
                }

                // Write Release Notes(Dev)
                if (SubTaskMaper.ContainsKey("Write Release Notes(Dev)"))
                {
                    subTaskSuite.WriteTestCaseByQA = SubTaskMaper["Write Release Notes(Dev)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.WriteTestCaseByQA);

                    subTaskSuite.Assignee7 = subTask.Assignee;
                    subTaskSuite.Status7   = subTask.Status;
                }

                // Review Release Notes(QA)
                if (SubTaskMaper.ContainsKey("Review Release Notes(QA)"))
                {
                    subTaskSuite.ReviewReleaseNotesByQA = SubTaskMaper["Review Release Notes(QA)"];

                    var subTask = await GetAssigneeAndStatus(subTaskSuite.ReviewReleaseNotesByQA);

                    subTaskSuite.Assignee8 = subTask.Assignee;
                    subTaskSuite.Status8   = subTask.Status;
                }

                subTaskSuites.Add(subTaskSuite);
            }

            return(subTaskSuites);
        }