示例#1
0
        public ActionResult RigAdminUserRoleAdd(AdminModel model)
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            if (ModelState.IsValid)
            {
                LookupListModel <dynamic> lkpList = UtilitySystem.GetLookupList("Position");

                UserModel user = ServiceSystem.GetUser(model.Passport);
                model.Name   = user.DisplayName;
                model.UserId = user.Passport;
                model.dt     = DateTime.Now;
                DataTable dt = this.GetIaType();
                if (model.Position == null || dt.Select("Name='" + model.Position + "'").Length == 0)
                {
                    model.Position = (string)lkpList.GetDisplayValue(user.Position);
                }

                IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Admin);
                AdminModel            item      = dataModel.GetItem(string.Format("UserId=\"{0}\" and RoleId={1} and Position=\"{2}\" ", model.UserId, model.RoleId, model.Position), "id");
                if (item == null)
                {
                    model = IrmaServiceSystem.Add(IrmaConstants.IrmaPobModels.Admin, model, true);
                }
            }

            return(PartialView("RigAdminUserRolePartial", manageRigModel.AdminUsers));
        }
示例#2
0
        public ActionResult ApprovalProcessApproval(int Id, int ApprovalId, int Approver, int Status, string Comment)
        {
            string                comment       = (Comment == "null") ? "" : Comment; // DevExpress sending the 'null' string when textbox is empty
            LessonLearnedModel    lessonLearned = (LessonLearnedModel)Session["LessonLearnedModel"];
            IIrmaServiceDataModel serviceSystem = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);
            ApprovalModel         approval      = serviceSystem.GetItem(string.Format("Id={0}", ApprovalId), "Id");

            approval.ApprovedDate     = DateTime.Now;
            approval.ApproverComments = Comment;
            approval.Status           = Status;
            lessonLearned.Approvals.FirstOrDefault(a => a.Id == ApprovalId).Status = Status;
            switch (Status)
            {
            case (int)IrmaConstants.ApprovalStatus.Approved:
                var approvedCount = lessonLearned.GetApprovals().Where(a => a.Status == (int)IrmaConstants.ApprovalStatus.Approved).Count();
                var totalCount    = lessonLearned.GetApprovals().Count();
                if (approvedCount == totalCount)     // Proceeds with the workflow / auto close
                {
                    lessonLearned.Status = "Closed";
                }
                break;

            case (int)IrmaConstants.ApprovalStatus.Rejected:
                lessonLearned.Status      = "Rejected";
                approval.ApproverComments = Comment;
                break;
            }
            dataModel = OAPServiceSystem.GetServiceModel(OAPServiceSystem.OAPDataModelType.LessonLearned);
            dataModel.Update(lessonLearned);
            serviceSystem.Update(approval);

            return(RedirectToAction("Edit", new { Id = Id }));
        }
示例#3
0
        public ActionResult PobSummaryReport()
        {
            PobSummaryReport report = new PobSummaryReport();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = HttpContext.Server.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = HttpContext.Server.MapPath("~/Images/irma.png");

            // Show/Hide Essential and Vantage
            IIrmaServiceDataModel   reqModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RigFieldVisible);
            RigFieldVisibilityModel req      = (RigFieldVisibilityModel)reqModel.GetItem(string.Format("Id=1"), "Id");

            report.ShowVantage.Value = (req != null) ? req.Visible : true;
            req = (RigFieldVisibilityModel)reqModel.GetItem(string.Format("Id=3"), "Id");
            report.ShowEssential.Value = (req != null) ? req.Visible : true;

            List <PobSummaryReportModel> list = new List <PobSummaryReportModel>();

            list.Add(IrmaServiceSystem.GetSummaryReportData());

            report.DataSource = list;

            Session["currentReport"] = report;

            return(RedirectToAction("ShowReport", "Report"));
        }
示例#4
0
        public ActionResult PersonnelArchivePartial()
        {
            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RigPersonnelArchive);
            DataTableModel        model     = new DataTableModel(1, dataModel.GetQueryable("Id"));

            return(PartialView("PersonnelArchivePartial", model));
        }
