Ejemplo n.º 1
0
        //public virtual void OnTriggerUp(object sender, TriggerEventArgs e)
        //{
        //    if (TriggerUp != null)
        //        TriggerUp(sender, e);
        //}

        public void ThreadProc()
        {
            bool          bLeftTrigger  = false;
            bool          bRightTrigger = false;
            TriggerStatus triggerStatus = TriggerStatus.NORMAL;

            while (bRuning)
            {
                triggerEvent.WaitOne();

                bLeftTrigger  = SysIoApi.TriggerKeyStatus(SysIoApi.LEFT_TRIGGER_KEY);
                bRightTrigger = SysIoApi.TriggerKeyStatus(SysIoApi.RIGHT_TRIGGER_KEY);

                if (bLeftTrigger || bRightTrigger) //trigger key down
                {
                    triggerEvent.Reset();

                    triggerStatus = TriggerStatus.DOWN;
                    TriggerEventArgs args = new TriggerEventArgs(triggerStatus);
                    OnTriggerDown(this, args);
                }

                Thread.Sleep(100);
            }
        }
        public void ChangeStatus(string newStatus, TriggerStatus expectedStatus)
        {
            var sql = String.Format("ALTER TRIGGER trig1 {0}", newStatus);

            var result = Compile(sql);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.HasErrors);

            Assert.AreEqual(1, result.Statements.Count);

            var statement = result.Statements.ElementAt(0);

            Assert.IsNotNull(statement);
            Assert.IsInstanceOf <AlterTriggerStatement>(statement);

            var alterTrigger = (AlterTriggerStatement)statement;

            Assert.IsNotNull(alterTrigger.TriggerName);
            Assert.IsNotNull(alterTrigger.Action);
            Assert.IsInstanceOf <ChangeTriggerStatusAction>(alterTrigger.Action);

            var action = (ChangeTriggerStatusAction)alterTrigger.Action;

            Assert.AreEqual(expectedStatus, action.Status);
        }
Ejemplo n.º 3
0
        public void ChangeStatus(string newStatus, TriggerStatus expectedStatus)
        {
            var sql = String.Format("ALTER TRIGGER trig1 {0}", newStatus);

            var result = Compile(sql);

            Assert.IsNotNull(result);
            Assert.IsFalse(result.HasErrors);

            Assert.AreEqual(1, result.Statements.Count);

            var statement = result.Statements.ElementAt(0);

            Assert.IsNotNull(statement);
            Assert.IsInstanceOf<AlterTriggerStatement>(statement);

            var alterTrigger = (AlterTriggerStatement) statement;

            Assert.IsNotNull(alterTrigger.TriggerName);
            Assert.IsNotNull(alterTrigger.Action);
            Assert.IsInstanceOf<ChangeTriggerStatusAction>(alterTrigger.Action);

            var action = (ChangeTriggerStatusAction) alterTrigger.Action;

            Assert.AreEqual(expectedStatus, action.Status);
        }
Ejemplo n.º 4
0
        public ChangeTriggerStatusAction(TriggerStatus status)
        {
            if (status == TriggerStatus.Unknown)
                throw new ArgumentException("Invalid status for the action");

            Status = status;
        }
