예제 #1
0
        private DataRow GetIssue_Row_Bykey(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(null);
            }
            var rows = Table_Issue_Lookup.Select("Key='" + key + "'");

            if (rows.Count() > 0)
            {
                return(rows[0]);
            }
            else //using Rest API get
            {
                string strFilter  = string.Format("search?jql=Key={0}", key);
                string strFields  = "&fields=issuelinks,issuetype,customfield_37381,customfield_38702,customfield_38719,customfield_29790,status,customfield_38751,customfield_38694,customfield_38693,timetracking,customfield_38725";
                string strOrderby = "+order+by+cf[38719]";
                string strSearch  = strFilter + strOrderby + strFields;
                string url        = System.IO.Path.Combine(Config.Instance.RestApi_Path, strSearch);

                string json = RestAPIAccess.ExecuteRestAPI_CURL(Config.Instance.UserName, Config.Instance.Password, url, "GET", string.Empty);

                try
                {
                    RootObject rb        = JsonConvert.DeserializeObject <RootObject>(json);
                    JObject    JOBJ_JSON = JObject.Parse(json);
                    if (rb.issues == null)
                    {
                        logger.Error("Data error:" + json);
                        return(null);
                    }
                    foreach (Issues issue in rb.issues)
                    {
                        TableObject newTabObj = new TableObject(issue);
                        newTabObj.Parent = GetParentIssue_Key(issue.key, JOBJ_JSON);
                        if (string.IsNullOrEmpty(newTabObj.Parent))
                        {
                            return(null);
                        }

                        return(Table_Issue_Lookup.Rows.Add(newTabObj.Key, newTabObj.ItemID, newTabObj.FP, newTabObj.UnifiedPriority, newTabObj.IssueType, newTabObj.ScrumTeamOwner, newTabObj.LeadRelease,
                                                           newTabObj.Status, newTabObj.StartFB, newTabObj.EndFB, newTabObj.TargetFB, newTabObj.OriginalEffort, newTabObj.RemWorkEffort, newTabObj.Parent, JOBJ_JSON));
                    }
                }
                catch
                {
                    return(null);
                }
                return(null);
            }
        }
예제 #2
0
        public void GetAllIssues()
        {
            //string strFilter = string.Format("search?jql=cf[29790]={0}%20and%20status=Open", Sto.Code) ;

            STO_AllIssues.Rows.Clear();
            DT_AvailIssues.Rows.Clear();
            DT_UntouchableIssues.Rows.Clear();
            string strFilter  = string.Format("search?jql=cf[29790]={0}", Sto.Code);
            string strFields  = "&fields=customfield_37381,customfield_38702,customfield_38719,customfield_29790,status,customfield_38751,customfield_38694,customfield_38693,timetracking,customfield_38725";
            string strOrderby = "+order+by+cf[38719]";
            string strSearch  = strFilter + strOrderby + strFields;
            string url        = System.IO.Path.Combine(Config.Instance.RestApi_Path, strSearch);

            int curIssueNum   = 0;
            int totalIssueNum = 1;

            while (curIssueNum < totalIssueNum)
            {
                string cmd  = "&startAt=" + curIssueNum.ToString();
                string json = RestAPIAccess.ExecuteRestAPI_CURL(Config.Instance.UserName, Config.Instance.Password, url, "GET", cmd);
                try
                {
                    RootObject rb = JsonConvert.DeserializeObject <RootObject>(json);
                    if (rb.issues == null)
                    {
                        logger.Error("Data error:" + json);
                        return;
                    }
                    foreach (Issues issue in rb.issues)
                    {
                        TableObject newTabObj = new TableObject(issue);
                        STO_AllIssues.Rows.Add(newTabObj.Key, newTabObj.ItemID, newTabObj.FP, newTabObj.UnifiedPriority, newTabObj.ScrumTeamOwner, newTabObj.LeadRelease,
                                               newTabObj.Status, newTabObj.StartFB, newTabObj.EndFB, newTabObj.TargetFB, newTabObj.OriginalEffort, newTabObj.RemWorkEffort);
                        var dt = newTabObj.Status == "Open" ? DT_AvailIssues : DT_UntouchableIssues;
                        dt.Rows.Add(newTabObj.Key, newTabObj.ItemID, newTabObj.FP, newTabObj.UnifiedPriority, newTabObj.ScrumTeamOwner, newTabObj.LeadRelease,
                                    newTabObj.Status, newTabObj.StartFB, newTabObj.EndFB, newTabObj.TargetFB, newTabObj.OriginalEffort, newTabObj.RemWorkEffort);
                    }
                    totalIssueNum = Convert.ToInt32(rb.total);
                    curIssueNum  += rb.issues.Count;
                }
                catch (SystemException exp)
                {
                    logger.Error("exception:" + exp.Message + "---" + json);
                    return;
                }
            }
        }
