示例#1
0
        public IssueFields()
        {
            summary = "";
            issuetype = new IssueType();
            description = "";
            customfield_10800 = "";
            customfield_10007 = "";
            customfield_10004 = "";
            updated = new DateTime();
            created = new DateTime();
            resolutiondate = new DateTime();

            status = new Status();
            timetracking = new Timetracking();

            labels = new List<String>();
            comments = new List<Comment>();
            issuelinks = new List<IssueLink>();
            attachment = new List<Attachment>();
            reporter = new JiraUser();
            assignee = new JiraUser();
            parent = new IssueRef();
            priority = new Priority();
            project = new ParentProject();
        }
        private void CreateComment(GitChangeSet changeSet, string ticket)
        {
            var issueRef = new IssueRef { id = ticket };

            var issue = this.Client.LoadIssue(issueRef);

            if (issue == null)
                return;

            this.Client.CreateComment(issueRef, changeSet.ToString());
        }
示例#3
0
        public static async Task<Comment> CreateComment(IssueRef issue, string caseComment)
        {
            IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng");

            var jiraComments = jira.GetComments(issue);
            bool isFound = false;
            Comment jiraComment = null;
            foreach (Comment temp in jiraComments)
            {
                if (temp.body.Equals(caseComment, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    jiraComment = temp;
                    isFound = true;
                    break;
                }
            }

            if (!isFound)
            {
                jiraComment = jira.CreateComment(issue, caseComment);
            }

            return jiraComment;
        }
示例#4
0
 public IEnumerable <Comment> GetComments(IssueRef issue)
 {
     return(client.GetComments(issue));
 }
示例#5
0
 public Issue TransitionIssue(IssueRef issue, Transition transition)
 {
     return(Issue.From(client.TransitionIssue(issue, transition)));
 }
示例#6
0
 public void DeleteIssue(IssueRef issue)
 {
     client.DeleteIssue(issue);
 }
示例#7
0
        public IEnumerable<Ticket> Tickets(IAvailableTicketTypes availableTypes)
        {
            var map = new JiraTypeMap(this, availableTypes);
            foreach (var jiraKey in jira.EnumerateIssues(jiraProject))
            {
                var issueRef = new IssueRef
                {
                    id = jiraKey.id,
                    key = jiraKey.key
                };
                var jiraTicket = jira.LoadIssue(issueRef);

                onDetailedProcessing(jiraTicket.key + " - " + jiraTicket.fields.summary);

                var ticket = new Ticket();
                ticket.TicketType = map[jiraTicket.fields.issuetype.name];
                ticket.ID = jiraTicket.key;
                ticket.Summary = JiraString.StripNonPrintable(jiraTicket.fields.summary);

                var status = jiraTicket.fields.status.statusCategory.key.ToUpper();
                switch (status)
                {
                    case "NEW":
                        ticket.TicketState = Ticket.State.Todo;
                        break;
                    case "DONE":
                        ticket.TicketState = Ticket.State.Done;
                        break;
                    case "INDETERMINATE":
                        ticket.TicketState = Ticket.State.InProgress;
                        break;
                    default:
                        ticket.TicketState = Ticket.State.Unknown;
                        break;
                }

                ticket.Parent = jiraTicket.fields.parent.key;

                ticket.Description = JiraString.StripNonPrintable(jiraTicket.fields.description);
                if (PreferHtml &&
                    string.IsNullOrWhiteSpace(jiraTicket.renderedFields.description) == false)
                {
                    ticket.Description = JiraString.StripNonPrintable(jiraTicket.renderedFields.description);
                }
                ticket.CreatedOn = jiraTicket.fields.created;
                ticket.LastModified = jiraTicket.fields.updated;

                ticket.CreatedBy = new User(jiraTicket.fields.reporter.displayName,
                    jiraTicket.fields.reporter.name,
                    jiraTicket.fields.reporter.emailAddress);
                ticket.AssignedTo = new User(jiraTicket.fields.assignee.displayName,
                    jiraTicket.fields.assignee.name,
                    jiraTicket.fields.assignee.emailAddress);

                ticket.Epic = jiraTicket.fields.customfield_10800;
                ticket.ExternalReference = jiraTicket.key;
                ticket.Url = jiraServer + "/browse/" + jiraTicket.key;
                int.TryParse(jiraTicket.fields.customfield_10004, out ticket.StoryPoints);

                foreach (var link in jiraTicket.fields.issuelinks)
                {
                    if (string.Compare(link.inwardIssue.key, jiraTicket.key) != 0)
                    {
                        ticket.Links.Add(new Link(link.inwardIssue.key, link.type.name));
                    }
                    if (string.Compare(link.outwardIssue.key, jiraTicket.key) != 0)
                    {
                        ticket.Links.Add(new Link(link.outwardIssue.key, link.type.name));
                    }
                }

                foreach (var jiraComment in jiraTicket.fields.comments)
                {
                    var author = new User(jiraComment.author.displayName,
                        jiraComment.author.name, jiraComment.author.emailAddress);
                    var comment = new Comment(author, jiraComment.body, jiraComment.created);
                    if (jiraComment.updated.Date > jiraComment.created.Date)
                    {
                        comment.Updated = jiraComment.updated;
                    }
                    ticket.Comments.Add(comment);
                }

                foreach (var attachment in jiraTicket.fields.attachment)
                {
                    ticket.Attachments.Add(new Attachment(attachment.filename, attachment.content));
                }

                ticket.Priority = jiraTicket.fields.priority.name;
                ticket.Project = jiraTicket.fields.project.name;
                if (jiraTicket.fields.resolutiondate != null)
                {
                    ticket.ClosedOn = jiraTicket.fields.resolutiondate;
                }

                yield return (ticket);
            }
        }
示例#8
0
 public IEnumerable <RemoteLink> GetRemoteLinks(IssueRef issue)
 {
     return(client.GetRemoteLinks(issue));
 }
示例#9
0
 public Issue <TIssueFields> LoadIssue(IssueRef issueRef)
 {
     return(LoadIssue(issueRef.JiraIdentifier));
 }
示例#10
0
 public IEnumerable <IssueLink> GetIssueLinks(IssueRef issue)
 {
     return(LoadIssue(issue).fields.issuelinks);
 }
示例#11
0
 public IEnumerable <Attachment> GetAttachments(IssueRef issue)
 {
     return(LoadIssue(issue).fields.attachment);
 }
        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;
        }
        private void btnMerge_Click(object sender, EventArgs e)
        {
            this.btnSync.Enabled = false;
            this.btnMerge.Enabled = false;
            
            DataTable dataTable = this.dgdMergeFileList.DataSource as DataTable;

            DataView dataTableView = dataTable.DefaultView;
            dataTableView.Sort = "CaseNumber ASC, UploadDate ASC";
            dataTable = dataTableView.ToTable();

            if (dataTable != null)
            {
                int rowCount = dataTable.Rows.Count;
                bool IsMerged = false;
                string caseId = "";
                string caseNumber = "";
                string caseAttachmentId = "";
                string caseFileName = "";
                string caseAttchmentId = "";
                string caseAttachmentType = "";
                string uploadedBy = "";
                string uploadDate = "";
                string jiraId = "";
                string jiraKey = "";
                string currentCaseNumber = "";
                string commentMoveFileList = string.Empty;

                IssueRef issueRef = new IssueRef();
                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    IsMerged = bool.Parse(row["IsMerged"].ToString());
                    caseId = row["CaseId"] as string;
                    caseNumber = row["CaseNumber"] as string;
                    caseAttachmentId = row["CaseAttchmentId"] as string;
                    caseFileName = row["CaseFileName"] as string;
                    caseAttchmentId = row["CaseAttchmentId"] as string;
                    caseAttachmentType = row["CaseAttachmentType"] as string;
                    uploadDate = row["UploadDate"] as string;
                    uploadedBy = row["UploadedBy"] as string;
                    jiraId = row["JiraId"] as string;
                    jiraKey = row["JiraKey"] as string;

                    if (!String.IsNullOrEmpty(commentMoveFileList) && currentCaseNumber != caseNumber)
                    {
                        // Upload jira comment
                        commentMoveFileList = "Copy some attachments from salesforce \n------------------------------------------------------------------------\n" + commentMoveFileList;
                        JiraProxy.CreateComment(issueRef, commentMoveFileList);
                        commentMoveFileList = string.Empty;
                    }

                    issueRef.id = jiraId;
                    issueRef.key = jiraKey;

                    if (IsMerged)
                    {
                        byte[] fileStream = SalesforceProxy.GetCaseAttachmentById(caseAttachmentId);                        
                        JiraProxy.UploadAttachment(issueRef, caseFileName, fileStream);

                        commentMoveFileList += "The file : <<" + caseFileName + ">> uploaded by <<" + uploadedBy + ">> on " + uploadDate + "\n";
                    }
                    
                    currentCaseNumber = caseNumber;                    
                }

                if (!String.IsNullOrEmpty(commentMoveFileList))
                {
                    // Upload jira comment
                    commentMoveFileList = "Copy some attachments from salesforce \n------------------------------------------------------------------------\n" + commentMoveFileList;
                    JiraProxy.CreateComment(issueRef, commentMoveFileList);
                    commentMoveFileList = string.Empty;
                }
            }

            this.btnSync.Enabled = true;
            this.btnMerge.Enabled = false;
        }