Ejemplo n.º 5
0
        private GenericResult HandleCommand(
            OrderStateMachine.Trigger trigger,
            ITriggerContext context,
            IOrderEditableData editableData = null,
            IOrderDealingData dealingData   = null,
            IOrderCoreData coreData         = null,
            TriggerStatus status            = TriggerStatus.Done)
        {
            Contract.Requires(context != null, "context != null");

            _workingData = CurrentData.Clone()
                           .SetRoutingData(dealingData)
                           .SetEditableData(editableData)
                           .SetTrigger(trigger)
                           .SetPendingTrigger(status.IsPendingReply() && this.PendingTrigger == trigger ? null : this.PendingTrigger);
            var result = EnforceTriggerStatus(trigger, ref status);

            if (result.IsFailure())
            {
                return(result);
            }
            if (status == TriggerStatus.Rejected)
            {
                result = GenericResult.Success();
            }
            else
            {
                var triggerSucceeded = status == TriggerStatus.Pending ? _stateMachine.CanFireTrigger(trigger) : _stateMachine.TryFireTrigger(trigger);
                result = triggerSucceeded ? GenericResult.Success() : GenericResult.Failure(string.Concat(_workingData.StateMachineErrorMessage, String.Format("The commmand {0} is not allowed when the order is in {1} state", trigger, OrderState)));
            }
            if (result.IsSuccess())
            {
                _workingData.SetOrderState(_stateMachine.GetState);
                if (editableData != null)
                {
                    if (coreData != null)
                    {
                        this.InsertDataFrom(coreData);
                    }
                    EventLogs.Add(new OrderParameterEventLog <IOrderEditableData>(context, trigger, status, _workingData.OrderState, this, editableData));
                }
                else if (dealingData != null)
                {
                    EventLogs.Add(new OrderParameterEventLog <IOrderDealingData>(context, trigger, status, _workingData.OrderState, this, dealingData));
                    if (dealingData.Trade != null)
                    {
                        _workingData.SetExecutionQuantity(ComputeExecutionQuantity(_workingData.Side));
                    }
                }
                else
                {
                    EventLogs.Add(new OrderEventLog(context, trigger, status, _workingData.OrderState, this));
                }
                _workingData.SetOrderStatus(ComputeOrderStatus(_workingData));
                RefreshCurrentData(_workingData);
            }
            _workingData = null;
            return(result);
        }
Ejemplo n.º 6
0
 protected EventLog(ITriggerContext context, TTrigger trigger, TriggerStatus triggerStatus, TTState state, TEntity entity)
 {
     Context       = context;
     Trigger       = trigger;
     TriggerStatus = triggerStatus;
     State         = state;
     Entity        = entity;
 }
 ///GENMHASH:06F61EC9451A16F634AEB221D51F2F8C:83A5F71A1B328D8D590BAEBFA00AFA7A
 public TriggerStatus Status()
 {
     if (this.inner.Status == null)
     {
         return(null);
     }
     return(TriggerStatus.Parse(this.inner.Status));
 }
 public Task <int> UpdateStatusAsync(string triggerId, TriggerStatus status)
 {
     return(Connection.UpdateAsync(new TJobTrigger
     {
         Id = triggerId,
         Status = (byte)status
     }, new[] { nameof(TJobTrigger.Status) }, Trans));
 }
Ejemplo n.º 9
0
 public Trigger(Condition condition, float interval = -1)
 {
     this.condition = condition;
     this.interval = interval;
     this.timer = new Timer(interval);
     this.status = TriggerStatus.Pending;
     TriggerRuntime.AddTrigger(this);
 }
        public ChangeTriggerStatusAction(TriggerStatus status)
        {
            if (status == TriggerStatus.Unknown)
            {
                throw new ArgumentException("Invalid status for the action");
            }

            Status = status;
        }
 ///GENMHASH:309B73D93D71EC09DB82348850B4DC3B:D542559E6A88EEE7C1240397E3414E87
 public RegistrySourceTriggerImpl WithTriggerStatus(TriggerStatus triggerStatus)
 {
     if (IsInCreateMode())
     {
         this.inner.Status = triggerStatus.ToString();
     }
     else
     {
         this.sourceTriggerUpdateParameters.Status = triggerStatus.ToString();
     }
     return(this);
 }
