本文整理匯總了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);
}
}