Ejemplo n.º 1
0
        /// <summary>
        /// Save Features.SavedQuery settings to the settings file
        /// </summary>
        /// <param name="sqNode">XML-node for the Features.SavedQuery settings</param>

        public void Save(XmlNode sqNode)
        {
            string xpath;

            xpath = "./storageType";
            SettingsHelper.SetSettingValue(xpath, sqNode, StorageType.ToString());

            xpath = "./enableCache";
            SettingsHelper.SetSettingValue(xpath, sqNode, EnableCache.ToString());

            xpath = "./cacheTime";
            SettingsHelper.SetSettingValue(xpath, sqNode, CacheTime.ToString());

            xpath = "./enableCORS";
            SettingsHelper.SetSettingValue(xpath, sqNode, EnableCORS.ToString());

            xpath = "./showPeriodAndId";
            SettingsHelper.SetSettingValue(xpath, sqNode, ShowPeriodAndId.ToString());

            xpath = "./enableLimiterRequest";
            SettingsHelper.SetSettingValue(xpath, sqNode, EnableLimitRequest.ToString());

            xpath = "./limiterRequests";
            SettingsHelper.SetSettingValue(xpath, sqNode, LimiterRequests.ToString());

            xpath = "./limiterTimespan";
            SettingsHelper.SetSettingValue(xpath, sqNode, LimiterTimespan.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts/configure NVelocity based on the properties.
        /// </summary>
        public void BeginInit()
        {
            vengine = new VelocityEngine();

            ExtendedProperties props = new ExtendedProperties();

            if (!string.IsNullOrEmpty(assemblyName))
            {
                AddResourceAssembly(assemblyName);
            }

            if (assemblies.Count != 0)
            {
                if (log.IsInfoEnabled)
                {
                    log.Info("Initializing NVelocityTemplateEngine component using Assemblies:");
                    foreach (string s in assemblies)
                    {
                        log.InfoFormat(" - {0}", s);
                    }
                }

                props.SetProperty(RuntimeConstants.RESOURCE_LOADER, "assembly");
                props.SetProperty("assembly.resource.loader.class", "NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader;NVelocity");
                props.SetProperty("assembly.resource.loader.cache", EnableCache.ToString().ToLower());
                props.SetProperty("assembly.resource.loader.assembly", assemblies);
            }
            else
            {
                String expandedTemplateDir = ExpandTemplateDir(templateDir);
                log.InfoFormat("Initializing NVelocityTemplateEngine component using template directory: {0}", expandedTemplateDir);

                FileInfo propertiesFile = new FileInfo(Path.Combine(expandedTemplateDir, "nvelocity.properties"));
                if (propertiesFile.Exists)
                {
                    log.Info("Found 'nvelocity.properties' on template dir, loading as base configuration");
                    using (Stream stream = propertiesFile.OpenRead())
                    {
                        props.Load(stream);
                    }
                }

                props.SetProperty(RuntimeConstants.RESOURCE_LOADER, "file");
                props.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, expandedTemplateDir);
                props.SetProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, EnableCache.ToString().ToLower());
            }

            vengine.Init(props);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Save Features.Api settings to the settings file
        /// </summary>
        /// <param name="apiNode">XML-node for the Features.Api settings</param>
        public void Save(XmlNode apiNode)
        {
            string xpath;

            xpath = "./urlRoot";
            SettingsHelper.SetSettingValue(xpath, apiNode, UrlRoot);

            xpath = "./routePrefix";
            SettingsHelper.SetSettingValue(xpath, apiNode, RoutePrefix);

            xpath = "./maxValuesReturned";
            SettingsHelper.SetSettingValue(xpath, apiNode, MaxValuesReturned.ToString());

            xpath = "./limiterRequests";
            SettingsHelper.SetSettingValue(xpath, apiNode, LimiterRequests.ToString());

            xpath = "./limiterTimespan";
            SettingsHelper.SetSettingValue(xpath, apiNode, LimiterTimespan.ToString());

            xpath = "./fetchCellLimit";
            SettingsHelper.SetSettingValue(xpath, apiNode, FetchCellLimit.ToString());

            xpath = "./enableCORS";
            SettingsHelper.SetSettingValue(xpath, apiNode, EnableCORS.ToString());

            xpath = "./enableCache";
            SettingsHelper.SetSettingValue(xpath, apiNode, EnableCache.ToString());

            xpath = "./showQueryInformation";
            SettingsHelper.SetSettingValue(xpath, apiNode, ShowQueryInformation.ToString());

            xpath = "./infoURL";
            SettingsHelper.SetSettingValue(xpath, apiNode, InfoURL);

            xpath = "./defaultExampleResponseFormat";
            SettingsHelper.SetSettingValue(xpath, apiNode, DefaultExampleResponseFormat);

            xpath = "./showSaveApiQueryButton";
            SettingsHelper.SetSettingValue(xpath, apiNode, ShowSaveApiQueryButton.ToString());

            xpath = "./saveApiQueryText";
            SettingsHelper.SetSettingValue(xpath, apiNode, SaveApiQueryText);
        }