示例#1
0
        protected void ADDNewRecordComments(object sender, DirectEventArgs e)
        {
            string noteText = e.ExtraParams["noteText"];

            X.Call("ClearNoteText");
            PostRequest <CaseComment> req = new PostRequest <CaseComment>();
            CaseComment note = new CaseComment();

            note.recordId = null;
            note.comment  = noteText;
            note.date     = DateTime.Now;
            note.caseId   = Convert.ToInt32(currentCase.Text);
            req.entity    = note;


            PostResponse <CaseComment> resp = _caseService.ChildAddOrUpdate <CaseComment>(req);

            if (!resp.Success)
            {
                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", resp.ErrorCode) != null ? GetGlobalResourceObject("Errors", resp.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + resp.LogId : resp.Summary).Show();
            }
            caseComments_RefreshData(Convert.ToInt32(currentCase.Text));

            //Reset all values of the relative object
        }
示例#2
0
        public object ValidateSave(bool isPhantom, string obj, JsonObject values)
        {
            if (!values.ContainsKey("comment"))
            {
                return(new { valid = false, msg = "Error in call" });
            }

            PostRequest <CaseComment> req = new PostRequest <CaseComment>();
            CaseComment note = JsonConvert.DeserializeObject <List <CaseComment> >(obj)[0];

            //note.recordId = id;
            note.caseId  = Convert.ToInt32(currentCase.Text);
            note.comment = values["comment"].ToString();
            int bulk;

            req.entity = note;

            PostResponse <CaseComment> resp = _caseService.ChildAddOrUpdate <CaseComment>(req);

            if (!resp.Success)
            {
                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", resp.ErrorCode) != null ? GetGlobalResourceObject("Errors", resp.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + resp.LogId : resp.Summary).Show();
                return(new { valid = false });
            }
            caseComments_RefreshData(note.caseId);
            return(new { valid = true });
        }
示例#3
0
        public void upLoad()
        {
            ServicePointManager.Expect100Continue = true;                       //Enables prolonged use
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12; //Sets needed security level

            var    list = new List <string>();                                  //List to hold case numbers that have been used
            string user = "";                                                   //Test salesforce user
            string pass = "";                                                   //Test salesforce pass

            binding         = new SforceService();                              //Initializs binding object
            binding.Timeout = 60000;                                            //Sets maximum time per binding
            WebReference.LoginResult lr;                                        //lr is my login result
            lr = binding.login(user, pass);                                     //Used lr to create credentials
            string authEndPoint = binding.Url;                                  //Not sure what this does honestly

            binding.Url = lr.serverUrl;                                         //Sets binding to correct server
            binding.SessionHeaderValue           = new SessionHeader();         //Header needed for API format
            binding.SessionHeaderValue.sessionId = lr.sessionId;                //Gives binder the session id

            try
            {
                Case          c     = new Case();
                Case[]        cases = new Case[1];
                CaseComment   com   = new CaseComment();
                CaseComment[] coms  = new CaseComment[1];

                //c.AccountId = "GBS Non Case Events";
                //c.Subject = "API Test";
                //c.Type = "MAC - Non-Billable";
                //c.Case_Product_Category__c = "Project";
                //c.Product_Subcategory__c = "Training";
                //c.Priority = "SLA - 5 - Client Request/Client Created Issue";
                //c.Origin = "Phone";
                //c.Reason = "Test Description";
                //c.Status = "Case Opened";
                //c.OwnerId = "Firaus Odeh";
                //c.ContactId = "";
                //c.Description = "Test";
                //c.IsEscalated = false;
                //c.SuppliedName = "Test Case";
                //c.SuppliedEmail = "";
                //c.SuppliedPhone = "";
                //c.SuppliedCompany = "";
                //SaveResult[] results = binding.create(cases);
                //Debug.WriteLine("valid Data");
                c.Id = "5000g000026SPQ8AAO";
                string      query1 = "Insert into Case (Comments) Value ('Test') Where CaseNumber = '00311360'";
                QueryResult result = binding.query(query1);
                com.Id          = result.ToString();
                c.Subject       = "Test";
                com.CommentBody = "Test comment";
                c.Comments      = "test";
                coms[0]         = com;
                SaveResult[] check = binding.create(coms);
            }
            catch
            {
                Debug.WriteLine("Invalid data");
            }
        }
