public void HandleEvent(CommandCompleted eventHandled)
        {
            #region Logging
            if (null != log)
            {
                log.LogDebug($"HandleEvent( CommandCompleted )",
                             nameof(Command_Summary_Projection));
            }
            #endregion

            if (null != eventHandled)
            {
                // Set the status as "processed"
                base.AddOrUpdateValue <CommandState>(nameof(CurrentState), 0, CommandState.Completed);
            }
            else
            {
                #region Logging
                if (null != log)
                {
                    log.LogWarning($"HandleEvent( CommandCompleted ) - parameter was null",
                                   nameof(Command_Summary_Projection));
                }
                #endregion
            }
        }
        public void PassThrough()
        {
            var context    = Substitute.For <IUpstreamContext>();
            var state      = new CommandCompleted(new DispatchCommand(new FakeCommand(), 3));
            var dispatcher = new RetryingHandler(3);

            dispatcher.HandleUpstream(context, state);

            context.Received().SendUpstream(Arg.Any <CommandCompleted>());
        }
Ejemplo n.º 3
0
 internal void RaiseCommandCompletedEvent(string requestId, int result, IntPtr bundleHandle)
 {
     if (bundleHandle != IntPtr.Zero)
     {
         CommandCompleted?.Invoke(this, new CommandCompletedEventArgs(requestId, result, new Bundle(new SafeBundleHandle(bundleHandle, true))));
     }
     else
     {
         CommandCompleted?.Invoke(this, new CommandCompletedEventArgs(requestId, result));
     }
 }
        public void HandleEvent(CommandCompleted eventHandled)
        {
            #region Logging
            if (null != log)
            {
                log.LogDebug($"HandleEvent( CommandCompleted )",
                             nameof(Command_Notifications_Projection));
            }
            #endregion

            if (null != eventHandled)
            {
                complete = true;
            }
        }
Ejemplo n.º 5
0
 private static void RegisterCommandCompletedEvent()
 {
     _commandCompletedCallback = (clientName, requestId, result, bundleHandle, _) =>
     {
         if (bundleHandle != IntPtr.Zero)
         {
             CommandCompleted?.Invoke(null, new CommandCompletedEventArgs(requestId, result, new Bundle(new SafeBundleHandle(bundleHandle, true))));
         }
         else
         {
             CommandCompleted?.Invoke(null, new CommandCompletedEventArgs(requestId, result));
         }
     };
     Native.SetEventReceivedCb(Handle, _commandCompletedCallback).
     ThrowIfError("Failed to init RegisterEventCompletedEvent.");
 }
Ejemplo n.º 6
0
        public static async Task <ActivityResponse> CommandCompleteActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            ActivityResponse ret = new ActivityResponse()
            {
                FunctionName = "CommandCompleteActivity"
            };

            try
            {
                CommandRequest <object> cmdResponse = context.GetInput <CommandRequest <object> >();

                if (null != cmdResponse)
                {
                    // Create a new "command completed" event
                    CommandCompleted commandCompletedEvent = new CommandCompleted()
                    {
                        Date_Completed = DateTime.UtcNow,
                        Notes          = cmdResponse.Status
                    };

                    EventStream commandEvents = EventStream.Create(Constants.Domain_Command,
                                                                   cmdResponse.CommandName,
                                                                   cmdResponse.CommandUniqueIdentifier.ToString());

                    if ((null != commandEvents) && (null != commandCompletedEvent))
                    {
                        await commandEvents.AppendEvent(commandCompletedEvent);
                    }
                }
            }
            catch (Exception ex)
            {
                ret.Message = $"Error marking command complete : {ex.Message }";
            }

            return(ret);
        }
 public Result OnCommandCompleted(Result res)
 {
     CommandCompleted?.Invoke(this, res);
     return(res);
 }
Ejemplo n.º 8
0
 void OnCommandCompleted()
 {
     Runtime.RunInMainThread(() => {
         CommandCompleted?.Invoke(this, EventArgs.Empty);
     }).WaitAndGetResult();
 }
Ejemplo n.º 9
0
        private void ExecuteCommand(ConstructorInfo constructorInfo, CommandLineObjectPicker picker)
        {
            List <object> parameterValues = new List <object>();
            bool          complainAboutExtraParameters = true;

            int idx = 0;

            //for each parameter on the constructor we want to invoke
            foreach (var parameterInfo in constructorInfo.GetParameters())
            {
                var required = new RequiredArgument(parameterInfo);

                var argDelegate = GetDelegate(required);

                //if it is an easy one to automatically fill e.g. IBasicActivateItems
                if (argDelegate != null && argDelegate.IsAuto)
                {
                    parameterValues.Add(argDelegate.Run(required));
                }
                else
                //if the constructor argument is a picker, use the one passed in
                if (parameterInfo.ParameterType == typeof(CommandLineObjectPicker))
                {
                    if (picker == null)
                    {
                        throw new ArgumentException($"Type {constructorInfo.DeclaringType} contained a constructor which took an {parameterInfo.ParameterType} but no picker was passed");
                    }

                    parameterValues.Add(picker);

                    //the parameters are expected to be consumed by the target constructors so it's not really a problem if there are extra
                    complainAboutExtraParameters = false;
                    continue;
                }
                else
                //if we have argument values specified
                if (picker != null)
                {
                    //and the specified value matches the expected parameter type
                    if (picker.HasArgumentOfType(idx, parameterInfo.ParameterType))
                    {
                        //consume a value
                        parameterValues.Add(picker[idx].GetValueForParameterOfType(parameterInfo.ParameterType));
                        idx++;
                        continue;
                    }

                    throw new Exception($"Expected parameter at index {idx} to be a {parameterInfo.ParameterType} (for parameter '{parameterInfo.Name}') but it was {(idx >= picker.Length ? "Missing":picker[idx].RawValue)}");
                }
                else
                {
                    parameterValues.Add(GetValueForParameterOfType(parameterInfo));
                }
            }

            if (picker != null && idx < picker.Length && complainAboutExtraParameters)
            {
                throw new Exception("Unrecognised extra parameter " + picker[idx].RawValue);
            }

            var instance = (IAtomicCommand)constructorInfo.Invoke(parameterValues.ToArray());

            if (instance.IsImpossible)
            {
                CommandImpossible?.Invoke(this, new CommandEventArgs(instance));
                return;
            }

            instance.Execute();
            CommandCompleted?.Invoke(this, new CommandEventArgs(instance));
        }
 void OnCommandCompleted(object sender, EventArgs e)
 {
     CommandCompleted?.Invoke(this, e);
 }