示例#14
0
 public IssueLink()
 {
     type         = new LinkType();
     inwardIssue  = new IssueRef();
     outwardIssue = new IssueRef();
 }
示例#15
0
        public static bool UploadAttachment(IssueRef issue, string fileName, byte[] fileStream)
        {
            IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng");
            jira.CreateAttachment(issue, fileStream, fileName);

            return true;
        }
        public static bool UpdateJIRAStatus(IssueRef issueRef, string jiraStatus, string jiraNextStatus)
        {
            // Start Review Case: Open -> In Progress
            //                    Pending -> In Progress
            //                    Resolved -> In Progress(Command: Re-Open)
            //                    Closed -> In Progress(Command: Re-Open)
            // Add some comment: In Progress -> Pending
            // 

            if (String.IsNullOrEmpty(jiraNextStatus))
            {
                return false;
            }

            IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng");
            var transitions = jira.GetTransitions(issueRef);

            if ("In Progress" == jiraNextStatus)
            {
                if ("Open".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    return true;
                }

                if ("Pending".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase)
                    || "Reopened".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    foreach (var transition in transitions)
                    {
                        if ("Analysis In Progress".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                        {
                            jira.TransitionIssue(issueRef, transition);
                            break;
                        }
                    }
                }
                else
                {
                    if ("Closed".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        foreach (var transition in transitions)
                        {
                            if ("Re-Open".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                            {
                                jira.TransitionIssue(issueRef, transition);
                                break;
                            }
                        }
                    }

                    if ("Resolved".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        foreach (var transition in transitions)
                        {
                            if ("Dev In Progress".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                            {
                                jira.TransitionIssue(issueRef, transition);
                                break;
                            }
                        }
                    }

                    transitions = jira.GetTransitions(issueRef);

                    foreach (var transition in transitions)
                    {
                        if ("Analysis In Progress".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                        {
                            jira.TransitionIssue(issueRef, transition);
                            break;
                        }
                    }
                }
            }

            if ("Pending" == jiraNextStatus)
            {
                if ("Open".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    foreach (var transition in transitions)
                    {
                        if ("Analysis In Progress".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                        {
                            jira.TransitionIssue(issueRef, transition);
                            break;
                        }
                    }

                    jiraStatus = "In Progress";
                }

                if ("In Progress".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                {
                    foreach (var transition in transitions)
                    {
                        if ("Commented".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                        {
                            jira.TransitionIssue(issueRef, transition);
                            break;
                        }
                    }
                }
            }

            if ("Closed" == jiraNextStatus)
            { 
            }

            return true;
        }
        private void btnMoveCommentToJIRA_Click(object sender, EventArgs e)
        {
            this.btnMoveCommentToJIRA.Enabled = false;

            DataTable dataTable = grdCaseList.DataSource as DataTable;
            if (dataTable != null)
            {
                int rowCount = dataTable.Rows.Count;
                string jiraKey = "";
                string jiraID = "";
                string lastModifiedDate = "";
                CaseComment caseComment = null;
                string today = "" + DateTime.Now.Year + "-" + (DateTime.Now.Month >= 10 ? "" + DateTime.Now.Month : "0" + DateTime.Now.Month) + "-" + (DateTime.Now.Day >= 10 ? "" + DateTime.Now.Day : "0" + DateTime.Now.Day);
                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    jiraKey = row["JiraKey"] as string;
                    jiraID = row["JiraID"] as string;
                    lastModifiedDate = row["SFLastModified"] as string;
                    caseComment = row["CaseComment"] as CaseComment;
                    
                    // No comment today
                    if (caseComment == null)
                    {
                        continue;
                    }

                    string createdDate = "" + caseComment.CreatedDate.Year + "-" + (caseComment.CreatedDate.Month >= 10 ? "" + caseComment.CreatedDate.Month : "0" + caseComment.CreatedDate.Month) + "-" + (caseComment.CreatedDate.Day >= 10 ? "" + caseComment.CreatedDate.Day : "0" + caseComment.CreatedDate.Day); 

                    if (caseComment != null
                        && today != lastModifiedDate
                        && today == createdDate)
                    {
                        IssueRef issue = new IssueRef();
                        issue.key = jiraKey;
                        issue.id = jiraID;

                        JiraProxy.CreateComment(issue, "Copied from salesforce:\n---------------------------------------------------------\n" + caseComment.CommentBody);
                    }
                }
            }

            this.btnMoveCommentToJIRA.Enabled = true;
        }
示例#18
0
 public IssueLink LoadIssueLink(IssueRef parent, IssueRef child, string relationship)
 {
     return(client.LoadIssueLink(parent, child, relationship));
 }
        private void btnUpdateJIRAStatus_Click(object sender, EventArgs e)
        {
            // Start Review Case: Open -> In Progress
            //                    Pending -> In Progress
            //                    Resolved -> In Progress(Command: Re-Open)
            //                    Closed -> In Progress(Command: Re-Open)
            // Add some comment: In Progress -> Pending
            // 

            this.btnUpdateJIRAStatus.Enabled = false;

            DataTable dataTable = grdCaseList.DataSource as DataTable;
            if (dataTable != null)
            {
                int rowCount = dataTable.Rows.Count;
                string jiraKey = "";
                string jiraID = "";
                string jiraStatus = "";
                string jiraNextStatus = "";
                string bzid = "";

                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    jiraKey = row["JiraKey"] as string;
                    jiraID = row["JiraID"] as string;
                    jiraStatus = row["JiraStatus"] as string;
                    jiraNextStatus = row["NextJiraStatus"] as string;
                    bzid = row["BZID"] as string;

                    if (!String.IsNullOrEmpty(jiraNextStatus))
                    {
                        IssueRef issue = new IssueRef();
                        issue.id = jiraID;
                        issue.key = jiraKey;
                        var updateJiraStatus = AccelaCaseUtil.UpdateJIRAStatus(issue, jiraStatus, jiraNextStatus);
                    }
                }
            }

            this.btnUpdateJIRAStatus.Enabled = true;
        }
示例#20
0
 public IEnumerable <History> GetChangeLog(IssueRef issue)
 {
     return(client.GetChangeLog(issue));
 }
        private async void btnSendRecreatedCase_Click(object sender, EventArgs e)
        {
            this.btnSendRecreatedCase.Enabled = false;

            DataTable dataTable = this.grdCaseList.DataSource as DataTable;

            DataView dataTableView = dataTable.DefaultView;
            dataTableView.Sort = "Assignee ASC";
            dataTable = dataTableView.ToTable();

            string dailyCaseSummary = "";
            dailyCaseSummary = @"<table cellspacing='1px' cellpadding='1px' border='1px' style='border-color:black;font-size:14px'>
                                    <tr>
                                        <th align='center'>No</th>
                                        <th align='center'>Product</th>                                       
                                        <th align='center'>Salesforce ID</th>
                                        <th align='center'>Jira Key</th> 
                                        <th align='center'>Version</th>
                                        <th align='center'>Priority</th>
                                        <th align='center'>Customer</th>
                                        <th align='center'>Summary</th>
                                        <th align='left'>Reopened Times</th>
                                        <th align='center'>Dev</th>
                                        <th align='center'>QA</th>    
                                        <th align='center'>Recreated Time</th>
                                    </tr>";

            int count = 0;
            if (dataTable != null)
            {
                int rowCount = dataTable.Rows.Count;
                string product = "";
                string caseId = "";
                string caseNumber = "";
                string jiraID = "";
                string jiraKey = "";
                string buildVersion = "";
                string priority = "";
                string customer = "";
                string summary = "";
                string reopenCount = "";
                string assignee = "";
                string assigneeQA = "";
                List<string> jiraLabels = null;

                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    product = row["Product"] as string;
                    caseId = row["ID"] as string;
                    caseNumber = row["SalesforceID"] as string;
                    jiraKey = row["JiraKey"] as string;
                    buildVersion = row["Version"] as string;
                    priority = row["Severity"] as string;
                    customer = row["Customer"] as string;
                    summary = row["Summary"] as string;
                    reopenCount = row["ReopenedCount"] as string;
                    assignee = row["Assignee"] as string;
                    assigneeQA = row["AssigneeQA"] as string; 
                    jiraLabels = row["JiraLabels"] as List<string>;

                    if (jiraLabels != null && !jiraLabels.Contains("Recreated_By_QA"))
                    {
                        continue;
                    }

                    
                    jiraID = row["JiraID"] as string;
					
					IssueRef issue = new IssueRef();
                    issue.key = jiraKey;
                    issue.id = jiraID;
                    var GetComments = JiraProxy.GetComments(issue);
                    var Comments = await GetComments;
                    DateTime recreatedTime = DateTime.Now;
                    if (Comments != null && Comments.Count > 0)
                    {
                        foreach (Comment comment in Comments)
                        {
                            if (comment != null 
                                && comment.body != null)
                            {
                                if(comment.body.ToLower().Contains("copied from salesforce:"))
                                {
                                    continue;
                                }

                                if(comment.body.ToLower().Contains("reproduce") 
                                    || comment.body.ToLower().Contains("recreate")
                                    || comment.body.ToLower().Contains("replicate"))
                                {
                                    if (comment.UpdateAuthor != null && comment.UpdateAuthor.displayName == assigneeQA)
                                    {
                                        recreatedTime = comment.Updated;
                                        break;
                                    }
                                    else if (comment.Author != null && comment.Author.displayName == assigneeQA)
                                    {
                                        recreatedTime = comment.Created;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    dailyCaseSummary += String.Format(@"<tr>
                                                        <td align='center'>{0}</td>
                                                        <td align='center'>{1}</td>
                                                        <td align='center'><a href='https://na26.salesforce.com/{12}'>{2}</a></td>
                                                        <td align='center'><a href='https://accelaeng.atlassian.net/browse/{3}'>{3}</a></td>
                                                        <td align='center'>{4}</td>
                                                        <td align='center'>{5}</td>
                                                        <td align='center'>{6}</td>
                                                        <td align='left'>{7}</td>
                                                        <td align='center'>{8}</td>
                                                        <td align='center'>{9}</td>
                                                        <td align='center'>{10}</td>    
                                                        <td align='center'>{11}</td>
                                                    </tr>",
                                                       ++count, // 0 - No
                                                       product, // 1 - Product
                                                       caseNumber, // 2 - Salesforce ID
                                                       jiraKey, // 3 - Jira Key
                                                       buildVersion, // 4 - Version
                                                       priority, // 5 - Priority
                                                       customer, // 6 - Customer
                                                       summary, // 7 - Summary
                                                       reopenCount, // 8 - Reopened Times
                                                       assignee, // 9 - Dev
                                                       assigneeQA, // 10 - QA
                                                       recreatedTime.ToShortDateString(), // 11 - Recreated Time
                                                       caseId
                                                       );
                }

                dailyCaseSummary += "</table>";

                if (count == 0)
                {
                    this.btnSendRecreatedCase.Enabled = true;
                    return;
                }

                string content = @"Hi, All guys<br/><br/>The following case are already recreated by our QA, please deal with them within one oe two days. If you finished it, please remove the label - Recreated_By_QA. Thanks a lot!<br/><br/>" + dailyCaseSummary + "<br/><br/>Thanks<br/>Accela Support Team";
                string from = "*****@*****.**";
                string to = "[email protected];[email protected];[email protected]";
                string cc = "*****@*****.**";
                string subject = "The Case List Recreated By QA - " + 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.btnSendRecreatedCase.Enabled = true;
            }
        }
示例#22
0
 public Issue LoadIssue(IssueRef issueRef)
 {
     return(Issue.From(client.LoadIssue(issueRef)));
 }
        private async void CreateDBInfoComment(string jiraKey, string customer)
        {
            if (AccelaDBMapper.ContainsKey(customer))
            {
                AcccelaDBModel dbInfo = AccelaDBMapper[customer];

                IssueRef issue = new IssueRef();
                issue.key = jiraKey;
                issue.id = jiraKey;

                string dbConnInfo = "";
                dbConnInfo += "Type: " + dbInfo.DBType + "\n";
                dbConnInfo += "IP: " + dbInfo.IP + "\n";
                dbConnInfo += "Port: " + dbInfo.Port + "\n";
                dbConnInfo += "SID: " + dbInfo.SID + "\n";
                dbConnInfo += "DB Name: " + dbInfo.DBName + "\n";
                dbConnInfo += "User: "******"\n";
                dbConnInfo += "Pass: "******"\n";
                dbConnInfo += "Version: " + dbInfo.Version + "\n";
                dbConnInfo += "Related Case: " + dbInfo.SFCase + "\n";

                JiraProxy.CreateComment(issue, "This client provide some database dump before, please have a try on it first:\n---------------------------------------------------------\n" + dbConnInfo);
            }
        }
示例#24
0
 public IEnumerable <Transition> GetTransitions(IssueRef issue)
 {
     return(client.GetTransitions(issue));
 }
示例#25
0
 public Comment CreateComment(IssueRef issue, string comment)
 {
     return(client.CreateComment(issue, comment));
 }
示例#26
0
 public IEnumerable <JiraUser> GetWatchers(IssueRef issue)
 {
     return(client.GetWatchers(issue));
 }
示例#27
0
 public void DeleteComment(IssueRef issue, Comment comment)
 {
     client.DeleteComment(issue, comment);
 }
示例#28
0
 public IssueLink()
 {
     type = new LinkType();
     inwardIssue = new IssueRef();
     outwardIssue = new IssueRef();
 }
示例#29
0
 public IEnumerable <Attachment> GetAttachments(IssueRef issue)
 {
     return(client.GetAttachments(issue));
 }
示例#30
0
        public static async Task<List<Attachment>> GetAttachments(IssueRef issue)
        {
            IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng");

            var jiraAttachments = jira.GetAttachments(issue);


            return (jiraAttachments as List<Attachment>);
        }
示例#31
0
 public Attachment CreateAttachment(IssueRef issue, Stream stream, string fileName)
 {
     return(client.CreateAttachment(issue, stream, fileName));
 }
示例#32
0
        public static async Task<bool> UpdateJiraStatus(IssueRef issueRef, string jiraStatus, string jiraNextStatus)
        {
            IJiraClient jira = new JiraClient("https://accelaeng.atlassian.net/", "*****@*****.**", "peter.peng");

            var transitions = jira.GetTransitions(issueRef);
            if ("Closed".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase)
                && jiraNextStatus == "In Progress")
            {
                foreach (var transition in transitions)
                {
                    if ("Re-Open".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        jira.TransitionIssue(issueRef, transition);
                        break;
                    }
                }
            }

            if ("Pending".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase)
                && jiraNextStatus == "In Progress")
            {
                foreach (var transition in transitions)
                {
                    if ("Analysis In Progress".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        jira.TransitionIssue(issueRef, transition);
                        break;
                    }
                }
            }

            if ("In Progress".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase)
                && jiraNextStatus == "Pending")
            {
                foreach (var transition in transitions)
                {
                    if ("Commented".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        jira.TransitionIssue(issueRef, transition);
                        break;
                    }
                }
            }

            if (("Pending".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase)
                || "Resolved".Equals(jiraStatus, System.StringComparison.InvariantCultureIgnoreCase))
                && jiraNextStatus == "Closed")
            {
                foreach (var transition in transitions)
                {
                    if ("Closed".Equals(transition.name, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        jira.TransitionIssue(issueRef, transition);
                        break;
                    }
                }
            }
            //var issues = jira.TransitionIssue(issueRef, inProgressOrReopen);

            // "Open" -> "In Progress"
            // "In Progress" -> "Commented"
            // "In Progress" -> "Closed"
            return true;
        }
示例#33
0
 public RemoteLink UpdateRemoteLink(IssueRef issue, RemoteLink remoteLink)
 {
     return(client.UpdateRemoteLink(issue, remoteLink));
 }
示例#34
0
 public void DeleteRemoteLink(IssueRef issue, RemoteLink remoteLink)
 {
     client.DeleteRemoteLink(issue, remoteLink);
 }
        private async void btnSyncCaseInJiraAndSF_Click(object sender, EventArgs e)
        {
            this.btnSyncCaseInJiraAndSF.Enabled = false;
                      
            DataTable dataTable = grdCaseList.DataSource as DataTable;
            if (dataTable != null)
            {
                int rowCount = dataTable.Rows.Count;
                string jiraKey = "";
                string jiraID = "";
                string jiraStatus = "";
                string jiraNextStatus = "";

                for (int i = 0; i < rowCount; i++)
                {
                    DataRow row = dataTable.Rows[i];
                    jiraKey = row["JiraKey"] as string;
                    jiraID = row["JiraID"] as string;
                    jiraStatus = row["JiraStatus"] as string;
                    jiraNextStatus = row["JiraNextStatus"] as string;

                    if (!String.IsNullOrEmpty(jiraNextStatus))
                    {
                        IssueRef issue = new IssueRef();
                        issue.id = jiraID;
                        issue.key = jiraKey;
                        var updateJiraStatus = AccelaCaseUtil.UpdateJIRAStatus(issue, jiraStatus, jiraNextStatus);                        
                    }
                }
            }

            this.btnSyncCaseInJiraAndSF.Enabled = true;
        }