/// <summary>
        /// 获取最后连接字符串MSSQL/MySQL
        /// </summary>
        /// <param name="sqlType">数据库类型,MSSQL/MySQL</param>
        /// <returns>数组 string[] sqlType, int sqlType, string Host, bool isPort, string Port, string Database, string Username, string Password</returns>
        public static string[] getLastConnectionStrings(string sqlType)
        {
            string temp = RWConfig.GetappSettingsValue("LastConnectionStringsFor" + sqlType, ConfigPath);

            string[] result = temp.Split(';');
            return(result);
        }
        /// <summary>
        /// 设置最后连接字符串
        /// </summary>
        /// <param name="sqlType">数据库类型 0=mssql 1=mysql</param>
        /// <param name="Host">数据库地址</param>
        /// <param name="isPort">是否需要端口</param>
        /// <param name="Port">端口号</param>
        /// <param name="Database">数据库名</param>
        /// <param name="Username">用户名</param>
        /// <param name="Password">密码</param>
        /// <returns>true/false</returns>
        public static bool setLastConnectionStrings(int sqlType, string Host, bool isPort, string Port, string Database, string Username, string Password)
        {
            string value = sqlType + ";" + Host + ";" + isPort + ";" + Port + ";" + Database + ";" + Username + ";" + Password;

            if (sqlType == 0 || sqlType == 1)//0=mssql,1=mysql
            {
                if (sqlType == 0)
                {
                    RWConfig.SetappSettingsValue("LastConnectionStringsForMSSQL", value, ConfigPath);
                    return(true);
                }
                if (sqlType == 1)
                {
                    RWConfig.SetappSettingsValue("LastConnectionStringsForMySQL", value, ConfigPath);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 根据常用SQL编码删除常用SQL
 /// </summary>
 /// <param name="CommonlyUsedSQLCode">常用SQL编码</param>
 /// <returns>string:删除成功/删除失败/没有匹配项/报错信息</returns>
 public static string delCommonlyUsedSQLCodeNameValue(string CommonlyUsedSQLCode)
 {
     try
     {
         string[] str = getCommonlyUsedSQLAllCodes();
         foreach (var item in str)
         {
             if (item == CommonlyUsedSQLCode)
             {
                 if (RWConfig.DelappSettingsValue(CommonlyUsedSQLCode, ConfigPath) == true)
                 {
                     List <string> list = str.ToList();
                     list.Remove(item);
                     str = list.ToArray();
                     string result = String.Join(";", str);
                     RWConfig.SetappSettingsValue("CommonlyUsedSQL", result, ConfigPath);
                     return(CommonlyUsedSQLCode + " 删除成功!");
                 }
                 else
                 {
                     return(CommonlyUsedSQLCode + " 删除失败!");
                 }
             }
         }
         return("没有匹配项!");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
        /// <summary>
        /// 根据快捷插入模块编码获取快捷插入模块名称、值
        /// </summary>
        public static string[] getQuickInsertModelNameValueByCode(string QuickInsertModelCode)
        {
            string[] result = { };
            string   str    = RWConfig.GetappSettingsValue(QuickInsertModelCode, ConfigPath);

            result = str.Split(';');
            return(result);
        }
        /// <summary>
        /// 根据配置文件中的Key获取对应Value
        /// </summary>
        /// <param name="ConfigKey">配置文件中的Key</param>
        /// <returns>返回Key对应Value,数组</returns>
        public static string[] getConfigValueByKey(string ConfigKey)
        {
            string[] result = { };
            string   str    = RWConfig.GetappSettingsValue(ConfigKey, ConfigPath);

            result = str.Split(';');
            return(result);
        }
 /// <summary>
 /// 如果配置文件中无常用SQL配置,则新建配置,值默认
 /// </summary>
 public static void setDefaultCommonlyUsedSQLIfIsNullOrEmptyByappSettings()
 {
     if (string.IsNullOrEmpty(CommonlyUsedSQL))
     {
         RWConfig.SetappSettingsValue("CommonlyUsedSQL", "CommonlyUsedSQL_Default", ConfigPath);
     }
     if (string.IsNullOrEmpty(CommonlyUsedSQL_Default))
     {
         RWConfig.SetappSettingsValue("CommonlyUsedSQL_Default", "常用SQL名;select * from xxx", ConfigPath);
     }
 }
 /// <summary>
 /// 获取配置文件中快捷插入配置
 /// </summary>
 public static void getQuickInsertSettingsByappSettings()
 {
     QuickInsert                 = RWConfig.GetappSettingsValue("QuickInsert", ConfigPath);
     QuickInsert_IDIncrement     = RWConfig.GetappSettingsValue("QuickInsert_IDIncrement", ConfigPath);
     QuickInsert_RandomNum       = RWConfig.GetappSettingsValue("QuickInsert_RandomNum", ConfigPath);
     QuickInsert_NewID           = RWConfig.GetappSettingsValue("QuickInsert_NewID", ConfigPath);
     QuickInsert_NewDateTime     = RWConfig.GetappSettingsValue("QuickInsert_NewDateTime", ConfigPath);
     QuickInsert_SameNewID       = RWConfig.GetappSettingsValue("QuickInsert_SameNewID", ConfigPath);
     QuickInsert_RandomStr       = RWConfig.GetappSettingsValue("QuickInsert_RandomStr", ConfigPath);
     QuickInsert_IDIncrementPlus = RWConfig.GetappSettingsValue("QuickInsert_IDIncrementPlus", ConfigPath);
 }
 /// <summary>
 /// 获取配置文件中右侧常用按钮的Text值
 /// </summary>
 public static void getDefaultBtnNameByappSettings()
 {
     btnname1 = RWConfig.GetappSettingsValue("btnname1", "./ToolsCollectionForProgram.exe");
     btnname2 = RWConfig.GetappSettingsValue("btnname2", "./ToolsCollectionForProgram.exe");
     btnname3 = RWConfig.GetappSettingsValue("btnname3", "./ToolsCollectionForProgram.exe");
     btnname4 = RWConfig.GetappSettingsValue("btnname4", "./ToolsCollectionForProgram.exe");
     btnname5 = RWConfig.GetappSettingsValue("btnname5", "./ToolsCollectionForProgram.exe");
     btnname6 = RWConfig.GetappSettingsValue("btnname6", "./ToolsCollectionForProgram.exe");
     btnname7 = RWConfig.GetappSettingsValue("btnname7", "./ToolsCollectionForProgram.exe");
     btnname8 = RWConfig.GetappSettingsValue("btnname8", "./ToolsCollectionForProgram.exe");
     btnname9 = RWConfig.GetappSettingsValue("btnname9", "./ToolsCollectionForProgram.exe");
 }
 /// <summary>
 /// 设置最后连接数据库类型
 /// </summary>
 /// <param name="sqlType">数据库类型,MSSQL/MySQL</param>
 /// <returns>true/false</returns>
 public static bool setLastConnectionType(string sqlType)
 {
     if (sqlType == "MSSQL" || sqlType == "MySQL")
     {
         RWConfig.SetappSettingsValue("LastConnectionType", sqlType, ConfigPath);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #10
0
 /// <summary>
 /// 新增appSettings配置
 /// </summary>
 /// <param name="Key">appSettings键</param>
 /// <param name="Value">appSettings值</param>
 /// <returns>true, false</returns>
 public static bool addappSettings(string key, string value)
 {
     try
     {
         RWConfig.SetappSettingsValue(key, value, CONFIGPATH);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #11
0
 private void getDefaultAppSettings()
 {
     appsetting1   = RWConfig.GetappSettingsValue("1", "./ANDOperationForBase.exe");
     appsetting2   = RWConfig.GetappSettingsValue("2", "./ANDOperationForBase.exe");
     appsetting4   = RWConfig.GetappSettingsValue("4", "./ANDOperationForBase.exe");
     appsetting8   = RWConfig.GetappSettingsValue("8", "./ANDOperationForBase.exe");
     appsetting16  = RWConfig.GetappSettingsValue("16", "./ANDOperationForBase.exe");
     appsetting32  = RWConfig.GetappSettingsValue("32", "./ANDOperationForBase.exe");
     appsetting64  = RWConfig.GetappSettingsValue("64", "./ANDOperationForBase.exe");
     appsetting128 = RWConfig.GetappSettingsValue("128", "./ANDOperationForBase.exe");
     appsetting256 = RWConfig.GetappSettingsValue("256", "./ANDOperationForBase.exe");
     appsetting512 = RWConfig.GetappSettingsValue("512", "./ANDOperationForBase.exe");
 }
        /// <summary>
        /// 根据数据库类型保存数据库连接记录
        /// </summary>
        /// <param name="sqlType">数据库类型 MSSQL MySQL</param>
        /// <param name="Host">数据库地址</param>
        /// <param name="isPort">是否需要端口</param>
        /// <param name="Port">端口号</param>
        /// <param name="Database">数据库名</param>
        /// <param name="Username">用户名</param>
        /// <param name="Password">密码</param>
        /// <returns>返回true/false</returns>
        public static bool saveConnectionStringBySQLType(string sqlType, string Host, bool isPort, string Port, string Database, string Username, string Password)
        {
            try
            {
                int n = getSameValueLenth(sqlType + "_Host", Host); //Host计数
                if (n == 0)                                         //说明没有该记录
                {
                    string[]      array = getConfigValueByKey(sqlType + "_Host");
                    List <string> List  = array.ToList();
                    List.Add(Host);
                    array = List.ToArray();
                    string value;
                    if (array[0] == "")
                    {
                        value = array[array.Length - 1];
                    }
                    else
                    {
                        value = String.Join(";", array);
                    }
                    RWConfig.SetappSettingsValue(sqlType + "_Host", value, ConfigPath);
                }

                n = getSameValueLenth(sqlType + "_DB_" + Host, Database); //DB计数
                if (n == 0)                                               //说明没有该记录
                {
                    string[]      array = getConfigValueByKey(sqlType + "_DB_" + Host);
                    List <string> List  = array.ToList();
                    List.Add(Database);
                    array = List.ToArray();
                    string value;
                    if (array[0] == "")
                    {
                        value = array[array.Length - 1];
                    }
                    else
                    {
                        value = String.Join(";", array);
                    }
                    RWConfig.SetappSettingsValue(sqlType + "_DB_" + Host, value, ConfigPath);
                }

                RWConfig.SetappSettingsValue(sqlType + "_Host_" + Host, isPort + ";" + Port + ";" + Username + ";" + Password, ConfigPath);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #13
0
 /// <summary>
 /// 获取配置文件中快捷插入配置所有配置编码
 /// </summary>
 public static string[] getQuickInsertSettingsAllCodes()
 {
     string[] result = { };
     QuickInsert = RWConfig.GetappSettingsValue("QuickInsert", ConfigPath);
     if (string.IsNullOrEmpty(QuickInsert))
     {
         setDefaultQuickInsertSettingsIfIsNullOrEmptyByappSettings();
         getQuickInsertSettingsByappSettings();
     }
     else
     {
         result = QuickInsert.Split(';');
     }
     return(result);
 }
Пример #14
0
 /// <summary>
 /// 获取配置文件中常用SQL配置所有配置编码
 /// </summary>
 public static string[] getCommonlyUsedSQLAllCodes()
 {
     string[] result = { };
     CommonlyUsedSQL = RWConfig.GetappSettingsValue("CommonlyUsedSQL", ConfigPath);
     if (string.IsNullOrEmpty(CommonlyUsedSQL))
     {
         setDefaultCommonlyUsedSQLIfIsNullOrEmptyByappSettings();
         getCommonlyUsedSQLByappSettings();
     }
     else
     {
         result = CommonlyUsedSQL.Split(';');
     }
     return(result);
 }
Пример #15
0
        /// <summary>
        /// 根据常用SQL编码获取常用SQL名称、语句
        /// </summary>
        public static string[] getCommonlyUsedSQLNameValueByCode(string CommonlyUsedSQLCode)
        {
            string[] result = { };
            string   str    = RWConfig.GetappSettingsValue(CommonlyUsedSQLCode, ConfigPath);

            result = str.Split(';');
            //数组转list,去除元素中结尾是空的元素
            List <string> list = result.ToList();

            for (int i = 0; i < list.Count; i++)
            {
                if (string.IsNullOrEmpty(list[list.Count - 1]))
                {
                    list.RemoveAt(list.Count - 1);
                }
            }
            result = list.ToArray();
            return(result);
        }
Пример #16
0
 /// <summary>
 /// 修改常用SQL配置
 /// </summary>
 /// <param name="Code">常用SQL编码</param>
 /// <param name="Name">常用SQL名称</param>
 /// <param name="Value">常用SQL语句</param>
 /// <returns>string:修改成功/修改失败/报错信息</returns>
 public static string editCommonlyUsedSQLCodeNameValue(string Code, string Name, string Value)
 {
     try
     {
         if (string.IsNullOrEmpty(Code) || string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Value))
         {
             return("常用SQL编码/名称/语句不能为空!");
         }
         else
         {
             RWConfig.SetappSettingsValue(Code, Name + ";" + Value, ConfigPath);
             return("修改成功");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Пример #17
0
 /// <summary>
 /// 修改快捷插入配置
 /// </summary>
 /// <param name="Code">快捷插入配置编码</param>
 /// <param name="Name">快捷插入配置名称</param>
 /// <param name="Value">快捷插入配置值</param>
 /// <returns>string:修改成功/修改失败/报错信息</returns>
 public static string editQuickInsertModelCodeNameValue(string Code, string Name, string Value, string Instruction)
 {
     try
     {
         if (string.IsNullOrEmpty(Code) || string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Value) || string.IsNullOrEmpty(Instruction))
         {
             return("快捷插入配置编码/名称/值/使用说明不能为空!");
         }
         else
         {
             RWConfig.SetappSettingsValue(Code, Name + ";" + Value + ";" + Instruction, ConfigPath);
             return("修改成功");
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Пример #18
0
 private void setDefaultAppSettingsIfIsNullOrEmpty()
 {
     if (string.IsNullOrEmpty(appsetting1))
     {
         RWConfig.SetappSettingsValue("1", "1", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting2))
     {
         RWConfig.SetappSettingsValue("2", "2", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting4))
     {
         RWConfig.SetappSettingsValue("4", "4", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting8))
     {
         RWConfig.SetappSettingsValue("8", "8", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting16))
     {
         RWConfig.SetappSettingsValue("16", "16", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting32))
     {
         RWConfig.SetappSettingsValue("32", "32", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting64))
     {
         RWConfig.SetappSettingsValue("64", "64", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting128))
     {
         RWConfig.SetappSettingsValue("128", "128", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting256))
     {
         RWConfig.SetappSettingsValue("256", "256", "./ANDOperationForBase.exe");
     }
     if (string.IsNullOrEmpty(appsetting512))
     {
         RWConfig.SetappSettingsValue("512", "512", "./ANDOperationForBase.exe");
     }
 }
Пример #19
0
 /// <summary>
 /// 修改appSettings配置
 /// </summary>
 /// <param name="Key">appSettings键</param>
 /// <param name="Value">appSettings值</param>
 /// <returns>true, false</returns>
 public static bool editappSettings(string key, string value)
 {
     try
     {
         if (!string.IsNullOrEmpty(RWConfig.GetappSettingsValue(key, CONFIGPATH)))
         {
             RWConfig.SetappSettingsValue(key, value, CONFIGPATH);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #20
0
        /// <summary>
        /// 查询appSettings配置,并对键值以分号分割
        /// </summary>
        /// <param name="Key">appSettings键</param>
        /// <returns>appSettings值,以分号分割,返回数组</returns>
        public static string[] getappSettingsSplitBySemicolon(string key)
        {
            string[] result = { };
            string   values = RWConfig.GetappSettingsValue(key, CONFIGPATH);

            for (int i = 0; i < 2; i++)
            {
                if (string.IsNullOrEmpty(values))
                {
                    init();
                }
                else
                {
                    result = values.Split(';');
                    break;
                }
            }
            return(result);
        }
Пример #21
0
        /// <summary>
        /// 新增常用SQL配置
        /// </summary>
        /// <param name="Code">常用SQL编码</param>
        /// <param name="Name">常用SQL名称</param>
        /// <param name="Value">常用SQL语句</param>
        /// <returns>string:新增成功/新增失败/新增项已存在,新增失败/报错信息</returns>
        public static string setCommonlyUsedSQLCodeNameValue(string Code, string Name, string Value)
        {
            try
            {
                if (string.IsNullOrEmpty(Code) || string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Value))
                {
                    return("常用SQL编码/名称/语句不能为空!");
                }
                else
                {
                    string[] str = getQuickInsertSettingsAllCodes();
                    foreach (var item in str)
                    {
                        if (item == Code)
                        {
                            return("在快捷插入配置编码中已存在相同编码,请确认!");
                        }
                    }

                    str = getCommonlyUsedSQLAllCodes();
                    foreach (var item in str)
                    {
                        if (item == Code)
                        {
                            return("在常用SQL配置编码中已存在相同编码,请确认!");
                        }
                    }

                    CommonlyUsedSQL = RWConfig.GetappSettingsValue("CommonlyUsedSQL", ConfigPath);
                    RWConfig.SetappSettingsValue(Code, Name + ";" + Value, ConfigPath);
                    RWConfig.SetappSettingsValue("CommonlyUsedSQL", CommonlyUsedSQL + ";" + Code, ConfigPath);
                    return("新增成功");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
 /// <summary>
 /// 如果配置文件中无右侧常用按钮的配置,则新建配置,值全为“暂无功能”
 /// </summary>
 public static void setDefaultBtnNameIfIsNullOrEmptyByappSettings()
 {
     if (string.IsNullOrEmpty(btnname1))
     {
         RWConfig.SetappSettingsValue("btnname1", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname2))
     {
         RWConfig.SetappSettingsValue("btnname2", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname3))
     {
         RWConfig.SetappSettingsValue("btnname3", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname4))
     {
         RWConfig.SetappSettingsValue("btnname4", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname5))
     {
         RWConfig.SetappSettingsValue("btnname5", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname6))
     {
         RWConfig.SetappSettingsValue("btnname6", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname7))
     {
         RWConfig.SetappSettingsValue("btnname7", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname8))
     {
         RWConfig.SetappSettingsValue("btnname8", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     if (string.IsNullOrEmpty(btnname9))
     {
         RWConfig.SetappSettingsValue("btnname9", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
 }
Пример #23
0
 /// <summary>
 /// 保存常用功能按钮配置
 /// </summary>
 public void setCommonFunctionsButtonName()
 {
     if (cmbboxCommonFunctionsButton1.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname1", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname1", cmbboxCommonFunctionsButton1.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton2.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname2", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname2", cmbboxCommonFunctionsButton2.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton3.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname3", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname3", cmbboxCommonFunctionsButton3.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton4.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname4", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname4", cmbboxCommonFunctionsButton4.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton5.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname5", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname5", cmbboxCommonFunctionsButton5.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton6.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname6", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname6", cmbboxCommonFunctionsButton6.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton7.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname7", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname7", cmbboxCommonFunctionsButton7.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton8.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname8", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname8", cmbboxCommonFunctionsButton8.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
     if (cmbboxCommonFunctionsButton9.SelectedIndex == -1)
     {
         RWConfig.SetappSettingsValue("btnname9", "暂无功能", "./ToolsCollectionForProgram.exe");
     }
     else
     {
         RWConfig.SetappSettingsValue("btnname9", cmbboxCommonFunctionsButton9.SelectedItem.ToString(), "./ToolsCollectionForProgram.exe");
     }
 }
Пример #24
0
 /// <summary>
 /// 获取配置文件中常用SQL配置
 /// </summary>
 public static void getCommonlyUsedSQLByappSettings()
 {
     CommonlyUsedSQL         = RWConfig.GetappSettingsValue("CommonlyUsedSQL", ConfigPath);
     CommonlyUsedSQL_Default = RWConfig.GetappSettingsValue("CommonlyUsedSQL_Default", ConfigPath);
 }
Пример #25
0
        /// <summary>
        /// 查询appSettings配置
        /// </summary>
        /// <param name="Key">appSettings键</param>
        /// <returns>appSettings值</returns>
        public static string getappSettings(string key)
        {
            string result = RWConfig.GetappSettingsValue(key, CONFIGPATH);

            return(result);
        }
Пример #26
0
        /// <summary>
        /// 如果配置文件中无快捷插入配置,则新建配置,值默认
        /// </summary>
        public static void setDefaultQuickInsertSettingsIfIsNullOrEmptyByappSettings()
        {
            if (string.IsNullOrEmpty(QuickInsert))
            {
                RWConfig.SetappSettingsValue("QuickInsert", "QuickInsert_IDIncrement;QuickInsert_RandomNum;QuickInsert_NewID;QuickInsert_NewDateTime;QuickInsert_SameNewID;QuickInsert_RandomStr;QuickInsert_IDIncrementPlus", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_IDIncrement))
            {
                RWConfig.SetappSettingsValue("QuickInsert_IDIncrement", "指定id递增;{{id:x}};x替换为开始的序号,从x开始生成(包含x)", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_RandomNum))
            {
                RWConfig.SetappSettingsValue("QuickInsert_RandomNum", "指定范围随机数;{{[1-2]}};-左边开始&#xA;-右边结束&#xA;不带小数点生成的随机数也不带", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_NewID))
            {
                RWConfig.SetappSettingsValue("QuickInsert_NewID", "生成newid/uuid;{{newid}};有匹配项就替换为新uuid", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_NewDateTime))
            {
                RWConfig.SetappSettingsValue("QuickInsert_NewDateTime", "指定时间递增;{{timed+x:yyyy-MM-dd HH:mm:ss}};+左边为时间类型(d|h|m|s 对应 日|时|分|秒)&#xA;+右边为递增/递减值", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_SameNewID))
            {
                RWConfig.SetappSettingsValue("QuickInsert_SameNewID", "生成相同newid/uuid;{{samenewid}};一次执行多条sql,使用相同uuid", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_RandomStr))
            {
                RWConfig.SetappSettingsValue("QuickInsert_RandomStr", "在指定元素中随机选择一项;{{[x;y;z...]}};x、y、z为指定元素,\n能在元素中随机选择一项,\n请将;换成英文分号", ConfigPath);
            }
            if (string.IsNullOrEmpty(QuickInsert_IDIncrementPlus))
            {
                RWConfig.SetappSettingsValue("QuickInsert_IDIncrementPlus", "指定id按指定数递增;{{id+x:y}};从y开始按指定x+-*/,\n(+|-|*|/)x:y,\n{{id-7:77}},\n77、70、63...", ConfigPath);
            }

            //快捷插入中缺失默认配置会自动新增
            getQuickInsertSettingsByappSettings();
            string append = "";

            string[] arrayQuickInsert = QuickInsert.Split(';');
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_IDIncrement") == -1)
            {
                append += ";QuickInsert_IDIncrement";
            }
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_RandomNum") == -1)
            {
                append += ";QuickInsert_RandomNum";
            }
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_NewID") == -1)
            {
                append += ";QuickInsert_NewID";
            }
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_NewDateTime") == -1)
            {
                append += ";QuickInsert_NewDateTime";
            }
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_SameNewID") == -1)
            {
                append += ";QuickInsert_SameNewID";
            }
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_RandomStr") == -1)
            {
                append += ";QuickInsert_RandomStr";
            }
            if (Array.IndexOf(arrayQuickInsert, "QuickInsert_IDIncrementPlus") == -1)
            {
                append += ";QuickInsert_IDIncrementPlus";
            }
            //不为空才更新,否则每次运行都会更新
            if (!string.IsNullOrEmpty(append))
            {
                RWConfig.SetappSettingsValue("QuickInsert", QuickInsert + append, ConfigPath);
            }
        }
        /// <summary>
        /// 获取最后连接数据库类型
        /// </summary>
        /// <returns>返回数据库类型,MSSQL/MySQL</returns>
        public static string getLastConnectionType()
        {
            string result = RWConfig.GetappSettingsValue("LastConnectionType", ConfigPath);

            return(result);
        }