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