示例#1
0
        public ActionResult GetDriverLogs(int id)
        {
            SingleBatchViewModel _model = new SingleBatchViewModel();

            using (RDATContext context = new RDATContext())
            {
                // List<TestingLog> _logs = context.TestingLogs.Where(tl => tl.Batch_Id == BatchId).ToList();
                List <BatchCompanyModel> _logs = (from tl in context.TestingLogs
                                                  join c in context.Companys on tl.Company_Id equals c.Id
                                                  join b in context.Batches on tl.Batch_Id equals b.Id
                                                  select new BatchCompanyModel()
                {
                    Id = tl.Id,
                    Driver_Id = tl.Driver_Id,
                    Driver_Name = tl.Driver_Name,
                    Company_Id = tl.Company_Id,
                    Company_Name = c.Name,
                    Reported_Results = tl.Reported_Results,
                    ResultsDate = tl.ResultsDate,
                    Batch_Id = tl.Batch_Id,
                    BatchDate = b.RunDate,
                    ClosedDate = tl.ClosedDate,
                    Test_Type = tl.Test_Type
                }).Where(tl => tl.Driver_Id == id).ToList();

                foreach (BatchCompanyModel l in _logs)
                {
                    l.Reported_Results = l.Reported_Results == "1" ? "Positive" : l.Reported_Results == "2" ? "Negative" : l.Reported_Results == "3" ? "Excused" : " ";
                }

                _model.TestingLogs = _logs;
            }

            return(View(_model));
        }
        private void GetIssuesForViewModel(SingleBatchViewModel singleBatchViewModel)
        {
            singleBatchViewModel.QualityIssues = singleBatchViewModel.Report.BatchIssues
                                                 .Where(x => IsAQualityIssues(x.FaultType) && x.RemoveIssue == false)
                                                 .ToList();

            singleBatchViewModel.TimeIssues = singleBatchViewModel.Report.BatchIssues
                                              .Where(x => IsATimeIssue(x.FaultType) && x.RemoveIssue == false)
                                              .OrderByDescending(x => x.TimeLost)
                                              .ToList();

            singleBatchViewModel.MatVarIssues = singleBatchViewModel.Report.BatchIssues
                                                .Where(x => IsAMatVarIssue(x.FaultType) && x.RemoveIssue == false)
                                                .OrderByDescending(x => x.PercentOut)
                                                .ToList();
        }
        public IActionResult ViewSingleBatchByNumber(string batchNum, int year)
        {
            SingleBatchViewModel singleBatchViewModel = new SingleBatchViewModel
            {
                Report = _BatchRepository.GetBatchByBatchNumber(batchNum, year)
            };

            singleBatchViewModel.RecipeViscoLimits = _recipeLimitRepository.GetLimitInfo(singleBatchViewModel.Report.RecipeType, LimitType.Visco);
            singleBatchViewModel.BatchTimeLimits   = _recipeLimitRepository.GetLimitInfo(singleBatchViewModel.Report.RecipeType, LimitType.MakeTime);

            foreach (var vessel in singleBatchViewModel.Report.AllVessels)
            {
                foreach (var material in vessel.Materials)
                {
                    vessel.Materials = vessel.Materials.OrderBy(m => m.StartTime).ToList();
                }
            }

            GetIssuesForViewModel(singleBatchViewModel);
            return(View("ViewSingleBatch", singleBatchViewModel));
        }
        public IActionResult ViewSingleBatch(int batchId)
        {
            BatchReport report = _BatchRepository.GetBatchById(batchId);

            SingleBatchViewModel singleBatchViewModel = new SingleBatchViewModel
            {
                Report = report
            };

            singleBatchViewModel.RecipeViscoLimits = _recipeLimitRepository.GetLimitInfo(report.RecipeType, LimitType.Visco);
            singleBatchViewModel.BatchTimeLimits   = _recipeLimitRepository.GetLimitInfo(report.RecipeType, LimitType.MakeTime);
            GetIssuesForViewModel(singleBatchViewModel);
            singleBatchViewModel.TotalTimeLost      = singleBatchViewModel.TimeIssues.Select(x => x.TimeLost).Sum();
            singleBatchViewModel.TotalMatvarIssues  = singleBatchViewModel.MatVarIssues.Count();
            singleBatchViewModel.TotalQualityIssues = singleBatchViewModel.QualityIssues.Count();

            foreach (var vessel in singleBatchViewModel.Report.AllVessels)
            {
                vessel.Materials = vessel.Materials.OrderBy(m => m.StartTime.Date).ThenBy(x => x.StartTime.TimeOfDay).ToList();
            }
            return(View(singleBatchViewModel));
        }
示例#5
0
        public IActionResult Outstanding(string type)
        {
            SingleBatchViewModel _model = new SingleBatchViewModel();

            ViewBag.type = type;
            using (RDATContext context = new RDATContext())
            {
                List <BatchCompanyModel> _logs = new List <BatchCompanyModel>();

                //List<Company> _co = context.Companys.ToList();

                //List<TestingLog> testingLogs = context.TestingLogs.Where(tl => tl.Test_Type == type && Convert.ToInt32(tl.Reported_Results) < 1).ToList();

                _logs = (from tl in context.TestingLogs
                         join c in context.Companys on tl.Company_Id equals c.Id
                         join b in context.Batches on tl.Batch_Id equals b.Id
                         select new BatchCompanyModel()
                {
                    Id = tl.Id,
                    Driver_Id = tl.Driver_Id,
                    Driver_Name = tl.Driver_Name,
                    Company_Id = tl.Company_Id,
                    Company_Name = c.Name,
                    Reported_Results = tl.Reported_Results,
                    ResultsDate = tl.ResultsDate,
                    ClosedDate = tl.ClosedDate,
                    Batch_Id = tl.Batch_Id,
                    BatchDate = b.RunDate,
                    Test_Type = tl.Test_Type
                }).Where(tl => tl.Test_Type == type && Convert.ToInt32(tl.Reported_Results) < 1).ToList();


                //_logs = testingLogs.Join(_co,
                //                            d => d.Company_Id,
                //                            co => co.Id,
                //                            (log, company) => new BatchCompanyModel
                //                            {
                //                                // Id = ,
                //                                Driver_Id = log.Driver_Id,
                //                                Driver_Name = log.Driver_Name,
                //                                Company_Id = log.Company_Id,
                //                                Company_Name = company.Name,
                //                                Reported_Results = log.Reported_Results,
                //                                ResultsDate = log.ResultsDate,
                //                                Batch_Id = log.Batch_Id,
                //                                // BatchDate = ,
                //                                Test_Type = log.Test_Type
                //                            }).ToList();



                foreach (BatchCompanyModel l in _logs)
                {
                    l.Reported_Results = l.Reported_Results == "1" ? "Positive" : l.Reported_Results == "2" ? "Negative" : l.Reported_Results == "3" ? "Excused" : " ";
                }

                _model.TestingLogs = _logs.OrderBy(o => o.Driver_Name).ToList();
            }

            return(View(_model));
        }