Пример #1
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                DateTime start = DateTime.Now;
                TaskLog.SendMessageLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------发送信息任务开始执行 " + start.ToString("yyyy-MM-dd HH:mm:ss") + " BEGIN-----------------------------\r\n\r\n");

                //取出所有当前待发送的消息
                List<Message> listWait = SQLHelper.ToList<Message>(strSQL2);
                bool isSucess = false;
                if (listWait == null || listWait.Count == 0)
                {
                    TaskLog.SendMessageLogInfo.WriteLogE("当前没有等待发送的消息!");
                }
                else
                {
                    foreach (var item in listWait)
                    {
                        isSucess = MessageHelper.SendMessage(item);
                        TaskLog.SendMessageLogInfo.WriteLogE(string.Format("接收人:{0},类型:{1},内容:“{2}”的消息发送{3}", item.Receiver, item.Type.ToString(), item.Content, isSucess ? "成功" : "失败"));
                    }
                }
                DateTime end = DateTime.Now;
                TaskLog.SendMessageLogInfo.WriteLogE("\r\n\r\n------------------发送信息任务完成:" + end.ToString("yyyy-MM-dd HH:mm:ss") + ",本次共耗时(分):" + (end - start).TotalMinutes + " END------------------------\r\n\r\n\r\n\r\n");
            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                TaskLog.SendMessageLogError.WriteLogE("发送信息任务异常", ex);
                //1.立即重新执行任务 
                e2.RefireImmediately = true;
            }
        }
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if ((int)context.JobDetail.JobDataMap.Get(CashBalanceInquiryJob.CashOnHand) > 100)
     {
         context.JobDetail.JobDataMap.Put(CashBalanceInquiryJob.CashOnHand, 1);
     }
 }
Пример #3
0
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if (DateTime.UtcNow > context.Trigger.EndTimeUtc)
         return;
     File.AppendAllText(@"C:\Intel\Logs\1.txt", context.Trigger.StartTimeUtc + " " + context.Trigger.EndTimeUtc);
     context.Scheduler.RescheduleJob(context.Trigger.Key, context.Trigger);
 }
Пример #4
0
 /// <summary>
 /// Called by the IScheduler after a IJobDetail has been executed, 
 /// and be for the associated IOperableTrigger's Triggered method has been called. 
 /// </summary>
 /// <param name="context">The IJobExecutionContext that was passed to the IJob'sExecute method.</param>
 /// <param name="jobException">Job execution exception, if any.</param>
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if (jobException != null)
         Log.Error(string.Format("The job '{0}' thow exception. {1}", context.JobDetail.Key, jobException.Message), jobException);
     else
         Log.DebugFormat("The job '{0}' was executed: Result = '{1}'.", context.JobDetail.Key, context.Result ?? "None");
 }
Пример #5
0
 public void JobWasExecuted(JobExecutionContext context, JobExecutionException jobException)
 {
     if(jobException == null)
         _jobs.Update(new { Status = "Complete",  RunTimeMinutes = Math.Round(context.JobRunTime.TotalMinutes, 2)}, context.JobDetail.JobDataMap["QueueID"]);
     else
         _jobs.Update(new { Status = "Error", RunTimeMinutes = Math.Round(context.JobRunTime.TotalMinutes, 2) }, context.JobDetail.JobDataMap["QueueID"]);
 }
Пример #6
0
 /// <summary>
 /// Entry point called when trigger fires.
 /// </summary>
 /// <param name="context"></param>
 public void Execute(JobExecutionContext context)
 {
     var settings = Load(context);
     
     try
     {
         foreach (var mdn in ExpiredMdns(settings))
         {
             using (TransactionScope scope = new TransactionScope())
             {
                 var message = CreateNotificationMessage(mdn, settings);
                 string filePath = Path.Combine(settings.PickupFolder, UniqueFileName());
                 MDNManager.TimeOut(mdn);
                 message.Save(filePath);
                 scope.Complete();
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error("Error in job!");
         Logger.Error(e.Message);
         var je = new JobExecutionException(e);
         throw je;
     }
 }
Пример #7
0
 public override void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     var description = "Job was executed: " + Describe(context);
     if (jobException != null)
         description += string.Format("<br/>with exception: <pre>{0}</pre>", HttpUtility.HtmlEncode(jobException.ToString()));
     entries.Add(new LogEntry(description));
 }
Пример #8
0
        public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            Sitecore.Diagnostics.Log.Info(String.Format("JobWasExecuted {0}", context.JobDetail.Key.Name), this);

            if (jobException != null)
                Sitecore.Diagnostics.Log.Error(String.Format("Sitecore.QuartzScheuler: JobWasExecuted {0} with Error : {1}",
                                                            context.JobDetail.Key.Name,
                                                            jobException.Message + Environment.NewLine + jobException.StackTrace),
                                                this);
        }
