Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult UpdateCronExpression(ScheduleJobModel model)
        {
            var result   = new { status = true, message = "" };
            var response = _jobManagerService.UpdateJobCronExpression(model.JobKey, model.CronExpression);

            if (!string.IsNullOrWhiteSpace(response))
            {
                return(Json(new { status = false, message = response }, JsonRequestBehavior.AllowGet));
            }
            _scheduleJobService.UpdateScheduleJobCronExpressionAndName(model.JobKey, model.CronExpression, model.JobName);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除定时任务
        /// </summary>
        /// <param name="jobId"></param>
        /// <returns></returns>
        public PushResultModel ScheduleJobDelete(ScheduleJobModel messages)
        {
            var ret = new PushResultModel();

            if (messages == null || string.IsNullOrEmpty(_appSecret))
            {
                return(ret);
            }

            const MiPushUrlEnum miPushUrlType = (MiPushUrlEnum)19;
            var urlChile   = miPushUrlType.GetPushUrl();
            var url        = Path.Combine(MiPushBaseUrl, urlChile);
            var postParams = GetProperties <ScheduleJobModel>(messages);
            var retString  = _miPushBll.Send(url, postParams, _appSecret);

            if (!string.IsNullOrEmpty(retString))
            {
                ret = JsonConvert.DeserializeObject <PushResultModel>(retString);
            }
            return(ret);
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
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)
            {
            }
        }
Ejemplo n.º 6
0
        public static void ProcessActiveDirectoryUsersJob(ScheduleJobModel job)
        {
            string AD = "ddr-ad04z";

            SchedulerService.ProcessActiveDirectoryUsersJob("ddr-ad04z");
        }