public void Execute(JobExecutionContext context) { try { log.Info("AllListJob开始更新"); var videos = ListCache.Instance.Items[new VideoNodeKey(null, 0, null)].Ver1; var root = new XElement("vlist"); int num = 0; foreach (var video in videos) { root.Add(ResponseUtils.ResponseBack(ListCache.Instance.Dictionary[video])); num++; } root.AddFirst(new XElement("count", num)); ResponseUtils.SaveXml("all.xml", root); YesterdayListCache.Instance.Refresh(videos); SerizlizerUtils<YesterdayVideoNode>.SerializeSplitCache(YesterdayListCache.Instance.Items, _buffername); //SerizlizerUtils<VideoNode>.SerializeSplitCache(videos, _buffername); } catch (Exception ex) { log.Error(ex); } finally { log.Info("AllListJob结束更新"); } }
public void Execute(JobExecutionContext context) { try { int taskid = Convert.ToInt32(context.JobDetail.Name); var taskruntimeinfo = TaskPoolManager.CreateInstance().Get(taskid.ToString()); if (taskruntimeinfo == null || taskruntimeinfo.DllTask == null) { LogHelper.AddTaskError("当前任务信息为空引用", taskid, new Exception()); return; } taskruntimeinfo.TaskLock.Invoke(() => { try { taskruntimeinfo.DllTask.TryRun(); } catch (Exception exp) { LogHelper.AddTaskError("任务" + taskid + "TaskJob回调时执行失败", taskid, exp); } }); } catch (Exception exp) { LogHelper.AddNodeError("任务回调时严重系统级错误", exp); } }
/// <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; } }
public void Execute(JobExecutionContext context) { var payments = _ctx.Messages.Where(p => p.MessageStatus == Domain.MessageStatus.Pending); int numberOfDaysOpenThreshold = 10; foreach (var payment in payments) { var transactionBatch = transactionBatchService.GetOpenBatch(); if (payment.CreateDate.AddDays(numberOfDaysOpenThreshold).Date > System.DateTime.Now.Date) { //Create a transaction to deposit payment amount in payer's account payment.Transactions.Add(new Domain.Transaction() { Amount = payment.Amount, Category = Domain.TransactionCategory.Payment, CreateDate = System.DateTime.Now, FromAccountId = payment.SenderAccountId.Value, PaymentChannelType = Domain.PaymentChannelType.Single, //PaymentId = payment.Id, StandardEntryClass = Domain.StandardEntryClass.Web, Status = Domain.TransactionStatus.Pending, TransactionBatchId = transactionBatch.Id, Type = Domain.TransactionType.Deposit }); } } }
protected override void ExecuteCommand(JobExecutionContext context) { logger.Debug(m => m("Sql job:{0} has been executed.", context.JobDetail.FullName)); JobDataMap dataMap = context.JobDetail.JobDataMap; projectId = dataMap["projectId"].ToString(); gatewayId = SystemInternalSetting.Projects[projectId].ToString(); DateTime dt = dataMap["lastTime"] == null ? DateTime.Now : dataMap.GetDateTime("lastTime"); logger.Debug(m => m("where datetime > {0}", dt)); string connectionString = SystemInternalSetting.ConnectionString; string sqlSyntax = SystemInternalSetting.QueryProjectUpdateSQL; sqlSyntax = string.Format(sqlSyntax, projectId, dt); logger.Debug(sqlSyntax); DateTime dt2 = DateTime.Now; DataSet dataSet = DatabaseUtility.Query( connectionString, sqlSyntax, ""); if (dataSet.Tables.Count == 0) return; if (dataSet.Tables[0].Rows.Count > 0) { //Enqueue data Report(dataSet); } dataMap.Put("lastTime", dt2); ScheduleSetting.SetLastTime(projectId, dt2); }
public void Execute(JobExecutionContext context) { try { if (!NetNodeService.Instance.IsRefresh) { _logger.Info("缓存未更新,连接数据库同步数据"); ListCacheJob job = new ListCacheJob(); job.Execute(context); } else { _logger.Info("缓存已更新"); NetNodeService.Instance.IsRefresh = false; } } catch (Exception ex) { _logger.Error(ex); } finally { _logger.Info("MonitorListJob结束更新"); } }
public void Execute(JobExecutionContext context) { if (!Monitor.TryEnter(_lock)) return; try { var dic = AppSettingCache.Instance.Dictionary; if (dic != null) { foreach (var process in dic) { var count = Process.GetProcessesByName(process.Key).Length; if (count <= 0) { if (System.IO.File.Exists(process.Value)) { using (System.Diagnostics.Process.Start(process.Value)) { } _log.InfoFormat("进程{0}不存在,重新启动", process.Key); } } } } } catch (Exception ex) { _log.Error(ex); } finally { Monitor.Exit(_lock); } }
public void Execute(JobExecutionContext context) { if (!_lock.TryEnter() && !NetNodeService.Instance.HasChildren) return; try { _logger.Info("ListExtensionJob开始更新"); //CustomerCache.Instance.RefreshExtension(); PlatFormInfoCache.Instance.RefreshExtension(); AuthenticationCache.Instance.RefreshExtension(); PlatFormCache.Instance.RefreshExtension(); if (bool.Parse(AppSettingCache.Instance["VodAct"])) //是否启动点播 { BoxTypeCache.Instance.RefreshExtension(); ListCache.Instance.RefreshExtension(); TagCache.Instance.RefreshExtension(); RecommandCache.Instance.RefreshExtension(); } if (bool.Parse(AppSettingCache.Instance["LiveAct"])) //是否启动直播 { ChannelLiveItemsCache.Instance.RefreshExtension(); LiveTypeCache.Instance.RefreshExtension(); LiveListCache.Instance.RefreshExtension(); LiveTypeDicCache.Instance.RefreshExtension(); LiveRecommandCache.Instance.RefreshExtension(); } if (NetNodeService.Instance.HasChildren) //有孩子节点启动分布式 { ThreadPool.QueueUserWorkItem(state => { if (!_synclock.TryEnter()) return; try { NetNodeService.Instance.SyncChildrenData(); } catch (Exception ex) { _logger.Error(ex); } finally { _synclock.Exit(); } }); } } catch (Exception ex) { _logger.Error(ex); } finally { _lock.Exit(); _logger.Info("ListExtensionJob结束更新"); } }
/// <summary> /// Invoke the method via the MethodInvoker. /// </summary> /// <param name="context"></param> protected override void ExecuteInternal(JobExecutionContext context) { if (methodInvoker == null) { throw new JobExecutionException("Could not execute job when method invoker is null"); } try { context.Result = methodInvoker.Invoke(); } catch (TargetInvocationException ex) { logger.Error(errorMessage, ex.GetBaseException()); if (ex.GetBaseException() is JobExecutionException) { // -> JobExecutionException, to be logged at info level by Quartz throw ex.GetBaseException(); } // -> "unhandled exception", to be logged at error level by Quartz throw new JobMethodInvocationFailedException(methodInvoker, ex.GetBaseException()); } catch (Exception ex) { // -> "unhandled exception", to be logged at error level by Quartz throw new JobMethodInvocationFailedException(methodInvoker, ex.GetBaseException()); } }
public void Execute(JobExecutionContext context) { JobDataMap map = context.MergedJobDataMap; ScheduleQuery details = (ScheduleQuery) map["Details"]; ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings[details.DatabaseName]; if (connectionStringSettings != null) { var nextRunDate = GetNextRunDate(context.Trigger); AdoTemplate template = CreateTemplate(connectionStringSettings); DateTime startTime = DateTime.Now; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { int numResults = RunQuery(template, details.QueryText); stopwatch.Stop(); PublishSuccessEvent(details, numResults, startTime, nextRunDate, stopwatch.Elapsed); } catch (Exception ex) { PublishFailEvent(details, startTime, nextRunDate, ex); } } }
public void Execute(JobExecutionContext context) { //The LogManager plugs into the Service's logger and gets it magically. //in test mode we have no logger, because we have no containing Service so it does nothing. ILog logger = LogManager.GetLogger(typeof(BirthDayJob)); //Actual work below. try { //ds will contain rows with a single column: mail addresses. DataSet ds = SqlHelper.ExecuteDataset(connStr, CommandType.Text, "select user_email"+ " from personalcard inner join users"+ " on personalcard_user_id = user_id "+ "WHERE " + " DAY(personalcard_birth_day) = DATEPART(DAY,GETDATE()) " + " and MONTH(personalcard_birth_day) = DATEPART(MONTH,GETDATE())"); logger.Debug("found " + ds.Tables[0].Rows.Count + " emails to send birthday greetings to."); //make the result available for everyone. _result = ds; } catch (Exception ex) { logger.Error("could not make query: " + ex.Message); } }
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"]); }
public virtual void Execute(JobExecutionContext context) { Logger = new ServiceLogger(context.JobDetail.Name); if (Monitor.TryEnter(SYNC_LOCK, 3000) == false) { Logger.Debug("上一次调度未完成,本次调度放弃运行"); return; } try { Logger.Info("调度开始执行"); InnerExecute(context); Logger.Info("调度正常结束"); } catch (Exception e) { Logger.Error("调度执行时发生异常: " + e); } finally { Monitor.Exit(SYNC_LOCK); } }
protected override void ExecuteDetails(JobExecutionContext context) { int fromCreatedToSignedProtectedDays = 3; int fromUpdatedToSignedProtectedDays = 1; int fromContractEndToResignedProtectedDays = 7; if (SystemTaskInConfig != null) { //对得到的时间,做一天的修正处理 fromCreatedToSignedProtectedDays = Converter.ChangeType(SystemTaskInConfig.GetAddonItemValue("fromCreatedToSignedProtectedDays"), 3) + 1; fromUpdatedToSignedProtectedDays = Converter.ChangeType(SystemTaskInConfig.GetAddonItemValue("fromUpdatedToSignedProtectedDays"), 1) + 1; fromContractEndToResignedProtectedDays = Converter.ChangeType(SystemTaskInConfig.GetAddonItemValue("fromContractEndToResignedProtectedDays"), 7) + 1; } //1. 释放录入及其修改后在一段时间内都未能形成派遣的劳务人员的保护 //string sqlClauseForSignProtected = string.Format("update [XQYCLabor] set IsProtectedByOwner ={0} where LaborWorkStatus={1} AND CreateDate< '{2}' AND LastUpdateDate<'{3}' ", // (int)Logics.False, (int)LaborWorkStatuses.NewWorker, DateTime.Today.AddDays(-fromCreatedToSignedProtectedDays), DateTime.Today.AddDays(-fromUpdatedToSignedProtectedDays)); //int rowCountForCreateUpdateProtected = LaborBLL.Instance.ExcuteNonQuery(sqlClauseForSignProtected); //2.释放合同到期之后的一段时间内未能形成二次签约的劳务人员的保护 string sqlClauseForReSignProtected = string.Format("update [XQYCLabor] set IsProtectedByOwner ={0} where LaborWorkStatus !={1} AND CurrentContractDiscontinueDate<='{2}' AND CurrentContractDiscontinueDate!='{3}' AND LastUpdateDate<'{4}' ", (int)Logics.False, (int)LaborWorkStatuses.Worked, DateTime.Today.AddDays(-fromContractEndToResignedProtectedDays), DateTimeHelper.Min, DateTime.Today.AddDays(fromUpdatedToSignedProtectedDays)); LaborBLL.Instance.ExcuteNonQuery(sqlClauseForReSignProtected); //3.释放****对劳务人员的保护 }
public void Execute(JobExecutionContext context) { Debugger.Break(); var action = context.MergedJobDataMap["action"] as Action; if (action != null) action(); }
public void Execute(JobExecutionContext context) { try { var message = "The quick brown fox jumps over the lazy dog."; if (Log.IsInfoEnabled) { Log.Info(message); } else { Console.WriteLine(message); } } catch (JobExecutionException exception) { var message = string.Format("Quartz.NET Job error: {0}", exception.Message); if (!Log.IsErrorEnabled) { Log.Error(message); } else { Console.WriteLine(message); } Console.WriteLine("Press any key to continue . . ."); Console.ReadKey(true); } }
/// <summary> /// The execute. /// </summary> /// <param name="context"> /// The context. /// </param> public void Execute(JobExecutionContext context) { Ioc.SatisfyImportsOnce(this); Logger.Log(LogSeverity.Information, "CleanUpCallsManagerJob", "Clean up service executing"); CleanUpTempFolder(); CleanUpPaperClipFolder(); }
public void Execute(JobExecutionContext context) { var footballDataRepository = new FootballDataRepository(); LoadResults(footballDataRepository); LoadFixtures(footballDataRepository); }
public void Execute(JobExecutionContext context) { if (this.IsExcuted() == false) { ExecuteDetails(context); Log(); } }
public void Execute(JobExecutionContext context) { //JobDataMap data = context.MergedJobDataMap; //string msg = data.GetString("MessageToLog") ?? string.Empty; QuartzJobs.CreatePendingVMs(); }
public void Execute(JobExecutionContext context) { var sluzba = context.JobDetail.JobDataMap["sluzba"] as IRegistr; if (sluzba != null) { sluzba.Rozesli(); } }
public void Execute(JobExecutionContext context) { Run(context); JobQueue jobQueue = (JobQueue)context.JobDetail.JobDataMap["JobQueue"]; jobQueue.ScheduleNext(); }
public void Execute(JobExecutionContext context) { var jsonRepository = Repsitory as JsonRepository; if (jsonRepository == null) throw new Exception("Backup currently supports only JsonRepository"); Cloud.ArchiveFolder(jsonRepository.DataPath); }
public void Execute(JobExecutionContext context) { string projectId = context.JobDetail.JobDataMap["projectId"].ToString(); string gatewayId = SystemInternalSetting.Projects[projectId].ToString(); Message message = MessageFactory.CreateHeartbeatMessage(projectId, gatewayId); MessageQueueManager.GetSendQueue(projectId).Enqueue(message); }
public void Execute(JobExecutionContext context) { // Say Hello to the World and display the date/time _log.Info(string.Format("Hello World! - {0}", System.DateTime.Now.ToString("r"))); Debug.Print("test debug "); //HttpContext.Current.Response.Write(string.Format("Hello World! - {0}", System.DateTime.Now.ToString("r"))); }
private void Load(JobExecutionContext context) { Days = context.JobDetail.JobDataMap.GetInt(DaysSetting); BulkCount = context.JobDetail.JobDataMap.GetInt(BulkCountSetting); if (BulkCount == 0) { BulkCount = BulkCountDefault; } }
/// <summary> /// /// </summary> /// <param name="context"></param> public void Execute(JobExecutionContext context) { _provider = context.JobDetail.JobDataMap.Get("Provider") as DropboxVirtualPathProvider; if (_provider==null) { throw new ArgumentException("Provider must be of type DropboxVirtualPathProvider"); } var root = new DirectoryInfo(_provider.PhysicalPath); if (!root.Exists) root.Create(); GetAndUpdateFiles(root); }
public void Execute(JobExecutionContext context) { string sql = "select top 10 OrderID,CustomerID,ShipName,OrderDate from Orders "; System.Data.DataTable dt = SqlHelper.ExecuteDataset(sql).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { log.Info("任务测试 打印 orderid:" + dt.Rows[i]["OrderID"].ToString() + "customerid:" + dt.Rows[i]["OrderID"].ToString() + "name:" + dt.Rows[i]["ShipName"].ToString() + DateTime.Now.ToLongTimeString() + " 执行!"); } }
/// <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); }
private void Load(JobExecutionContext context) { BulkCount = context.JobDetail.JobDataMap.GetInt(BulkCountSetting); int minutes = context.JobDetail.JobDataMap.GetInt(ExpiredMinutesSetting); m_exiredMinutes = TimeSpan.FromMinutes(minutes); PickupFolder = context.JobDetail.JobDataMap.GetString(PickupFolderSettings); }
public void Execute(Quartz.JobExecutionContext context) { string name = context.JobDetail.Name; if (QuartzWorker.workCache[name]) { return; } QuartzWorker.workCache[name] = true; try { DoWork(); } catch (Exception ero) { Log(GetType() + "执行出错:" + ero.Message); } QuartzWorker.workCache[name] = false; }
public void Execute(Quartz.JobExecutionContext context) { string name = context.JobDetail.Name; if (QuartzWorker.workCache[name]) { EventLog.Log(DoWork.Target.GetType() + " 没运行完又自动触发,被忽略", "info"); return; } QuartzWorker.workCache[name] = true; try { DoWork(null, null); } catch (Exception ero) { EventLog.Log(DoWork.Target.GetType() + " 执行出错:" + ero, true); } QuartzWorker.workCache[name] = false; }
/// <summary> /// Called after the <see cref="IScheduler" /> has executed the /// <see cref="JobDetail" /> associated with the <see cref="Trigger" /> in order /// to get the final instruction code from the trigger. /// </summary> /// <param name="jobCtx"> /// The <see cref="JobExecutionContext" /> 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(JobExecutionContext 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); }
public virtual SchedulerInstruction ExecutionComplete(JobExecutionContext context, JobExecutionException result);