Пример #1
0
 /// <summary>
 /// load button background
 /// </summary>
 private void LoadBtnBackground()
 {
     if (btnSetupOrUninstallService.IsEnabled)
     {
         btnSetupOrUninstallService.Background = new SolidColorBrush(Color.FromRgb((byte)42, (byte)72, (byte)254));
     }
     else
     {
         btnSetupOrUninstallService.Background = new SolidColorBrush(Color.FromRgb((byte)212, (byte)208, (byte)200));
     }
     if (btnStartOrStopService.IsEnabled)
     {
         btnStartOrStopService.Background = new SolidColorBrush(Color.FromRgb((byte)42, (byte)72, (byte)254));
     }
     else
     {
         btnStartOrStopService.Background = new SolidColorBrush(Color.FromRgb((byte)212, (byte)208, (byte)200));
     }
     if (ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(_xPathIsLogging, _path)))
     {
         btnStartOrStopLog.Content = "停用日志";
     }
     else
     {
         btnStartOrStopLog.Content = "启用日志";
     }
 }
Пример #2
0
        /// <summary>
        /// fetch sql string from config file
        /// </summary>
        /// <param name="sqlId">sql id</param>
        /// <param name="sqlFilePath">sql config file path</param>
        /// <returns>sql file path</returns>
        private string FetchSqlById(string sqlId, string sqlFilePath = "")
        {
            string sqlXPath = string.Format("/sqls/sql[@id='{0}']", sqlId);

            if (string.IsNullOrWhiteSpace(sqlFilePath))
            {
                sqlFilePath = AppDomain.CurrentDomain.BaseDirectory + "Config\\AllSqls.xml";
            }
            return(XmlTool.GetNodeValueByXPath(sqlXPath, sqlFilePath, false));
        }
Пример #3
0
        /// <summary>
        /// fetch sql string from config file
        /// </summary>
        /// <param name="sqlFileName">sql file name</param>
        /// <param name="sqlId">sql id</param>
        /// <param name="sqlFilePath">sql config file path</param>
        /// <returns>sql string</returns>
        private string FetchSqlById(string sqlFileName, string sqlId, string sqlFilePath = null)
        {
            if (string.IsNullOrWhiteSpace(sqlFileName) || string.IsNullOrWhiteSpace(sqlId))
            {
                return(string.Empty);
            }
            string sqlXPath = string.Format("/sqls/sql[@id='{0}']", sqlId);

            if (string.IsNullOrWhiteSpace(sqlFilePath))
            {
                sqlFilePath = AppDomain.CurrentDomain.BaseDirectory + string.Format("Config\\Sqls\\{0}Sqls.xml", sqlFileName);
            }
            return(XmlTool.GetNodeValueByXPath(sqlXPath, sqlFilePath, false));
        }
Пример #4
0
        /// <summary>
        /// load all setting
        /// </summary>
        internal static void LoadSetting()
        {
            BasicConfigLoaded = true;
            string styleXPath    = "/DbConfig/DbStyle";
            string trustedXPath  = "/DbConfig/DbTrusted";
            string hostXPath     = "/DbConfig/DbHost";
            string userXPath     = "/DbConfig/DbUser";
            string passwordXPath = "/DbConfig/DbPassword";
            string portXPath     = "/DbConfig/DbPort";
            string instanceXPath = "/DbConfig/DbInstance";
            string nameXPath     = "/DbConfig/DbName";
            string embedXPath    = "/DbConfig/DbEmbed";
            string positionXPath = "/DbConfig/DbPosition";
            string dbStyle       = XmlTool.GetNodeValueByXPath(styleXPath, _path);

            switch (dbStyle.ToLower())
            {
            case "sqlserver":
                DbStyle = DbStyleDefine.SqlServer;
                break;

            case "oracle":
                DbStyle = DbStyleDefine.Oracle;
                break;

            case "postgres":
                DbStyle = DbStyleDefine.Postgres;
                break;

            case "mysql":
                DbStyle = DbStyleDefine.MySql;
                break;

            case "firebird":
                DbStyle = DbStyleDefine.Firebird;
                break;

            case "sqlite":
                DbStyle = DbStyleDefine.Sqlite;
                break;

            case "access":
                DbStyle = DbStyleDefine.Access;
                break;

            default:
                DbStyle = DbStyleDefine.MySql;
                break;
            }
            DbTrusted  = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(trustedXPath, _path));
            DbHost     = XmlTool.GetNodeValueByXPath(hostXPath, _path);
            DbUser     = XmlTool.GetNodeValueByXPath(userXPath, _path);
            DbPassword = XmlTool.GetNodeValueByXPath(passwordXPath, _path);
            DbPort     = ConvertTool.GetInt(XmlTool.GetNodeValueByXPath(portXPath, _path));
            if (DbPort > 65535)
            {
                DbPort = 65534;
                XmlTool.SetNodeValueByXPath(portXPath, DbPort.ToString(), _path);
            }
            DbInstance = XmlTool.GetNodeValueByXPath(instanceXPath, _path);
            DbName     = XmlTool.GetNodeValueByXPath(nameXPath, _path);
            DbEmbed    = ConvertTool.GetBool(XmlTool.GetNodeValueByXPath(embedXPath, _path));
            DbPosition = XmlTool.GetNodeValueByXPath(positionXPath, _path);
        }