public override async Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            UserSettings.AddToTopOfMruList(((Wizard)this.Wizard).UserSettings.MruEndpoints, this.Endpoint);
            try
            {
                if (!UserSettings.GenerateCSharpClient && !UserSettings.GenerateCSharpController && !UserSettings.GenerateTypeScriptClient)
                {
                    throw new Exception("Should check one of the checkboxes for generating!");
                }

                this.SpecificationTempPath = await GetSpecification();

                return(await base.OnPageLeavingAsync(args));
            }
            catch (Exception e)
            {
                return(await Task.FromResult <PageNavigationResult>(
                           new PageNavigationResult
                {
                    ErrorMessage = e.Message,
                    IsSuccess = false,
                    ShowMessageBoxOnFailure = true
                }));
            }
        }
Exemple #2
0
        public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            if (this.IsCustomDomain && this.MyDomainViewModel.IsValid)
            {
                UserSettings.AddToTopOfMruList(this.Wizard.UserSettings.MruMyDomains, this.MyDomainViewModel.MyDomain.ToString());
            }

            return(base.OnPageLeavingAsync(args));
        }
 public override Task<PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     // If the user has entered and left this page, validate the RuntimeAuthOption has been set to a valid value
     if (this.RuntimeAuthOptions == RuntimeAuthOptions.None)
     {
         this.HasErrors = true;
     }
     return base.OnPageLeavingAsync(args);
 }
 public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     // If the user has entered and left this page, validate the RuntimeAuthOption has been set to a valid value
     if (this.RuntimeAuthOptions == RuntimeAuthOptions.None)
     {
         this.HasErrors = true;
     }
     return(base.OnPageLeavingAsync(args));
 }
        /// <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)
        {
            if (!Instance.Metadata.ContainsKey(Constants.MetadataKeyForStoringReceiverSecrets))
                Instance.Metadata.Add(Constants.MetadataKeyForStoringReceiverSecrets, new List<WebHookReceiverSecret>());

            ((List<WebHookReceiverSecret>)Instance.Metadata[Constants.MetadataKeyForStoringReceiverSecrets]).Clear();
            foreach (var item in ReceiverSecrets)
            {
                ((List<WebHookReceiverSecret>)Instance.Metadata[Constants.MetadataKeyForStoringReceiverSecrets]).Add(item);
            }

            TelemetryWrapper.EndPageView();

            return base.OnPageLeavingAsync(args);
        }
Exemple #7
0
        public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            if (!Instance.Metadata.ContainsKey(Constants.MetadataKeyForStoringReceiverSecrets))
            {
                Instance.Metadata.Add(Constants.MetadataKeyForStoringReceiverSecrets, new List <WebHookReceiverSecret>());
            }

            ((List <WebHookReceiverSecret>)Instance.Metadata[Constants.MetadataKeyForStoringReceiverSecrets]).Clear();
            foreach (var item in ReceiverSecrets)
            {
                ((List <WebHookReceiverSecret>)Instance.Metadata[Constants.MetadataKeyForStoringReceiverSecrets]).Add(item);
            }

            TelemetryWrapper.EndPageView();

            return(base.OnPageLeavingAsync(args));
        }
Exemple #8
0
 public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     UserSettings.AddToTopOfMruList(((Wizard)this.Wizard).UserSettings.MruEndpoints, this.Endpoint);
     try
     {
         this.MetadataTempPath = GetMetadata(out var version);
         this.EdmxVersion      = version;
         return(base.OnPageLeavingAsync(args));
     }
     catch (Exception e)
     {
         return(Task.FromResult <PageNavigationResult>(
                    new PageNavigationResult()
         {
             ErrorMessage = e.Message,
             IsSuccess = false,
             ShowMessageBoxOnFailure = true
         }));
     }
 }
 public override Task<PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     UserSettings.AddToTopOfMruList(((ODataConnectedServiceWizard)this.Wizard).UserSettings.MruEndpoints, this.Endpoint);
     Version version;
     try
     {
         this.MetadataTempPath = GetMetadata(out version);
         this.EdmxVersion = version;
         return base.OnPageLeavingAsync(args);
     }
     catch (Exception e)
     {
         return Task.FromResult<PageNavigationResult>(
             new PageNavigationResult()
             {
                 ErrorMessage = e.Message,
                 IsSuccess = false,
                 ShowMessageBoxOnFailure = true
             });
     }
 }
        public override async Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            UserSettings.AddToTopOfMruList(((Wizard)this.Wizard).UserSettings.MruEndpoints, this.Endpoint);
            try
            {
                if (!UserSettings.GenerateCSharpClient && !UserSettings.GenerateCSharpController && !UserSettings.GenerateTypeScriptClient)
                {
                    throw new Exception("Should check one of the checkboxes for generating!");
                }

                this.SpecificationTempPath = await GetSpecificationAsync();

                // convert from OData specification
                if (this.UserSettings.ConvertFromOdata)
                {
                    var csdl  = File.ReadAllText(this.SpecificationTempPath);
                    var model = CsdlReader.Parse(XElement.Parse(csdl).CreateReader());
                    if ((this.UserSettings.OpenApiConvertSettings.ServiceRoot == null || this.UserSettings.OpenApiConvertSettings.ServiceRoot.Host.Contains("localhost")) &&
                        this.UserSettings.Endpoint.StartsWith("http", StringComparison.Ordinal))
                    {
                        this.UserSettings.OpenApiConvertSettings.ServiceRoot = new Uri(this.UserSettings.Endpoint.TrimEnd("$metadata".ToCharArray()));
                    }
                    var document   = model.ConvertToOpenApi(this.UserSettings.OpenApiConvertSettings);
                    var outputJson = document.SerializeAsJson(this.UserSettings.OpenApiSpecVersion);
                    File.WriteAllText(this.SpecificationTempPath, outputJson);
                }

                return(await base.OnPageLeavingAsync(args));
            }
            catch (Exception e)
            {
                return(await Task.FromResult <PageNavigationResult>(
                           new PageNavigationResult
                {
                    ErrorMessage = e.Message,
                    IsSuccess = false,
                    ShowMessageBoxOnFailure = true
                }));
            }
        }
 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
         }));
     }
 }
