Beispiel #1
0
        public ActionResult _RiskLevelData()
        {
            List <Models.RiskLevel> modelList = new List <Models.RiskLevel>();

            using (iobserverContext context = new iobserverContext())
            {
                var startDate = DateTime.Today.AddDays(-30);
                var endData   = DateTime.Today;
                // var data = context.V_reports.Where(a => a.Language_code == "en").ToList();
                var data          = System.Web.HttpContext.Current.Session["data"] as List <V_report>;
                var disRisksLevel = data.Select(a => a.Risklevel).Distinct().ToList().OrderBy(o => o);

                foreach (var rlevel in disRisksLevel)
                {
                    var hcount    = data.Where(aa => aa.Risklevel == rlevel && aa.Scenario_Name == "Hazard").Count();
                    var bcount    = data.Where(aa => aa.Risklevel == rlevel && aa.Scenario_Name == "Risky Behavior").Count();
                    var gjobcount = data.Where(aa => aa.Risklevel == rlevel && aa.Scenario_Name == "Good Job").Count();

                    modelList.Add(new Models.RiskLevel()
                    {
                        Risk_Level = rlevel, Hazard_Count = hcount, Behv_Count = bcount, GoodJob_Count = gjobcount
                    });
                }
            }

            return(Json(modelList));
        }
Beispiel #2
0
 public ActionResult ViewImage(string id)
 {
     using (iobserve.Data.iobserverContext context = new iobserverContext())
     {
         var img = context.V_reportsdetails.Where(a => a.Id == id).Select(a => a.Media_picture_id).FirstOrDefault();
         return(View(new QuestionDetails {
             Image = img
         }));
     }
 }
Beispiel #3
0
 public ActionResult ObservationDetails(Models.QuestionDetails model)
 {
     using (iobserve.Data.iobserverContext context = new iobserverContext())
     {
         var data = context.Reports.Where(a => a.Id == model.Id).FirstOrDefault();
         data.Remarks = model.Comments;
         //var statusid = context.Captions.Where(a => a.Label_text == model.SelectedStatus).FirstOrDefault().Label_id;
         data.Status_label_id = model.SelectedStatus;
         context.SaveChanges();
     }
     return(RedirectToAction("Dashboard", new { @isReload = true }));
 }
Beispiel #4
0
 private void SetSession(DateTime startDate, DateTime endData)
 {
     try
     {
         using (iobserverContext context = new iobserverContext())
         {
             var data = context.V_reports.Where(a => a.Language_code == "en" && a.__createdAt >= startDate && a.__createdAt <= endData).ToList();
             // var data = context.V_reports.Where(a => a.Language_code == "en").Take(10).ToList();
             System.Web.HttpContext.Current.Session.Add("data", data);
             System.Web.HttpContext.Current.Session.Add("gridData", Load_Observations());
         }
     }
     catch (Exception e)
     {
         Trace.WriteLine(e.Message);
     }
 }
Beispiel #5
0
        //string dd = "ANSWER, PgS1_q1a5, PgS1_q1a4, PgS1_q1a1, PgS1_q1a2, PgS1_q1a3";
        public ActionResult ObservationDetails(string DetailId, string id)
        {
            var lstQ = new List <Models.Question>();
            List <Models.Labels> StatusList = new List <Labels>();


            using (iobserve.Data.iobserverContext context = new iobserverContext())
            {
                var data = System.Web.HttpContext.Current.Session["data"] as List <V_report>;
                //var response = data.Where(a => a.Id == id).FirstOrDefault();
                StatusList = (from label in context.Captions.Where(a => (a.Label_id == LabelIds.PENDING || a.Label_id == LabelIds.REVIEWED || a.Label_id == LabelIds.SUBMITTED) && a.Language_code == "en")
                              select new Models.Labels
                {
                    Label_Id = label.Label_id,
                    Label = label.Label_text
                }).ToList();
                System.Web.HttpContext.Current.Session["StatusList"] = StatusList;
                var statusToUpdate = context.Reports.Where(a => a.Id == id).FirstOrDefault();
                if (statusToUpdate.Status_label_id == LabelIds.SUBMITTED)
                {
                    statusToUpdate.Status_label_id = LabelIds.REVIEWED;
                    context.SaveChanges();
                }
                var response  = context.V_reportsdetails.Where(a => a.Id == id).FirstOrDefault();
                var questions = context.V_questions.Where(a => a.Location_scenario_id == DetailId && a.Language_code == "en").OrderBy(a => a.Seqno).ToList();

                //\q1+\a\d+
                Debug.WriteLine(response);
                Debug.WriteLine("Total questions found : " + questions.Count.ToString());
                questions.ForEach(q =>
                {
                    var question = new iobserve_Azure.Models.Question();

                    question.QuestionText = q.Question_text;
                    var qData             = q.Answer_options_text.Split(new char[] { ';' });
                    question.Type         = q.Answer_format;
                    question.SequenceNo   = q.Seqno.GetValueOrDefault();
                    int ansOptSequenceno  = 1;
                    List <Models.AnswerOptions> optList = new List <Models.AnswerOptions>();

                    qData.ToList().ForEach(ans =>
                    {
                        optList.Add(new Models.AnswerOptions
                        {
                            OptionText = ans,
                            SequenceNo = ansOptSequenceno++
                        });
                    });
                    var wno        = q.Seqno.ToString();
                    string pattern = @"q" + wno + @"a(?<AnsNo>\d+)";
                    var matches    = Regex.Matches(response.Response_array, pattern);
                    if (matches.Count == 0)
                    {
                        Debug.WriteLine("Question no : " + wno + " No match");
                    }
                    foreach (Match m in matches)
                    {
                        var ans = int.Parse(m.Groups["AnsNo"].Value);
                        Models.AnswerOptions cAnsOption = optList.Where(a => a.SequenceNo == ans).FirstOrDefault();
                        if (cAnsOption != null)
                        {
                            cAnsOption.IsSelected = true;
                            Debug.WriteLine("Question No :" + wno.ToString() + " " + "Answer No :" + ans.ToString());
                        }
                    }
                    question.AnswerOptionList = optList;
                    lstQ.Add(question);
                });
                //                [6/22/2014 6:07:52 PM] Faisal Asif: Supervisor notified?
                //Work Stopped? (I am verifying this)
                //Risk Level
                //Cutomer Information
                //Action Taken:
                //supp notified,
                //risk eliminated,
                //notes,
                //status
                return(View(new Models.QuestionDetails {
                    SupervisorNotified = response.Supnotified, RiskEliminated = "YES", Comments = response.Remarks, SelectedStatus = response.Status_text, Questions = lstQ, Image = response.Media_picture_id, Id = response.Id, RiskLevel = response.Risklevel, CustomerInfo = response.Customer, ActionTaken = response.Actiontaken
                }));
            }
        }