public override void Execute(PipelineHistoryCreatedArgs args) { Console.WriteLine($"PipelineRun:{args.Id} is being Created in background"); var diagram = Digram.CreateInstance(args.Diagram); var pipelineRun = new PipelineRun(args.Id.ToString(), "ci-nebula"); foreach (var node in diagram.NodeList) { var @params = new List <Param>(); var inputResources = new List <PipelineTaskInputResource>(); var runAfter = new List <string>(); node.Property?.Params.ForEach(r => @params.Add(new Param(r.Name, r.Value))); node.Property?.Resources?.Inputs.ForEach(r => inputResources.Add(new PipelineTaskInputResource(r.Name, r.Resource))); node.Source.ForEach(r => runAfter.Add(r)); pipelineRun.AddTask(node.Id, node.Name, @params, inputResources, runAfter); } _pipelineHistoryService.Create(pipelineRun); Console.WriteLine($"PipelineRun:{args.Id} is Created in background"); //_pipelineHistoryStatusCheckerWorker.AddPipelineHistoryId(args.Id); _pipelineHistoryStatusCheckerWorker.PipelineHistoryCreatedQueue.Enqueue(args.Id); Console.WriteLine($"PipelineRun:{args.Id} status check id added to background"); }
/* * private async Task InitAsync(PeriodicBackgroundWorkerContext workerContext) * { * var pipelineHistoryRepository = workerContext.ServiceProvider * .GetRequiredService<IRepository<PipelineHistory, int>>(); * * _pipelineHistoryIdList = await pipelineHistoryRepository.Where(p => !p.()).Select(p => p.Id).ToListAsync(); * } */ private async Task <PipelineHistory> UpdatePipelineHistoryAsync(int pipelineHistoryId, PeriodicBackgroundWorkerContext workerContext) { var pipelineHistoryRepository = workerContext.ServiceProvider .GetRequiredService <IRepository <PipelineHistory, int> >(); var pipelineHistoryService = workerContext.ServiceProvider .GetRequiredService <PipelineHistoryService>(); var pipelineRunStatus = await pipelineHistoryService.GetStatusAsync(pipelineHistoryId.ToString()); var pipelineHistory = await pipelineHistoryRepository.GetAsync(pipelineHistoryId); var nodeDic = Digram.CreateInstance(pipelineHistory.Diagram).NodeList.ToDictionary(t => t.Id); pipelineRunStatus.TaskRunStatusList.ForEach(t => { t.TaskAnnoName = nodeDic[t.ShapeId].AnnoName; t.ConfigUrl = nodeDic[t.ShapeId].ConfigUrl; t.ResultUrl = nodeDic[t.ShapeId].ResultUrl; nodeDic[t.ShapeId].Destination.ForEach(id => t.NextShapes.Add(id)); if (t.Log == null) { return; } if (t.Log.StartTime == null) { t.Log.ExecTime = null; } else if (t.Log.CompletionTime == null) { t.Log.ExecTime = DateTime.Now - t.Log.StartTime; } else { t.Log.ExecTime = t.Log.CompletionTime - t.Log.StartTime; } }); /*pipelineHistory * .SetStatus( * pipelineRunStatus.Status, * pipelineRunStatus.StartTime, * pipelineRunStatus.CompletionTime, * pipelineRunStatus.Percent, * pipelineRunStatus.Logs)*/ pipelineHistory .SetStatus(pipelineRunStatus.Status) .SetStartTime(pipelineRunStatus.StartTime) .SetCompletionTime(pipelineRunStatus.CompletionTime) .SetPercent(pipelineRunStatus.Percent) .SetLogs(pipelineRunStatus.Logs) .SetMessage(pipelineRunStatus.Message); await pipelineHistoryRepository.UpdateAsync(pipelineHistory); return(pipelineHistory); }