Ejemplo n.º 12
0
 public Trigger(Strategy strategy, TriggerType type, DoubleSeries series, double level, Signal signal)
 {
     this.fStrategy       = strategy;
     this.fType           = type;
     this.fSeries         = series;
     this.fLevel          = level;
     this.fSignal         = signal;
     this.fStatus         = TriggerStatus.Active;
     this.fCreationTime   = Clock.Now;
     this.fCompletionTime = DateTime.MinValue;
     this.fStrategy.AddTrigger(this);
     this.Connect();
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Returns true if the trigger exists and the method body of the trigger matches the expected method body.  This exists to handle
        /// the situation where a trigger is created on a table then the schema of the live table or the archive table is altered subsequently.
        ///
        /// <para>The best way to implement this is to regenerate the trigger and compare it to the current code fetched from the ddl</para>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual bool CheckUpdateTriggerIsEnabledAndHasExpectedBody()
        {
            //check server has trigger and it is on
            TriggerStatus isEnabledSimple = GetTriggerStatus();

            if (isEnabledSimple == TriggerStatus.Disabled || isEnabledSimple == TriggerStatus.Missing)
            {
                return(false);
            }

            CheckColumnDefinitionsMatchArchive();

            return(true);
        }
Ejemplo n.º 14
0
        public GenericResult HandleEditionCommand(OrderStateMachine.Trigger trigger,
                                                  ITriggerContext context,
                                                  IOrderEditableData editableData = null,
                                                  IOrderCoreData coreData         = null,
                                                  TriggerStatus status            = TriggerStatus.Done)
        {
            var resultCore = OrderValidator.OrderCoreValidator.IsValid(coreData);

            if (resultCore.IsSuccess())
            {
                var resultEditable = OrderValidator.OrderEditableValidator.IsValid(editableData);
                return(resultEditable.IsSuccess() ? HandleCommand(trigger, context, editableData, null, coreData, status) : resultEditable);
            }
            return(resultCore);
        }
Ejemplo n.º 15
0
        public override void Update(GameTime gameTime)
        {
            if (Status == TriggerStatus.Complete)
            {
                return;
            }

            if (_triggerEvent())
            {
                Status = TriggerStatus.Active;
            }

            if (Status == TriggerStatus.Active && _onTrigger())
            {
                Status = TriggerStatus.Complete;
            }
        }
Ejemplo n.º 16
0
 public Trigger(Strategy strategy, TriggerType type, DoubleSeries series, double level, Signal signal)
     : base()
 {
     this.pEXA4yCenN = Color.Brown;
     this.pZXAJFXyGb = Color.Green;
     this.YCKA0R33mr = Color.DarkGray;
     this.yXsAvQ0snw = true;
     this.wuIAEWD0JW = true;
     this.HKDAVnUw46 = "fdsdf";
     this.nquAKcUOSY = strategy;
     this.k5kAXvwmyK = type;
     this.fISADbUH9Z = series;
     this.J3YAFHAWt0 = level;
     this.eiNALoFbZL = signal;
     this.lh4APrSwVL = TriggerStatus.Active;
     this.a9QA39LDVd = Clock.Now;
     this.gixAsE4W2J = DateTime.MinValue;
     this.nquAKcUOSY.YFmhKSovu(this);
     this.ULWAhR6fQR();
 }
Ejemplo n.º 17
0
        public async Task <DResult> UpdateTriggerStatus(string triggerId, TriggerStatus status)
        {
            var result = await _contract.UpdateTriggerStatusAsync(triggerId, status);

            if (result > 0)
            {
                switch (status)
                {
                case TriggerStatus.Disable:
                    await _scheduler.PauseTrigger(triggerId);

                    break;

                case TriggerStatus.Enable:
                    await _scheduler.ResumeTrigger(triggerId);

                    break;
                }
            }
            return(FromResult(result, "更新触发器状态失败"));
        }
Ejemplo n.º 18
0
 public TriggerEventArgs(TriggerStatus triggerStatus)
 {
     this.triggerStatus = triggerStatus;
 }
Ejemplo n.º 19
0
		private void KWCAC961IE(TriggerStatus obj0)
		{
			this.lh4APrSwVL = obj0;
			this.gixAsE4W2J = Clock.Now;
			this.nquAKcUOSY.l7R1qp1JA(this);
		}
Ejemplo n.º 20
0
 public void Reset()
 {
     status = TriggerStatus.Pending;
     timer.Reset(interval);
 }
Ejemplo n.º 21
0
 public static bool IsFailure(this TriggerStatus triggerStatus)
 {
     return(triggerStatus == TriggerStatus.Failed);
 }
Ejemplo n.º 22
0
 public static bool IsValid(this TriggerStatus triggerStatus)
 {
     return(triggerStatus == TriggerStatus.Accepted || triggerStatus == TriggerStatus.Done);
 }
 /// <summary>
 /// The function that defines a base image trigger with all possible parameters for base image trigger creation.
 /// </summary>
 /// <param name="baseImageTriggerName">The name of the base image trigger.</param>
 /// <param name="baseImageTriggerType">The trigger type for the base image. Can be "All", "Runtime", or something else that the user inputs.</param>
 /// <param name="triggerStatus">The status for the trigger. Can be enabled, disabled, or something else that the user inputs.</param>
 /// <return>The next stage of the container registry task definition.</return>
 RegistryTask.Definition.ITaskCreatable RegistryTask.Definition.ITriggerTypes.WithBaseImageTrigger(string baseImageTriggerName, BaseImageTriggerType baseImageTriggerType, TriggerStatus triggerStatus)
 {
     return(this.WithBaseImageTrigger(baseImageTriggerName, baseImageTriggerType, triggerStatus));
 }
Ejemplo n.º 24
0
 private void _TriggerSet(uint idxCurrent)
 {
     Status = TriggerStatus.Trigd;
     idxTrigger = idxCurrent;
 }
Ejemplo n.º 25
0
 public OrderParameterEventLog(ITriggerContext context, OrderStateMachine.Trigger trigger,
                               TriggerStatus triggerStatus, OrderStateMachine.State state, IOrder order, TParam parameters)
     : base(context, trigger, triggerStatus, state, order)
 {
     Parameters = parameters;
 }
Ejemplo n.º 26
0
        private void UpdateMode()
        {
            switch( Mode)
            {
                case TriggerMode.Scan:
                    Status = TriggerStatus.Scan;
                    break;
                case TriggerMode.Normal:
                    Status = TriggerStatus.Armed;
                    break;
                default:
                    Status = TriggerStatus.Scan;
                    break;
            }

            return;
        }
Ejemplo n.º 27
0
 private GenericResult EnforceTriggerStatus(OrderStateMachine.Trigger trigger, ref TriggerStatus triggerStatus)
 {
     if (IsTriggerHandlePending(trigger))
     {
         if (_workingData.PendingTrigger != null)
         {
             if (triggerStatus.IsPending())
             {
                 return(GenericResult.FailureFormat("There is already a {0} pending command. You must handle it before", _workingData.PendingTrigger));
             }
             if (trigger != _workingData.PendingTrigger)
             {
                 return(GenericResult.FailureFormat("There is a {0} pending not a {1}. You cannot {0} it", _workingData.PendingTrigger, trigger, triggerStatus));
             }
             _workingData.SetPendingTrigger(null);
         }
         else
         {
             triggerStatus = TriggerStatus.Pending;
         }
     }
     else if (triggerStatus.IsPending() || triggerStatus.IsPendingReply())
     {
         return(GenericResult.FailureFormat("The command {0} could not be {1}. No pending required", trigger, triggerStatus));
     }
     return(GenericResult.Success());
 }
Ejemplo n.º 28
0
 public static void ChangeTriggerStatus(this IQuery query, ObjectName triggerName, TriggerStatus status)
 {
     query.AlterTrigger(triggerName, new ChangeTriggerStatusAction(status));
 }
Ejemplo n.º 29
0
 public void Resume()
 {
     status = TriggerStatus.Pending;
 }
Ejemplo n.º 30
0
		public Trigger(Strategy strategy, TriggerType type, DoubleSeries series, double level, Signal signal)
			: base()
		{
			this.pEXA4yCenN = Color.Brown;
			this.pZXAJFXyGb = Color.Green;
			this.YCKA0R33mr = Color.DarkGray;
			this.yXsAvQ0snw = true;
			this.wuIAEWD0JW = true;
			this.HKDAVnUw46 = "fdsdf";
			this.nquAKcUOSY = strategy;
			this.k5kAXvwmyK = type;
			this.fISADbUH9Z = series;
			this.J3YAFHAWt0 = level;
			this.eiNALoFbZL = signal;
			this.lh4APrSwVL = TriggerStatus.Active;
			this.a9QA39LDVd = Clock.Now;
			this.gixAsE4W2J = DateTime.MinValue;
			this.nquAKcUOSY.YFmhKSovu(this);
			this.ULWAhR6fQR();
		}
        /// <summary>
        /// Select a trigger status (state and next fire time).
        /// </summary>
        /// <param name="conn">the DB Connection</param>
        /// <param name="triggerName">the name of the trigger</param>
        /// <param name="groupName">the group containing the trigger</param>
        /// <returns>
        /// a <see cref="TriggerStatus" /> object, or null
        /// </returns>
        public virtual TriggerStatus SelectTriggerStatus(ConnectionAndTransactionHolder conn, string triggerName,
                                                         string groupName)
        {
            using (IDbCommand cmd = PrepareCommand(conn, ReplaceTablePrefix(SqlSelectTriggerStatus)))
            {
                TriggerStatus status = null;

                AddCommandParameter(cmd, 1, "triggerName", triggerName);
                AddCommandParameter(cmd, 2, "triggerGroup", groupName);
                using (IDataReader rs = cmd.ExecuteReader())
                {
                    if (rs.Read())
                    {
                        string state = GetString(rs[ColumnTriggerState]);
                        long nextFireTime = Convert.ToInt64(rs[ColumnNextFireTime], CultureInfo.InvariantCulture);
                        string jobName = GetString(rs[ColumnJobName]);
                        string jobGroup = GetString(rs[ColumnJobGroup]);

                        NullableDateTime nft = null;

                        if (nextFireTime > 0)
                        {
                            nft = new DateTime(nextFireTime);
                        }

                        status = new TriggerStatus(state, nft);
                        status.Key = new Key(triggerName, groupName);
                        status.JobKey = new Key(jobName, jobGroup);
                    }
                }
                return status;
            }
        }
Ejemplo n.º 32
0
 public TradeEventLog(Interfaces.Models.ITriggerContext context, TradeTrigger trigger, TriggerStatus triggerStatus, TradeState state, ITrade trade = null)
     : base(context, trigger, triggerStatus, state, trade)
 {
 }
 /// <summary>
 /// The function that defines a base image trigger with all possible parameters for base image trigger update.
 /// </summary>
 /// <param name="baseImageTriggerName">The name of the base image trigger.</param>
 /// <param name="baseImageTriggerType">The trigger type for the base image. Can be "All", "Runtime", or something else that the user inputs.</param>
 /// <param name="triggerStatus">The status for the trigger. Can be enabled, disabled, or something else that the user inputs.</param>
 /// <return>The next stage of the container registry task update.</return>
 RegistryTask.Update.IUpdate RegistryTask.Update.ITriggerTypes.UpdateBaseImageTrigger(string baseImageTriggerName, BaseImageTriggerType baseImageTriggerType, TriggerStatus triggerStatus)
 {
     return(this.UpdateBaseImageTrigger(baseImageTriggerName, baseImageTriggerType, triggerStatus));
 }
Ejemplo n.º 34
0
 private void UpdateStatus(TriggerStatus newStatus)
 {
     Status = newStatus;
     delay  = 0;
 }
Ejemplo n.º 35
0
 public static bool IsPendingReply(this TriggerStatus triggerStatus)
 {
     return(triggerStatus == TriggerStatus.Rejected || triggerStatus == TriggerStatus.Accepted);
 }
Ejemplo n.º 36
0
    // Use this for initialization
    void Start()
    {
        Status = TriggerStatus.None;

        CollidedObj = null;
    }
Ejemplo n.º 37
0
 public static bool IsPending(this TriggerStatus triggerStatus)
 {
     return(triggerStatus == TriggerStatus.Pending);
 }
        public override SqlStatement VisitCreateTriggerStatement(PlSqlParser.CreateTriggerStatementContext context)
        {
            var triggerName = Name.Object(context.objectName());
            var orReplace   = context.OR() != null && context.REPLACE() != null;

            TriggerStatus status = TriggerStatus.Unknown;

            if (context.DISABLE() != null)
            {
                status = TriggerStatus.Disabled;
            }
            else if (context.ENABLE() != null)
            {
                status = TriggerStatus.Enabled;
            }

            var simpleDml = context.simpleDmlTrigger();

            ObjectName       onObject  = null;
            TriggerEventType eventType = new TriggerEventType();
            TriggerEventTime eventTime = new TriggerEventTime();

            if (simpleDml != null)
            {
                bool before = simpleDml.BEFORE() != null;
                bool after  = simpleDml.AFTER() != null;

                var events = simpleDml.dmlEventClause().dmlEventElement().Select(x => {
                    if (x.DELETE() != null)
                    {
                        return(TriggerEventType.Delete);
                    }
                    if (x.UPDATE() != null)
                    {
                        return(TriggerEventType.Update);
                    }
                    if (x.INSERT() != null)
                    {
                        return(TriggerEventType.Insert);
                    }

                    throw new InvalidOperationException();
                });

                foreach (var type in events)
                {
                    eventType |= type;
                }

                if (before)
                {
                    eventTime = TriggerEventTime.Before;
                }
                else if (after)
                {
                    eventTime = TriggerEventTime.After;
                }

                onObject = Name.Object(simpleDml.dmlEventClause().objectName());
            }

            var triggerBody = context.triggerBody();

            if (triggerBody.triggerBlock() != null)
            {
                var declarations = triggerBody.triggerBlock().declaration().Select(Visit);
                var body         = (PlSqlBody)Visit(triggerBody.triggerBlock().body());

                var plsqlBody = body.AsPlSqlStatement();
                foreach (var declaration in declarations)
                {
                    plsqlBody.Declarations.Add(declaration);
                }

                return(new CreateTriggerStatement(triggerName, onObject, plsqlBody, eventTime, eventType)
                {
                    ReplaceIfExists = orReplace,
                    Status = status
                });
            }

            var procName = Name.Object(triggerBody.objectName());
            var args     = new InvokeArgument[0];

            if (triggerBody.function_argument() != null)
            {
                args = triggerBody.function_argument()
                       .argument()
                       .Select(FunctionArgument.Form)
                       .Select(x => new InvokeArgument(x.Id, x.Expression))
                       .ToArray();
            }

            return(new CreateProcedureTriggerStatement(triggerName, onObject, procName, args, eventTime, eventType)
            {
                ReplaceIfExists = orReplace,
                Status = status
            });
        }
Ejemplo n.º 39
0
 public static bool IsUnvalid(this TriggerStatus triggerStatus)
 {
     return(triggerStatus == TriggerStatus.Rejected || triggerStatus == TriggerStatus.Failed ||
            triggerStatus == TriggerStatus.Pending);
 }
Ejemplo n.º 40
0
 public void Pause()
 {
     status = TriggerStatus.Paused;
 }
Ejemplo n.º 41
0
 public Task <int> UpdateTriggerStatusAsync(string triggerId, TriggerStatus status)
 {
     return(_triggerRepository.UpdateStatusAsync(triggerId, status));
 }
Ejemplo n.º 42
0
 public void ResetTrigger()
 {
     Status = TriggerStatus.Armed;
     idxTrigger = 0;
 }