示例#1
0
        public override string ToString()
        {
            if (Executions == null)
            {
                throw new ArgumentNullException(nameof(Executions));
            }

            if (Executions.Contains(null))
            {
                throw new ArgumentNullException($"{nameof(Executions)} contained null! {Executions.Prettify()}");
            }

            var table = new Dictionary <object, object>()
            {
                [nameof(Total)]   = Total,
                [nameof(Average)] = Average,
                [nameof(Min)]     = Min,
                [nameof(Max)]     = Max,
            }.Prettify();

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (Nickname != null)
            {
                table = table.PrefixIfMissing("\n").Prefix(Nickname);
            }

            return(table);
        }
示例#2
0
 public BossBrain(Unit myOwner)
     : base(myOwner)
 {
     AbilityTracker   = new Dictionary <BossSpawnAbilities, long>();
     SpawnList        = new List <Creature>();
     CurrentPhase     = 0;
     ConditionManager = new Conditions(_unit, Combat);
     ExecutionManager = new Executions(_unit, Combat, this);
 }
示例#3
0
        public void InsertIfNotExits(BfProductCode productCode, BfaPrivateExecution exec)
        {
            var rec = GetExecutions().Where(e => e.ExecutionId == exec.ExecutionId).FirstOrDefault();

            if (rec == default)
            {
                Executions.Add(new DbPrivateExecution(productCode, exec));
            }
        }
示例#4
0
        Task <bool> ITaskResultStorage.CreateTaskExecution(TaskExecutionDto taskExecution)
        {
            lock (_executionsLock)
            {
                Executions.Add(taskExecution);
            }

            return(Task.FromResult(true));
        }
示例#5
0
文件: Database.cs 项目: malooba/flow
        /// <summary>
        /// Start a new workflow
        /// </summary>
        /// <param name="json">The entire message body from the request</param>
        /// <returns></returns>
        public string StartWorkflow(string json)
        {
            // This presently uses the Event as the body of the start message because it's convenient
            //
            var workflowName    = "";
            var workflowVersion = "";
            var executionId     = Guid.NewGuid();

            try
            {
                // Neither of these operation should ever fail as they cannot be conflicted
                var wfStartData = JsonConvert.DeserializeObject <WorkflowExecutionStartedEvent>(json);
                workflowName    = wfStartData.WorkflowName;
                workflowVersion = wfStartData.WorkflowVersion;
                var wf = GetWorkflow(workflowName, workflowVersion);
                if (wf == null)
                {
                    log.Error($"Unknown workflow definition - {workflowName} v {workflowVersion} ");
                    throw new ApplicationException($"Unknown workflow definition - {workflowName} v {workflowVersion} ");
                }
                var wfDefinition = JsonConvert.DeserializeObject <WorkflowObj>(wf.Json);

                Executions.InsertOnSubmit(new Execution
                {
                    ExecutionId  = executionId,
                    JobId        = (string)wfStartData.Input.SelectToken("_jobId"),
                    Workflow     = wf,
                    DecisionList = wfStartData.DecisionList ?? wfDefinition.DecisionList ?? "decider",
                    ExecutionStartToCloseTimeout = (int?)(wfStartData.ExecutionStartToCloseTimeout ?? wfDefinition.DefaultExecutionStartToCloseTimeout),
                    TaskStartToCloseTimeout      = (int?)(wfStartData.TaskStartToCloseTimeout ?? wfDefinition.DefaultTaskStartToCloseTimeout),
                    TaskScheduleToCloseTimeout   = null, // What goes here?
                    TaskScheduleToStartTimeout   = null, // and here?
                    HistorySeen      = 0,
                    AwaitingDecision = true,
                    LastSeen         = DateTime.UtcNow,
                    ExecutionState   = new ExecutionState {
                        State = ExState.Running
                    }
                });

                wfStartData.ExecutionId = executionId;
                wfStartData.Id          = 0;
                wfStartData.Timestamp   = DateTime.UtcNow;

                Histories.InsertOnSubmit(wfStartData);

                SubmitChanges(ConflictMode.FailOnFirstConflict);
            }
            catch (ChangeConflictException ex)
            {
                log.Error("Failed to create new workflow execution", ex);
                throw new ApplicationException($"Failed to create new workflow execution - {workflowName} v {workflowVersion} ");
            }
            return(new JObject(new JProperty("executionId", executionId.ToString())).ToString(Formatting.None));
        }
