Beispiel #1
0
        public string GetLastExecutionDescription()
        {
            if (LastExecution == null)
            {
                return("None");
            }

            return(LastExecution.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// Gets the next execution time for a specific scheduler instruction
        /// </summary>
        /// <param name="schedulerInstruction">the scheduler instruction that was provided for a specific task</param>
        /// <returns>the next execution time for the task</returns>
        private DateTime GetNextExecutionTime(string schedulerInstruction)
        {
            int seconds;

            if (int.TryParse(schedulerInstruction, out seconds))
            {
                return(LastExecution.AddSeconds(seconds));
            }

            return(DateTime.Now);
        }
Beispiel #3
0
        protected override TimeSpan PlanNextExecution() {
            if (LastExecution == default(DateTime)) {
                return TimeSpan.Zero;
            }

            var lastTemperature = CreateContext().GetLastTemperature();
            var next = RetrievalPlanner.Next(lastTemperature, DateTime.Now);

            // min delay protection
            if (DateTime.Now.Add(next) < LastExecution.Add(MinDelay)) {
                return MinDelay;
            }

            return next;
        }
Beispiel #4
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Workflow?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Description?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (StartDateTime?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ExpireOn?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CronExpression?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LastExecution?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LastExecutionMessage?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (IsLastExecutionSuccess.GetHashCode());
            hashCode = hashCode * -1521134295 + (Active.GetHashCode());
            hashCode = hashCode * -1521134295 + (HumanReadableExpression?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (NextExecutionTime?.GetHashCode() ?? 0);
            return(hashCode);
        }
Beispiel #5
0
        protected virtual void ReadExecutions()
        {
            var query  = $"select [side], [execType], [ordStatus], [ordType], [price], [stopPx], [leavesQty], [cumQty], [orderQty], [lastQty], [execID], [orderID], [timestamp] from [{ExecutionTable}] where [timestamp] > '{LastExecution.ToString(Const.DATETIME_FORMAT)}'";
            var result = Database.Select(query).Rows;

            Executions.Clear();
            foreach (DataRow row in result)
            {
                var execution = new Execution(row);
                Executions[execution.OrderId] = execution;
                updateTimestamps(execution);
            }
            void updateTimestamps(Execution execution)
            {
                if (execution.Timestamp > LastExecution)
                {
                    LastExecution = execution.Timestamp;
                }
                if (execution.OrdStatus == OrdStatus.Filled)
                {
                    LastFills[(Side)execution.Side] = execution.Timestamp;
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Metodo richiamato ad ogni tic del Timer
        /// </summary>
        /// <param name="state">TimerWork di riferimento</param>
        private void OnTimerCallback(object state)
        {
            // Elenco dei moduli da eseguire
            var tw = (TimerWork)state;

            // Loggo lo status del Timer
            FileLogger.Debug(ThreadedModuleLogger, string.Format("TimerCallback: {0} -> IsBusy: {1} | Enabled: {2}", tw, IsBusy, Enabled));

            if (IsBusy || !Enabled)
            {
                return;
            }

            try
            {
                FileLogger.Info(Name, string.Format("TimerCallback: {0} -> IsBusy: {1} | Enabled: {2}", tw, IsBusy, Enabled));
                var signal = DateTime.Now;
                switch (tw.Type)
                {
                case TimerType.Single:
                    if (Tools.CheckSignalTime(signal, tw.BeginTime, LastExecution))
                    {
                        FileLogger.Debug(Name, string.Format("Avvio modulo: {0}", Name));
                        // Imposto il valore della prossima esecuzione
                        NextExecution = Tools.GetNextExecution(signal, tw.BeginTime);
                        DoWork();
                    }
                    else
                    {
                        // Non eseguo il modulo, già eseguito
                        FileLogger.Debug(Name, String.Format("Modulo {0} già eseguito: {1}", Name, LastExecution.GetValueOrDefault(DateTime.MinValue).ToLongTimeString()));
                    }
                    break;

                case TimerType.Multiple:
                    // Nessuna verifica
                    FileLogger.Debug(Name, String.Format("Avvio modulo: {0}", Name));
                    NextExecution = Tools.GetNextExecution(signal, tw.Period);
                    DoWork();
                    break;

                case TimerType.Timerange:
                    if (Tools.CheckSignalTime(signal, tw.BeginTime, tw.EndTime))
                    {
                        FileLogger.Debug(Name, String.Format("Avvio modulo: {0}", Name));
                        NextExecution = Tools.GetNextExecution(signal, tw.BeginTime, tw.EndTime, tw.Period);
                        DoWork();
                    }
                    else
                    {
                        FileLogger.Debug(Name, String.Format("Modulo {0} non eseguito, fuori fascia oraria", Name));
                    }
                    break;
                }
            }
            catch (Exception exc)
            {
                // Errore in chiamata modulo
                FileLogger.Error(Name, "Errore in avvio modulo", exc);
                Enabled = false;
            }
        }