private void GenerateSettings()
 {
     this.settings = new NavControlAddInSettings
     {
         ExtensionVersion    = "1.0.0.5",
         ApplicationVersion  = "17.0.0.0",
         PlatformVersion     = "17.0.0.0",
         RuntimeVersion      = "6.0",
         DependenciesJson    = "[{\"id\": \"aa674118-6bda-4ffb-9c00-2fa79a1d13d5\", \"name\": \"Meta UI Wizard\", \"publisher\": \"Global Mediator\", \"version\": \"1.0.0.4\"}]",
         IdRangesJson        = "[{\"from\": 50000, \"to\": 50100}]",
         ClientId            = "02aab7a9-5e57-44e1-900e-546a34d4940e",
         ClientSecret        = @"-qq_~Ciq31FoQXu475CrZ54-Us3GTfpA1-",
         EnvironmentName     = "test",
         EnvironmentTenantId = "d25c5a7b-54fb-4863-88b9-5ccf8190a323",
         ExtensionPublisher  = "Global Mediator",
         SymbolsToDownload   = new List <SymbolsConfiguration>
         {
             new SymbolsConfiguration {
                 Publisher = "Microsoft", AppName = "Application", VersionText = "18.0.0.0"
             },
             new SymbolsConfiguration {
                 Publisher = "Microsoft", AppName = "Base Application", VersionText = "18.0.0.0"
             },
             new SymbolsConfiguration {
                 Publisher = "Microsoft", AppName = "System Application", VersionText = "18.0.0.0"
             },
             new SymbolsConfiguration {
                 Publisher = "Microsoft", AppName = "System", VersionText = "18.0.0.0"
             },
             new SymbolsConfiguration {
                 Publisher = "Global Mediator", AppName = "Meta UI Wizard", VersionText = "1.0.0.4"
             }
         },
         ControlId          = Guid.NewGuid(),
         CustomStylesString = "",
         InitEventName      = "init",
         ControlHtmlContext = "<meta-ui-grid></meta-ui-grid>",
         ControlAddInName   = "Customers",
         PluginDetailsUrl   = "test settings",
         ExtensionPages     = new List <ExtensionPage>
         {
             new ExtensionPage {
                 PageExtensionId = "50001", PageExtensionName = "Customer Grid", PageToExtendName = "Customer List"
             }
         },
         Scripts = new List <string>
         {
             "https://dev-navnxt-angular.azureedge.net/dist/meta-ui-two/meta-ui-grid.js"
         },
         Styles = new List <string>
         {
             "https://cdn.jsdelivr.net/npm/[email protected]/primeicons.min.css",
             "https://cdn.jsdelivr.net/npm/primeng@6/resources/primeng.min.css",
             "https://cdn.jsdelivr.net/npm/[email protected]/resources/themes/nova-light/theme.min.css"
         }
     };
 }
 private string ReplacePlaceholders(string content, NavControlAddInSettings settings)
 {
     foreach (var page in settings.ExtensionPages)
     {
         content = content
                   .Replace("{{Version}}", settings.ExtensionVersion)
                   .Replace("{{DependenciesJson}}", settings.DependenciesJson)
                   .Replace("{{PlatformVersion}}", settings.PlatformVersion)
                   .Replace("{{ApplicationVersion}}", settings.ApplicationVersion)
                   .Replace("{{IdRangesJson}}", settings.IdRangesJson)
                   .Replace("{{RuntimeVersion}}", settings.RuntimeVersion)
                   .Replace("{{InitEventName}}", settings.InitEventName)
                   .Replace("{{ControlHtmlContext}}", settings.ControlHtmlContext)
                   .Replace("{{ControlAddInName}}", settings.ControlAddInName)
                   .Replace("{{PluginDetailsUrl}}", settings.PluginDetailsUrl)
                   .Replace("{{PageExtensionId}}", page.PageExtensionId)
                   .Replace("{{PageExtensionName}}", page.PageExtensionName)
                   .Replace("{{PageToExtendName}}", page.PageToExtendName)
                   .Replace("{{ScriptsPlaceholder}}", $"'{settings.Scripts.Aggregate((x, y) => x == string.Empty ? y : $"{y}', '{x}")}'")
Exemplo n.º 3
0
        private async Task SetupSettingsAsync(HttpRequestMessage httpRequest)
        {
            // Read request body params
            NameValueCollection formData;

            try
            {
                logger.LogInformation("Reading http request form data");
                formData = await httpRequest.Content.ReadAsFormDataAsync();
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to read http request form data", ex?.InnerException);
            }

            // Create settings for generator
            try
            {
                var controlSettings = new NavControlAddInSettings
                {
                    ApplicationVersion = formData["ApplicationVersion"],
                    PlatformVersion    = formData["PlatformVersion"],
                    RuntimeVersion     = formData["RuntimeVersion"],
                    DependenciesJson   = formData["DependenciesJson"],
                    IdRangesJson       = formData["IdRangesJson"],

                    ClientId            = formData["ClientId"],
                    ClientSecret        = formData["ClientSecret"],
                    EnvironmentName     = formData["EnvironmentName"],
                    EnvironmentTenantId = formData["EnvironmentTenantId"],
                    SymbolsToDownload   = new List <SymbolsConfiguration>(),

                    ExtensionPublisher = formData["ExtensionPublisher"],
                    ExtensionVersion   = formData["ExtensionVersion"],

                    ControlAddInName   = formData["ControlAddInName"],
                    ControlHtmlContext = formData["ControlHtmlContext"],
                    ControlId          = Guid.Parse(formData["ControlId"]),
                    CustomStylesString = formData["CustomStylesString"],
                    ExtensionPages     = new List <ExtensionPage>(),
                    InitEventName      = formData["InitEventName"],
                    PluginDetailsUrl   = formData["PluginDetailsUrl"],
                    Scripts            = new List <string>(),
                    Styles             = new List <string>()
                };

                // Deserialize extra data
                controlSettings.ExtensionPages    = JsonConvert.DeserializeObject <List <ExtensionPage> >(formData["ExtensionPages"]);
                controlSettings.Scripts           = JsonConvert.DeserializeObject <List <string> >(formData["Scripts"]);
                controlSettings.Styles            = JsonConvert.DeserializeObject <List <string> >(formData["Styles"]);
                controlSettings.SymbolsToDownload = JsonConvert.DeserializeObject <List <SymbolsConfiguration> >(formData["SymbolsToDownload"]);

                // Set provider's settings
                settingsProvider.ControlAddInSettings = controlSettings;

                logger.LogInformation($"Initialized control settings.");
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to create control settings", ex?.InnerException);
            }
        }