Пример #9
0
        /// <summary>
        /// 작업이 완료(성공이던 실패던)되었을 때, 호출됩니다.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="jobException"></param>
        public override void JobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
            base.JobWasExecuted(context, jobException);

            if(jobException != null) {
                if(log.IsWarnEnabled)
                    log.WarnException(string.Format("Job[{0}] 실행에 예외가 발생했습니다!!!", context.JobDetail.FullName), jobException);
            }
            else if(IsDebugEnabled)
                log.Debug(@"Job[{0}] 이 수행되었습니다.", context.JobDetail.FullName);
        }
Пример #10
0
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if (jobException != null)
     {
         loggerPool.Log(Name, new LogContentEntity()
         {
             Level = "Error",
             Message = string.Format("[{0}]:[{1}] Has An Exceptions:", context.JobDetail.Key.Name, context.JobDetail.Key.Group) + jobException.Message + jobException.StackTrace
         });
     }
 }
 public virtual void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if (jobException == null)
     {
         Logger.Info($"Job {context.JobDetail.JobType.Name} sucessfully executed.");
     }
     else
     {
         Logger.Error($"Job {context.JobDetail.JobType.Name} failed with exception:{jobException}");
     }
 }
Пример #12
0
        /// <summary>
        /// Called by the Scheduler after a <see cref="IJobDetail" />
        /// has been executed, and be for the associated <see cref="ITrigger" />'s
        /// <see cref="IOperableTrigger.Triggered" /> method has been called.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="jobException"></param>
        public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            Logger.InfoFormat("JobWasExecuted: {0}, {1}", context.JobDetail.Key.Name, context.JobDetail.Key.Group);

            var auditLog = GetAuditLog("JobWasExecuted", context);
            if (null != jobException)
            {
                auditLog.ExecutionException = jobException.ToString();
            }
            
            _persistanceStore.InsertAuditLog(auditLog);
        }
Пример #13
0
        public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            var jobName = ((JobDetailImpl)context.JobDetail).Name;

            if (jobException != null)
            {
                log.Error(string.Format("Job {0} error", jobName), jobException);
            }
            else
            {
                log.Debug(string.Format("Job {0} complete", jobName));
            }
        }
Пример #14
0
        public override void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            // for now if nothing has gone wrong we won't log anything
            if (jobException == null) return;

            Log.ErrorFormat("An exception occurred running job {0} (Refire Immediately? {1} Unschedule trigger? {2} Unschedule all triggers? {3})",
                jobException,
                context.JobDetail.JobType,
                jobException.RefireImmediately,
                jobException.UnscheduleFiringTrigger,
                jobException.UnscheduleAllTriggers
            );
        }
