Exemplo n.º 1
0
        public override void JobWasExecuted(Quartz.IJobExecutionContext context, Quartz.JobExecutionException jobException)
        {
            base.JobWasExecuted(context, jobException);

            long scheduledTaskId = (long)context.MergedJobDataMap["scheduledTaskId"];
            ScheduledTaskRunStatistics lastRunStatistics = new ScheduledTaskRunStatistics();

            lastRunStatistics.StartTimeUtc = context.FireTimeUtc.HasValue ? context.FireTimeUtc.Value.DateTime : new DateTime?();
            lastRunStatistics.EndTimeUtc   = context.FireTimeUtc.HasValue ? context.FireTimeUtc.Value.Add(context.JobRunTime).DateTime : new DateTime?();
            if (jobException != null)
            {
                lastRunStatistics.Status = ScheduledTaskStatus.Failed;
                lastRunStatistics.Error  = jobException.Message;
            }
            else
            {
                ExecuteSequenceJobResult result = (ExecuteSequenceJobResult)context.Result;
                lastRunStatistics.Status = result.RunStatus;
                lastRunStatistics.Error  = result.RunError;
            }

            string connectionString         = (string)context.MergedJobDataMap["connectionString"];
            SchedulingController controller = new SchedulingController(connectionString);

            controller.SetScheduledTaskLastRunStatistics(scheduledTaskId, lastRunStatistics);

            zOnTaskComplete(new TaskEventArgs(scheduledTaskId));

            m_IsJobRunning = false;
        }
Exemplo n.º 2
0
        public override void Execute(Quartz.IJobExecutionContext context)
        {
            if (context.ScheduledFireTimeUtc.HasValue)
            {
                DateTimeOffset scheduledTime   = context.ScheduledFireTimeUtc.Value;
                DateTime       easternDateTime = TimeZoneInfo.ConvertTimeFromUtc(scheduledTime.UtcDateTime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));

                // If it's the weekend, don't send email
                if (easternDateTime.DayOfWeek == DayOfWeek.Sunday || easternDateTime.DayOfWeek == DayOfWeek.Saturday)
                {
                    return;
                }

                // Is today a stock market holiday?
                if (this.IsStockMarketHoliday(easternDateTime))
                {
                    return;
                }
            }

            IEnumerable <IUser> usersWithActiveSubscription = _database.GetActiveUsersWantingToReceiveAlerts;

            // Get the email
            IEmail morningMarketAlertEmail = _emailFactory.CreateEmail(
                contents: this.GetEmailContents(),
                subject: "Market Alert",
                // recipients: new List<IEmailRecipient>() { new EmailRecipient() { Name = "Mohammad Mohammadi", EmailAddress = "*****@*****.**" },
                // new EmailRecipient() { Name = "Mehdi Ghaffari", EmailAddress = "*****@*****.**" },
                // new EmailRecipient() { Name = "Ameen Tayyebi", EmailAddress = "*****@*****.**" } });
                recipients: usersWithActiveSubscription);

            morningMarketAlertEmail.Send();
        }
Exemplo n.º 3
0
        public void Execute(Quartz.IJobExecutionContext context)
        {
            string jobId     = context.JobDetail.Key.Name;
            var    container = context.Scheduler.Context.Get("Container") as ScheduleContainer;

            container.CallExecute(jobId);
        }
        public void Execute(Quartz.IJobExecutionContext context)
        {
            if (!threadSafe)
            {
                return;
            }
            threadSafe = false;
            try
            {
                //DateTime currentDate = ParseHelper.ToDatetime("2015-07-06 17:00:00");

                DateTime currentDate = DateTime.Now;
                //DateModel modelsave = new DateModel()
                //{
                //    date = currentDate
                //};
                //List<DateModel> listDate1 = new List<DateModel>()
                //    {
                //        new DateModel() {date=currentDate}
                //    };
                //XmlHelper.ToXml(filePath, listDate1);
                LogHelper.LogWriterString("扫表开始:时间:" + DateTime.Now.ToString());

                List <DateModel> dateModel = XmlHelper.ToObject <List <DateModel> >(filePath);
                //XmlDocument xdoc = new XmlDocument();

                //xdoc.Load(path);
                //XmlNode dateNode = xdoc.SelectSingleNode("date");
                //DateTime sqldate = DateTime.MinValue;
                //DateTime.TryParse(dateNode.Value, out sqldate);
                //DateTime lastdate = DateTime.Now;
                // 按照 sqldate 查询数据库
                var receviceAddressDao = new ReceviceAddressDao();
                var resultcount        = receviceAddressDao.GetAddress(ParseHelper.ToDatetime(dateModel[0].date, currentDate));
                if (resultcount > 0)
                {
                    //本次查询的ID大于上次查询的ID查询成功
                    //XmlElement dateElement = (XmlElement)dateNode;
                    //dateElement.InnerText = lastdate.ToString();
                    List <DateModel> listDate = new List <DateModel>()
                    {
                        new DateModel()
                        {
                            date = currentDate
                        }
                    };
                    XmlHelper.ToXml(filePath, listDate);
                }
                //xdoc.Save(path);
                LogHelper.LogWriterString("扫表结束:时间:" + DateTime.Now.ToString() + "本次影响行数:" + resultcount);
            }
            catch (Exception ex)
            {
                LogHelper.LogWriter(ex);
            }
            finally
            {
                threadSafe = true;
            }
        }
Exemplo n.º 5
0
        protected override DateTime BenchDate(Quartz.IJobExecutionContext context)
        {
            //every 5mins, figure out new create/updated products, promotions
            var dataMap      = context.JobDetail.JobDataMap;
            int intervalMins = dataMap.ContainsKey("interval") ? dataMap.GetIntValue("interval") : 5;

            return(DateTime.Now.AddMinutes(-intervalMins));
        }
