Exemplo n.º 1
0
        public void Cancel()
        {
            if (State != CommandStates.Trying)
            {
                if (State != CommandStates.Rollback)
                {
                    CommanderReader.DispatchNack(Node, MessageId, TrackingExtraData, ResponseDispatcher);
                }

                STrace.Debug(typeof(DeviceCommand).FullName, Node.Id, String.Format("CMD: State={0} MessageId={1} SecondsTimeout={2} Cancel No se inicia por estado invalido.", State, MessageId, SecondsTimeout));
                return;
            }

            State = CommandStates.TryingCancel;
            CommanderReader.DispatchNack(Node, MessageId, TrackingExtraData, ResponseDispatcher);

            if (Timer == null)
            {
                return;
            }
            Timer.Change(10000, Timeout.Infinite);
        }
Exemplo n.º 2
0
        public static void CreateCommand(INode node, IDataTransportLayer disp, ulong messageId, int gatewayMessageId, int timeout, Action action, String trackingExtraData, CommanderReader commanderReader)
        {
            var command = new DeviceCommand(messageId, gatewayMessageId, node, disp, timeout, trackingExtraData);

            GetDeviceList(node.GetDeviceId()).Add(command);
            try
            {
                if (node == null)
                {
                    throw new ArgumentNullException("node");
                }

                node.ExecuteOnGuard(action.Invoke, "CreateCommand", "");
                command.Begin();
            }
            catch
            {
                command.Rollback();
                GetDeviceList(node.Id).Remove(command);
                throw;
            }
        }