public OrchestrationWorkflow(IOrchestrationCommand orch, ISyncCommand sync, IOrderCloudIntegrationsFunctionToken token, LogQuery log)
 {
     _orch  = orch;
     _sync  = sync;
     _log   = log;
     _token = token;
 }
 /****************************************************************************************************
  * 
  ****************************************************************************************************/
 /// <summary>
 /// Calls the handler for the command
 /// </summary>
 public void DispatchCommand(ISyncCommand command)
 {
     { var arg = command as AddEntryCommand;     if (arg != null) { _handler.AddValue    (arg.TrackIndex, arg.TrackEntry); return; } }
     { var arg = command as RemoveEntryCommand;  if (arg != null) { _handler.DeleteValue (arg.TrackIndex, arg.RowIndex);   return; } }
     { var arg = command as SetRowIndexCommand;  if (arg != null) { _handler.SetRowIndex (arg.RowIndex);                   return; } }
     { var arg = command as SetPauseCommand;     if (arg != null) { _handler.SetPause    (arg.IsPaused);                   return; } }
     { var arg = command as ExportCommand;       if (arg != null) { _handler.Export      ();                               return; } }
     throw new SyncException(string.Format("Unknown Sync Command: {0}", command.GetType().Name));
 }
Exemplo n.º 3
0
        /// <inheritdoc cref="ISyncCommandMediary.Command{TContext,TResult}"/>
        public virtual TResult Command <TContext, TResult>(ISyncCommand <TContext, TResult> command, TContext context)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(Decorator.Decorate(GetOperationName(command, nameof(command.Execute)), () => command.Execute(context)));
        }
Exemplo n.º 4
0
        public virtual void Command <TContext>(ISyncCommand <TContext> command, TContext context)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            Decorator.Decorate(command, () => command.Execute(context));
        }
Exemplo n.º 5
0
 public virtual TResult Command <TContext, TResult>(ISyncCommand <TContext, TResult> command)
 {
     return(Invoker.Command(command, GetContext <TContext>()));
 }
Exemplo n.º 6
0
 public virtual void Command <TContext>(ISyncCommand <TContext> command)
 {
     Invoker.Command(command, GetContext <TContext>());
 }
 /****************************************************************************************************
  * Serialization
  ****************************************************************************************************/
 public void SerializeCommand(ISyncCommand command)
 {
     switch (command.Id)
     {
         case CommandId.RequestTrack:
         {
             Write((byte)command.Id);
             Write((command as RequestTrackCommand).TrackName);
             break;
         }
         case CommandId.SetRowIndex:
         {
             Write((byte)command.Id);
             Write((command as SetRowIndexCommand).RowIndex);
             break;
         }
         default:
             throw new SyncException(string.Format("Unable to serialize sync command: {0} ", command.Id));
     }
 }
Exemplo n.º 8
0
 /// <inheritdoc cref="ISyncCommandMagneto.Command{TContext,TResult}"/>
 public virtual TResult Command <TContext, TResult>(ISyncCommand <TContext, TResult> command) =>
 Mediary.Command(command, GetContext <TContext>());
Exemplo n.º 9
0
 /// <inheritdoc cref="ISyncCommandMagneto.Command{TContext}"/>
 public virtual void Command <TContext>(ISyncCommand <TContext> command) =>
 Mediary.Command(command, GetContext <TContext>());