Пример #15
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                object objParam = context.JobDetail.JobDataMap.Get("TaskParam");
                if (objParam != null)
                {
                    ProxyParam Param = JsonConvert.DeserializeObject<ProxyParam>(objParam.ToString());
                    DateTime start = DateTime.Now;
                    TaskLog.IpProxyLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------爬虫开始执行获取代理ip任务 " + start.ToString("yyyy-MM-dd HH:mm:ss") + " BEGIN-----------------------------\r\n\r\n");


                    //每执行10次任务,换一个代理IP
                    if (NeedChangeIP || ExecuteCount % Speed == 0)
                    {
                        if (NeedChangeIP)
                        {
                            ExecuteCount = (ExecuteCount / Speed + 1) * Speed;
                        }
                        TaskLog.IpProxyLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------开始解析使用的代理ip " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " BEGIN-----------------------------\r\n\r\n");
                        ProxyIp = IpProxyGet.GetCorrectIP(Param);
                        TaskLog.IpProxyLogInfo.WriteLogE("------------------保存使用的代理ip:" + ProxyIp + " -----------------------------");
                        SQLHelper.ExecuteNonQuery("INSERT INTO dbo.p_ProxyIPUseHistory(ProxyIP,Type) VALUES (@ProxyIP,'IpProxyJob')", new { ProxyIP = ProxyIp });
                        NeedChangeIP = false;
                    }
                    Param.ProxyIp = ProxyIp;
                    TaskLog.IpProxyLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------任务使用的代理ip:" + Param.ProxyIp + "----------------------------\r\n\r\n");

                    List<IPProxy> list = IpProxyGet.ParseProxy(Param);
                    if (list.Count == 0)
                    {
                        //没有返回数据.表示当前IP已经被锁定需要更换
                        NeedChangeIP = true;
                    }

                    DateTime end = DateTime.Now;
                    ExecuteCount++;
                    TaskLog.IpProxyLogInfo.WriteLogE("\r\n\r\n------------------爬虫完成获取代理ip任务:" + end.ToString("yyyy-MM-dd HH:mm:ss") + ",本次共耗时(分):" + (end - start).TotalMinutes + " END------------------------\r\n\r\n\r\n\r\n");
                }
            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                TaskLog.IpProxyLogError.WriteLogE("爬虫获取代理ip任务异常", ex);
                ExecuteCount++;
                //1.立即重新执行任务 
                e2.RefireImmediately = true;
                //2 立即停止所有相关这个任务的触发器
                //e2.UnscheduleAllTriggers=true; 
            }
        }
Пример #16
0
        public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            DateTimeOffset now = DateTimeOffset.UtcNow;
            JobInfo info = GetJobInfo(context);

            info.IsRunning = false;
            info.LastResult = jobException ?? context.Result;
            info.LastEnded = now;
            info.LastDuration = now - info.LastStarted;

            // cleanup instance
            using (context.JobInstance as IDisposable)
            {
            }
        }
Пример #17
0
        public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            if (jobException == null)
                return;

            var retryableJob = context.JobInstance as IRetryableJob;
            if (retryableJob == null)
                return;

            int numberTries = context.JobDetail.JobDataMap.GetIntValue(NumberTriesJobDataMapKey);
            if (numberTries >= retryableJob.MaxNumberTries)
                return; // Max number tries reached

            // Schedule next try
            ScheduleRetryableJob(context, retryableJob);
        }
Пример #18
0
        /// <summary>
        /// Entry point called when trigger fires.
        /// </summary>
        /// <param name="context"></param>
        public void Execute(JobExecutionContext context)
        {
            var settings = Load(context);

            try
            {
                Store.Mdns.RemoveDispositions(TimeSpan.FromDays(settings.Days), settings.BulkCount);
            }
            catch (Exception e)
            {
                Logger.Error("Error in job!");
                Logger.Error(e.Message);
                var je = new JobExecutionException(e);
                throw je;
            }
        }
Пример #19
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                object objParam = context.JobDetail.JobDataMap.Get("TaskParam");
                if (objParam != null)
                {
                    DateTime start = DateTime.Now;
                    TaskLog.ExpressProgressLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------快递进度信息任务开始执行 " + start.ToString("yyyy-MM-dd HH:mm:ss") + " BEGIN-----------------------------\r\n\r\n");

                    //每执行5次任务,换一个代理IP
                    if (NeedChangeIP || ExecuteCount % Speed == 0)
                    {
                        if (NeedChangeIP)
                        {
                            ExecuteCount = (ExecuteCount / Speed + 1) * Speed;
                        }
                        TaskLog.ExpressProgressLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------开始解析使用的代理ip " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " BEGIN-----------------------------\r\n\r\n");
                        ProxyIp = ExpressUtil.GetCorrectIP(objParam.ToString());
                        TaskLog.ExpressProgressLogInfo.WriteLogE("------------------保存使用的代理ip:" + ProxyIp + " -----------------------------");
                        SQLHelper.ExecuteNonQuery("INSERT INTO dbo.p_ProxyIPUseHistory(ProxyIP,Type) VALUES (@ProxyIP,'ExpressProgressJob')", new { ProxyIP = ProxyIp });
                        NeedChangeIP = false;
                    }

                    TaskLog.ExpressProgressLogInfo.WriteLogE("\r\n\r\n\r\n\r\n------------------任务使用的代理ip:" + ProxyIp + "----------------------------\r\n\r\n");

                    if (!ExpressUtil.HandleProecssInfo(ProxyIp))
                    {
                        NeedChangeIP = true;
                    }

                    DateTime end = DateTime.Now;
                    ExecuteCount++;
                    TaskLog.ExpressProgressLogInfo.WriteLogE("\r\n\r\n------------------快递进度信息任务完成:" + end.ToString("yyyy-MM-dd HH:mm:ss") + ",本次共耗时(分):" + (end - start).TotalMinutes + " END------------------------\r\n\r\n\r\n\r\n");

                }
            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                TaskLog.ExpressProgressLogError.WriteLogE("快递进度信息任务异常", ex);
                ExecuteCount++;
                //1.立即重新执行任务 
                e2.RefireImmediately = true;
            }
        }
