/// <inheritdoc /> public async Task ExecuteAsync(OperationExecutionContext <SessionState, TaskState> context) { var operation = context.Operation; // Sample of immutable state context.NewState = operation.State.WithResult(operation.State.Number * 2); // long work imitation await Task.Delay(100, context.Cancellation); // example of child activity using (context.Tracer.StartActivity("db")) { await Task.Delay(200); } using (context.Tracer.StartActivity("ext_api")) { await Task.Delay(300); } await Task.Delay(100, context.Cancellation); // Session can be accessed context.Session.Messages.Add(new Message($"Input: {operation.State.Number}, Result: {operation.State.Result}")); }
/// <inheritdoc/> public KeyMapping Replay(Session session) { if (session.Operations.IsRegisteringOperation) { throw new InvalidOperationException(Strings.ExRunningOperationRegistrationMustBeFinished); } var executionContext = new OperationExecutionContext(session); bool isSystemOperationLog = LogType == OperationLogType.SystemOperationLog; KeyMapping keyMapping = null; Transaction transaction = null; using (session.Activate()) { using (isSystemOperationLog ? session.OpenSystemLogicOnlyRegion() : null) using (var tx = session.OpenTransaction(TransactionOpenMode.New)) { foreach (var operation in operations) { operation.Prepare(executionContext); } session.Query.Many <Entity>(executionContext.KeysToPrefetch).Run(); foreach (var operation in operations) { var identifierToKey = new Dictionary <string, Key>(); var handler = new EventHandler <OperationCompletedEventArgs>((sender, e) => { foreach (var pair in e.Operation.IdentifiedEntities) { identifierToKey.Add(pair.Key, pair.Value); } }); session.Operations.OutermostOperationCompleted += handler; try { operation.Execute(executionContext); } finally { session.Operations.OutermostOperationCompleted -= handler; } foreach (var pair in operation.IdentifiedEntities) { string identifier = pair.Key; var oldKey = pair.Value; var newKey = identifierToKey.GetValueOrDefault(identifier); if (newKey != null) { executionContext.AddKeyMapping(oldKey, newKey); } } } keyMapping = new KeyMapping(executionContext.KeyMapping); tx.Complete(); } return(keyMapping); } }
/// <inheritdoc/> public void Execute(OperationExecutionContext context) { foreach (var operation in PrecedingOperations) { operation.Execute(context); } ExecuteSelf(context); foreach (var operation in FollowingOperations) { operation.Execute(context); } }
public IAcisSMEOperationResponse DeletePublisher(string Subscription, string PublisherCode, string approver, string approverLink, IAcisSMEEndpoint endpoint, IAcisSMEOperationProgressUpdater updater, OperationExecutionContext context) { SmeRdfeHelper helper = new SmeRdfeHelper(endpoint, updater, this, context); return(helper.DeletePublisher(Subscription, PublisherCode)); }
public IAcisSMEOperationResponse ListServiceSettings(IAcisSMEEndpoint endpoint, IAcisSMEOperationProgressUpdater updater, OperationExecutionContext context) { SmeRdfeHelper helper = new SmeRdfeHelper(endpoint, updater, this, context); return(helper.ListServiceSettings()); }
public OperationResult Execute(OperationExecutionContext context) { return(new OperationResult { Value = context.Arguments.First().Value }); }
/// <summary> /// Executes the operation itself. /// </summary> /// <param name="context">The operation execution context.</param> protected abstract void ExecuteSelf(OperationExecutionContext context);
public IAcisSMEOperationResponse DeleteServiceSetting(string name, string approver, string approverLink, IAcisSMEEndpoint endpoint, IAcisSMEOperationProgressUpdater updater, OperationExecutionContext context) { SmeRdfeHelper helper = new SmeRdfeHelper(endpoint, updater, this, context); return(helper.DeleteServiceSetting(name)); }
public IAcisSMEOperationResponse UnregisterCacheAccount(string accountname, string approver, string approverLink, IAcisSMEEndpoint endpoint, IAcisSMEOperationProgressUpdater updater, OperationExecutionContext context) { SmeRdfeHelper helper = new SmeRdfeHelper(endpoint, updater, this, context); return(helper.UnregisterCacheAccount(accountname)); }
public IAcisSMEOperationResponse RegisterCacheAccount(string cacheAccountName, string cacheAccountCurrentKeyIndex, string location, string cacheAccountStampName, string cacheAccountIsStampActive, string cacheAccountTypeOfCache, string approver, string approverLink, IAcisSMEEndpoint endpoint, IAcisSMEOperationProgressUpdater updater, OperationExecutionContext context) { SmeRdfeHelper helper = new SmeRdfeHelper(endpoint, updater, this, context); return(helper.RegisterCacheAccount(cacheAccountName, cacheAccountCurrentKeyIndex, location, cacheAccountStampName, cacheAccountIsStampActive, cacheAccountTypeOfCache)); }
public IAcisSMEOperationResponse RotateCacheAccountKey(string cacheAccountName, string approver, string approverLink, IAcisSMEEndpoint endpoint, IAcisSMEOperationProgressUpdater updater, OperationExecutionContext context) { SmeRdfeHelper helper = new SmeRdfeHelper(endpoint, updater, this, context); return(helper.RotateCacheAccountKey(cacheAccountName)); }