コード例 #1
0
        public ModuleVm()
        {
            FilterVm   = new FilterVm();
            StatsVm    = new ContentStatsVm();
            ProgressVm = new ContentProgressVm();

            LoadCommand = new BlazorCommand();
            LoadCommand.AsyncDelegate += OnLoadAsync;
        }
コード例 #2
0
        //private CrossModuleVisualizationRequest GetDefaultRequest()
        //{
        //	return new CrossModuleVisualizationRequest
        //	{
        //		MissionIds = new[] { "e8d88c8a-b82d-4911-9539-3080ef877653" },
        //		MissionInstanceIds = new[] { "0" }
        //	};
        //}

        private async Task <ContentStatsVm> GetStatsVm()
        {
            if (string.IsNullOrWhiteSpace(FilterVm.SelectedMissionInstance))
            {
                throw new ArgumentException(nameof(FilterVm.SelectedMissionInstance));
            }
            if (string.IsNullOrWhiteSpace(FilterVm.SelectedTimeRange))
            {
                throw new ArgumentException(nameof(FilterVm.SelectedTimeRange));
            }

            var workflowInstanceIds = await GetWorkflowInstanceIdsAsync(FilterVm.SelectedMissionInstance);

            if (workflowInstanceIds == null || workflowInstanceIds.Length == 0)
            {
                return(new ContentStatsVm());
            }

            // Get stats for the selected time range
            try
            {
                var args = new RetrieveContentGroupStatisticsArgs
                {
                    WorkflowInstanceIds = workflowInstanceIds,
                    ReportDays          = GetTimeRange(FilterVm.SelectedTimeRange)
                };
                var data = await _netStore.ExecuteAsync(args);

                var model = new ContentStatsVm
                {
                    ContentDurationProp        = { Value = data.ContentDuration },
                    ExploitingDurationProp     = { Value = data.ExploitingDuration },
                    ExploitedDurationProp      = { Value = data.ExploitedDuration },
                    ExploitedPercentageProp    = { Value = data.ExploitedPercentage },
                    TaggerExploitationTimeProp = { Value = data.TaggerExploitationTime },
                    TaggersProp         = { Value = data.Taggers },
                    TagsProp            = { Value = data.Tags },
                    TaskDoneProp        = { Value = data.TaskDone },
                    TaskOutstandingProp = { Value = data.TaskOutstanding }
                };

                // Get stats for the last 24 hours
                args = new RetrieveContentGroupStatisticsArgs
                {
                    WorkflowInstanceIds = workflowInstanceIds,
                    ReportDays          = 1
                };
                data = await _netStore.ExecuteAsync(args);

                model.TodayExploitedPercentageProp.Value = data.ExploitedPercentage;
                model.TodayTagsProp.Value    = data.Tags;
                model.TodayTaggersProp.Value = data.Taggers;

                // Get all time stats
                args = new RetrieveContentGroupStatisticsArgs
                {
                    WorkflowInstanceIds = workflowInstanceIds,
                };
                data = await _netStore.ExecuteAsync(args);

                model.TotalContentDurationProp.Value = data.ContentDuration;

                model.TotalExploitingDurationProp.Value  = data.ExploitingDuration;
                model.TotalExploitedPercentageProp.Value = data.ExploitedPercentage;
                model.TotalTagsProp.Value    = data.Tags;
                model.TotalTaggersProp.Value = data.Taggers;

                // Get labels
                model.ContentDurationLabelProp.Value          = GetLabel(model.ContentDurationProp.Value);
                model.ExploitingDurationLabelProp.Value       = GetLabel(model.ExploitingDurationProp.Value);
                model.ExploitedDurationLabelProp.Value        = GetLabel(model.ExploitedDurationProp.Value);
                model.ExploitedPercentageLabelProp.Value      = GetLabel(GetRounded(model.ExploitedPercentageProp.Value));
                model.TaggerExploitationTimeLabelProp.Value   = GetLabel(model.TaggerExploitationTimeProp.Value);
                model.TodayExploitedPercentageLabelProp.Value = GetLabel(GetRounded(model.TodayExploitedPercentageProp.Value));
                model.TotalContentDurationLabelProp.Value     = GetLabel(model.TotalContentDurationProp.Value);
                model.TotalExploitingDurationLabelProp.Value  = GetLabel(model.TotalExploitingDurationProp.Value);
                model.TotalExploitedPercentageLabelProp.Value = GetLabel(GetRounded(model.TotalExploitedPercentageProp.Value));

                return(model);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }