本文整理汇总了C#中TriggerKey类的典型用法代码示例。如果您正苦于以下问题:C# TriggerKey类的具体用法?C# TriggerKey怎么用?C# TriggerKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TriggerKey类属于命名空间,在下文中一共展示了TriggerKey类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LoadExtendedTriggerProperties
public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
using (IDbCommand cmd = CommandAccessor.PrepareCommand(conn, AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlSelectSimpleTrigger, TablePrefix, SchedNameLiteral)))
{
CommandAccessor.AddCommandParameter(cmd, "triggerName", triggerKey.Name);
CommandAccessor.AddCommandParameter(cmd, "triggerGroup", triggerKey.Group);
using (IDataReader rs = cmd.ExecuteReader())
{
if (rs.Read())
{
int repeatCount = rs.GetInt32(AdoConstants.ColumnRepeatCount);
long repeatInterval = rs.GetInt64(AdoConstants.ColumnRepeatInterval);
int timesTriggered = rs.GetInt32(AdoConstants.ColumnTimesTriggered);
SimpleScheduleBuilder sb = SimpleScheduleBuilder.Create()
.WithRepeatCount(repeatCount)
.WithInterval(TimeSpan.FromMilliseconds(repeatInterval));
string[] statePropertyNames = {"timesTriggered"};
object[] statePropertyValues = {timesTriggered};
return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues);
}
}
throw new InvalidOperationException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlSelectSimpleTrigger, TablePrefix, SchedNameLiteral));
}
}
开发者ID:jondhinkle,项目名称:Rock,代码行数:28,代码来源:SimpleTriggerPersistenceDelegate.cs
示例2: 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);
}
开发者ID:vgreggio,项目名称:CrossoverTest,代码行数:7,代码来源:SchedulerEngine.cs
示例3: LoadExtendedTriggerProperties
public TriggerPropertyBundle LoadExtendedTriggerProperties(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
using (IDbCommand cmd = CommandAccessor.PrepareCommand(conn, AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlSelectCronTriggers, TablePrefix, SchedNameLiteral)))
{
CommandAccessor.AddCommandParameter(cmd, "triggerName", triggerKey.Name);
CommandAccessor.AddCommandParameter(cmd, "triggerGroup", triggerKey.Group);
using (IDataReader rs = cmd.ExecuteReader())
{
if (rs.Read())
{
string cronExpr = rs.GetString(AdoConstants.ColumnCronExpression);
string timeZoneId = rs.GetString(AdoConstants.ColumnTimeZoneId);
CronScheduleBuilder cb = CronScheduleBuilder.CronSchedule(cronExpr);
if (timeZoneId != null)
{
cb.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId));
}
return new TriggerPropertyBundle(cb, null, null);
}
}
throw new InvalidOperationException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlSelectCronTriggers, TablePrefix, SchedNameLiteral));
}
}
开发者ID:jondhinkle,项目名称:Rock,代码行数:28,代码来源:CronTriggerPersistenceDelegate.cs
示例4: Deserialize
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
{
if (nominalType != typeof(TriggerKey) || actualType != typeof(TriggerKey))
{
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)
{
TriggerKey item;
bsonReader.ReadStartDocument();
item = new TriggerKey(
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);
}
}
开发者ID:Jiangew,项目名称:quartz.net-mongodb,代码行数:32,代码来源:TriggerKeySerializer.cs
示例5: OnStart
public override bool OnStart()
{
Trace.WriteLine("WorkerRole1 Run", "Information");
var properties = new NameValueCollection();
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.clustered"] = "true";
properties["quartz.jobStore.selectWithLockSQL"] = string.Format(CultureInfo.InvariantCulture, "SELECT * FROM {0}{1} WHERE {2} = {3} AND {4} = @lockName", new object[] { "{0}", "LOCKS", "SCHED_NAME", "{1}", "LOCK_NAME" });
properties["quartz.jobStore.acquireTriggersWithinLock"] = "true";
properties["quartz.scheduler.instanceId"] = "AUTO";
properties["quartz.threadPool.threadCount"] = "1";
properties["quartz.jobStore.tablePrefix"] = "Scheduling.";
properties["quartz.dataSource.default.connectionString"] = @"Server = (local)\sqlexpress; Database = DB; Integrated Security = True";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
var scheduler = new StdSchedulerFactory(properties).GetScheduler();
scheduler.Clear();
var triggerKey = new TriggerKey("t1");
var trigger = scheduler.GetTrigger(triggerKey);
var jobBuilder = JobBuilder.Create<Job>();
var job = jobBuilder.Build();
var t = scheduler.GetTrigger(new TriggerKey("t1"));
trigger = new SimpleTriggerImpl("t1", 100000, TimeSpan.FromSeconds(5));
scheduler.ScheduleJob(job, trigger);
scheduler.Start();
return base.OnStart();
}
开发者ID:peterhholroyd,项目名称:fmg_dhc,代码行数:35,代码来源:WorkerRole.cs
示例6: ExampleTrigger
public ExampleTrigger(TriggerKey key, DateTime startTimeRetryUtc, DateTime? endTimeRetryUtc, int v, TimeSpan zero)
{
this._key = key;
this._startTimeRetryUtc = startTimeRetryUtc;
this._endTimeRetryUtc = endTimeRetryUtc;
this._v = v;
this._zero = zero;
}
开发者ID:devworker55,项目名称:SourceLab,代码行数:8,代码来源:ExampleTrigger.cs
示例7: PostRestartTrigger
public void PostRestartTrigger(string key)
{
var triggerKey = new TriggerKey(key);
var trigger = _scheduler.GetTrigger(triggerKey);
if (trigger == null)
throw new HttpResponseException(HttpStatusCode.NotFound);
_scheduler.ResumeTrigger(triggerKey);
}
开发者ID:kaleyroy,项目名称:QuartzNetAPI,代码行数:8,代码来源:TriggersController.cs
示例8: TriggerKeyShouldBeSerializable
public void TriggerKeyShouldBeSerializable()
{
TriggerKey original = new TriggerKey("name", "group");
TriggerKey cloned = original.DeepClone();
Assert.That(cloned.Name, Is.EqualTo(original.Name));
Assert.That(cloned.Group, Is.EqualTo(original.Group));
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:9,代码来源:TriggerKeyTest.cs
示例9: DeleteExtendedTriggerProperties
public int DeleteExtendedTriggerProperties(ConnectionAndTransactionHolder conn, TriggerKey triggerKey)
{
using (IDbCommand cmd = DbAccessor.PrepareCommand(conn, AdoJobStoreUtil.ReplaceTablePrefix(StdAdoConstants.SqlDeleteCronTrigger, TablePrefix, SchedNameLiteral)))
{
DbAccessor.AddCommandParameter(cmd, "triggerName", triggerKey.Name);
DbAccessor.AddCommandParameter(cmd, "triggerGroup", triggerKey.Group);
return cmd.ExecuteNonQuery();
}
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:10,代码来源:CronTriggerPersistenceDelegate.cs
示例10: GetTriggerState
/// <summary>
/// Get the current state of the identified <see cref="T:Quartz.ITrigger"/>.
/// </summary>
/// <seealso cref="T:Quartz.TriggerState"/>
public override TriggerState GetTriggerState(TriggerKey triggerKey)
{
var triggerHashKey = this.RedisJobStoreSchema.TriggerHashkey(triggerKey);
if (
this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.Paused),
triggerHashKey) != null ||
this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.PausedBlocked),
triggerHashKey) != null)
{
return TriggerState.Paused;
}
if (
this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.Blocked), triggerHashKey) != null)
{
return TriggerState.Blocked;
}
if (
this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.Waiting),
triggerHashKey) != null || this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.Acquired),triggerHashKey) !=null)
{
return TriggerState.Normal;
}
if (
this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.Completed),
triggerHashKey) != null)
{
return TriggerState.Complete;
}
if (
this.Db.SortedSetScore(this.RedisJobStoreSchema.TriggerStateSetKey(RedisTriggerState.Error), triggerHashKey)
!= null)
{
return TriggerState.Error;
}
return TriggerState.None;
}
开发者ID:icyice80,项目名称:QuartzRedisJobStore,代码行数:42,代码来源:RedisStorage.cs
示例11: NotifySchedulerListenersResumedTrigger
/// <summary>
/// Notifies the scheduler listeners resumed trigger.
/// </summary>
public virtual void NotifySchedulerListenersResumedTrigger(TriggerKey triggerKey)
{
// build a list of all job listeners that are to be notified...
IList<ISchedulerListener> schedListeners = BuildSchedulerListenerList();
// notify all scheduler listeners
foreach (ISchedulerListener sl in schedListeners)
{
try
{
sl.TriggerResumed(triggerKey);
}
catch (Exception e)
{
log.Error(string.Format(CultureInfo.InvariantCulture, "Error while notifying SchedulerListener of resumed trigger. Trigger={0}", triggerKey), e);
}
}
}
开发者ID:natenho,项目名称:quartznet,代码行数:21,代码来源:QuartzScheduler.cs
示例12: RemoveTrigger
/// <summary>
/// Remove (delete) the <see cref="ITrigger" /> with the
/// given name.
///
/// </summary>
/// <returns>
/// <see langword="true" /> if a <see cref="ITrigger" /> with the given
/// name and group was found and removed from the store.
/// </returns>
/// <param name="key">The <see cref="ITrigger" /> to be removed.</param>
/// <param name="removeOrphanedJob">Whether to delete orpahaned job details from scheduler if job becomes orphaned from removing the trigger.</param>
public virtual bool RemoveTrigger(TriggerKey key, bool removeOrphanedJob)
{
bool found;
lock (lockObject)
{
var trigger = this.RetrieveTrigger(key);
found = trigger != null;
if (found)
{
this.Triggers.Remove(
Query.EQ("_id", trigger.Key.ToBsonDocument()));
if (removeOrphanedJob)
{
IJobDetail jobDetail = this.RetrieveJob(trigger.JobKey);
IList<IOperableTrigger> trigs = this.GetTriggersForJob(jobDetail.Key);
if ((trigs == null
|| trigs.Count == 0)
&& !jobDetail.Durable)
{
if (this.RemoveJob(jobDetail.Key))
{
signaler.NotifySchedulerListenersJobDeleted(jobDetail.Key);
}
}
}
}
}
return found;
}
开发者ID:KevinVoell,项目名称:quartznet-mongodb,代码行数:43,代码来源:JobStore.cs
示例13: WithIdentity
/// <summary>
/// Use a TriggerKey with the given name and group to
/// identify the Trigger.
/// </summary>
/// <remarks>
/// <para>If none of the 'withIdentity' methods are set on the TriggerBuilder,
/// then a random, unique TriggerKey will be generated.</para>
/// </remarks>
/// <param name="name">the name element for the Trigger's TriggerKey</param>
/// <param name="group">the group element for the Trigger's TriggerKey</param>
/// <returns>the updated TriggerBuilder</returns>
/// <seealso cref="TriggerKey" />
/// <seealso cref="ITrigger.Key" />
public TriggerBuilder WithIdentity(string name, string group)
{
key = new TriggerKey(name, group);
return this;
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:18,代码来源:TriggerBuilder.cs
示例14: Build
/// <summary>
/// Produce the <see cref="ITrigger" />.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>a Trigger that meets the specifications of the builder.</returns>
public ITrigger Build()
{
if (scheduleBuilder == null)
{
scheduleBuilder = SimpleScheduleBuilder.Create();
}
IMutableTrigger trig = scheduleBuilder.Build();
trig.CalendarName = calendarName;
trig.Description = description;
trig.StartTimeUtc = startTime;
trig.EndTimeUtc = endTime;
if (key == null)
{
key = new TriggerKey(Guid.NewGuid().ToString(), null);
}
trig.Key = key;
if (jobKey != null)
{
trig.JobKey = jobKey;
}
trig.Priority = priority;
if (!jobDataMap.IsEmpty)
{
trig.JobDataMap = jobDataMap;
}
return trig;
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:36,代码来源:TriggerBuilder.cs
示例15: GetTrigger
/// <summary>
/// Get the <see cref="ITrigger" /> instance with the given name and
/// group.
/// </summary>
public virtual ITrigger GetTrigger(TriggerKey triggerKey)
{
ValidateState();
return resources.JobStore.RetrieveTrigger(triggerKey);
}
开发者ID:natenho,项目名称:quartznet,代码行数:10,代码来源:QuartzScheduler.cs
示例16: MatchTriggerListener
private bool MatchTriggerListener(ITriggerListener listener, TriggerKey key)
{
IList<IMatcher<TriggerKey>> matchers = ListenerManager.GetTriggerListenerMatchers(listener.Name);
if (matchers == null)
{
return true;
}
return matchers.Any(matcher => matcher.IsMatch(key));
}
开发者ID:natenho,项目名称:quartznet,代码行数:9,代码来源:QuartzScheduler.cs
示例17: ResumeTrigger
/// <summary>
/// Resume (un-pause) the <see cref="ITrigger" /> with the given
/// name.
/// <para>
/// If the <see cref="ITrigger" /> missed one or more fire-times, then the
/// <see cref="ITrigger" />'s misfire instruction will be applied.
/// </para>
/// </summary>
public virtual void ResumeTrigger(TriggerKey triggerKey)
{
ValidateState();
resources.JobStore.ResumeTrigger(triggerKey);
NotifySchedulerThread(null);
NotifySchedulerListenersResumedTrigger(triggerKey);
}
开发者ID:natenho,项目名称:quartznet,代码行数:16,代码来源:QuartzScheduler.cs
示例18: NotifySchedulerListenersUnscheduled
/// <summary>
/// Notifies the scheduler listeners about job that was unscheduled.
/// </summary>
public virtual void NotifySchedulerListenersUnscheduled(TriggerKey triggerKey)
{
// build a list of all scheduler listeners that are to be notified...
IList<ISchedulerListener> schedListeners = BuildSchedulerListenerList();
// notify all scheduler listeners
foreach (ISchedulerListener sl in schedListeners)
{
try
{
if (triggerKey == null)
{
sl.SchedulingDataCleared();
}
else
{
sl.JobUnscheduled(triggerKey);
}
}
catch (Exception e)
{
log.ErrorFormat(
CultureInfo.InvariantCulture,
"Error while notifying SchedulerListener of unscheduled job. Trigger={0}",
e,
(triggerKey == null ? "ALL DATA" : triggerKey.ToString()));
}
}
}
开发者ID:natenho,项目名称:quartznet,代码行数:32,代码来源:QuartzScheduler.cs
示例19: RescheduleJob
/// <summary>
/// Remove (delete) the <see cref="ITrigger" /> with the
/// given name, and store the new given one - which must be associated
/// with the same job.
/// </summary>
/// <param name="triggerKey">the key of the trigger</param>
/// <param name="newTrigger">The new <see cref="ITrigger" /> to be stored.</param>
/// <returns>
/// <see langword="null" /> if a <see cref="ITrigger" /> with the given
/// name and group was not found and removed from the store, otherwise
/// the first fire time of the newly scheduled trigger.
/// </returns>
public virtual DateTimeOffset? RescheduleJob(TriggerKey triggerKey, ITrigger newTrigger)
{
ValidateState();
if (triggerKey == null)
{
throw new ArgumentException("triggerKey cannot be null");
}
if (newTrigger == null)
{
throw new ArgumentException("newTrigger cannot be null");
}
var trigger = (IOperableTrigger) newTrigger;
ITrigger oldTrigger = GetTrigger(triggerKey);
if (oldTrigger == null)
{
return null;
}
trigger.JobKey = oldTrigger.JobKey;
trigger.Validate();
ICalendar cal = null;
if (newTrigger.CalendarName != null)
{
cal = resources.JobStore.RetrieveCalendar(newTrigger.CalendarName);
}
DateTimeOffset? ft = trigger.ComputeFirstFireTimeUtc(cal);
if (!ft.HasValue)
{
var message = string.Format("Based on configured schedule, the given trigger '{0}' will never fire.", trigger.Key);
throw new SchedulerException(message);
}
if (resources.JobStore.ReplaceTrigger(triggerKey, trigger))
{
NotifySchedulerThread(newTrigger.GetNextFireTimeUtc());
NotifySchedulerListenersUnscheduled(triggerKey);
NotifySchedulerListenersScheduled(newTrigger);
}
else
{
return null;
}
return ft;
}
开发者ID:natenho,项目名称:quartznet,代码行数:62,代码来源:QuartzScheduler.cs
示例20: ResumeTrigger
/// <summary>
/// Resume (un-pause) the <see cref="ITrigger" /> with the given key.
/// </summary>
/// <remarks>
/// If the <see cref="ITrigger" /> missed one or more fire-times, then the
/// <see cref="ITrigger" />'s misfire instruction will be applied.
/// </remarks>
public virtual void ResumeTrigger(TriggerKey triggerKey)
{
lock (lockObject)
{
IOperableTrigger trigger = this.Triggers.FindOneByIdAs<IOperableTrigger>(triggerKey.ToBsonDocument());
// does the trigger exist?
if (trigger == null)
{
return;
}
BsonDocument triggerState = this.Triggers.FindOneByIdAs<BsonDocument>(triggerKey.ToBsonDocument());
// if the trigger is not paused resuming it does not make sense...
if (triggerState["State"] != "Paused" &&
triggerState["State"] != "PausedAndBlocked")
{
return;
}
if (this.BlockedJobs.FindOneByIdAs<BsonDocument>(trigger.JobKey.ToBsonDocument()) != null)
{
triggerState["State"] = "Blocked";
}
else
{
triggerState["State"] = "Waiting";
}
this.ApplyMisfire(trigger);
this.Triggers.Save(triggerState);
}
}
开发者ID:KevinVoell,项目名称:quartznet-mongodb,代码行数:41,代码来源:JobStore.cs
注:本文中的TriggerKey类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论