示例#5
0
        // GET: IRMA/Report

        public ActionResult RosterSignInByMusterStationReport()
        {
            RosterSignInByMusterStation report = new RosterSignInByMusterStation();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = HttpContext.Server.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = HttpContext.Server.MapPath("~/Images/irma.png");

            IIrmaServiceDataModel  dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RosterByMusterStation);
            List <RosterUserModel> list      = dataModel.GetAllItems().Cast <RosterUserModel>().ToList();

            report.DataSource = list;

            Session["currentReport"] = report;

            //PopupModel popupModel = new PopupModel();
            //popupModel.Name = "RosterSignInByMusterStationReport";
            //popupModel.Title = "Roster SignIn By Muster Station";
            //popupModel.AllowResize = true;
            //popupModel.MaximizeBox = true;
            //popupModel.ContentUrl = Url.Action("ShowReportPartial", "Report", new { Area = "IRMA" });
            //popupModel.Data = report;
            //Session["PopupModel"] = popupModel;

            //return RedirectToAction("EnscoPopup", "Common", new { Area = "Common" });

            return(RedirectToAction("ShowReport", "Report"));
        }
示例#6
0
        public ActionResult EmergencyTeams()
        {
            EmergencyTeamReport report = new EmergencyTeamReport();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = HttpContext.Server.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = HttpContext.Server.MapPath("~/Images/irma.png");

            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.EmergencyTeamReportView);

            List <dynamic> list = dataModel.GetAllItems();

            string yesUrl = HttpContext.Server.MapPath("~/Images/Yes.png");
            string noUrl  = HttpContext.Server.MapPath("~/Images/No.png");

            foreach (EmergencyTeamReportModel item in list)
            {
                item.ImageUrlNo  = System.IO.File.ReadAllBytes(HttpContext.Server.MapPath("~/Images/No.png"));
                item.ImageUrlYes = System.IO.File.ReadAllBytes(HttpContext.Server.MapPath("~/Images/Yes.png"));
            }
            report.DataSource = list;

            Session["currentReport"] = report;

            return(RedirectToAction("ShowReport", "Report"));
        }
示例#7
0
        public ActionResult RigAdminUserRolePartial()
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.AdminView);

            manageRigModel.AdminUsers = new DataTableModel(1, dataModel.GetQueryable("id"));
            this.ViewBag.IaType       = this.GetIaType();
            return(PartialView("RigAdminUserRolePartial", manageRigModel.AdminUsers));
        }
示例#8
0
        public ActionResult RigAdminIsolationLockPartial()
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.IsolationLock);

            manageRigModel.IsolationLocks = new DataTableModel(1, dataModel.GetQueryable("id"));

            return(PartialView("RigAdminIsolationLockPartial", manageRigModel.IsolationLocks));
        }
示例#9
0
        public ActionResult EmailReport()
        {
            DevExpress.XtraReports.UI.XtraReport currentReport = (DevExpress.XtraReports.UI.XtraReport)Session["currentReport"];

            IIrmaServiceDataModel emailDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Emails);
            PobEmailModel         emailModel     = emailDataModel.GetItem(string.Format("Name=\"PobSummaryReport\""), "Name");

            char[]            sep          = { ';' };
            string[]          recipients   = (emailModel != null && emailModel.Recipients != null) ? emailModel.Recipients.Split(sep) : null;
            IServiceDataModel pobDataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.User);

            try
            {
                using (SmtpClient client = new SmtpClient("smtp.ensco.ws"))
                {
                    MemoryStream memStream = new MemoryStream();
                    currentReport.ExportToPdf(memStream);

                    memStream.Seek(0, System.IO.SeekOrigin.Begin);
                    Attachment att = new Attachment(memStream, "PobSummayReport.pdf", "application/pdf");

                    MailMessage message = new MailMessage();
                    message.Attachments.Add(att);
                    message.From    = new MailAddress("*****@*****.**");
                    message.Subject = emailModel.Subject;

                    // Get recepients
                    foreach (string id in recipients)
                    {
                        UserModel user = pobDataModel.GetItem(string.Format("Id={0}", id), "Id");
                        if (user != null && user.Email != null)
                        {
                            message.To.Add(new MailAddress(user.Email));
                        }
                    }

                    // This line can be used to embed HTML into the email itself
                    // MailMessage message = currentReport.ExportToMail("*****@*****.**", emailModel.Recipients, emailModel.Subject);

                    // Get correct credentials for irma profile
                    client.Credentials = new System.Net.NetworkCredential("Ensco\\023627", "");
                    client.Send(message);

                    memStream.Close();
                    memStream.Flush();
                }
            }
            catch (Exception ex)
            {
            }

            return(View("ShowReportPartial", currentReport));
        }