Exemplo n.º 6
0
        public override void Execute(Quartz.IJobExecutionContext context)
        {
            IEnumerable <MemberInGame> nonWinners = gameEntity.game.MemberInGames.ToList <MemberInGame>().Where(x => x.WinIndicator == false || x.PaymentIndicator == false);

            newGame.game.MemberInGames = nonWinners.ToArray <MemberInGame>();
            newGame.makeReady();
            newGame.makeReleased();
            gameEntity.db.Games.Add(newGame.game);
            gameEntity.db.SaveChanges();
        }
 public override async void ExecuteCore(Quartz.IJobExecutionContext context)
 {
     try
     {
         await LocationHandler.ExportAubuchonLocations(TenantId, FilePath);
     }
     catch (Exception ex)
     {
         _logger.Error(ex.Message, ex);
     }
 }
Exemplo n.º 8
0
        public override void Execute(Quartz.IJobExecutionContext context)
        {
            if (gameEntity.resolvePotentialWinners() == GameResolveStatus.OUTSTANDING)
            {
                this.ExecuteTime = ExecuteTime.AddSeconds(10);  ///TODO is this correct?
                schedule(context.Scheduler);
            }

            gamerule.ExcecuteTime = ExecuteTime.DateTime;

            gameEntity.db.SaveChanges();
        }
Exemplo n.º 9
0
        public void Execute(Quartz.IJobExecutionContext context)
        {
            LogMgnt.Instance["ScheduleTaskService"].Info("------------任务调度服务开始运行-------------");
            try
            {
                TemplateConfigInstanceOperator.Instance.ScheduleTask(20);
            }
            catch (Exception ex)
            {
                LogMgnt.Instance["ScheduleTaskService"].Error("任务执行异常,错误信息{0},错误堆栈{1}", ex.Message, ex.StackTrace);
            }

            LogMgnt.Instance["ScheduleTaskService"].Info("------------任务调度服务结束运行-------------");
        }
