Ejemplo n.º 1
0
        public static async Task <bool> EntryPoint()
        {
            if (BasePath != null)
            {
                return(false);
            }

            if (await Engine.LocalStorage.ContainKeyAsync("Settings"))
            {
                Console.WriteLine("Loading Settings...");
                Engine.Settings = await Engine.LocalStorage.GetItemAsync <Config>("Settings");
            }
            else
            {
                Console.WriteLine("Using Default Settings...");
                Engine.Settings = new Config()
                {
                    AcceptableRanges = "0-9A-Za-zÀ-ÃÇ-ÎÓ-ÕÚ-Ûà-ãç-îó-õú-û。-゚!?~.,[](){}''\"",
                    AllowNumbers     = true,
                    Breakline        = "\\n",
                    DenyList         = "@;§;_;<;>;/;=",
                    FromAsian        = false,
                    IgnoreList       = ";、;。;%;{;}",
                    QuoteList        = "<>;();[];“”;[];《》;«»;「」;『』;【】;();'';\"\"",
                    Sensitivity      = 3,
                    BackupOn         = 15,
                    Language         = 0
                };
            }

            await UpdateSettings(false);

            Strings.Initialize();

            BasePath = await JSWrapper.GetBaseDirectory();

            if (!BasePath.EndsWith("/"))
            {
                BasePath += "/";
            }

            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            return(true);
        }
Ejemplo n.º 2
0
        public override void Load()
        {
            System.Configuration.Configuration config;
            try
            {
                string serviceExe = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName;

                if (String.IsNullOrEmpty(serviceExe))
                {
                    serviceExe = Path.Combine(Path.Combine(Path.Combine(AppUtil.InstallDir, "bin"), "service"), "Alachisoft.NosDB.ConfigurationService.exe");
                }

                config = ConfigurationManager.OpenExeConfiguration(serviceExe);
            }
            catch (Exception ex) { return; }

            try
            {
                if (config.AppSettings.Settings["ConfigServerIP"] != null)
                {
                    IP = IPAddress.Parse(config.AppSettings.Settings["ConfigServerIP"].Value);
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["ConfigServerPort"] != null)
                {
                    int tempInt = Int32.Parse(config.AppSettings.Settings["ConfigServerPort"].Value);

                    if (tempInt <= 0)
                    {
                        throw new Exception("");
                    }
                    Port = tempInt;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["LogConfiguration"] != null)
                {
                    LogConfiguration = config.AppSettings.Settings["LogConfiguration"].Value;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["BasePath"] != null)
                {
                    BasePath = config.AppSettings.Settings["BasePath"].Value;
                    if (!(BasePath.EndsWith("\\") || BasePath.EndsWith("/")))
                    {
                        BasePath += "\\";
                    }
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["DeploymentPath"] != null)
                {
                    DeploymentPath = config.AppSettings.Settings["DeploymentPath"].Value;
                    if (!(DeploymentPath.EndsWith("\\") || DeploymentPath.EndsWith("/")))
                    {
                        BasePath += "\\";
                    }
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["CurrentUsername"] != null)
                {
                    CurrentUsername = config.AppSettings.Settings["CurrentUsername"].Value;
                }
            }
            catch (Exception ex) { }

            try
            {
                IsSecurityEnabled = true;
                if (config.AppSettings.Settings["IsSecurityEnabled"] != null)
                {
                    bool isSecurityEnabled;
                    Boolean.TryParse(config.AppSettings.Settings["IsSecurityEnabled"].Value, out isSecurityEnabled);
                    IsSecurityEnabled = isSecurityEnabled;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["ConfigServerConfigurationFile"] != null)
                {
                    ConfigurationFile = config.AppSettings.Settings["ConfigServerConfigurationFile"].Value;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["SecurityConfigFile"] != null)
                {
                    SecurityConfigFile = config.AppSettings.Settings["SecurityConfigFile"].Value;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["DbManagementServerPort"] != null)
                {
                    int tempPort = Int32.Parse(config.AppSettings.Settings["DbManagementServerPort"].Value);
                    if (tempPort < 1024)
                    {
                        tempPort = Util.NetworkUtil.DEFAULT_DB_HOST_PORT;
                    }
                    ManagementServerPort = tempPort;
                }
            }
            catch (Exception ex) { }
        }
Ejemplo n.º 3
0
        public override void Load()
        {
            LoadCsConfig();
            LoadRestApiConfig();
            System.Configuration.Configuration config;
            try
            {
                string serviceExe = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName;
                if (String.IsNullOrEmpty(serviceExe))
                {
                    serviceExe = Path.Combine(Path.Combine(Path.Combine(AppUtil.InstallDir, "bin"), "service"), "Alachisoft.NosDB.DatabaseService.exe");
                }
                config = ConfigurationManager.OpenExeConfiguration(serviceExe);
            }
            catch (Exception ex) { return; }

            try
            {
                if (config.AppSettings.Settings["ManagementServerIP"] != null)
                {
                    IP = IPAddress.Parse(config.AppSettings.Settings["ManagementServerIP"].Value);
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["ManagementServerPort"] != null)
                {
                    int tempInt = Int32.Parse(config.AppSettings.Settings["ManagementServerPort"].Value);

                    if (tempInt <= 0)
                    {
                        throw new Exception("");
                    }
                    Port = tempInt;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["LogConfiguration"] != null)
                {
                    LogConfiguration = config.AppSettings.Settings["LogConfiguration"].Value;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["DataPath"] != null)
                {
                    BasePath = config.AppSettings.Settings["DataPath"].Value;
                    if (!(BasePath.EndsWith("\\") || BasePath.EndsWith("/")))
                    {
                        BasePath += "\\";
                    }
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["ServerConfigfile"] != null)
                {
                    ConfigurationFile = config.AppSettings.Settings["ServerConfigfile"].Value;
                }
            }
            catch (Exception ex) { }

            try
            {
                IsSecurityEnabled = true;
                if (config.AppSettings.Settings["IsSecurityEnabled"] != null)
                {
                    bool isSecurityEnabled;
                    Boolean.TryParse(config.AppSettings.Settings["IsSecurityEnabled"].Value, out isSecurityEnabled);
                    IsSecurityEnabled = isSecurityEnabled;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["DeploymentPath"] != null)
                {
                    DeploymentPath = config.AppSettings.Settings["DeploymentPath"].Value;
                    if (!(DeploymentPath.EndsWith("\\") || DeploymentPath.EndsWith("/")))
                    {
                        BasePath += "\\";
                    }
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["OperationLogSize"] != null)
                {
                    OpLogSize = Convert.ToInt64(config.AppSettings.Settings["OperationLogSize"].Value) * 1024 * 1024;
                }
            }
            catch (Exception ex) { }

            try
            {
                if (config.AppSettings.Settings["SecurityConfigFile"] != null)
                {
                    SecurityConfigFile = config.AppSettings.Settings["SecurityConfigFile"].Value;
                }
            }
            catch (Exception ex) { }
        }