示例#10
0
        public ActionResult LessonsLearnedPreApprovalReviewDeletePartial(int Id)
        {
            IIrmaServiceDataModel serviceSystem = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);
            var approver = (ApprovalModel)serviceSystem.GetItem(string.Format("Id={0}", Id), "Id");

            if (approver != null)
            {
                serviceSystem.Delete(approver);
                var lessonLearnedModel = (LessonLearnedModel)Session["LessonLearnedModel"];
                lessonLearnedModel.Approvals.RemoveAll(o => o.Id == approver.Id);
            }
            return(LessonsLearnedPreApprovalReviewPartial());
        }
示例#11
0
        public ActionResult RigAdminFieldsVisiblePartial()
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            manageRigModel.SelectedPersonnelRigId = UtilitySystem.Settings.RigId;
            IIrmaServiceDataModel rigReqs = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RigFieldVisible);

            if (rigReqs != null)
            {
                manageRigModel.FieldsVisible = rigReqs.GetAllItems();
            }

            return(PartialView("RigAdminFieldsVisiblePartial", manageRigModel));
        }
示例#12
0
        public static void AddApprover(ApprovalModel approvalModel, LessonLearnedModel lessonLearned)
        {
            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);
            var approver = ServiceSystem.GetUser((int)approvalModel.Approver);

            approvalModel.Type          = (int)ApprovalModel.ApprovalType.LessonsLearnedApproval;
            approvalModel.RequestItemId = lessonLearned.Id;
            approvalModel.Name          = lessonLearned.Title;
            approvalModel.Requester     = UtilitySystem.CurrentUserId;
            approvalModel.RequestedDate = DateTime.Now;
            approvalModel.Position      = (int)approver.Position;

            approvalModel = dataModel.Add(approvalModel);
            lessonLearned.Approvals.Add(approvalModel);
        }
示例#13
0
        public ActionResult RosterSignInReport()
        {
            RosterSignInSheet report = new RosterSignInSheet();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = HttpContext.Server.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = HttpContext.Server.MapPath("~/Images/irma.png");

            IIrmaServiceDataModel  dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RosterFull);
            List <RosterUserModel> list      = dataModel.GetAllItems().Cast <RosterUserModel>().ToList();

            report.DataSource        = list;
            Session["currentReport"] = report;

            return(RedirectToAction("ShowReport", "Report"));
        }
示例#14
0
        public ActionResult RigAdminIsolationLockDelete(LockModel model)
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            if (ModelState.IsValid)
            {
                IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.IsolationLock);
                LockModel             entity    = dataModel.GetItem(string.Format("id={0}", model.id), "id");
                if (entity != null)
                {
                    bool bResult = dataModel.Delete(entity);
                }
            }

            return(PartialView("RigAdminIsolationLockPartial", manageRigModel.IsolationLocks));
        }
示例#15
0
        public ActionResult CrewArrivalDepartureLogReport(int Id)
        {
            PobArrivalDepartureLogReport report = new PobArrivalDepartureLogReport();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = HttpContext.Server.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = HttpContext.Server.MapPath("~/Images/irma.png");

            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.CrewArrivalDepartureLog);

            report.DataSource = dataModel.GetItems(string.Format("CrewChangeId={0}", Id), "Id");

            Session["currentReport"] = report;

            return(RedirectToAction("ShowReport", "Report"));
        }