示例#4
0
        public async Task <IActionResult> Create(int id, [Bind("CaseCommentID,Comment,CommentTimestamp,CaseID,LocalUserID")] CaseComment caseComment)
        {
            //caseComment.CaseID = cid;
            //HttpContext.Request.Form["UserName"];
            try
            {
                if (ModelState.IsValid)
                {
                    Console.WriteLine("Check Check");
                    Console.WriteLine(id);
                    _context.Add(caseComment);
                    await _context.SaveChangesAsync();

                    //return RedirectToAction("", new { id = 99 });
                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error Palash!");
            }

            //ViewData["CaseID"] = new SelectList(_context.Case, "CaseID", "CaseID", caseComment.CaseID);
            //ViewData["UserID"] = new SelectList(_context.User, "UserID", "UserID", caseComment.UserID);
            return(View(caseComment));
        }
示例#5
0
        public async Task <IActionResult> Edit(int id, [Bind("CaseCommentID,Comment,CommentTimestamp,CaseID,LocalUserID")] CaseComment caseComment)
        {
            if (id != caseComment.CaseCommentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(caseComment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CaseCommentExists(caseComment.CaseCommentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CaseID"]      = new SelectList(_context.Case, "CaseID", "CaseID", caseComment.CaseID);
            ViewData["LocalUserID"] = new SelectList(_context.LocalUser, "LocalUserID", "LocalUserID", caseComment.LocalUserID);
            return(View(caseComment));
        }
示例#6
0
        public static CaseCommentDTO ToModel(this CaseComment entity)
        {
            if (entity == null)
            {
                return(null);
            }

            return(new CaseCommentDTO
            {
                Id = entity.Id,
                UserId = (Guid)entity.UserId,
                CaseId = entity.CaseId,
                CreatedAt = entity.CreatedAt,
                Comment = entity.Comment,
            });
        }
        public async Task <Guid> CreateAsync(CaseCommentDTO model)
        {
            var entity = new CaseComment()
            {
                Id        = Guid.NewGuid(),
                UserId    = model.UserId,
                CaseId    = model.CaseId,
                Comment   = model.Comment,
                CreatedAt = model.CreatedAt
            };

            await _caseCommentRepository.InsertAsync(entity);

            await _caseCommentRepository.SaveAsync();

            return(entity.Id);
        }
示例#8
0
        public void DeleteCase(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                CaseComment s = new CaseComment();
                s.caseId   = Convert.ToInt32(currentCase.Text);
                s.comment  = "";
                s.seqNo    = Convert.ToInt16(index);
                s.userId   = 0;
                s.userName = "";
                s.date     = DateTime.Now;



                PostRequest <CaseComment> req = new PostRequest <CaseComment>();
                req.entity = s;
                PostResponse <CaseComment> r = _caseService.ChildDelete <CaseComment>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    caseCommentStore.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
        //https://github.com/developerforce/Force.com-Toolkit-for-NET/blob/master/samples/SimpleConsole/Program.cs
        public async Task <Message> GetCaseDetailsAsync(string caseNumber)
        {
            var commentProps = new CaseComment().GetCommaSepListOfPropNames();
            var caseQuery    = "SELECT Id, CaseNumber, Subject, Description, CreatedDate, OwnerId, LastModifiedDate, IsClosed, Priority " +
                               " , Account.Name " +
                               $" , (Select {commentProps} FROM CaseComments) " +
                               " FROM Case " +
                               $" WHERE CaseNumber = '{caseNumber}'";

            /*
             * Case.GetSelectQuery() returns all these fields
             *
             * SELECT Id, IsDeleted, CaseNumber, ContactId, AccountId, AssetId, ParentId, SuppliedName, SuppliedEmail, SuppliedPhone, SuppliedCompany, Type,
             * Status, Reason, Origin, Subject, Priority, Description, IsClosed, ClosedDate, IsEscalated, OwnerId, CreatedDate, CreatedById, LastModifiedDate,
             * LastModifiedById, SystemModstamp, LastViewedDate, LastReferencedDate, EngineeringReqNumber__c, SLAViolation__c, Product__c, PotentialLiability__c FROM Case
             */


            var client = GetClientAsync().Result;
            var task   = await client.QueryAsync <Case>(caseQuery);

            var result = task;

            if (result.Records.Count == 0)
            {
                return(new Message {
                    Text = $"records not found for case {caseNumber}"
                });
            }
            if (result.Records.Count > 1)
            {
                var matchingCaseNumbers = string.Join(",", result.Records.Select(c => c.CaseNumber));
                return(new Message {
                    Text = $"Multiple records found {matchingCaseNumbers}"
                });
            }

            var sfCase = result.Records.First();

            return(_caseMessageFormatter.GetCaseMessage(sfCase));
        }
        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;
        }
示例#11
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;
        }
示例#12
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;
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            this.btnSend.Enabled = false;

            string weekyIndicatorSummary = "";

            weekyIndicatorSummary = @"<table cellspacing='1' cellpadding='1' border='0' bgcolor='111111' style='border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;'>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>New Jira Ticket Count:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{0}</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Monday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{5}</td>
                                            </tr>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Production Bug Count:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{1}</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Tuesday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{6}</td>
                                            </tr>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Eng Case Count:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{2}</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Wednesday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{7}</td>
                                            </tr>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Eng QA Case Count:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{3}</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Thursday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{8}</td>
                                            </tr>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Case Comment Count:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{4}</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Friday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{9}</td>
                                            </tr>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>&nbsp;</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>&nbsp;</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Saturday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{10}</td>
                                            </tr>
                                            <tr>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>&nbsp;</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>&nbsp;</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>Sunday:</td>
                                                <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{11}</td>
                                            </tr>
                                        </table>";
            weekyIndicatorSummary = String.Format(weekyIndicatorSummary, this.txtNewJiraTicketCount.Text,
                                                  this.txtProductionBugCount.Text,
                                                  this.txtEngCaseCount.Text,
                                                  this.txtEngQACaseCount.Text,
                                                  this.txtTotalCaseCommentCount.Text,
                                                  this.txtMondayCaseCommentCount.Text,
                                                  this.txtTuesdayCaseCommentCount.Text,
                                                  this.txtWednesdayCaseCommentCount.Text,
                                                  this.txtThursdayCaseCommentCount.Text,
                                                  this.txtFridayCaseCommentCount.Text,
                                                  this.txtSaturdayCaseCommentCount.Text,
                                                  this.txtSundayCaseCommentCount.Text);


            string weekyCaseSummary = "";

            weekyCaseSummary = @"<table cellspacing='1' cellpadding='1' border='0' bgcolor='111111' style='border-collapse:collapse;border-spacing:0;border-left:1px solid #888;border-top:1px solid #888;background:#efefef;'>
                                    <tr>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>No</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Product</th>                                       
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>SF#</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Jira#</th> 
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Severity</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Rank</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Version</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Type</th>
                                        <th align='left' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Customer</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Orgin</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Open Date</th>    
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Reopened#</th>                                    
                                        <th align='left' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Summary</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Reviewer</th>                                   
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Comments</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Case Comment Count</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Total Case Comment</th>
                                        <th align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;font-weight:bold;background:#ccc;'>Total Time Spent</th>
                                    </tr>";

            DataTable   dataTable   = grdCaseList.DataSource as DataTable;
            CaseComment caseComment = null;

            if (dataTable != null)
            {
                int    rowCount          = dataTable.Rows.Count;
                string product           = "";
                string caseNumber        = "";
                string jiraKey           = "";
                string priority          = "";
                int    rank              = 0;
                string buildVersion      = "";
                string type              = "";
                string summary           = "";
                string customer          = "";
                string origin            = "";
                string description       = "";
                string openDate          = "";
                string reopenCount       = "";
                string assignee          = "";
                string jiaStstus         = "";
                string caseId            = "";
                string comment           = "";
                string caseCommentBody   = "";
                double CaseCommentCount  = 0.0;
                double TotalCommentCount = 0.0;
                double TotalTimespent    = 0.0;

                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    product      = row["ProductForUI"] as string;
                    caseNumber   = row["SalesforceID"] as string;
                    jiraKey      = row["JiraKey"] as string;
                    priority     = row["Severity"] as string;
                    rank         = (int)row["Rank"];
                    buildVersion = row["Version"] as string;
                    type         = row["IssueCategory"] as string;
                    if (String.IsNullOrEmpty(type))
                    {
                        //type = row["Type"] as string;
                        type = "";
                    }
                    customer    = row["Customer"] as string;
                    origin      = row["Orgin"] as string;
                    openDate    = row["OpenDate"] as string;
                    reopenCount = row["ReopenedCount"] as string;
                    summary     = row["Summary"] as string;
                    assignee    = row["Reviewer"] as string;
                    jiaStstus   = row["JiraStatus"] as string;
                    description = row["Description"] as string;
                    comment     = row["Comments"] as string;
                    caseId      = row["ID"] as string;

                    caseComment     = row["CaseComment"] as CaseComment;
                    caseCommentBody = (caseComment != null ? caseComment.CommentBody : "");

                    CaseCommentCount  = (int)row["CaseCommentCount"];
                    TotalCommentCount = (int)row["TotalCommentCount"];
                    TotalTimespent    = (double)row["Timespent"];

                    weekyCaseSummary += String.Format(@"<tr>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{0}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{1}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'><a href='https://na26.salesforce.com/{14}'><font style='{15}'>{2}</font></a></td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'><a href='https://accelaeng.atlassian.net/browse/{3}'>{3}</a></td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{4}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{16}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{5}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{6}</td>
                                                        <td align='left' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{7}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{8}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{9}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{10}</td>
                                                        <td align='left' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{11}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{12}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{13}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{17}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{18}</td>
                                                        <td align='center' style='border-right:1px solid #888;border-bottom:1px solid #888;padding:1px 10px;'>{19}h</td>
                                                    </tr>",
                                                      (i + 1),          // 0
                                                      product,          // 1
                                                      caseNumber,       // 2
                                                      jiraKey,          // 3
                                                      priority,         // 4
                                                      buildVersion,
                                                      type,
                                                      customer,
                                                      origin,
                                                      openDate,
                                                      reopenCount,
                                                      summary,
                                                      assignee,
                                                      //jiaStstus,
                                                      comment,
                                                      caseId,
                                                      "",  //(isNeedDoubleReview ? "font-weight:bold;font-style:italic;color:red" : "color:green")
                                                      (rank == 0 ? "" : "" + rank),
                                                      CaseCommentCount,
                                                      TotalCommentCount,
                                                      TotalTimespent
                                                      );
                }
            }
            weekyCaseSummary += "</table>";

            string content = @"Hi All,<br/><br/>Below is the Weekly Case Review Summary report. Please kindly let us know if you have any further question.<br/><br/>" + weekyIndicatorSummary + "<br/><br/>" + weekyCaseSummary + "<br/><br/>Thanks<br/>Accela Support Team";
            string from    = "*****@*****.**";
            string to      = "[email protected];[email protected];[email protected]";
            string cc      = "*****@*****.**";

            string subject = "Weekly Case Review Summary - " + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + DateTime.Now.Year;

            try
            {
                EmailUtil.SendEmail(from, to, cc, subject, content);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failed to send email");
            }

            this.btnSend.Enabled = true;
        }