本文整理汇总了C#中Quartz.JobExecutionContext类的典型用法代码示例。如果您正苦于以下问题:C# JobExecutionContext类的具体用法?C# JobExecutionContext怎么用?C# JobExecutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobExecutionContext类属于Quartz命名空间,在下文中一共展示了JobExecutionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
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结束更新");
}
}
示例2: Execute
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);
}
}
示例3: Execute
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);
}
}
示例4: Execute
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
});
}
}
}
示例5: JobWasExecuted
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: Execute
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);
}
}
}
示例7: Execute
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结束更新");
}
}
示例8: Execute
public void Execute(JobExecutionContext context)
{
Debugger.Break();
var action = context.MergedJobDataMap["action"] as Action;
if (action != null)
action();
}
示例9: ExecuteInternal
/// <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());
}
}
示例10: Execute
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);
}
}
示例11: Execute
/// <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;
}
}
示例12: Execute
public void Execute(JobExecutionContext context)
{
var footballDataRepository = new FootballDataRepository();
LoadResults(footballDataRepository);
LoadFixtures(footballDataRepository);
}
示例13: Execute
/// <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();
}
示例14: Execute
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);
}
}
示例15: Execute
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);
}
}