示例#16
0
        public ActionResult RoomBedSummaryReport()
        {
            RoomBedSummaryReport report = new RoomBedSummaryReport();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = HttpContext.Server.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = HttpContext.Server.MapPath("~/Images/irma.png");

            IIrmaServiceDataModel dataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RoomBedSummary);

            report.DataSource = dataModel.GetAllItems();

            Session["currentReport"] = report;

            return(RedirectToAction("ShowReport", "Report"));
        }
示例#17
0
        public static IIrmaServiceDataModel GetServiceModel(JobConstants.Models modelType)
        {
            IIrmaServiceDataModel service = null;

            switch (modelType)
            {
            case JobConstants.Models.JobSummary:
                service = new IrmaServiceDataModel <JobSummaryModel, JOB_SummaryView>();
                break;

            case JobConstants.Models.Permits:
                service = new IrmaServiceDataModel <PermitModel, JOB_PermitView>();
                break;
            }

            return(service);
        }
示例#18
0
        public ActionResult RigAdminListsPartial()
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            IIrmaServiceDataModel emailDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Emails);
            PobEmailModel         pobEmail       = emailDataModel.GetItem(string.Format("Name=\"PobSummaryReport\""), "Name");
            PobEmailModel         dailyEmail     = emailDataModel.GetItem(string.Format("Name=\"DailySummaryReport\""), "Name");

            char[] sep = { ';' };
            manageRigModel.MaxPOB                = IrmaServiceSystem.GetMaxPOB();
            manageRigModel.DateFormat            = UtilitySystem.Settings.ConfigSettings["DateFormat"];
            manageRigModel.DateTimeFormat        = UtilitySystem.Settings.ConfigSettings["DateTimeFormat"];
            manageRigModel.PobSummaryEmailList   = (pobEmail != null && pobEmail.Recipients != null) ? pobEmail.Recipients.Split(sep) : null;
            manageRigModel.DailySummaryEmailList = (dailyEmail != null && dailyEmail.Recipients != null) ? dailyEmail.Recipients.Split(sep) : null;

            // Phase 1 Parameters
            string val = IrmaServiceSystem.GetAdminCustomValue("EmailTime");

            manageRigModel.EmailTime = (val != null) ? DateTime.Parse(val) : DateTime.Now;

            val = IrmaServiceSystem.GetAdminCustomValue("Brazil");
            manageRigModel.IsRigInBrazil = (val != null && val == "1") ? true : false;
            val = IrmaServiceSystem.GetAdminCustomValue("RequireClientSignature");
            manageRigModel.ChooseClientSignAtTimeOfPermit = (val != null && val == "1") ? true : false;
            val = IrmaServiceSystem.GetAdminCustomValue("ClientHotWork");
            manageRigModel.IsClientRequireSignHotWorkPermit = (val != null && val == "1") ? true : false;
            val = IrmaServiceSystem.GetAdminCustomValue("ClientColdWork");
            manageRigModel.IsClientRequireSignColdWorkPermit = (val != null && val == "1") ? true : false;
            val = IrmaServiceSystem.GetAdminCustomValue("ClientConfinedSpace");
            manageRigModel.IsClientRequireSignConfinedWorkPermit = (val != null && val == "1") ? true : false;
            val = IrmaServiceSystem.GetAdminCustomValue("OIM");
            UserModel userOIM = ServiceSystem.GetUserFromPassport(val.Trim());

            manageRigModel.CurrentOIM = userOIM.Id;
            val = IrmaServiceSystem.GetAdminCustomValue("Master");
            UserModel userMaster = ServiceSystem.GetUserFromPassport(val.Trim());

            if (userMaster != null)
            {
                manageRigModel.CurrentMaster = userMaster.Id;
            }

            Session["manageRigModel"] = manageRigModel;
            return(PartialView("RigAdminListsPartial", manageRigModel));
        }
