Ejemplo n.º 1
0
        public async Task ResetSelection()
        {
            IsLoadedData   = false;
            IsWizardFinish = false;

            SelectionHistory = new LinkedList <WizardItem>();
            SelectedItem     = null;

            var id = _wizardId;

            _wizardId = null;
            if (id != null && this.HyperStore != null)
            {
                await this.HyperStore.ExecuteAsync(new StepAheadWizardArgs()
                {
                    JobId = id, Abort = true
                });
            }

            _pendingConfig = null;
            _currentStage  = null;


            MessageDescription = "Select Wizard";
            TextBlockStatus    = String.Empty;

            if (this.HyperStore != null)
            {
                var args        = new GetHyperJobTypesArgs();
                var wizardTypes = await this.HyperStore.ExecuteAsync(args);

                if (wizardTypes != null)
                {
                    var wTypes = wizardTypes.Where(it => it.Name.ToLower().Contains("wizard")).ToArray();

                    if (wTypes != null)
                    {
                        Items = wTypes.Select(it => new WizardItem {
                            TypeSource = it
                        }).ToList();
                    }
                }
            }

            IsLoadedData = true;
        }
Ejemplo n.º 2
0
        public async Task InitWizzard()
        {
            if (HyperStore == null)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(_wizardId))
            {
                await this.HyperStore.ExecuteAsync(new StepAheadWizardArgs()
                {
                    JobId = _wizardId, Abort = true
                });

                _wizardId = null;
            }

            _pendingConfig = null;
            _currentStage  = null;

            var args        = new GetHyperJobTypesArgs();
            var wizardTypes = await this.HyperStore.ExecuteAsync(args);

            if (wizardTypes != null)
            {
                var wTypes = wizardTypes.Where(it => it.Name.ToLower().Contains("wizard")).ToArray();

                if (wTypes != null)
                {
                    Items = wTypes.Select(it => new WizardItem {
                        TypeSource = it
                    }).ToList();
                }
            }

            IsLoadedData = true;
        }
Ejemplo n.º 3
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;
        }