public ActionResult SubmitResponse(string[] arr) { IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.Attachment); IrmaCapaModel m = this.GetModel(this.CapaId); m.DateCompleted = DateTime.Parse(arr[0]); m.WO = arr[1]; m.CompletionDescription = arr[2]; ServiceSystem.Save(EnscoConstants.EntityModel.IrmaCapa, m, true); // if(arr != null) for (int i = 3; i < arr.Length; i++) { AttachmentModel attachment = dataModel.GetItem(string.Format("FilePath =\"{0}\"", HttpUtility.UrlDecode(arr[i])), "Id"); if (attachment != null) { dataModel.Delete(attachment); } } // this.UpdateAttachment(this.CapaId); //this.UpdateAttachment(0); return(RedirectToAction("Index/" + this.CapaId.ToString())); return(null); }
public static AuthenticationResult ResetPassword(int id) { AuthenticationResult result = new AuthenticationResult(); IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.User); UserModel model = dataModel.GetItem(string.Format("Id={0}", id), "Id"); if (model == null) { return(new AuthenticationResult("User not found in the system")); } model.Password = Cryptography.Encrypt(model.Passport, "123"); model.RequirePasswordChange = true; bool bSaved = ServiceSystem.Save(EnscoConstants.EntityModel.User, model, true); if (bSaved) { result = new AuthenticationResult(); } else { result = new AuthenticationResult("Internal Error. Failed to save password"); } return(result); }
public ActionResult SubmitForVerification(int id) { IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.IrmaCapaPlan); IrmaCapaPlanModel m = new IrmaCapaPlanModel(); m = dataModel.GetItem("Id=" + id.ToString(), "Id"); m.Status = "Pending Verification"; ServiceSystem.Save(EnscoConstants.EntityModel.IrmaCapaPlan, m, true); TaskModel taskModel = new TaskModel(); taskModel.AssignedAt = DateTime.Now; taskModel.AssignedBy = UtilitySystem.CurrentUserId; int oimId = 0; DataTable dt = this.GetDataSet("select dbo.fn_OimPassportId() ").Tables[0]; if (dt.Rows.Count > 0) { int.TryParse(dt.Rows[0][0].ToString(), out oimId); } taskModel.AssigneeUserId = oimId; taskModel.SourceForm = "CapaPlan"; taskModel.SourceFormId = id.ToString(); taskModel.SourceFormURL = "/irma/capa/capaPlan/" + id.ToString(); taskModel.Status = "Pending"; taskModel.Message = ""; ServiceSystem.Add(EnscoConstants.EntityModel.Task, taskModel, true); return(null); }
public ActionResult CapaPlan(int?id = 0) { IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.IrmaCapaPlan); IrmaCapaPlanModel m = new IrmaCapaPlanModel(); if (id == 0) { this.Session["Source"] = Guid.NewGuid().ToString(); m.RigId = UtilitySystem.CurrentRigId; } else { m = dataModel.GetItem("Id=" + id.ToString(), "Id"); } m.OwnersList = (m.Owners == null ? UtilitySystem.CurrentUserId.ToString() : m.Owners).Split(','); Session["CapaPlan"] = m; bool readOnly = true; if (id == 0 || (m.OwnersList.Contains(UtilitySystem.CurrentUserId.ToString()) && m.Status == "Open")) { readOnly = false; } this.ViewBag.readOnly = readOnly; this.ViewBag.dsSummary = this.GetDataSet("exec usp_GetCapaPlanSummary " + id.ToString()); return(View(m)); }
public void UpdateAttachment(int?id) { IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.Attachment); if (id != 0) { string source = this.Session["Source"] == null ? "" : this.Session["Source"].ToString(); IEnumerable <AttachmentModel> attachments = ServiceSystem.GetAttachments(source, "0"); if (attachments != null) { foreach (AttachmentModel attachment in attachments) { attachment.SourceFormId = id?.ToString(); attachment.SourceForm = "CapaPlan"; dataModel.Update(attachment); } } } else { string[] arr = this.Request.Form.GetValues("Removed"); if (arr != null) { foreach (string path in arr) { AttachmentModel attachment = dataModel.GetItem(string.Format("FilePath =\"{0}\"", HttpUtility.UrlDecode(path)), "Id"); if (attachment != null) { dataModel.Delete(attachment); } } } } }
public static void ProcessPobSummaryEmalJob() { IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.Scheduler); ScheduleJobModel job = dataModel.GetItem(string.Format("Id={0}", 1), "Id"); // PobSummaryReport job id if (job == null) { return; } ProcessPobSummaryEmailJob(job); }
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)); }
public static AuthenticationResult ChangePassword(string curPassword, string newPassword, string confirmPassword, IAuthenticationManager authMgr) { AuthenticationResult result = new AuthenticationResult(); try { if (newPassword != confirmPassword) { return(new AuthenticationResult("New and Confirm Passwords do not match.")); } UserSession userInfo = UtilitySystem.CurrentUser; if (userInfo == null) { return(new AuthenticationResult("User session expired")); } IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.User); UserModel model = dataModel.GetItem(string.Format("Id={0}", userInfo.UserId), "Id"); if (model == null) { return(new AuthenticationResult("User not found in the system")); } string ecurPwd = Cryptography.Encrypt(userInfo.Passport, curPassword); if (ecurPwd != model.Password) { return(new AuthenticationResult("Current password incorrect")); } model.Password = Cryptography.Encrypt(userInfo.Passport, newPassword); model.RequirePasswordChange = false; bool bSaved = ServiceSystem.Save(EnscoConstants.EntityModel.User, model, true); if (bSaved) { result = new AuthenticationResult(); } else { result = new AuthenticationResult("Internal Error. Failed to save password"); } } catch (Exception ex) { Logger.Error(new LogInfo(MethodBase.GetCurrentMethod(), ex.Message)); } return(result); }
IrmaCapaModel GetModel(int id) { IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.IrmaCapa); IrmaCapaModel m = dataModel.GetItem("Id=" + id.ToString(), "Id"); if (m != null) { m.AssignedTos = m.AssignedTo == null ? null : m.AssignedTo.Split(','); //m.NotifyIds = m.NotifyId == null ? null : m.NotifyId.Split(','); } else { m = new IrmaCapaModel(); } this.CapaId = m.Id; return(m); }
public static void ProcessJob(int jobid) { Logger.Info(new LogInfo(MethodBase.GetCurrentMethod(), string.Format("Processing scheduled job with jobId={0}", jobid))); IServiceDataModel dataModel = ServiceSystem.GetServiceModel(EnscoConstants.EntityModel.Scheduler); ScheduleJobModel job = dataModel.GetItem(string.Format("Id={0}", jobid), "Id"); if (job == null) { return; } switch ((ScheduleJobModel.ScheduledJobType)job.JobType) { case ScheduleJobModel.ScheduledJobType.PobSummaryEmail: ProcessPobSummaryEmailJob(job); break; case ScheduleJobModel.ScheduledJobType.ActiveDirUserInfo: ProcessActiveDirectoryUsersJob(job); break; } }
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) { } }