示例#19
0
        static public JobsHomeModel GetJobsHomeModel()
        {
            JobsHomeModel model = new JobsHomeModel();

            // Permits summary
            IIrmaServiceDataModel summaryModel = GetServiceModel(JobConstants.Models.JobSummary);
            JobSummaryModel       item         = (JobSummaryModel)summaryModel.GetItem("", "Id");

            model.Summary = new List <JobSummaryModel>();
            model.Summary.Add(item);

            // Permits
            IIrmaServiceDataModel permitsModel = GetServiceModel(JobConstants.Models.Permits);

            model.Permits = new DataTableModel(1, permitsModel.GetQueryable("Id"));

            return(model);
        }
示例#20
0
        public ActionResult RigAdminFieldsVisibleUpdate(RigFieldVisibilityModel model)
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            if (ModelState.IsValid)
            {
                IIrmaServiceDataModel   rigReqs     = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RigFieldVisible);
                RigFieldVisibilityModel entityModel = rigReqs.GetItem(string.Format("Id={0}", model.Id), "Id");
                if (entityModel != null)
                {
                    entityModel.Visible = model.Visible;
                    entityModel.Name    = model.Name;
                    rigReqs.Update(entityModel);
                    manageRigModel.FieldsVisible = rigReqs.GetAllItems();
                }
            }

            return(PartialView("RigAdminFieldsVisiblePartial", manageRigModel));
        }
示例#21
0
        public ActionResult CapBookApprovalStatusUpdate(int Id, int ApprovalId, int Approver, int Status)
        {
            ManageCapBookModel model = (ManageCapBookModel)Session["ManageCapBookModel"];

            IIrmaServiceDataModel statusDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);
            ApprovalModel         approval        = statusDataModel.GetItem(string.Format("Id={0}", ApprovalId), "Id");

            if (approval != null)
            {
                approval.Status = Status;
                if (Status != 2)
                {
                    approval.ApprovedDate = DateTime.Now;
                }
                statusDataModel.Update(approval);
            }

            return(View("CapBookApproval", model));
        }
示例#22
0
        static public LookupListModel <dynamic> GetLookupList(JobConstants.LookupLists type)
        {
            IIrmaServiceDataModel     dataModel = null;
            LookupListModel <dynamic> model     = new LookupListModel <dynamic>();

            model.Name = type.ToString();
            string filter = null;

            switch (type)
            {
            }

            if (dataModel != null)
            {
                model.Items = (filter != null) ? dataModel.GetItems(filter, "Id") : dataModel.GetAllItems();
            }

            model.Initialize();

            return(model);
        }
示例#23
0
        public ActionResult CapBookApprovalDetailUpdate(ApprovalModel approval)
        {
            ManageCapBookModel model = (ManageCapBookModel)Session["ManageCapBookModel"];

            if (ModelState.IsValid)
            {
                IIrmaServiceDataModel approvalModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);
                ApprovalModel         entity        = approvalModel.GetItem(string.Format("Id={0}", approval.Id), "Id");
                if (entity != null)
                {
                    entity.ApproverComments = approval.ApproverComments;
                    approvalModel.Update(entity);
                    int index = model.Approvals.FindIndex(x => x.Id == approval.Id);
                    if (index >= 0 && index < model.Approvals.Count)
                    {
                        model.Approvals[index].ApproverComments = approval.ApproverComments;
                    }
                }
            }

            return(PartialView("CapBookApprovalDetailPartial", model));
        }
示例#24
0
        public static LessonLearnedModel GetLessonLearned(int id)
        {
            var dataModel = GetServiceModel(OAPDataModelType.LessonLearned);
            LessonLearnedModel lessonLearned = dataModel.GetItem(string.Format("Id={0}", id), "Id");

            IIrmaServiceDataModel approvalDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Approval);

            var approvals = approvalDataModel.GetItems(
                string.Format("RequestItemId={0}", lessonLearned.Id), "Id").Cast <ApprovalModel>().ToList();

            foreach (var approver in approvals)
            {
                var user = ServiceSystem.GetUser((int)approver.Approver);
                approver.Position = (int)user.Position;
                approver.Initialize();
            }
            lessonLearned.Approvals = approvals;

            dataModel = OAPServiceSystem.GetServiceModel(OAPDataModelType.LessonLearnedType);
            LessonLearnedType lessonType = (LessonLearnedType)dataModel.GetItem(string.Format("Id={0}", lessonLearned.TypeId), "Id");

            lessonLearned.Type = lessonType;

            lessonLearned.Attachments = ServiceSystem.GetAttachments("Lessons Learned", lessonLearned.Id.ToString());

            dataModel = GetServiceModel(OAPDataModelType.LessonLearnedOriginator);
            var originators = dataModel.GetItems(string.Format("LessonId={0}", lessonLearned.Id), "Id").Cast <LessonLearnedOriginatorModel>().ToList();

            foreach (var originator in originators)
            {
                var user = ServiceSystem.GetUser(originator.PassportId);
                originator.Position = (int)user.Position;
            }
            lessonLearned.Originators = originators;

            return(lessonLearned);
        }
        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);
        }
