public void StartExecution(ExecutionInfoEntity algoExe, string executedBy, string resultPath, int projectExeutionID) { algoExe.ProjectExecutionId = projectExeutionID; SendStartExeMessage(executedBy, algoExe.AlgoName); ExecutionHabContext.Clients.All.Started(algoExe); if (algoExe.ProjectId != 0) { resultPath = Path.Combine(resultPath, string.Format("{0}_{1}", algoExe.Id, algoExe.AlgoId)); Directory.CreateDirectory(resultPath); } string inputFilePath = Path.Combine(resultPath, "Input.csv"); string outputFilePath = Path.Combine(resultPath, "Output.csv"); CreateInputCsvFile(algoExe.ExeParams, inputFilePath); try { RunPyton(inputFilePath, outputFilePath, algoExe.FileExePath); SendEndExeMessage(executedBy, algoExe.AlgoName, algoExe.ProjectId > 0, resultPath); } catch (Exception ex) { SendErrorExeMessage(executedBy, algoExe.AlgoName, resultPath); } finally { ProjectsRepository.EndAlgoExecution(algoExe.Id, algoExe.ProjectExecutionId); ExecutionHabContext.Clients.All.Finished(algoExe.Id); } }
internal List <ExecutionInfoEntity> SetAlgoExecutions(ProjectAlgoListEntity projectAlg, string executerName) { List <ExecutionInfoEntity> exeInfoList = new List <ExecutionInfoEntity>(); Random rand = new Random(); int projectID = 0; string projectName = string.Empty; if (projectAlg.ProjectId > 0) { projectID = projectAlg.ProjectId; projectName = _dbContext.Projects.First(x => x.Id == projectAlg.ProjectId).Name; } foreach (var algo in projectAlg.Algos) { var exe = new ExecutionInfoEntity { Id = rand.Next(), AlgoName = algo.Name, ProjectId = projectID, ProjectName = projectName, StartDate = DateTime.Now, ExecutedBy = executerName, FileExePath = algo.FileServerPath, AlgoId = algo.Id, ExeParams = algo.AlgoParams.Select(x => new AlgoExecutionParamEntity { Name = x.Name, Value = x.Value }).ToList() }; exeInfoList.Add(exe); //AddNewAlg to db _dbContext.ExecutionInfos.Add(_mapper.Map <ExecutionInfo>(exe)); } return(exeInfoList); }
private void FinishProjectExecution(string executedBy, ExecutionInfoEntity firstAlgoExe) { var message = MessagesRepository.AddNewMessage("Execution results", $"Project [{firstAlgoExe.ProjectName}] finish execution.", executedBy); MessageHubContext.Clients.All.Send(message); }
public Task Started(ExecutionInfoEntity exeInfo) { return(Clients.All.Started(exeInfo)); }