public ActionResult SaveComments(string key, string comment)
        {
            var results = listIssues.Where(x => x.key == key).FirstOrDefault();

            results.comment      = comment;
            chia                 = new ChiaDetails();
            chia.issueInfo       = listIssues;
            ViewBag.From         = from;
            ViewBag.To           = to;
            ViewBag.DeptList     = DeptList;
            ViewBag.SelectedDept = SelectedDept;
            using (OleDbConnection connection = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source ="
                                                                    + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\CommentsDB.accdb")))
            {
                try
                {
                    OleDbCommand cmd = new OleDbCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "UPDATE CHIAComments SET Comments = ? WHERE key = ?";
                    cmd.Parameters.Add("@p1", OleDbType.VarChar).Value = comment;
                    cmd.Parameters.Add("@p2", OleDbType.VarChar).Value = key;
                    cmd.Connection = connection;
                    connection.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    TempData["ErrorMessage"] = ErrorMessage = e.Message;
                }
            }
            return(View(chia));
        }
        public ActionResult GetChiaList()
        {
            if (Session["userName"] != null)
            {
                if (Getdata == 1)
                {
                    try
                    {
                        Getdata = 0;
                        return(View("GetChiaList", GettingCHIAIssues()));
                    }
                    catch (Exception e)
                    {
                        TempData["ErrorMessage"] = "Error in fetching data Check your internet connection and try again ";
                        return(View("GetChiaList"));
                    }
                }
                else
                {
                    chia                 = new ChiaDetails();
                    chia.issueInfo       = listIssues;
                    chia.DeptList        = DeptList;
                    ViewBag.From         = from;
                    ViewBag.To           = to;
                    ViewBag.DeptList     = DeptList;
                    ViewBag.SelectedDept = SelectedDept;

                    return(View(chia));
                }
            }
            else
            {
                return(View("Login"));
            }
        }
Ejemplo n.º 3
0
        public void WhenClickOnSort()
        {
            var         obj         = new ChiaApplicationController();
            var         actResult   = obj.GetChiaList() as ViewResult;
            ChiaDetails chiaDetails = (ChiaDetails)actResult.Model;

            Assert.That(chiaDetails.issueInfo.Count > 0);
            Assert.That(actResult.View, Is.EqualTo(null));
        }
Ejemplo n.º 4
0
        public void ValidUserNamePassword()
        {
            var        obj  = new ChiaApplicationController();
            LoginModel uspw = new LoginModel();

            uspw.UserName = "******";
            uspw.Password = "******";
            var         actResult = obj.GetChia(uspw) as ViewResult;
            ChiaDetails model     = (ChiaDetails)actResult.Model;

            Assert.That(actResult.ViewName, Is.EqualTo("GetChiaList"));
            Assert.That(model.FromDate, Is.EqualTo(null));
            Assert.That(model.ToDate, Is.EqualTo(null));
            Assert.That(model.issueInfo.Count, Is.EqualTo(0));
        }
        public ChiaDetails GettingCHIAIssues()
        {
            Dictionary <string, string> CommentDict = new Dictionary <string, string>();

            ViewBag.From         = from;
            ViewBag.To           = to;
            ViewBag.DeptList     = DeptList;
            ViewBag.SelectedDept = SelectedDept;
            string teams = "(";

            for (int k = 0; k < SelectedDept.Length; k++)
            {
                if (SelectedDept[k] != null)
                {
                    if (k > 0)
                    {
                        teams = teams + " OR ";
                    }
                    teams = teams + "\"Originating Team\" ~ " + SelectedDept[k];
                }
            }
            teams = teams + ")";
            string     url         = "https://jira3.cerner.com/rest/api/2/search?jql=project = CHIA AND issuetype = Assessment AND createdDate >=" + "'" + from + "'" + " AND createdDate<=" + "'" + to + "'" + " AND Assessment = \"CHIA Required\" AND status != Reviewed AND " + teams + " &maxResults=1000";
            WebRequest myReq       = WebRequest.Create(url);
            string     credentials = user + ":" + pwd;

            myReq.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials));
            WebResponse  wr            = myReq.GetResponse();
            Stream       receiveStream = wr.GetResponseStream();
            StreamReader reader        = new StreamReader(receiveStream, Encoding.UTF8);
            string       content       = reader.ReadToEnd();

            Rootobjectdetails = JsonConvert.DeserializeObject <Rootobject>(content);
            getComments(ref CommentDict);
            listIssues = new List <ChiaIssueDetails>();
            for (int i = 0; i < Rootobjectdetails.issues.Length; i++)
            {
                Dictionary <string, string> CRList = new Dictionary <string, string>();
                chiaobj                    = new ChiaIssueDetails();
                chiaobj.key                = Rootobjectdetails.issues[i].key;
                chiaobj.summary            = Rootobjectdetails.issues[i].fields.summary.ToString();
                chiaobj.createdDate        = Rootobjectdetails.issues[i].fields.created.Date.ToShortDateString();
                chiaobj.status             = Rootobjectdetails.issues[i].fields.status.name.ToString();
                chiaobj.CHIA_Id            = Rootobjectdetails.issues[i].fields.customfield_13331 == null ? "NA" : Rootobjectdetails.issues[i].fields.customfield_13331.ToString();
                chiaobj.compliance_Analyst = Rootobjectdetails.issues[i].fields.customfield_13310 == null ? "NA" : Rootobjectdetails.issues[i].fields.customfield_13310.displayName.ToString();
                chiaobj.age                = (int)Math.Floor((DateTime.Now - Rootobjectdetails.issues[i].fields.created.Date).TotalDays);
                getremotelinks(chiaobj.key.ToString(), ref CRList);

                var results = CommentDict.Where(x => x.Key == chiaobj.key).FirstOrDefault();
                if (results.Key != null)
                {
                    chiaobj.comment = results.Value;
                }
                else
                {
                    createDatabaseEntry(chiaobj.key);
                }

                if (CRList.Count == 0)
                {
                    chiaobj.CHIA_CR = "";
                    chiaobj.CR_url  = "";
                }
                else
                {
                    foreach (var obj in CRList)
                    {
                        chiaobj.CHIA_CR = obj.Key;
                        chiaobj.CR_url  = obj.Value;
                    }
                }
                listIssues.Add(chiaobj);
            }
            chia           = new ChiaDetails();
            listIssues     = listIssues.OrderByDescending(o => o.status).ThenBy(o => o.createdDate).ToList();
            chia.issueInfo = listIssues;
            return(chia);
        }