示例#26
0
        public ActionResult RigAdminListsPartial(RigAdminManageModel model)
        {
            RigAdminManageModel manageRigModel = (RigAdminManageModel)Session["manageRigModel"];

            if (ModelState.IsValid)
            {
                IrmaServiceSystem.SaveMaxPOB(model.MaxPOB);
                //UtilitySystem.Settings.ConfigSettings["DateFormat"] = model.DateFormat;
                //UtilitySystem.Settings.ConfigSettings["DateTimeFormat"] = model.DateTimeFormat;
                //UtilitySystem.SaveConfigSettings();
                IrmaServiceSystem.UpdateAdminCustomValue("DateFormat", model.DateFormat);
                IrmaServiceSystem.UpdateAdminCustomValue("DateTimeFormat", model.DateTimeFormat);
                UtilitySystem.Settings.ConfigSettings["DateFormat"]     = model.DateFormat;
                UtilitySystem.Settings.ConfigSettings["DateTimeFormat"] = model.DateTimeFormat;

                IIrmaServiceDataModel emailDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Emails);
                PobEmailModel         emailModel     = emailDataModel.GetItem(string.Format("Name=\"PobSummaryReport\""), "Name");
                emailModel.Recipients = (model.PobSummaryEmailList != null) ? string.Join(";", model.PobSummaryEmailList) : null;
                emailDataModel.Update(emailModel);

                emailModel            = emailDataModel.GetItem(string.Format("Name=\"DailySummaryReport\""), "Name");
                emailModel.Recipients = (model.DailySummaryEmailList != null) ? string.Join(";", model.DailySummaryEmailList) : null;
                emailDataModel.Update(emailModel);

                string dailyEmails = "";
                if (model.DailySummaryEmailList != null)
                {
                    char[] sep = { ';' };
                    foreach (string sid in model.DailySummaryEmailList)
                    {
                        int id = 0;
                        if (!int.TryParse(sid, out id))
                        {
                            continue;
                        }

                        UserModel user = ServiceSystem.GetUser(id);
                        if (user != null && user.Email != null && user.Email.Length > 0)
                        {
                            dailyEmails += user.Email + ";";
                        }
                    }
                    dailyEmails = dailyEmails.Trim(sep);
                }

                UserModel userOIM    = ServiceSystem.GetUser(model.CurrentOIM);
                UserModel userMaster = ServiceSystem.GetUser(model.CurrentMaster);

                // Phase 1 parameters
                IrmaServiceSystem.UpdateAdminCustomValue("EmailTime", model.EmailTime.ToString("HH:mm"));

                IrmaServiceSystem.UpdateAdminCustomValue("Brazil", string.Format("{0}", model.IsRigInBrazil ? "1" : "0"));
                IrmaServiceSystem.UpdateAdminCustomValue("RequireClientSignature", string.Format("{0}", model.ChooseClientSignAtTimeOfPermit ? "1" : "0"));
                IrmaServiceSystem.UpdateAdminCustomValue("ClientHotWork", string.Format("{0}", model.IsClientRequireSignHotWorkPermit ? "1" : "0"));
                IrmaServiceSystem.UpdateAdminCustomValue("ClientColdWork", string.Format("{0}", model.IsClientRequireSignColdWorkPermit ? "1" : "0"));
                IrmaServiceSystem.UpdateAdminCustomValue("ClientConfinedSpace", string.Format("{0}", model.IsClientRequireSignConfinedWorkPermit ? "1" : "0"));
                IrmaServiceSystem.UpdateAdminCustomValue("DailySummaryEmails", dailyEmails);
                if (userOIM != null)
                {
                    IrmaServiceSystem.UpdateAdminCustomValue("OIM", userOIM.Passport);
                    IrmaServiceSystem.UpdateAdminCustomValue("OIMName", userOIM.DisplayName);
                }
                if (userMaster != null)
                {
                    IrmaServiceSystem.UpdateAdminCustomValue("Master", userMaster.Passport);
                    IrmaServiceSystem.UpdateAdminCustomValue("MasterName", userMaster.DisplayName);
                }

                manageRigModel = model;
            }
            ControllerContext.HttpContext.Response.Redirect("RigRequirements");
            ViewBag.Flag = "Save";
            return(null);

            return(PartialView("RigAdminListsPartial", manageRigModel));
        }