示例#6
0
        public ActionResult Execute(string accessToken)
        {
            ViewBag.AccessToken = accessToken;
            if (String.IsNullOrEmpty(accessToken))
            {
                throw new ArgumentNullException();
            }
            Executions executions = new Executions();

            executions.StandardExecution(accessToken);
            return(View("Finished"));
        }
        public async Task GetAllTest_Success()
        {
            var mockValue = new Executions {
                execution = new List <Execution> {
                    TestData.pendingExecution
                }
            };

            mockCache.Setup(x => x.Get()).ReturnsAsync(mockValue);

            var instance = new MergeSortOperation(mockCache.Object, mockLogger.Object);
            var result   = await instance.Get();

            mockValue.Should().BeEquivalentTo(result);
        }
示例#8
0
 public NpcBrain(Unit myOwner) : base(myOwner)
 {
     NextAbilityExecution = 0;
     ConditionManager     = new Conditions(_unit, Combat);
     ExecutionManager     = new Executions(_unit, Combat, this);
     Abilities            = new List <CreatureSmartAbilities>();
     AbilityTracker       = new Dictionary <CreatureSmartAbilities, long>();
     if (_unit is Creature)
     {
         Proto = (_unit as Creature).Spawn.Proto;
     }
     else
     {
         throw new Exception("_Unit is not Creature");
     }
 }
        public void AddExecutionReport(ExecutionReport executionReport)
        {
            Executions.Add(executionReport);
            AvgPrice = executionReport.AveragePrice;
            Status   = executionReport.Status;

            var executionReportAddedEventArgs = new ExecutionReportAddedEventArgs {
                ExecutionReport = executionReport
            };
            var executionReportAddedHandler = ExecutionReportAdded;

            if (executionReportAddedHandler != null)
            {
                executionReportAddedHandler(this, executionReportAddedEventArgs);
            }
        }
示例#10
0
        public Task StartExecution(MazeTask mazeTask, TaskSession taskSession, TaskExecution taskExecution)
        {
            taskExecution.TaskExecutionId = Guid.NewGuid();
            taskExecution.TaskSessionId   = taskSession.TaskSessionId;

            lock (_executionsLock)
                lock (_sessionsLock)
                {
                    if (!Sessions.Any(x => x.TaskSessionId == taskSession.TaskSessionId && x.TaskReferenceId == mazeTask.Id))
                    {
                        Sessions.Add(taskSession);
                    }

                    Executions.Add(taskExecution);
                }

            return(Task.CompletedTask);
        }
示例#11
0
        public ActionResult <Executions> savereport([FromBody] SanityReport report)
        {
            int       startCoordinateVertexCount = 1;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            var execution = new Executions
            {
                commmands = report.commmands.Count,
                result    = report.commmands.Select(x => x.steps).Sum() + startCoordinateVertexCount,
                timestamp = DateTime.Now
            };

            stopwatch.Stop();
            execution.duration = (decimal)stopwatch.Elapsed.TotalSeconds;
            _context.Executions.Add(execution);
            _context.SaveChanges();
            return(execution);
        }
示例#12
0
文件: Database.cs 项目: malooba/flow
        /// <summary>
        /// Insert an asynchronous signal into an execution's history
        /// </summary>
        /// <param name="executionid"></param>
        /// <param name="signal"></param>
        public void SignalExecution(Guid executionid, WorkflowSignalledEvent signal)
        {
            try
            {
                var execution = Executions.SingleOrDefault(e => e.ExecutionId == executionid);

                if (execution == null)
                {
                    log.Warn($"Signal for unknown execution with id {executionid} ignored");
                    return;
                }
                InsertHistory(this, execution, signal);
                SubmitChanges();
            }
            catch (Exception ex)
            {
                log.Error($"Failed to signal execution with id {executionid}", ex);
            }
        }
