/// <summary>
        /// Executed when leaving the page for selecting schema types.
        /// It checks if there is a type that is required but has not been selected.
        /// If found, these types are automatically selected and the user notified.
        /// </summary>
        /// <param name="args">Event arguments being passed to the method.</param>
        public override async Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            SaveToUserSettings();

            var numberOfTypesToBeIncluded = 0;

            var correctTypeSelection = true;

            PageLeaving?.Invoke(this, EventArgs.Empty);

            //check each excluded schema type and check if they are required. If so, then automatically select them.
            foreach (var schemaType in ExcludedSchemaTypeNames)
            {
                if (RelatedTypes.TryGetValue(schemaType, out ICollection <string> relatedTypes))
                {
                    //Check if any of the related types has been selected
                    if (relatedTypes.Any(o =>
                    {
                        if (SchemaTypeModelMap.TryGetValue(o, out SchemaTypeModel schemaTypeModel))
                        {
                            return(schemaTypeModel.IsSelected);
                        }

                        return(false);
                    }))
                    {
                        if (SchemaTypeModelMap.TryGetValue(schemaType, out SchemaTypeModel schemaTypeModel))
                        {
                            schemaTypeModel.IsSelected = true;
                            correctTypeSelection       = false;
                            numberOfTypesToBeIncluded++;
                        }
                    }
                }
            }

            if (!correctTypeSelection)
            {
                return(await Task.FromResult(new PageNavigationResult
                {
                    ErrorMessage = $"{numberOfTypesToBeIncluded} {Constants.SchemaTypesWillAutomaticallyBeIncluded}",
                    IsSuccess = correctTypeSelection,
                    ShowMessageBoxOnFailure = true
                }).ConfigureAwait(false));
            }
            else
            {
                return(await base.OnPageLeavingAsync(args).ConfigureAwait(false));
            }
        }
 public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     try
     {
         this.MetadataTempPath = GetMetadata(out var version);
         // Makes sense to add MRU endpoint at this point since GetMetadata manipulates UserSettings.Endpoint
         UserSettings.AddMruEndpoint(UserSettings.Endpoint);
         this.EdmxVersion = version;
         PageLeaving?.Invoke(this, EventArgs.Empty);
         return(base.OnPageLeavingAsync(args));
     }
     catch (Exception e)
     {
         return(Task.FromResult(
                    new PageNavigationResult
         {
             ErrorMessage = e.Message,
             IsSuccess = false,
             ShowMessageBoxOnFailure = true
         }));
     }
 }
示例#3
0
        public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            SaveToUserSettings();
            var wizard = this.Wizard as ODataConnectedServiceWizard;

            UserSettings.AddToTopOfMruList(wizard?.UserSettings?.MruEndpoints, this.Endpoint);
            try
            {
                this.MetadataTempPath = GetMetadata(out var version);
                this.EdmxVersion      = version;
                PageLeaving?.Invoke(this, EventArgs.Empty);
                return(base.OnPageLeavingAsync(args));
            }
            catch (Exception e)
            {
                return(Task.FromResult(
                           new PageNavigationResult
                {
                    ErrorMessage = e.Message,
                    IsSuccess = false,
                    ShowMessageBoxOnFailure = true
                }));
            }
        }