Пример #20
0
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if (jobException == null)
     {
         if (log.IsInfoEnabled)
         {
             log.InfoFormat("{0} completed. {1}", context.JobDetail.JobType.Name, context.Result ?? string.Empty);
         }
     }
     else
     {
         if (log.IsErrorEnabled)
         {
             log.ErrorFormat("{0} failed. {1}", context.JobDetail.JobType.Name, jobException.Message);
         }
     }
 }
Пример #21
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                object objParam = context.JobDetail.JobDataMap.Get("TaskParam");
                if (objParam != null)
                {
                    string[] listexe = objParam.ToString().Split(';');
                    string processName;
                    int startIndex, endIndex;
                    foreach (var path in listexe)
                    {
                        if (File.Exists(path))
                        {
                            if (!dictProcess.TryGetValue(path, out processName))
                            {
                                startIndex = path.LastIndexOf("\\") + 1;
                                endIndex = path.LastIndexOf(".");
                                //进程名默认为运行程序名称
                                processName = path.Substring(startIndex, endIndex - startIndex);
                            }
                            if (Process.GetProcessesByName(processName).ToList().Count <= 0)
                            {
                                //不存在
                                ProcessStartInfo ps = new ProcessStartInfo(path);
                                ps.UseShellExecute = false;
                                ps.CreateNoWindow = true;
                                ps.RedirectStandardOutput = true;
                                Process p = Process.Start(ps);
                                processName = p.ProcessName;
                            }
                            dictProcess[path] = processName;

                            TaskLog.AutoRunLogInfo.WriteLogE("程序:【" + processName + "】已经运行,时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "||" + Process.GetProcessesByName(processName).Count());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                TaskLog.AutoRunLogError.WriteLogE("自动运行程序的任务异常", ex);
                //1.立即重新执行任务
                e2.RefireImmediately = true;
            }
        }
Пример #22
0
        /// <summary>
        /// Load applicatioin settings.
        /// </summary>
        protected CleanupSettings Load(JobExecutionContext context)
        {
            try
            {
                var settings = new CleanupSettings(context);
                m_store = new ConfigStore(settings.ConnectionString, settings.QueryTimeout);
                m_logger = Log.For(this);

                return settings;
            }
            catch (Exception e)
            {
                WriteToEventLog(e);
                var je = new JobExecutionException(e);
                je.UnscheduleAllTriggers = true;
                throw je;
            }
        }
Пример #23
0
        public void Execute(IJobExecutionContext context)
        {
            log.Info("开始用户自动服务。");

            try
            {
                UserTableBLL bll = new UserTableBLL();
                DataTable dt = bll.GetUserList();

                log.Info("用户数:" + dt.Rows.Count);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message + Environment.NewLine + ex.StackTrace);
                JobExecutionException jobException = new JobExecutionException(ex);
                throw jobException;
            }
        }
Пример #24
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                //获取任务执行参数,任务启动时会读取配置文件TaskConfig.xml节点TaskParam的值传递过来
                object objParam = context.JobDetail.JobDataMap.Get("TaskParam");
                LogHelper.WriteLog("测试任务,当前系统时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                LogHelper.WriteLog("测试任务异常", ex);
                //1.立即重新执行任务
                e2.RefireImmediately = true;
                //2 立即停止所有相关这个任务的触发器
                //e2.UnscheduleAllTriggers=true;
            }
        }