示例#13
0
        public ActionResult CreateExecutions(Executions Executions, string[] AccountIdList)
        {
            if (ModelState.IsValid)
            {
                var NowTime = DateTime.Now;
                var UserID  = Session["UserID"].ToString();

                Executions.id       = Guid.NewGuid();
                Executions.CreateID = UserID;
                Executions.Createdt = NowTime;
                Executions.UpdateID = UserID;
                Executions.Updatedt = NowTime;

                db.Executions.Add(Executions);

                if (AccountIdList != null)
                {
                    foreach (var AccountId in AccountIdList)
                    {
                        if (!string.IsNullOrEmpty(AccountId))
                        {
                            ExecutionsAccount ExecutionsAccount = new ExecutionsAccount
                            {
                                ExecutionsId = Executions.id,
                                AccountId    = Guid.Parse(AccountId),
                                CreateID     = UserID,
                                Createdt     = NowTime
                            };

                            db.ExecutionsAccount.Add(ExecutionsAccount);
                        }
                    }
                }
                db.SaveChanges();
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false }));
            }
        }
示例#14
0
        private void Client_ExecutionsReceived(object sender, CollectionReceivedEventArgs <Execution> e)
        {
            var i = Instruments.FirstOrDefault(m => m.Id == e.Data[0].InstrumentId);

            if (i != null)
            {
                i.LastError = null;

                lock (Executions)
                {
                    foreach (var m in e.Data)
                    {
                        Executions.Add(new ExecutionEntry(e.Action, i, m));
                    }

                    const int MAX = 100;
                    while (Executions.Count > 100)
                    {
                        Executions.RemoveAt(Executions.Count - 1 - MAX);
                    }
                }
            }
        }
示例#15
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;
                }
            }
        }
示例#16
0
        public ActionResult EditExecutions(Executions Executions, string[] AccountIdList)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var sql = db.Executions.Find(Executions.id);
                    sql.Name                = Executions.Name;
                    sql.Status              = Executions.Status;
                    sql.MinQuantity         = Executions.MinQuantity;
                    sql.MinDifferencePrices = Executions.MinDifferencePrices;
                    sql.ExchangeType        = Executions.ExchangeType;
                    sql.CurrencyValue       = Executions.CurrencyValue;
                    sql.UpdateID            = Session["UserID"].ToString();
                    sql.Updatedt            = DateTime.Now;

                    db.ExecutionsAccount.RemoveRange(sql.ExecutionsAccount);
                    if (AccountIdList != null)
                    {
                        foreach (var AccountId in AccountIdList)
                        {
                            if (!string.IsNullOrEmpty(AccountId))
                            {
                                ExecutionsAccount ExecutionsAccount = new ExecutionsAccount
                                {
                                    ExecutionsId = Executions.id,
                                    AccountId    = Guid.Parse(AccountId),
                                    CreateID     = Session["UserID"].ToString(),
                                    Createdt     = DateTime.Now
                                };

                                db.ExecutionsAccount.Add(ExecutionsAccount);
                            }
                        }
                    }

                    db.SaveChanges();

                    //開啟搬磚程式
                    if (Executions.Status == 1)
                    {
                        SetExecutions.KillProcess(Executions.id.ToString());
                        string ProcessName = Server.MapPath("~") + @"cmd\BitcoinDeveloper.exe";
                        var    Url         = Request.Url.Scheme + "://" + Request.Url.Authority + "/api/api.asmx?op=ReturnMessage";
                        SetExecutions.StartProcess(ProcessName, Executions.id.ToString(), Url);
                    }
                    else if (Executions.Status == 0)
                    {
                        SetExecutions.KillProcess(Executions.id.ToString());
                    }

                    return(Json(new { success = true }));
                }
                catch (Exception)
                {
                    return(Json(new { success = false }));
                }
            }
            else
            {
                return(Json(new { success = false }));
            }
        }
示例#17
0
 public void addExecution(IAppExecution execution)
 {
     Executions.Add(execution);
 }
示例#18
0
 public IQueryable <DbPrivateExecution> GetExecutions() => Executions.AsQueryable();