예제 #1
0
파일: Get.cs 프로젝트: tle5/elsa-core
        public async Task <ActionResult <PagedList <WorkflowExecutionLogRecord> > > Handle(string id, int?page = default, int?pageSize = default, CancellationToken cancellationToken = default)
        {
            var specification = new WorkflowInstanceIdSpecification(id);
            var totalCount    = await _workflowExecutionLogStore.CountAsync(specification, cancellationToken);

            var paging = page != null?Paging.Page(page.Value, pageSize ?? 100) : default;

            var orderBy = OrderBySpecification.OrderBy <WorkflowExecutionLogRecord>(x => x.Timestamp);
            var records = await _workflowExecutionLogStore.FindManyAsync(specification, orderBy, paging, cancellationToken).ToList();

            return(new PagedList <WorkflowExecutionLogRecord>(records, page, pageSize, totalCount));
        }
예제 #2
0
파일: Get.cs 프로젝트: tle5/elsa-core
        public async Task <ActionResult <ActivityStats> > Handle(string workflowInstanceId, string activityId, CancellationToken cancellationToken = default)
        {
            var specification = new WorkflowInstanceIdSpecification(workflowInstanceId).And(new ActivityIdSpecification(activityId));
            var orderBy       = OrderBySpecification.OrderBy <WorkflowExecutionLogRecord>(x => x.Timestamp);
            var records       = await _workflowExecutionLogStore.FindManyAsync(specification, orderBy, null, cancellationToken).ToList();

            var eventCounts    = records.GroupBy(x => x.EventName).ToList();
            var executions     = GetExecutions(records).ToList();
            var executionTimes = executions.Select(x => x.Duration).OrderBy(x => x).ToList();
            var faultRecord    = records.FirstOrDefault(x => x.EventName == "Faulted");
            var activityFault  = faultRecord != null ? new ActivityFault(faultRecord.Message !) : null;

            var model = new ActivityStats
            {
                EventCounts          = eventCounts.Select(x => new ActivityEventCount(x.Key !, x.Count())).ToList(),
                LastExecutedAt       = executions.Select(x => x.Timestamp).OrderByDescending(x => x).FirstOrDefault(),
                SlowestExecutionTime = executionTimes.LastOrDefault(),
                FastestExecutionTime = executionTimes.FirstOrDefault(),
                AverageExecutionTime = executionTimes.Any() ? Duration.FromTicks(executionTimes.Average(x => x.TotalTicks)) : default,