Example #1
0
        public ModuleVm()
        {
            FilterVm   = new FilterVm();
            StatsVm    = new ContentStatsVm();
            ProgressVm = new ContentProgressVm();

            LoadCommand = new BlazorCommand();
            LoadCommand.AsyncDelegate += OnLoadAsync;
        }
Example #2
0
        private async Task <ContentProgressVm> GetProgressVm()
        {
            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 ContentProgressVm());
            }

            try
            {
                var args = new RetrieveContentGroupProgressArgs
                {
                    WorkflowInstanceIds = workflowInstanceIds,
                    ReportDays          = GetTimeRange(FilterVm.SelectedTimeRange)
                };
                args.TimeStep = GetTimeStep(args.ReportDays);
                var data = await _netStore.ExecuteAsync(args);

                var dateFormatString = GetDateTimeFormatString(args.ReportDays);

                var model = new ContentProgressVm
                {
                    ExploitedDurationProp       = { Value = GetModel(data?.ExploitedDuration, dateFormatString) },
                    TotalDurationProp           = { Value = GetModel(data?.TotalDuration, dateFormatString) },
                    TasksPerformedProp          = { Value = GetModel(data?.TasksPerformed, dateFormatString) },
                    TasksOutstandingProp        = { Value = GetModel(data?.TasksOutstanding, dateFormatString) },
                    TasksCompletedPerPeriodProp = { Value = GetModel(data?.TasksCompletedPerPeriod, dateFormatString) },
                    CompletionPercentProp       = { Value = GetModel(data?.CompletionPercent, dateFormatString) },
                    SessionsProp                       = { Value = GetModel(data?.Sessions, dateFormatString) },
                    NewTaggersProp                     = { Value = GetModel(data?.NewTaggers, dateFormatString) },
                    ExploitationSaturationProp         = { Value = GetModel(data?.ExploitationSaturation, dateFormatString) },
                    CompletionPercentMinValueProp      = { Value = 0 },
                    SessionsMinValueProp               = { Value = 0 },
                    NewTaggersMinValueProp             = { Value = 0 },
                    ExploitationSaturationMinValueProp = { Value = 0 }
                };

                if (data?.CompletionPercent != null)
                {
                    var value = GetMaxValue(data.CompletionPercent.Select(it => it.Value));
                    if (value > 0)
                    {
                        model.CompletionPercentMaxValueProp.Value = value;
                    }
                }

                if (data?.Sessions != null)
                {
                    var value = GetMaxValue(data.Sessions.Select(it => it.Value));
                    if (value > 10)
                    {
                        model.SessionsMaxValueProp.Value = value;
                    }
                }

                if (data?.NewTaggers != null)
                {
                    var value = GetMaxValue(data.NewTaggers.Select(it => it.Value));
                    if (value > 10)
                    {
                        model.NewTaggersMaxValueProp.Value = value;
                    }
                }

                if (data?.ExploitationSaturation != null)
                {
                    var value = GetMaxValue(data.ExploitationSaturation.Select(it => it.Value));
                    if (value > 0)
                    {
                        model.ExploitationSaturationMaxValueProp.Value = value;
                    }
                }

                model.CategoriesProp.Value = model.ExploitedDurationProp.Value.Select(it => it.Key).ToArray();

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