Esempio n. 1
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));
        }