예제 #3
0
        private void btnTestConn_Click(object sender, EventArgs e)
        {
            string res = RestAPIAccess.ExecuteRestAPI_CURL(txtUserName.Text.Trim(), txtUserPassword.Text.Trim(), txtRestApiPath.Text.Trim(), "GET", "search?jql=cf[29790]=1312&startAt=0&maxResults=3");

            try
            {
                var jobj       = JObject.Parse(res);
                int issuecount = 0;

                if (int.TryParse(jobj["total"].ToString(), out issuecount) && issuecount > 0)
                {
                    MessageBox.Show("Test OK");
                }
                else
                {
                    MessageBox.Show("Test Failed");
                }
            }
            catch
            {
                MessageBox.Show("Test Failed");
            }
        }
예제 #4
0
        public int GetAllIssues()
        {
            JOBJ_JSON = null;
            STO_AllIssues.Rows.Clear();
            DT_AvailIssues.Rows.Clear();
            DT_UntouchableIssues.Rows.Clear();
            Table_Issue_Lookup.Rows.Clear();
            string strFilter  = string.Format("search?jql=cf[29790]={0}", Sto.Code);
            string strFields  = "&fields=issuelinks,issuetype,customfield_37381,customfield_38702,customfield_38719,customfield_29790,status,customfield_38751,customfield_38694,customfield_38693,timetracking,customfield_38725";
            string strOrderby = "+order+by+cf[38719]";
            string strSearch  = strFilter + strOrderby + strFields;
            string url        = System.IO.Path.Combine(Config.Instance.RestApi_Path, strSearch);

            int curIssueNum   = 0;
            int totalIssueNum = 1;

            while (curIssueNum < totalIssueNum)
            {
                string cmd  = "&startAt=" + curIssueNum.ToString();
                string json = RestAPIAccess.ExecuteRestAPI_CURL(Config.Instance.UserName, Config.Instance.Password, url, "GET", cmd);
                try
                {
                    RootObject rb;
                    try
                    {
                        rb = JsonConvert.DeserializeObject <RootObject>(json);
                    }
                    catch (Newtonsoft.Json.JsonReaderException exp)
                    {
                        logger.Error("exception:" + exp.Message + "---" + json);
                        return(-1);
                    }
                    JOBJ_JSON = JObject.Parse(json);



                    if (rb.issues == null)
                    {
                        logger.Error("Data error:" + json);
                        return(0);
                    }
                    foreach (Issues issue in rb.issues)
                    {
                        TableObject newTabObj = new TableObject(issue);
                        newTabObj.Parent = GetParentIssue_Key(issue.key, JOBJ_JSON);


                        STO_AllIssues.Rows.Add(newTabObj.Key, newTabObj.ItemID, newTabObj.FP, newTabObj.UnifiedPriority, newTabObj.IssueType, newTabObj.ScrumTeamOwner, newTabObj.LeadRelease,
                                               newTabObj.Status, newTabObj.StartFB, newTabObj.EndFB, newTabObj.TargetFB, newTabObj.OriginalEffort, newTabObj.RemWorkEffort, newTabObj.Parent);



                        DataTable dt = null;
                        if (newTabObj.IssueType == "Epic")
                        {
                            if (newTabObj.Status == "Open" || (newTabObj.Status == "Scheduled" /* && string.IsNullOrEmpty(newTabObj.TargetFB) */))
                            {
                                dt = DT_AvailIssues;
                            }
                            else if (/*newTabObj.Status == "Scheduled" || */ newTabObj.Status == "In Progress")
                            {
                                dt = DT_UntouchableIssues;
                            }
                        }
                        else if (newTabObj.IssueType == "Competence Area")
                        {
                            dt = DT_CA;
                        }

                        if (dt != null)
                        {
                            dt.Rows.Add(newTabObj.Key, newTabObj.ItemID, newTabObj.FP, newTabObj.UnifiedPriority, newTabObj.IssueType, newTabObj.ScrumTeamOwner, newTabObj.LeadRelease,
                                        newTabObj.Status, newTabObj.StartFB, newTabObj.EndFB, newTabObj.TargetFB, newTabObj.OriginalEffort, newTabObj.RemWorkEffort, newTabObj.Parent);
                        }
                    }
                    totalIssueNum = Convert.ToInt32(rb.total);
                    curIssueNum  += rb.issues.Count;
                }
                catch (SystemException exp)
                {
                    logger.Error("exception:" + exp.Message + "---" + json);
                    Program.fmMainWindow.RefreshStatus("REST API Error");
                    return(-1);
                }
            }
            Program.fmMainWindow.RefreshStatus("REST API OK");
            return(totalIssueNum);
        }