本文整理汇总了C#中JobKey.ToBsonDocument方法的典型用法代码示例。如果您正苦于以下问题:C# JobKey.ToBsonDocument方法的具体用法?C# JobKey.ToBsonDocument怎么用?C# JobKey.ToBsonDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JobKey
的用法示例。
在下文中一共展示了JobKey.ToBsonDocument方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveJob
/// <summary>
/// Remove (delete) the <see cref="IJob" /> with the given
/// name, and any <see cref="ITrigger" /> s that reference
/// it.
/// </summary>
/// <returns>
/// <see langword="true" /> if a <see cref="IJob" /> with the given name and
/// group was found and removed from the store.
/// </returns>
public virtual bool RemoveJob(JobKey jobKey)
{
bool found;
lock (lockObject)
{
// keep separated to clean up any staled trigger
IList<IOperableTrigger> triggersForJob = this.GetTriggersForJob(jobKey);
foreach (IOperableTrigger trigger in triggersForJob)
{
this.RemoveTrigger(trigger.Key);
}
found = this.CheckExists(jobKey);
if (found)
{
this.Jobs.Remove(
Query.EQ("_id", jobKey.ToBsonDocument()));
this.BlockedJobs.Remove(
Query.EQ("_id", jobKey.ToBsonDocument()));
var others = this.Jobs.FindAs<BsonDocument>(
Query.EQ("Group", jobKey.Group));
if (others.Count() == 0)
{
this.PausedJobGroups.Remove(
Query.EQ("_id", jobKey.Group));
}
}
}
return found;
}
示例2: CheckExists
/// <summary>
/// Determine whether a <see cref="IJob"/> with the given identifier already
/// exists within the scheduler.
/// </summary>
/// <param name="jobKey">the identifier to check for</param>
/// <returns>true if a Job exists with the given identifier</returns>
public bool CheckExists(JobKey jobKey)
{
lock (lockObject)
{
return this.Jobs.FindOneByIdAs<BsonDocument>(jobKey.ToBsonDocument()) != null;
}
}
示例3: GetTriggersForJob
/// <summary>
/// Get all of the Triggers that are associated to the given Job.
/// <para>
/// If there are no matches, a zero-length array should be returned.
/// </para>
/// </summary>
public virtual IList<IOperableTrigger> GetTriggersForJob(JobKey jobKey)
{
lock (lockObject)
{
return this.Triggers
.FindAs<Spi.IOperableTrigger>(
Query.EQ("JobKey", jobKey.ToBsonDocument()))
.ToList();
}
}
示例4: RetrieveJob
/// <summary>
/// Retrieve the <see cref="IJobDetail" /> for the given
/// <see cref="IJob" />.
/// </summary>
/// <returns>
/// The desired <see cref="IJob" />, or null if there is no match.
/// </returns>
public virtual IJobDetail RetrieveJob(JobKey jobKey)
{
lock (lockObject)
{
return this.Jobs
.FindOneByIdAs<IJobDetail>(jobKey.ToBsonDocument());
}
}
示例5: RetrieveJob
/// <summary>
/// Retrieve the <see cref="IJobDetail" /> for the given
/// <see cref="IJob" />.
/// </summary>
/// <returns>
/// The desired <see cref="IJob" />, or null if there is no match.
/// </returns>
public IJobDetail RetrieveJob(JobKey jobKey)
{
try
{
var jobInfo = JobCollection.FindOneById(jobKey.ToBsonDocument());
return jobInfo.Job;
}
catch (Exception e)
{
throw new JobPersistenceException("Couldn't retrieve job: " + e.Message, e);
}
}
示例6: GetTriggersForJob
/// <summary>
/// Get all of the Triggers that are associated to the given Job.
/// </summary>
/// <remarks>
/// If there are no matches, a zero-length array should be returned.
/// </remarks>
public IList<IOperableTrigger> GetTriggersForJob(JobKey jobKey)
{
var id = jobKey.ToBsonDocument();
var jobInfo = JobCollection.FindOneById(id);
foreach (var triggerInfo in jobInfo.Triggers)
{
triggerInfo.Trigger.Key = triggerInfo.Id;
triggerInfo.Trigger.JobKey = jobKey;
}
var triggers = jobInfo.Triggers.Select(x => x.Trigger);
return triggers.ToList();
}
示例7: CheckExists
/// <summary>
/// Determine whether a <see cref="IJob" /> with the given identifier already
/// exists within the scheduler.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="jobKey">the identifier to check for</param>
/// <returns>true if a job exists with the given identifier</returns>
public bool CheckExists(JobKey jobKey)
{
var id = jobKey.ToBsonDocument();
var count = JobCollection.Count(Query.EQ("_id", id));
return (count > 0);
}
示例8: DeleteJob
private void DeleteJob(JobKey key)
{
var query = Query.EQ("_id", key.ToBsonDocument());
JobCollection.Remove(query);
}