Ejemplo n.º 1
0
 public void OnClickFilter(WizardItem item)
 {
 }
Ejemplo n.º 2
0
        public async Task OnOpenWizzard(WizardItem item)
        {
            IsLoadedData = false;

            if (item != null)
            {
                SelectedItem = item;

                SelectionHistory.AddLast(item);
            }

            WizardStageResult selections = null;

            if (_wizardId == null)
            {
                var wizardType = item.TypeSource;
                if (wizardType == null || this.HyperStore == null)
                {
                    IsLoadedData = true;
                    return;
                }

                var attr       = wizardType.AsType()?.GetCustomAttributes(true);
                var configAttr = attr?.OfType <ConfigAttribute>().FirstOrDefault();

                if (_pendingConfig == null)
                {
                    var configType = configAttr?.ConfigType;

                    _pendingConfig = configType != null ? (HyperJobConfig)Activator.CreateInstance(configType) : null;
                    if (_pendingConfig != null)
                    {
                        // Show the wizard properties before anything else.
                        ShowPropertyGrid = true;
                        IsLoadedData     = true;

                        SelectionHistory.RemoveLast();                         //

                        return;
                    }
                }

                // Create a new wizard.
                var res = await this.HyperStore.ExecuteAsync(new StartHyperJobArgs(wizardType) { JobConfig = _pendingConfig });

                // Clean it up from the last populate.
                Items.Clear();
                _pendingConfig = null;
                _wizardId      = res.JobId;
            }
            else
            {
                if (_currentStage is WizardListStage)
                {
                    //selections = new WizardStageResult() { Results = Items.Where(it=>it.Selected == true).Select(it => it.Name).ToArray() };
                    selections = new WizardStageResult()
                    {
                        Results = new[] { SelectedItem.Value }
                    };
                }
                else if (_currentStage is WizardDataInputStage)
                {
                    //selections = new WizardStageResult() { Results = new string[] { _lastInputValue } };
                    selections = new WizardStageResult()
                    {
                        Results = new string[] { ConfirmDialogMessage }
                    };
                }
            }

            MessageDescription = "Wizard working...";
            Items.Clear();

            _currentStage = await this.HyperStore.ExecuteAsync(new StepAheadWizardArgs()
            {
                JobId = _wizardId, PreviousStepResult = selections
            });

            if (_currentStage == null || _currentStage.IsFinal)
            {
                if (_wizardId != null)
                {
                    MessageDescription = "Wizard Completed, Hit RESET to start over";
                    Items.Clear();
                    IsWizardFinish = true;
                }
            }
            else
            {
                var listStage  = _currentStage as WizardListStage;
                var inputStage = _currentStage as WizardDataInputStage;

                if (listStage != null)
                {
                    var items = listStage.Entries.Select(it => new WizardItem()
                    {
                        Title = it.Title, Selected = it.PreSelected, Value = it.Value
                    });

                    Items.Clear();
                    Items.AddRange(items);

                    // MultiSelect ?

                    MessageDescription = _currentStage.Title;
                }
                else if (inputStage != null)
                {
                    ShowConfirmDialog = true;

                    ConfirmDialogTitle = inputStage.Title;
                    if (inputStage.DefaultValue != null)
                    {
                        ConfirmDialogMessage = Convert.ToString(inputStage.DefaultValue);
                    }
                }
            }

            IsLoadedData = true;
        }