示例#27
0
        public static void ProcessPobSummaryEmailJob(ScheduleJobModel job)
        {
            Logger.Info(new LogInfo(MethodBase.GetCurrentMethod(), string.Format("Processing jobId={0}", job.Id)));

            PobSummaryReport report = new PobSummaryReport();

            report.RigName.Value  = Ensco.Utilities.UtilitySystem.Settings.RigName;
            report.LogoFile.Value = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/ensco.png");
            report.IrmaFile.Value = System.Web.Hosting.HostingEnvironment.MapPath("~/Images/irma.png");

            // Show/Hide Essential and Vantage
            IIrmaServiceDataModel   reqModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.RigFieldVisible);
            RigFieldVisibilityModel req      = (RigFieldVisibilityModel)reqModel.GetItem(string.Format("Id=1"), "Id");

            report.ShowVantage.Value = (req != null) ? req.Visible : true;
            req = (RigFieldVisibilityModel)reqModel.GetItem(string.Format("Id=3"), "Id");
            report.ShowEssential.Value = (req != null) ? req.Visible : true;

            List <PobSummaryReportModel> list = new List <PobSummaryReportModel>();

            list.Add(IrmaServiceSystem.GetSummaryReportData());

            report.DataSource = list;

            IIrmaServiceDataModel emailDataModel = IrmaServiceSystem.GetServiceModel(IrmaConstants.IrmaPobModels.Emails);
            PobEmailModel         emailModel     = emailDataModel.GetItem(string.Format("Name=\"PobSummaryReport\""), "Name");

            char[]            sep          = { ';' };
            string[]          recipients   = (emailModel != null && emailModel.Recipients != null) ? emailModel.Recipients.Split(sep) : null;
            IServiceDataModel pobDataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.User);

            try
            {
                using (SmtpClient client = new SmtpClient("smtp.ensco.ws"))
                {
                    MemoryStream memStream = new MemoryStream();
                    report.ExportToPdf(memStream);

                    memStream.Seek(0, System.IO.SeekOrigin.Begin);
                    Attachment att = new Attachment(memStream, "PobSummayReport.pdf", "application/pdf");

                    MailMessage message = new MailMessage();
                    message.Attachments.Add(att);
                    message.From    = new MailAddress("*****@*****.**");
                    message.Subject = emailModel.Subject;

                    // Get recepients
                    foreach (string id in recipients)
                    {
                        UserModel user = pobDataModel.GetItem(string.Format("Id={0}", id), "Id");
                        if (user != null && user.Email != null)
                        {
                            message.To.Add(new MailAddress(user.Email));
                        }
                    }

                    // This line can be used to embed HTML into the email itself
                    // MailMessage message = currentReport.ExportToMail("*****@*****.**", emailModel.Recipients, emailModel.Subject);

                    // Get correct credentials for irma profile
                    client.Credentials = new System.Net.NetworkCredential("Ensco\\023627", "");
                    client.Send(message);

                    memStream.Close();
                    memStream.Flush();
                }
            }
            catch (Exception ex)
            {
            }
        }