Exemplo n.º 10
0
        public void Execute(Quartz.IJobExecutionContext context)
        {
            if (!threadSafe)
            {
                return;
            }
            threadSafe = false;
            try
            {
                LogHelper.LogWriter("执行啦:" + DateTime.Now);

                //获取未发送短信集合
                IList <MessageModel> list = messageDao.GetMessageList(0);
                foreach (var item in list)
                {
                    switch (item.PushWay)
                    {
                    case (int)MessagePushWay.Message:
                    {
                        SendMessageTarget(item);
                    }
                    break;

                    case (int)MessagePushWay.App:
                    {
                        SendAppTarget(item);
                    }
                    break;

                    case (int)MessagePushWay.MessageAndApp:
                    {
                        SendMessageTarget(item);
                        SendAppTarget(item);
                    }
                    break;

                    default: break;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogWriter(ex);
            }
            finally
            {
                threadSafe = true;
            }
        }
Exemplo n.º 11
0
 public override async Task Execute(Quartz.IJobExecutionContext context)
 {
     using (var s = IocContext.Instance.Scope())
     {
         try
         {
             await Task.CompletedTask;
         }
         catch (Exception e)
         {
             var logger = s.ServiceProvider.Resolve_ <ILogger <CleanEsJob> >();
             logger.AddErrorLog(e.Message, e);
         }
     }
 }
Exemplo n.º 12
0
        private static bool threadSafe = true;//线程安全
        #region IJob 成员

        public void Execute(Quartz.IJobExecutionContext context)
        {
            if (!threadSafe)
            {
                return;
            }
            threadSafe = false;
            try
            {
                LogHelper.LogWriter("执行啦:" + DateTime.Now);
                double hour = ParseHelper.ToDouble(Config.ConfigKey("DataTime"), -1);
                if (hour == -1)
                {
                    return;
                }
                ClienterDao clienterDao           = new ClienterDao();
                BusinessDao businessDao           = new BusinessDao();
                OrderDao    orderDao              = new OrderDao();
                IList <NonJoinWithdrawModel> list = orderDao.GetNonJoinWithdraw(hour);//获取没给可提现金额加钱的订单
                foreach (var item in list)
                {
                    using (IUnitOfWork tran = EdsUtilOfWorkFactory.GetUnitOfWorkOfEDS())
                    {
                        try
                        {
                            LogHelper.LogWriter(string.Concat("执行订单ID:", item.id, ",ClienterId:", item.clienterId));
                            clienterDao.UpdateAllowWithdrawPrice(item.clienterPrice, item.clienterId);
                            //businessDao.UpdateAllowWithdrawPrice(item.businessPrice, item.businessId);
                            orderDao.UpdateJoinWithdraw(item.id);
                            tran.Complete();
                        }
                        catch (Exception ex)
                        {
                            LogHelper.LogWriter(ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogWriter(ex);
            }
            finally
            {
                threadSafe = true;
            }
        }
        public void Execute(Quartz.IJobExecutionContext context)
        {
            Common.ScheduleService.Log.Instance.Info("Service begin execute");
            //查出上报月所有订阅了的系统以及人
            // List<B_Subscription> result = B_SubscriptionOperator.Instance.GetallSubscriptionList().ToList();

            int times = 60;

            try
            {
                string tim = ConfigurationManager.AppSettings["duration"];
                if (tim != null && tim != "")
                {
                    times = int.Parse(tim);
                }
                Common.ScheduleService.Log.Instance.Info("系统开放日服务,在App.Config读取时间间隔成功{0}", times);
            }
            catch (Exception)
            {
                Common.ScheduleService.Log.Instance.Error("系统开放日服务,在App.Config内读取时间间隔错误,请确保其为数字,没有空格.而且其单位为分钟");
            }

            //拿出系统开放实体
            C_ReportTime SysConfigModel = C_ReportTimeOperator.Instance.GetReportTime();

            Common.ScheduleService.Log.Instance.Info("系统开放日服务,执行逻辑业务开始");

            try
            {
                if (SysConfigModel.SysOpenDay != null)
                {
                    if (SysConfigModel.SysOpenDay.Value.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
                    {
                        SysConfigModel.ReportTime = SysConfigModel.WantTime;
                        SysConfigModel.OpenStatus = "1";
                        C_ReportTimeOperator.Instance.UpdateReportTime(SysConfigModel);
                    }
                }

                Common.ScheduleService.Log.Instance.Info("系统开放日服务,执行逻辑业务结束");
            }
            catch (Exception ex)
            {
                Common.ScheduleService.Log.Instance.Error("系统开放日服务,执行逻辑业务报错:" + ex.ToString());
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Updates the LastStatusMessage of the Rock Job associated with the IJobExecutionContext
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="message">The message.</param>
        public static void UpdateLastStatusMessage(this Quartz.IJobExecutionContext context, string message)
        {
            // save the message to context.Result so that RockJobListener will set the save the same message when the Job completes
            context.Result = message;

            int jobId = context.GetJobId();

            using (var rockContext = new RockContext())
            {
                var jobService = new ServiceJobService(rockContext);
                var job        = jobService.Get(jobId);
                if (job != null)
                {
                    job.LastStatusMessage = message;
                    rockContext.SaveChanges();
                }
            }
        }
Exemplo n.º 15
0
 public void Execute(Quartz.IJobExecutionContext context)
 {
     using (var message = new MailMessage("*****@*****.**", "*****@*****.**"))
     {
         message.Subject = "Test";
         message.Body    = "Test at " + DateTime.Now;
         using (SmtpClient client = new SmtpClient
         {
             EnableSsl = true,
             Host = "smtp.gmail.com",
             Port = 587,
             Credentials = new NetworkCredential("*****@*****.**", "password")
         })
         {
             client.Send(message);
         }
     }
 }
Exemplo n.º 16
0
        //使用Common.Logging.dll日志接口实现日志记录
        #region IJob 成员

        public void Execute(Quartz.IJobExecutionContext context)
        {
            try
            {
                int daysAgo = ETS.Config.ClienterCrossShopLogDaysAgo;
                CrossShopStatisticLogProvider CrossShopLog = new CrossShopStatisticLogProvider();
                if (CrossShopLog.InsertDataCrossShopStatisticLog(daysAgo))
                {
                    ETS.Util.LogHelper.LogWriter("获取跨店奖励统计计算成功" + DateTime.Now.ToString() + ":");
                }
                else
                {
                    ETS.Util.LogHelper.LogWriter("获取跨店奖励统计计算失败" + DateTime.Now.ToString() + ":");
                }
            }
            catch (Exception ex)
            {
                ETS.Util.LogHelper.LogWriter(ex.Message + DateTime.Now.ToString());
            }
        }
Exemplo n.º 17
0
        private JobLogEntry CreateEntry(Quartz.IJobExecutionContext jobContext, string kind, Quartz.JobExecutionException exception = null)
        {
            JobLogEntry entry = new JobLogEntry();

            entry.Group               = jobContext.JobDetail.Key.Group;
            entry.Name                = jobContext.JobDetail.Key.Name;
            entry.Kind                = kind;
            entry.Timestamp           = DateTime.UtcNow;
            entry.JobRunTime          = jobContext.JobRunTime;
            entry.NextFireTimeUtc     = jobContext.NextFireTimeUtc;
            entry.PreviousFireTimeUtc = jobContext.PreviousFireTimeUtc;

            if (exception != null)
            {
                entry.ExceptionMessage    = exception.Message;
                entry.ExceptionStackTrace = exception.StackTrace;
            }

            return(entry);
        }
Exemplo n.º 18
0
        public void Execute(Quartz.IJobExecutionContext context)
        {
            List <Email> emailjob = new List <Email>();
            IRepository <Email, int?> mailRepo = new EmailRepository();

            try
            {
                MailUtility mailUtility = new MailUtility();
                foreach (Email msg in mailRepo.Get().Where(x => x.Active == true).ToList())
                {
                    if (mailUtility.Send(msg.ToAddress, msg.Subject, msg.Body))
                    {
                        log.Info("Mail Sent: " + msg.ToAddress + " " + msg.Subject);
                        mailRepo.Remove(msg);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 19
0
        public void Execute(Quartz.IJobExecutionContext context)
        {
            var loConfig = JsonConvert.DeserializeObject <Config>(context.JobDetail.JobDataMap.GetString(Constants.JobConfigEntry));

            this.RaiseException(loConfig);

            string    lsResponse;
            WebClient loNewWebClient = new WebClient();

            lsResponse = loNewWebClient.DownloadString(loConfig.Url);

            //WebRequest loRequest = HttpWebRequest.Create(loConfig.Url);
            //WebResponse loResponse = loRequest.GetResponse();

            //using (StreamReader loReader = new StreamReader(loResponse.GetResponseStream()))
            //{
            //    lsResponse = loReader.ReadToEnd();
            //}

            moLogger.InfoFormat("Call url {0} successfully", loConfig.Url);
            context.Result = lsResponse;
        }
Exemplo n.º 20
0
 private static bool threadSafe = true;//线程安全
 public void Execute(Quartz.IJobExecutionContext context)
 {
     LogHelper.LogWriter("执行啦:" + DateTime.Now);
     if (!threadSafe)
     {
         return;
     }
     threadSafe = false;
     try
     {
         IExportSqlManageProvider xx = new ExportSqlManageProvider();
         xx.QueryForWindows(new DataManageSearchCriteria());
     }
     catch (Exception ex)
     {
         LogHelper.LogWriter(ex);
     }
     finally
     {
         threadSafe = true;
     }
 }
Exemplo n.º 21
0
        public virtual async System.Threading.Tasks.Task Execute(Quartz.IJobExecutionContext context)
        {
            if (context.CancellationToken.IsCancellationRequested)
            {
                Console.WriteLine("取消执行。");
                return;
            }
            try
            {
                DistributingData disriObj =
                    context.JobDetail.JobDataMap.Get("distriData") as DistributingData;

                Console.WriteLine(@"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + disriObj.DistributeFlag + disriObj.PageIndex.ToString());
            }
            catch (Exception ep)
            {
                Quartz.JobExecutionException jobep = new Quartz.JobExecutionException();
                //jobep.RefireImmediately=false;
                throw jobep;
            }
        }
Exemplo n.º 22
0
        public override void JobToBeExecuted(Quartz.IJobExecutionContext context)
        {
            base.JobToBeExecuted(context);

            m_IsJobRunning = true;

            long scheduledTaskId = (long)context.MergedJobDataMap["scheduledTaskId"];
            ScheduledTaskRunStatistics lastRunStatistics = new ScheduledTaskRunStatistics();

            lastRunStatistics.StartTimeUtc = context.FireTimeUtc.HasValue ? context.FireTimeUtc.Value.DateTime : new DateTime?();
            lastRunStatistics.EndTimeUtc   = null;
            lastRunStatistics.Status       = ScheduledTaskStatus.Running;
            lastRunStatistics.Error        = null;

            DateTime?nextScheduledRunTimeUtc = context.NextFireTimeUtc.HasValue ? context.NextFireTimeUtc.Value.DateTime : new DateTime?();

            string connectionString         = (string)context.MergedJobDataMap["connectionString"];
            SchedulingController controller = new SchedulingController(connectionString);

            controller.SetScheduledTaskLastRunStatistics(scheduledTaskId, lastRunStatistics);
            controller.SetScheduledTaskNextScheduledRunTime(scheduledTaskId, nextScheduledRunTimeUtc);

            zOnTaskStart(new TaskEventArgs(scheduledTaskId));
        }
        public void Execute(Quartz.IJobExecutionContext context)
        {
            Common.ScheduleService.Log.Instance.Info("Service begin execute");
            //查出上报月所有订阅了的系统以及人
            List <B_Subscription> result = B_SubscriptionOperator.Instance.GetallSubscriptionList().ToList();
            int times = 60;

            try
            {
                string tim = ConfigurationManager.AppSettings["duration"];
                if (tim != null && tim != "")
                {
                    times = int.Parse(tim);
                }
                Common.ScheduleService.Log.Instance.Info("在App.Config读取时间间隔成功{0}", times);
            }
            catch (Exception)
            {
                Common.ScheduleService.Log.Instance.Error("在App.Config内读取时间间隔错误,请确保其为数字,没有空格.而且其单位为分钟");
            }



            if (result.Count > 0)
            {
                try
                {
                    //循环所有订阅了系统的人
                    for (int i = 0; i < result.Count; i++)
                    {
                        //循环获得每个系统下每个订阅过的人的Action(要求时间内)
                        List <B_MonthlyReportAction> ReportAction = B_MonthlyReportActionOperator.Instance.GetMonthlyReportActionOneHour(result[i].SystemID, result[i].FinMonth, result[i].FinYear, times);
                        if (ReportAction != null)
                        {
                            if (ReportAction.Count > 0)
                            {
                                string system = C_SystemOperator.Instance.GetSystem(ReportAction[0].SystemID).SystemName;
                                Common.ScheduleService.Log.Instance.Info("读取{0}在{1}年{2}月{3}系统下所有的操作消息成功", result[i].CreatorName, result[i].FinYear, result[i].FinMonth, system);
                                TSM_Messages model = new TSM_Messages();
                                model.ID = new Guid();

                                model.Target = result[i].CreatorName; //用户RTX账号
                                model.Title  = "经营系统上报消息提示";          //消息标题

                                model.Priority    = 0;                //优先级
                                model.MessageType = 1;                //消息类型
                                model.CreateTime  = DateTime.Now;     //创建时间
                                model.SendTime    = DateTime.Now;     //发送时间
                                model.Status      = 0;
                                model.TryTimes    = 0;

                                string starttime   = DateTime.Now.AddMinutes(times * -1).ToLocalTime().ToString();
                                string endtime     = DateTime.Now.ToLocalTime().ToString();
                                string stringtime  = ConfigurationManager.AppSettings["ContextFormatTime"];
                                string stringvalue = ConfigurationManager.AppSettings["ContextFormatValue"];
                                string Content     = string.Format("亲爱的用户,在{0}到{1}之间,{2}", starttime, endtime, system);
                                if (stringtime != null && stringtime != "")
                                {
                                    if (stringtime.Trim() != "")
                                    {
                                        Content = string.Format(stringtime, starttime, endtime, system);
                                        Common.ScheduleService.Log.Instance.Info("在App.Config读取拼接ContextFormatTime字符串成功'{0}'", stringtime);
                                    }
                                    else
                                    {
                                        Common.ScheduleService.Log.Instance.Error("在App.Config读取拼接ContextFormatTime字符串为空,取默认值");
                                    }
                                }
                                else
                                {
                                    Common.ScheduleService.Log.Instance.Error("在App.Config读取拼接ContextFormatTime字符串失败,取默认值");
                                }

                                //循环操作枚举
                                for (int a = 1; a <= EnumUtil.GetItems(typeof(MonthlyReportLogActionType)).Count; a++)
                                {
                                    int    sum        = 0;
                                    string ActionEnum = EnumHelper.GetEnumDescription(typeof(MonthlyReportLogActionType), a);

                                    //循环Action,若该action中的操作位当前ActionEnum,则i++,最后统计出该操作总共做了多少次
                                    for (int s = 0; s < ReportAction.Count; s++)
                                    {
                                        if (ReportAction[s].Action == ActionEnum)
                                        {
                                            sum++;
                                        }
                                    }
                                    if (sum > 0)//如果该操作操作次数为0,则跳过
                                    {
                                        if (stringvalue != null && stringvalue != "")
                                        {
                                            if (stringvalue.Trim() != "")
                                            {
                                                Common.ScheduleService.Log.Instance.Info("在App.Config读取拼接ContextFormatValue字符串成功'{0}'", stringvalue);
                                                Content += string.Format(stringvalue, ActionEnum, sum);
                                            }
                                            else
                                            {
                                                Common.ScheduleService.Log.Instance.Info("在App.Config读取拼接ContextFormatValue字符串为空,取默认值");
                                            }
                                        }
                                        else
                                        {
                                            Content += string.Format("有{0}操作{1}个,", ActionEnum, sum);
                                            Common.ScheduleService.Log.Instance.Info("在App.Config读取拼接ContextFormatValue字符串失败,取默认值");
                                        }
                                    }
                                }
                                model.Content = Content.TrimEnd(',');//去掉最后一个""
                                TSM_MessagesOperator.Instance.AddTSM_Messages(model);
                                Common.ScheduleService.Log.Instance.Info("发送信息成功");
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    Common.ScheduleService.Log.Instance.Error("在编写发送消息时出错");
                }
            }
            Common.ScheduleService.Log.Instance.Info("Service execute finished");
        }
        public void Execute(Quartz.IJobExecutionContext context)
        {
            Common.ScheduleService.Log.Instance.Info("合并流程服务,开始执行");

            DateTime datetime = StaticResource.Instance.GetReportDateTime();

            finMonth = datetime.Month;
            finYear  = datetime.Year;
            //string[] array = System.Configuration.ConfigurationManager.AppSettings["GroupTypes"].Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
            var array = StaticResource.Instance.SystemList.Where(x => !string.IsNullOrEmpty(x.GroupType));

            foreach (var c_System in array)
            {
                bool _WFStarts = true;

                Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,读取批次表里是否有合适的数据Stare!");

                B_SystemBatch batchModel = B_SystemBatchOperator.Instance.GetSystemBatchByDraft(c_System.GroupType, finYear, finMonth);

                if (batchModel == null)
                {
                    continue;
                }
                if (batchModel != null)
                {
                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "读取数据成功!" + batchModel.FinYear + "年" + batchModel.FinMonth + "月");

                    BatchRptList = JsonConvert.DeserializeObject <List <V_SubReport> >(batchModel.SubReport);
                    int n = BatchRptList.Count(x => !x.IsReady);
                    _WFStarts = n == 0;
                }

                Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,读取批次表里是否有合适的数据End!");

                if (_WFStarts)
                {
                    string ProcessKey = c_System.Configuration.Element("ProcessCode").Value + "-HB";
                    //string ProcessKey = "YY_ZBGK-FDCHZ";
                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,有符合条件的的数据!");

                    this.ProcessKey = ProcessKey;
                    this.BusinessID = batchModel.ID.ToString();

                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,有符合条件的的数据BusinessID=" + this.BusinessID + "!");

                    //添加日志
                    B_MonthlyReportAction _bMonthlyReportAction = new B_MonthlyReportAction();
                    _bMonthlyReportAction.SystemID        = Guid.Empty;
                    _bMonthlyReportAction.MonthlyReportID = batchModel.ID;
                    _bMonthlyReportAction.FinYear         = batchModel.FinYear;
                    _bMonthlyReportAction.FinMonth        = batchModel.FinMonth;
                    _bMonthlyReportAction.Action          = EnumHelper.GetEnumDescription(typeof(MonthlyReportLogActionType), (int)MonthlyReportLogActionType.Submit);
                    _bMonthlyReportAction.Operator        = this.CurrentUser;
                    _bMonthlyReportAction.OperatorTime    = DateTime.Now;
                    _bMonthlyReportAction.ModifierName    = this.CurrentUser;
                    _bMonthlyReportAction.CreatorName     = this.CurrentUser;
                    B_MonthlyReportActionOperator.Instance.AddMonthlyReportAction(_bMonthlyReportAction);


                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,准备启动合并流程数据!");

                    try
                    {
                        if (!WFClientSDK.Exist(BusinessID)) //判断业务ID是否存在
                        {                                   //开启流程
                            CallMethed("startprocess", c_System.GroupType);
                            Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,合并流程数据启动完成!");
                        }
                        else
                        {
                            Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,有错误!!!!!!");
                            //当汇总后流程退回,再次发起用该方法
                            if (batchModel.WFBatchStatus == "Draft")
                            {
                                #region 该方法只能在草稿状态的时候启动

                                try
                                {
                                    string FinYear  = batchModel.FinYear.ToString() + "年";
                                    string FinMonth = batchModel.FinMonth.ToString("D2");
                                    //string _Title = "项目系统(南、中、北、大项目)" + FinYear + FinMonth + "月度报告";
                                    string _Title = c_System.SystemName + FinYear + FinMonth + "汇总月度报告";
                                    Dictionary <string, string> Dic = new Dictionary <string, string>();
                                    Dic["ReportName"] = _Title;
                                    Dic["ProcessKey"] = ProcessKey;

                                    #region 记录审批日志的Json

                                    Common.ScheduleService.Log.Instance.Info("合并流程再次启动开始!");


                                    string opiniontext = string.Empty;


                                    //重新在批次表中,获取数据
                                    BatchRptList = JsonConvert.DeserializeObject <List <V_SubReport> >(batchModel.SubReport);
                                    List <BPF.Workflow.Object.ProcessLog> _list = new List <ProcessLog>();
                                    if (BatchRptList.Count > 0)
                                    {
                                        BatchRptList.ForEach(BR =>
                                        {
                                            //B_MonthlyReport bm = B_MonthlyreportOperator.Instance.GetMonthlyreport(BR.ReportID);
                                            _list.AddRange(BPF.Workflow.Client.WFClientSDK.GetProcessLogList(BR.ReportID.ToString()));
                                        });
                                    }
                                    batchModel.Opinions = JsonConvert.SerializeObject(_list.OrderByDescending(p => p.FinishDateTime));

                                    #endregion

                                    WorkflowContext workflow = WFClientSDK.GetProcess(null, this.BusinessID, new UserInfo()
                                    {
                                        UserCode = "$VirtualUserCode$" + this.CurrentUser
                                    });
                                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程,获取流程成功!");
                                    //先启动流程,流程能启动了,在写入数据库流程审批日志
                                    Dictionary <string, object> formParams = new Dictionary <string, object>();
                                    formParams.Add("ReportName", _Title);
                                    formParams.Add("ProcessKey", ProcessKey);

                                    var        DynamicRoleUserList = JsonUser.GetDynamicRoleUserList(ProcessKey);
                                    BizContext bizContext          = new BizContext();
                                    bizContext.NodeInstanceList     = workflow.NodeInstanceList;
                                    bizContext.ProcessRunningNodeID = workflow.ProcessInstance.RunningNodeID;
                                    bizContext.BusinessID           = BusinessID;
                                    bizContext.FlowCode             = ProcessKey;
                                    bizContext.ApprovalContent      = "各区域数据已经汇总完成,请领导审批";
                                    bizContext.CurrentUser          = new UserInfo()
                                    {
                                        UserCode = "$VirtualUserCode$" + this.CurrentUser
                                    };
                                    bizContext.ProcessURL          = "/BusinessReport/TargetApprove.aspx?ProType=Batch";
                                    bizContext.FormParams          = formParams;
                                    bizContext.DynamicRoleUserList = DynamicRoleUserList;
                                    bizContext.ExtensionCommond    = new Dictionary <string, string>();
                                    bizContext.ExtensionCommond.Add("RejectNode", Guid.Empty.ToString());
                                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程,流程参数配置成功!");
                                    WorkflowContext wfc = WFClientSDK.ExecuteMethod("SubmitProcess", bizContext);
                                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程,流程提交成功!");
                                    OperationType = 1;
                                    //ProcessExecute();


                                    //先启动流程,流程能启动了,在写入数据库流程审批日志
                                    //ProcessResponse r = ClientProcess.MoveTo(BusinessID, "南、北、中、文旅项目已经汇总完成,请领导审批", Dic, "", true);

                                    //将批次的审批状态改变
                                    ExceptionHelper.TrueThrow(batchModel == null, string.Format("cannot find the report data which id={0}", BusinessID));
                                    batchModel.WFBatchStatus = "Progress";
                                    //batchModel.Description = GetDescription(c_System.ID, batchModel.FinYear, batchModel.FinMonth);
                                    //获取流程导航
                                    List <NavigatActivity1> listna = GetProcessIntance(wfc);

                                    if (listna.Count > 0)
                                    {
                                        batchModel.ReportApprove = JsonConvert.SerializeObject(listna);
                                    }

                                    B_SystemBatchOperator.Instance.UpdateSystemBatch(batchModel);



                                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,再次合并流程数据启动完成!");
                                }
                                catch (Exception ex)
                                {
                                    Common.ScheduleService.Log.Instance.Error(c_System.SystemName + "合并流程再次启动失败!,错误信息:" + ex.ToString());
                                }

                                #endregion
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.ScheduleService.Log.Instance.Error("合并流程启动失败!,错误信息:" + ex.ToString());
                    }
                }
                else
                {
                    Common.ScheduleService.Log.Instance.Info(c_System.SystemName + "合并流程服务,没有查找到符合条件合并流程!");
                }
            }
        }
Exemplo n.º 25
0
 public void Execute(Quartz.IJobExecutionContext context)
 {
     ProveedoresOnLine.RestrictiveListProcessBatch.RestrictiveListSendProcess.StartProcess();
 }
 public void Execute(Quartz.IJobExecutionContext context)
 {
     ProveedoresOnLine.ThirdKnowledgeBatch.ThirdKnowledgeFTPProcess.StartProcess();
 }
        public void Execute(Quartz.IJobExecutionContext context)
        {
            var reportTime = StaticResource.Instance.GetReportDateTime();

            Common.ScheduleService.Log.Instance.Info("提交虚拟暂挂节点处理开始!");
            bool IsChildrenSubmit        = false;
            int  month                   = reportTime.Month;
            List <B_SystemBatch> listBSB = B_SystemBatchOperator.Instance.GetSystemBatchList(month).ToList();

            foreach (B_SystemBatch Bsystembatch in listBSB)
            {
                try
                {
                    if (BPF.Workflow.Client.WFClientSDK.Exist(Bsystembatch.ID.ToString()))
                    {
                        WorkflowContext SummaryProcessWorkflow = WFClientSDK.GetProcess(null, Bsystembatch.ID.ToString(), new UserInfo()
                        {
                            UserCode = "$VirtualUserCode$" + userName
                        });
                        if (SummaryProcessWorkflow.ProcessInstance.Status == 3)
                        {
                            List <V_SubReport> listVs = JsonConvert.DeserializeObject <List <V_SubReport> >(Bsystembatch.SubReport);
                            foreach (V_SubReport vs in listVs)
                            {
                                if (BPF.Workflow.Client.WFClientSDK.Exist(vs.ReportID.ToString()))
                                {
                                    WorkflowContext ChildrenWorkflow = WFClientSDK.GetProcess(null, vs.ReportID.ToString(), new UserInfo()
                                    {
                                        UserCode = "$VirtualUserCode$" + userName
                                    });

                                    if (ChildrenWorkflow.ProcessInstance.Status != 3)
                                    {
                                        Common.ScheduleService.Log.Instance.Info("项目系统子流程,流程开始提交!ID=" + vs.ReportID.ToString());
                                        Dictionary <string, object> formParams = new Dictionary <string, object>();
                                        formParams.Add("ReportName", ChildrenWorkflow.ProcessInstance.ProcessTitle);
                                        formParams.Add("ProcessKey", ChildrenWorkflow.ProcessInstance.FlowCode);
                                        BizContext bizContext = new BizContext();
                                        bizContext.NodeInstanceList     = ChildrenWorkflow.NodeInstanceList;
                                        bizContext.ProcessRunningNodeID = ChildrenWorkflow.ProcessInstance.RunningNodeID;
                                        bizContext.BusinessID           = vs.ReportID.ToString();
                                        bizContext.FlowCode             = ChildrenWorkflow.ProcessInstance.FlowCode;
                                        bizContext.ApprovalContent      = "同意";
                                        bizContext.CurrentUser          = new UserInfo()
                                        {
                                            UserCode = "$VirtualUserCode$" + CurrentUser
                                        };
                                        bizContext.ProcessURL       = "/BusinessReport/TargetApprove.aspx";
                                        bizContext.FormParams       = formParams;
                                        bizContext.ExtensionCommond = new Dictionary <string, string>();
                                        bizContext.ExtensionCommond.Add("RejectNode", Guid.Empty.ToString());
                                        WorkflowContext wfc = WFClientSDK.ExecuteMethod("SubmitProcess", bizContext);
                                        if (wfc.StatusCode != 0)
                                        {
                                            //throw wfc.LastException;
                                            Common.ScheduleService.Log.Instance.Info(Bsystembatch.BatchType + "版块分支流程提交失败,原因:" + wfc.StatusMessage + "!ID=" + vs.ReportID.ToString());
                                        }
                                        else
                                        {
                                            Update(vs);
                                            Common.ScheduleService.Log.Instance.Info(Bsystembatch.BatchType + "版块分支流程提交成功!ID=" + vs.ReportID.ToString());
                                        }
                                    }
                                    else
                                    {
                                        IsChildrenSubmit = true;
                                    }
                                }
                            }
                        }
                        if (IsChildrenSubmit)
                        {
                            Common.ScheduleService.Log.Instance.Info(Bsystembatch.BatchType + "版块子流程,没有子流程提交!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Common.ScheduleService.Log.Instance.Error(Bsystembatch.BatchType + "版块子流程,流程提交失败!" + ex.ToString());
                }
            }
            Common.ScheduleService.Log.Instance.Info("提交虚拟暂挂节点处理结束!");
        }
Exemplo n.º 28
0
 public override void Execute(Quartz.IJobExecutionContext context)
 {
     Console.WriteLine(".........");
 }
Exemplo n.º 29
0
 public void Execute(Quartz.IJobExecutionContext context)
 {
     ProveedoresOnLine.CalificationBatch.CalificationProcess.StartProcess();
 }
Exemplo n.º 30
0
        public void Execute(Quartz.IJobExecutionContext context)
        {
            Common.ScheduleService.Log.Instance.Info("计算未完成指标考核范围Stare!");

            //获取需要的项目系统
            List <C_System> sysList = C_SystemOperator.Instance.GetSystemListBySeq().ToList();

            //获取上报年
            C_ReportTime RTime = C_ReportTimeOperator.Instance.GetReportTime();

            sysList.ForEach(S =>
            {
                Common.ScheduleService.Log.Instance.Info("循环系统 Stare! " + S.SystemName);

                //筛选指标类型是 收入和净利润 (这里还包含了,旅业的客流量) ,不包含成本类的指标
                List <C_Target> targetList = StaticResource.Instance.GetTargetList(S.ID, DateTime.Now).Where(T => T.NeedEvaluation == true && (T.TargetType != (int)EnumTargetType.Cost)).ToList();

                targetList.ForEach(t =>
                {
                    Common.ScheduleService.Log.Instance.Info("循环系统下的考核指标 Stare! " + t.TargetName.ToString());
                    //获取上报年计划指标 (参数,公司ID, 指标ID, 系统ID)
                    List <A_TargetPlanDetail> targetPlanList = A_TargetplandetailOperator.Instance.GetTargetplandetailList(S.ID, RTime.ReportTime.Value.Year).ToList();

                    for (int i = 1; i <= 12; i++)
                    {
                        Common.ScheduleService.Log.Instance.Info("循环系统下的考核指标的 全年12月 Stare! " + i.ToString() + "月");

                        #region  循环12月,在里面查询公司

                        //每个月,上报的月报单独指标 A表
                        List <A_MonthlyReportDetail> currentMRDList = A_MonthlyreportdetailOperator.Instance.GetAMonthlyreportdetailList(S.ID, RTime.ReportTime.Value.Year, i).Where(M => M.TargetID == t.ID).ToList();


                        //每个月,上报的月报单独指标, B表
                        List <B_MonthlyReportDetail> currentB_MRDList = B_MonthlyreportdetailOperator.Instance.GetMonthlyreportdetailList(S.ID, RTime.ReportTime.Value.Year, i, Guid.Empty).Where(M => M.TargetID == t.ID).ToList();

                        //未完成数量
                        int MissTargetA = 0;
                        int MissTargetB = 0;

                        MissTargetA = currentMRDList.Where(p => p.IsMissTarget == true).ToList().Count();

                        MissTargetB = currentB_MRDList.Where(p => p.IsMissTarget == true).ToList().Count();

                        //每个月的单独计划指标公司
                        List <A_TargetPlanDetail> currentTargetPlanList = targetPlanList.Where(tp => tp.FinMonth <= i && tp.TargetID == t.ID).ToList();


                        //获取上报且考核的公司
                        List <C_Company> companyList = C_CompanyOperator.Instance.GetCompanyListByNeedEvaluation(t.ID, S.ID).ToList();


                        //该list 作为记数用 A表的
                        List <C_Company> companyListCount = new List <C_Company>();

                        //该list 作为记数用 B表的
                        List <C_Company> companyB_ListCount = new List <C_Company>();


                        //这里循环有效的考核范围公司
                        companyList.ForEach(c =>
                        {
                            //首先判断当月公司是否存在,存在代表:大于0
                            int isCompanyCount = currentTargetPlanList.Where(P => P.CompanyID == c.ID).Count();

                            //获取当月指标等于0的个数
                            int tempCount = currentTargetPlanList.Where(P => P.CompanyID == c.ID && P.Target == 0).Count();

                            //记录A表数据
                            int isMonthRotCount = currentMRDList.Where(MR => MR.CompanyID == c.ID).Count();

                            //记录B表数据
                            int isB_MonthRotCount = currentB_MRDList.Where(MR => MR.CompanyID == c.ID).Count();


                            A_MonthlyReportDetail MonthRpt = currentMRDList.Where(MR => MR.CompanyID == c.ID).FirstOrDefault();

                            B_MonthlyReportDetail B_MonthRpt = currentB_MRDList.Where(MR => MR.CompanyID == c.ID).FirstOrDefault();

                            //A表数据的List
                            if (isMonthRotCount > 0 && isCompanyCount > 0 && tempCount != i)
                            {
                                //这里排除总部
                                if (c.CompanyName.IndexOf("总部") == -1 && MonthRpt.CompanyProperty1 != "筹备门店")
                                {
                                    companyListCount.Add(c);
                                }
                            }

                            //B表数据的List
                            if (isB_MonthRotCount > 0 && isCompanyCount > 0 && tempCount != i)
                            {
                                //这里排除总部
                                if (c.CompanyName.IndexOf("总部") == -1 && B_MonthRpt.CompanyProperty1 != "筹备门店")
                                {
                                    companyB_ListCount.Add(c);
                                }
                            }
                        }); //End companyList

                        try
                        {
                            //首先获取数据 , 这里区分A表 和B表的数据 (A表数据)
                            R_MissTargetEvaluationScope UpdateModel = R_MissTargetEvaluationScopeOperator.Instance.GetEvaluationDetailByType(S.ID, t.ID, RTime.ReportTime.Value.Year, i, "NeedEvaluation");

                            if (UpdateModel != null)
                            {
                                //修改
                                if (companyListCount != null)
                                {
                                    UpdateModel.EvaluationNumber = companyListCount.Count;
                                }
                                else
                                {
                                    UpdateModel.EvaluationNumber = 0;
                                }
                                UpdateModel.MissTargetNumber = MissTargetA;
                                UpdateModel.ModifierName     = "Sys";
                                UpdateModel.ModifyTime       = DateTime.Now;
                                R_MissTargetEvaluationScopeOperator.Instance.UpdateMissTargetEvaluationScope(UpdateModel);
                            }
                            else
                            {
                                //新增
                                R_MissTargetEvaluationScope ScopeModel = new R_MissTargetEvaluationScope();
                                if (companyListCount != null)
                                {
                                    ScopeModel.EvaluationNumber = companyListCount.Count;
                                }
                                else
                                {
                                    ScopeModel.EvaluationNumber = 0;
                                }
                                ScopeModel.MissTargetNumber = MissTargetA;
                                ScopeModel.FinMonth         = i;
                                ScopeModel.FinYear          = RTime.ReportTime.Value.Year;
                                ScopeModel.SystemID         = S.ID;
                                ScopeModel.TargetID         = t.ID;
                                ScopeModel.EvaluationType   = "NeedEvaluation";
                                ScopeModel.CreateTime       = DateTime.Now;
                                ScopeModel.CreatorName      = "Sys";

                                //12个月的,每个月,添加一次
                                R_MissTargetEvaluationScopeOperator.Instance.AddMissTargetEvaluationScope(ScopeModel);
                            }

                            //-----------------------------------------------------------------------------------------------------------------

                            //这里代表B表的数据
                            R_MissTargetEvaluationScope B_UpdateModel = R_MissTargetEvaluationScopeOperator.Instance.GetEvaluationDetailByType(S.ID, t.ID, RTime.ReportTime.Value.Year, i, "BNeedEvaluation");

                            if (UpdateModel != null)
                            {
                                //修改
                                if (companyB_ListCount != null)
                                {
                                    B_UpdateModel.EvaluationNumber = companyB_ListCount.Count;
                                }
                                else
                                {
                                    B_UpdateModel.EvaluationNumber = 0;
                                }
                                B_UpdateModel.MissTargetNumber = MissTargetB;
                                B_UpdateModel.ModifierName     = "Sys";
                                B_UpdateModel.ModifyTime       = DateTime.Now;
                                R_MissTargetEvaluationScopeOperator.Instance.UpdateMissTargetEvaluationScope(B_UpdateModel);
                            }
                            else
                            {
                                //新增
                                R_MissTargetEvaluationScope ScopeModel = new R_MissTargetEvaluationScope();
                                if (companyB_ListCount != null)
                                {
                                    ScopeModel.EvaluationNumber = companyB_ListCount.Count;
                                }
                                else
                                {
                                    ScopeModel.EvaluationNumber = 0;
                                }
                                ScopeModel.MissTargetNumber = MissTargetB;
                                ScopeModel.FinMonth         = i;
                                ScopeModel.FinYear          = RTime.ReportTime.Value.Year;
                                ScopeModel.SystemID         = S.ID;
                                ScopeModel.TargetID         = t.ID;
                                ScopeModel.EvaluationType   = "BNeedEvaluation";
                                ScopeModel.CreateTime       = DateTime.Now;
                                ScopeModel.CreatorName      = "Sys";

                                //12个月的,每个月,添加一次
                                R_MissTargetEvaluationScopeOperator.Instance.AddMissTargetEvaluationScope(ScopeModel);
                            }
                        }
                        catch (Exception Exp)
                        {
                            Common.ScheduleService.Log.Instance.Error("添加错误 TargetID" + t.ID + "SystemID" + S.ID + "FinMonth" + i + "FinYear" + RTime.ReportTime.Value.Year);
                        }

                        #endregion
                    }

                    Common.ScheduleService.Log.Instance.Info("循环系统下的考核指标 End!" + t.TargetName.ToString());
                }); //End targetList

                Common.ScheduleService.Log.Instance.Info("循环系统 End!" + S.SystemName.ToString());
            });// End sysList



            Common.ScheduleService.Log.Instance.Info("计算未完成指标考核范围End!");
        }