本文整理汇总了C#中JobKey类的典型用法代码示例。如果您正苦于以下问题:C# JobKey类的具体用法?C# JobKey怎么用?C# JobKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobKey类属于命名空间,在下文中一共展示了JobKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JobInfo
public JobInfo(JobKey id, JobDetailImpl job)
{
Id = id;
Job = job;
Triggers = new TriggerInfo[0];
TriggerCount = 0;
}
示例2: ShouldDisposeScopeAfterJobCompletion
public void ShouldDisposeScopeAfterJobCompletion()
{
var key = new JobKey("disposable", "grp2");
var job1 = JobBuilder.Create<SampleJob>().WithIdentity(key).StoreDurably(true)
.Build();
var trigger =
TriggerBuilder.Create().WithSimpleSchedule(s => s.WithIntervalInSeconds(1).WithRepeatCount(1)).Build();
var scopesCreated = 0;
var scopesDisposed = 0;
DisposableDependency dependency = null;
_lifetimeScope.ChildLifetimeScopeBeginning += (sender, args) =>
{
scopesCreated++;
dependency = args.LifetimeScope.Resolve<DisposableDependency>();
args.LifetimeScope.CurrentScopeEnding += (o, eventArgs) => { scopesDisposed++; };
};
_scheduler.ScheduleJob(job1, trigger);
_scheduler.Start();
Thread.Sleep(3.Seconds());
_jobFactory.RunningJobs.Should().BeEmpty("Scope was not disposed after job completion");
dependency.Disposed.Should().BeTrue("Dependency must be disposed");
scopesDisposed.Should().Be(scopesCreated, "All scopes must be disposed");
}
示例3: Deserialize
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
{
if (nominalType != typeof(JobKey) || actualType != typeof(JobKey))
{
var message = string.Format("Can't deserialize a {0} from {1}.", nominalType.FullName, this.GetType().Name);
throw new BsonSerializationException(message);
}
var bsonType = bsonReader.CurrentBsonType;
if (bsonType == BsonType.Document)
{
JobKey item;
bsonReader.ReadStartDocument();
item = new JobKey(
bsonReader.ReadString("Name"),
bsonReader.ReadString("Group"));
bsonReader.ReadEndDocument();
return item;
}
else if (bsonType == BsonType.Null)
{
bsonReader.ReadNull();
return null;
}
else
{
var message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType);
throw new BsonSerializationException(message);
}
}
示例4: GetSchedule
public JobSchedule GetSchedule()
{
var jobKey = new JobKey(JobName, JobGroup);
var trigger = Instance.GetTriggersOfJob(jobKey).FirstOrDefault();
var js = new JobSchedule();
if (trigger != null)
{
js.Name = trigger.Key.Name;
js.Group = trigger.Key.Group;
js.Description = trigger.Description;
js.Priority = trigger.Priority;
js.TriggerType = trigger.GetType().Name;
js.TriggerState = Instance.GetTriggerState(trigger.Key).ToString();
DateTimeOffset? startTime = trigger.StartTimeUtc;
js.StartTime = TimeZone.CurrentTimeZone.ToLocalTime(startTime.Value.DateTime);
var nextFireTime = trigger.GetNextFireTimeUtc();
if (nextFireTime.HasValue)
{
js.NextFire = TimeZone.CurrentTimeZone.ToLocalTime(nextFireTime.Value.DateTime);
}
var previousFireTime = trigger.GetPreviousFireTimeUtc();
if (previousFireTime.HasValue)
{
js.LastFire = TimeZone.CurrentTimeZone.ToLocalTime(previousFireTime.Value.DateTime);
}
}
return js;
}
示例5: ExceptionPolicyNoRestartImmediately
public void ExceptionPolicyNoRestartImmediately()
{
sched.Start();
JobKey jobKey = new JobKey("ExceptionPolicyNoRestartJob", "ExceptionPolicyNoRestartGroup");
JobDetailImpl exceptionJob = new JobDetailImpl(jobKey.Name, jobKey.Group, typeof (ExceptionJob));
exceptionJob.Durable = true;
sched.AddJob(exceptionJob, false);
ExceptionJob.ThrowsException = true;
ExceptionJob.Refire = false;
ExceptionJob.UnscheduleAllTriggers = false;
ExceptionJob.UnscheduleFiringTrigger = false;
ExceptionJob.LaunchCount = 0;
sched.TriggerJob(jobKey);
int i = 10;
while ((i > 0) && (ExceptionJob.LaunchCount <= 1))
{
i--;
Thread.Sleep(200);
if (ExceptionJob.LaunchCount > 1)
{
break;
}
}
sched.DeleteJob(jobKey);
Assert.AreEqual(1, ExceptionJob.LaunchCount, "The job should NOT have been refired after exception");
}
示例6: ScheduleJob
public static void ScheduleJob(this IScheduler scheduler, JobKey jobKey, string scheduleText, TimeZoneInfo timeZone)
{
TextToScheduleFactory factory = new TextToScheduleFactory();
var english = factory.CreateEnglishParser();
var results = english.Parse(scheduleText, timeZone);
results.ScheduleWithJobKey(scheduler, jobKey);
}
示例7: AddRepeatingJob
public void AddRepeatingJob(Type aType, string aName, string aGroup, int aSecondsToSleep, params JobItem[] aItems)
{
JobKey key = new JobKey(aName, aGroup);
if (Scheduler.GetJobDetail(key) != null)
{
Log.Error("AddRepeatingJob(" + aType.Name + ", " + aName + ", " + aGroup + ") already exists");
return;
}
Log.Info("AddRepeatingJob(" + aType.Name + ", " + aName + ", " + aGroup + ", " + aSecondsToSleep + ")");
_scheduledJobs.Add(key);
var data = new JobDataMap();
foreach (JobItem item in aItems)
{
data.Add(item.Key, item.Value);
}
IJobDetail job = JobBuilder.Create(aType)
.WithIdentity(key)
.UsingJobData(data)
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(aName, aGroup)
.WithSimpleSchedule(x => x.WithIntervalInSeconds(aSecondsToSleep).RepeatForever())
.Build();
Scheduler.ScheduleJob(job, trigger);
}
示例8: GetJobDetailsData
public JobDetailsData GetJobDetailsData(JobKey jobKey)
{
var scheduler = _schedulerProvider.Scheduler;
if (scheduler.IsShutdown)
{
return null;
}
var job = scheduler.GetJobDetail(jobKey);
if (job == null)
{
return null;
}
var detailsData = new JobDetailsData
{
PrimaryData = GetJobData(scheduler, jobKey)
};
foreach (var key in job.JobDataMap.Keys)
{
detailsData.JobDataMap.Add(key, job.JobDataMap[key]);
}
detailsData.JobProperties.Add("Description", job.Description);
detailsData.JobProperties.Add("Full name", job.Key.Name);
detailsData.JobProperties.Add("Job type", job.JobType);
detailsData.JobProperties.Add("Durable", job.Durable);
//detailsData.JobProperties.Add("Volatile", job.);
return detailsData;
}
示例9: RemoveSchedule
public void RemoveSchedule(Schedule schedule)
{
var triggerKey = new TriggerKey(schedule.Id.ToString(), schedule.CommandId.ToString());
var jobKey = new JobKey(schedule.Id.ToString(), schedule.CommandId.ToString());
scheduler.UnscheduleJob(triggerKey);
scheduler.DeleteJob(jobKey);
}
示例10: JobDeleted
public void JobDeleted(JobKey jobKey)
{
foreach (ISchedulerListener listener in listeners)
{
listener.JobDeleted(jobKey);
}
}
示例11: PostTriggerJob
public HttpResponseMessage PostTriggerJob(string id)
{
JobKey jobKey = new JobKey(id);
_scheduler.TriggerJob(jobKey);
return new HttpResponseMessage();
}
示例12: IsBelongsToGroup
private bool IsBelongsToGroup(JobKey jobKey)
{
var jobDetail = _scheduler.GetJobDetail(jobKey);
if (jobDetail.JobDataMap == null || !jobDetail.JobDataMap.Contains("data"))
return false;
var data = JsonConvert.DeserializeObject<SendCreativePackagesWithIntervalTask.Data>((string) jobDetail.JobDataMap["data"]);
return data.Group == Group;
}
示例13: GetTriggers
private static IEnumerable<TriggerWithState> GetTriggers(ISchedulerWrapper scheduler, JobKey jobKey) {
var triggers = scheduler.GetTriggersOfJob(jobKey);
if (triggers == null)
return null;
return triggers.Select(t => {
var state = scheduler.GetTriggerState(t.Key);
return new TriggerWithState(t, state);
});
}
示例14: JobModel
public JobModel(IScheduler scheduler, JobKey jobKey)
{
foreach (ITrigger trigger in scheduler.GetTriggersOfJob(jobKey))
{
_triggersForJob.Add(new TriggerModel(trigger));
}
MapValuesFromJobDetail(scheduler.GetJobDetail(jobKey));
}
示例15: DeleteJob
/// <summary>
/// 删除现有任务
/// </summary>
/// <param name="JobKey"></param>
public static void DeleteJob(string JobKey)
{
JobKey jk = new JobKey(JobKey);
if (scheduler.CheckExists(jk))
{
//任务已经存在则删除
scheduler.DeleteJob(jk);
LogHelper.WriteLog(string.Format("任务“{0}”已经删除", JobKey));
}
}