Exemple #12
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
                }));
            }
        }
Exemple #13
0
 public override Task <WizardNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     return(base.OnPageLeavingAsync(args));
 }
        public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            TelemetryWrapper.EndPageView();

            return(base.OnPageLeavingAsync(args));
        }
        public override Task<PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            TelemetryWrapper.EndPageView();

            return base.OnPageLeavingAsync(args);
        }
Exemple #16
0
 public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     UserSettings.AddToTopOfMruList(((ODataConnectedServiceWizard)this.Wizard).UserSettings.MruEndpoints, this.Endpoint);
     return(base.OnPageLeavingAsync(args));
 }
 public override async Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     return(await base.OnPageLeavingAsync(args));
 }
        public override Task<WizardNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            if (this.IsCustomDomain && this.MyDomainViewModel.IsValid)
            {
                UserSettings.AddToTopOfMruList(this.Wizard.UserSettings.MruMyDomains, this.MyDomainViewModel.MyDomain.ToString());
            }

            return base.OnPageLeavingAsync(args);
        }
 public override Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     SaveToUserSettings();
     return(base.OnPageLeavingAsync(args));
 }
Exemple #20
0
        public override async Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            PageNavigationResult result;

            using (this.Wizard.Context.StartBusyIndicator(Resources.DesignTimeAuthenticationViewModel_AuthenticatingProgress))
            {
                string error = null;

                if (this.Authentication.RefreshToken == null)
                {
                    // New identity or a existing identity w/no refresh token
                    error = this.AuthenticateUser();

                    if (error == null && this.Authentication.EnvironmentType == EnvironmentType.Custom)
                    {
                        UserSettings.AddToTopOfMruList(this.Wizard.UserSettings.MruMyDomains, this.Authentication.MyDomain.ToString());
                    }
                }
                else if (this.Authentication.AccessToken == null)
                {
                    // Existing identity w/no access token
                    try
                    {
                        await AuthenticationHelper.RefreshAccessTokenAsync(this.Authentication);
                    }
                    catch (ForceException ex)
                    {
                        if (ex.Error == Error.InvalidGrant) // Expired refresh token
                        {
                            this.Authentication.RefreshToken = null;
                            error = this.AuthenticateUser();
                        }
                        else
                        {
                            error = ex.Message;
                        }
                    }
                }
                // else - Existing identity w/access and refresh token

                if (error == null)
                {
                    UserSettings.AddToTopOfMruList(this.Wizard.UserSettings.MruDesignTimeAuthentications, this.Authentication);
                    result = PageNavigationResult.Success;

                    if (this.PageLeaving != null)
                    {
                        this.PageLeaving(this, EventArgs.Empty);
                    }
                }
                else
                {
                    result = new PageNavigationResult()
                    {
                        ErrorMessage = error, ShowMessageBoxOnFailure = true
                    };
                }
            }

            return(result);
        }
        public override async Task<PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
        {
            PageNavigationResult result;

            using (this.Wizard.Context.StartBusyIndicator(Resources.DesignTimeAuthenticationViewModel_AuthenticatingProgress))
            {
                string error = null;

                if (this.Authentication.RefreshToken == null)
                {
                    // New identity or a existing identity w/no refresh token
                    error = this.AuthenticateUser();

                    if (error == null && this.Authentication.EnvironmentType == EnvironmentType.Custom)
                    {
                        UserSettings.AddToTopOfMruList(this.Wizard.UserSettings.MruMyDomains, this.Authentication.MyDomain.ToString());
                    }
                }
                else if (this.Authentication.AccessToken == null)
                {
                    // Existing identity w/no access token
                    try
                    {
                        await AuthenticationHelper.RefreshAccessTokenAsync(this.Authentication);
                    }
                    catch (ForceException ex)
                    {
                        if (ex.Error == Error.InvalidGrant) // Expired refresh token
                        {
                            this.Authentication.RefreshToken = null;
                            error = this.AuthenticateUser();
                        }
                        else
                        {
                            error = ex.Message;
                        }
                    }
                }
                // else - Existing identity w/access and refresh token

                if (error == null)
                {
                    UserSettings.AddToTopOfMruList(this.Wizard.UserSettings.MruDesignTimeAuthentications, this.Authentication);
                    result = PageNavigationResult.Success;

                    if (this.PageLeaving != null)
                    {
                        this.PageLeaving(this, EventArgs.Empty);
                    }
                }
                else
                {
                    result = new PageNavigationResult() { ErrorMessage = error, ShowMessageBoxOnFailure = true };
                }
            }

            return result;
        }
 /// <summary>
 /// Executed when leaving the page for selecting operation imports.
 /// </summary>
 /// <param name="args">Event arguments being passed to the method.</param>
 public override async Task <PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     SaveToUserSettings();
     return(await base.OnPageLeavingAsync(args).ConfigureAwait(false));
 }
 public override Task<PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     return base.OnPageLeavingAsync(args);
 }
 public override Task<PageNavigationResult> OnPageLeavingAsync(WizardLeavingArgs args)
 {
     UserSettings.AddToTopOfMruList(((ODataConnectedServiceWizard)this.Wizard).UserSettings.MruEndpoints, this.Endpoint);
     return base.OnPageLeavingAsync(args);
 }