本文整理汇总了C#中IWriteOnlyTransaction类的典型用法代码示例。如果您正苦于以下问题:C# IWriteOnlyTransaction类的具体用法?C# IWriteOnlyTransaction怎么用?C# IWriteOnlyTransaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IWriteOnlyTransaction类属于命名空间,在下文中一共展示了IWriteOnlyTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.AddToSet(
"failed",
context.JobId,
JobHelper.ToTimestamp(DateTime.UtcNow));
}
示例2: FailedStateHandlerFacts
public FailedStateHandlerFacts()
{
_context = new ApplyStateContextMock();
_context.StateContextValue.JobIdValue = JobId;
_context.NewStateValue = new FailedState(new InvalidOperationException());
_transaction = Substitute.For<IWriteOnlyTransaction>();
}
示例3: Apply
public override void Apply(
ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.AddToSet(
"processing",
context.JobId,
JobHelper.ToTimestamp(DateTime.UtcNow));
}
示例4: OnStateUnapplied
public void OnStateUnapplied(
ApplyStateContext context, IWriteOnlyTransaction transaction)
{
Assert.NotNull(context);
Assert.NotNull(transaction);
_results.Add(String.Format("{0}::{1}", _name, "OnStateUnapplied"));
}
示例5: ProcessingStateHandlerFacts
public ProcessingStateHandlerFacts()
{
_context = new ApplyStateContextMock();
_context.StateContextValue.JobIdValue = JobId;
_context.NewStateValue = new ProcessingState("server", 1);
_transaction = Substitute.For<IWriteOnlyTransaction>();
}
示例6: DeletedStateHandlerFacts
public DeletedStateHandlerFacts()
{
_context = new ApplyStateContextMock();
_context.StateContextValue.JobIdValue = JobId;
_context.NewStateValue = new DeletedState();
_transaction = Substitute.For<IWriteOnlyTransaction>();
}
示例7: SucceededStateHandlerFacts
public SucceededStateHandlerFacts()
{
_context = new ApplyStateContextMock();
_context.StateContextValue.JobIdValue = JobId;
_context.NewStateValue = new SucceededState(null, 11, 123);
_transaction = Substitute.For<IWriteOnlyTransaction>();
}
示例8: OnStateApplied
public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
var awaitingState = context.NewState as AwaitingState;
if (awaitingState != null)
{
context.JobExpirationTimeout = awaitingState.Expiration;
}
}
示例9: OnStateApplied
public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
var failedState = context.NewState as FailedState;
if (failedState != null)
{
Logger.ErrorException(
String.Format("Background job #{0} was failed with an exception.", context.JobId),
failedState.Exception);
}
}
示例10: Apply
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
var enqueuedState = context.NewState as EnqueuedState;
if (enqueuedState == null)
{
throw new InvalidOperationException(String.Format(
"`{0}` state handler can be registered only for the Enqueued state.",
typeof(Handler).FullName));
}
transaction.AddToQueue(enqueuedState.Queue, context.JobId);
}
示例11: Apply
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
var scheduledState = context.NewState as ScheduledState;
if (scheduledState == null)
{
throw new InvalidOperationException(String.Format(
"`{0}` state handler can be registered only for the Scheduled state.",
typeof(Handler).FullName));
}
var timestamp = JobHelper.ToTimestamp(scheduledState.EnqueueAt);
transaction.AddToSet("schedule", context.JobId, timestamp);
}
示例12: ApplyState
public void ApplyState(IWriteOnlyTransaction transaction, ApplyStateContext context)
{
var filterInfo = GetFilters(context.Job);
var filters = filterInfo.ApplyStateFilters;
foreach (var state in context.TraversedStates)
{
transaction.AddJobState(context.JobId, state);
}
foreach (var handler in _handlers.GetHandlers(context.OldStateName))
{
handler.Unapply(context, transaction);
}
foreach (var filter in filters)
{
filter.OnStateUnapplied(context, transaction);
}
transaction.SetJobState(context.JobId, context.NewState);
foreach (var handler in _handlers.GetHandlers(context.NewState.Name))
{
handler.Apply(context, transaction);
}
foreach (var filter in filters)
{
filter.OnStateApplied(context, transaction);
}
if (context.NewState.IsFinal)
{
transaction.ExpireJob(context.JobId, context.JobExpirationTimeout);
}
else
{
transaction.PersistJob(context.JobId);
}
}
示例13: Apply
public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.InsertToList("deleted", context.BackgroundJob.Id);
transaction.TrimList("deleted", 0, 99);
}
示例14: Unapply
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.RemoveFromList("deleted", context.BackgroundJob.Id);
}
示例15: Unapply
public void Unapply(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
transaction.DecrementCounter("stats:deleted");
}