private IEnumerable <OpenFSOGridModel> GetOpenFsoGridModelList(OapChecklist corpFSOChecklist) { IEnumerable <RigOapChecklist> checklists = GetOpenFsoChecklists(corpFSOChecklist); List <OpenFSOGridModel> modelList = new List <OpenFSOGridModel>(); foreach (var checklist in checklists) { UserModel user = ServiceSystem.GetUser(checklist.OwnerId); PositionModel position = ServiceSystem.GetUserPosition(checklist.OwnerId); OpenFSOGridModel gridModel = new OpenFSOGridModel() { Id = checklist.Id, Title = checklist.Title, ChecklistDateTime = checklist.ChecklistDateTime, RigChecklistUniqueId = checklist.RigChecklistUniqueId, Observer = user?.DisplayName, Position = position?.Name, Company = user?.Company, Location = user?.RigId }; modelList.Add(gridModel); } return(modelList); }
private IList <OIMDashboardOAPGridViewModel> GenerateChecklistViewModelList(ObservableCollection <RigOapChecklist> checklistList) { IList <OIMDashboardOAPGridViewModel> viewModelList = new List <OIMDashboardOAPGridViewModel>(); foreach (var checklist in checklistList) { var leadAssessor = checklist.Assessors?.FirstOrDefault(a => a.IsLead); UserModel assessor = null; PositionModel leadAssessorPosition = null; if (leadAssessor != null && leadAssessor.UserId != 0) { assessor = ServiceSystem.GetUser(leadAssessor.UserId); leadAssessorPosition = ServiceSystem.GetUserPosition(leadAssessor.UserId); } int nonConformityCount = 0; foreach (var question in checklist.Questions) { nonConformityCount += question.Answers.Count(a => a.Value == "N"); } var viewModel = new OIMDashboardOAPGridViewModel() { Id = checklist.RigChecklistUniqueId, ChecklistGuid = checklist.Id, Assessor = assessor?.DisplayName, Position = leadAssessorPosition?.Name, Title = checklist.Title, Date = checklist.ChecklistDateTime, Location = checklist.LocationName, NonConformity = nonConformityCount }; viewModelList.Add(viewModel); } return(viewModelList); }
private List <TrainedObserversViewModel> GetTrainedObservers(OapChecklist corpFSOChecklist) { IIrmaServiceDataModel pobDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RigPersonnel); //.RigPersonnelHistory); IEnumerable <RigPersonnelModel> currentPob = pobDataModel.GetItems("Status = 1", "Id").Cast <RigPersonnelModel>(); IEnumerable <RigOapChecklist> fsoChecklistsLast40Days = RigOapChecklistClient.GetFsoChecklistByMinDateAsync(DateTime.Now.AddDays(-40).Date, corpFSOChecklist.Id).Result?.Result?.Data; List <TrainedObserversViewModel> trainedObservers = new List <TrainedObserversViewModel>(); foreach (RigPersonnelModel person in currentPob) { UserModel userRecord = ServiceSystem.GetUser(person.PassportId); if (userRecord == null || !person.DateStart.HasValue) { continue; } PositionModel position = ServiceSystem.GetUserPosition(person.PassportId); TimeSpan timeOnBoard = DateTime.Now.Subtract(person.DateStart.Value); TrainedObserversViewModel observer = new TrainedObserversViewModel() { Name = userRecord?.DisplayName, Position = position?.Name, DaysOnboard = timeOnBoard.Days }; int numberOfObservations = 0; IEnumerable <RigOapChecklist> checklistsWhileOnboard = fsoChecklistsLast40Days.Where(c => c.ChecklistDateTime >= person.DateStart); DateTime?lastObservationDate = null; foreach (RigOapChecklist fsoChecklist in checklistsWhileOnboard) { if (fsoChecklist.Assessors == null) { continue; } IEnumerable <RigOapChecklistAssessor> checklistParticipations = fsoChecklist.Assessors.Where(a => a.UserId == userRecord.Id); numberOfObservations += checklistParticipations.Count(); if (checklistParticipations.Count() > 0 && (lastObservationDate == null || fsoChecklist.ChecklistDateTime > lastObservationDate)) { lastObservationDate = fsoChecklist.ChecklistDateTime; } } observer.LastObservation = lastObservationDate; int weeksOnBoard = timeOnBoard.Days / 7; bool isInCompliance = true; if (timeOnBoard.Days > 7) { isInCompliance = numberOfObservations > 0 ? (numberOfObservations / weeksOnBoard >= 1) : false; } observer.Observations = numberOfObservations; observer.IsInCompliance = isInCompliance; trainedObservers.Add(observer); } return(trainedObservers); }
public ActionResult BACPendingReviewPartial() { ViewBag.GridName = "BACPendingGrid"; ViewBag.GridTitle = "Barrier Authority Checklists Pending Review"; ViewBag.GridLinkController = "BarrierAuthority"; var bacList = RigOapChecklistClient.GetAllByTypeStatusAsync("Barrier Authority Checklist", "Pending").Result?.Result.Data; IList <OIMDashboardBACGridViewModel> viewModelList = new List <OIMDashboardBACGridViewModel>(); foreach (var bacChecklist in bacList) { var leadAssessor = bacChecklist.Assessors.FirstOrDefault(a => a.IsLead); UserModel assessor = null; PositionModel leadAssessorPosition = null; if (leadAssessor != null && leadAssessor.UserId != 0) { assessor = ServiceSystem.GetUser(leadAssessor.UserId); leadAssessorPosition = ServiceSystem.GetUserPosition(leadAssessor.UserId); } OIMDashboardBACGridViewModel viewModel = new OIMDashboardBACGridViewModel() { ChecklistGuid = bacChecklist.Id, Id = bacChecklist.RigChecklistUniqueId, Location = bacChecklist.LocationName, Title = bacChecklist.Title, Assessor = assessor?.DisplayName, Position = leadAssessorPosition?.Name }; foreach (var question in bacChecklist.Questions) { foreach (var answer in question.Answers) { if (answer.Value == "N") { switch (answer.Ordinal) { case 0: viewModel.Day1.ConformityCount++; break; case 1: viewModel.Day2.ConformityCount++; break; case 2: viewModel.Day3.ConformityCount++; break; case 3: viewModel.Day4.ConformityCount++; break; case 4: viewModel.Day5.ConformityCount++; break; case 5: viewModel.Day6.ConformityCount++; break; case 6: viewModel.Day7.ConformityCount++; break; default: break; } } } } viewModelList.Add(viewModel); } return(PartialView("BarrierAuthorityPendingReviewPartial", viewModelList)); }