Пример #25
0
		/// <summary>
		/// Handles operations related to finished schedule fire such as statistics and next time of firing.
		/// </summary>
        public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
        {
            if (context.JobInstance is GXScheduleJob)
            {
                GXSchedule schedule = null;
                try
                {
                    schedule = context.JobDetail.JobDataMap["Target"] as GXSchedule;
                    schedule.Statistics.LastRunTime = DateTime.Now;
                    if (jobException == null)
                    {
                        ++schedule.Statistics.RunCount;
                    }
                    else
                    {
                        ++schedule.Statistics.RunFailCount;
                        if (schedule != null)
                        {
                            schedule.Parent.Parent.NotifyError(schedule, jobException.GetBaseException());
                        }
                    }
                    //If this is last execution time.
                    if (context.NextFireTimeUtc == null)
                    {
                        if (schedule != null)
                        {
                            schedule.Statistics.EndTime = DateTime.Now;
                            schedule.Status &= ~ScheduleState.Run;
                            schedule.NotifyChange(ScheduleState.End);
                            context.Scheduler.DeleteJob(new JobKey(schedule.Name + schedule.ID.ToString(), schedule.Name + schedule.ID.ToString()));
                        }
                    }
                }
                catch (Exception Ex)
                {
                    if (schedule != null)
                    {
                        schedule.Parent.Parent.NotifyError(schedule, Ex);
                    }
                }
            }
        }
Пример #26
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                while (!_interrupted && true)
                {
                    LogHelper.WriteLog("测试任务,当前系统时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }

            }
            catch (Exception ex)
            {
                JobExecutionException e2 = new JobExecutionException(ex);
                LogHelper.WriteLog("测试任务异常", ex);
                //1.立即重新执行任务
                e2.RefireImmediately = true;
                //2 立即停止所有相关这个任务的触发器
                //e2.UnscheduleAllTriggers=true;
            }
        }
Пример #27
0
        public virtual void JobWasExecuted(JobExecutionContext inContext, JobExecutionException inException)
        {
            string m_strJobName = inContext.JobDetail.FullName;

            log.Info("报表监视器: " + m_strJobName + " Execution was Executed。\r\n");
            try
            {
                //如果任务发生错误
                if (inException != null)
                {
                    log.Info(inException.Message);

                    //重试
                    inException.RefireImmediately = true;

                    //if (inContext.RefireCount != Model.DelLogCfg.RefireCount) return;
                }

            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
 public void JobWasExecuted(JobExecutionContext context, JobExecutionException jobException)
 {
 }
Пример #29
0
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     _container.Dispose();
 }
 public void JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
 {
     if (jobException != null)
         _exceptionHandler(jobException);
 }
Пример #31
0
        /// <summary>
        /// Called after the <see cref="IScheduler" /> has executed the
        /// <see cref="IJobDetail" /> associated with the <see cref="ITrigger" /> in order
        /// to get the final instruction code from the trigger.
        /// </summary>
        /// <param name="jobCtx">
        /// The <see cref="IJobExecutionContext" /> that was used by the
        /// <see cref="IJob" />'s <see cref="IJob.Execute" /> method.
        /// </param>
        /// <param name="result">
        /// The <see cref="JobExecutionException" /> thrown by the
        /// <see cref="IJob" />, if any (may be <see langword="null" />)
        /// </param>
        /// <returns> one of the Trigger.INSTRUCTION_XXX constants.
        /// </returns>
        public override SchedulerInstruction ExecutionComplete(IJobExecutionContext jobCtx, JobExecutionException result)
        {
            if (result != null && result.RefireImmediately)
            {
                return(SchedulerInstruction.ReExecuteJob);
            }

            if (result != null && result.UnscheduleFiringTrigger)
            {
                return(SchedulerInstruction.SetTriggerComplete);
            }

            if (result != null && result.UnscheduleAllTriggers)
            {
                return(SchedulerInstruction.SetAllJobTriggersComplete);
            }

            if (!GetMayFireAgain())
            {
                return(SchedulerInstruction.DeleteTrigger);
            }

            return(SchedulerInstruction.NoInstruction);
        }
Пример #32
0
 public virtual SchedulerInstruction ExecutionComplete(JobExecutionContext context, JobExecutionException result);