/// <summary> /// Get ini instnce ,if already existed one instance, can reread ini file into this instance /// </summary> /// <param name="path">*.ini file path</param> /// <param name="iniInfo">already exist instance</param> /// <returns>inifile</returns> public static IniInformation GetIniInstance(string path, IniInformation iniInfo = null) { if (iniInfo == null) { iniInfo = new IniInformation(path); } iniInfo.ReadIniFile(); GlobalConfigurationAndSetup.TraceLogger.TraceLog(String.Format("数据库配置信息:{0}", iniInfo.ToString())); return iniInfo; }
/// <summary> /// Reconfig *.ini file, if existed one inifile instance, can pass it as parameter to reuse /// </summary> /// <param name="key">section key</param> /// <param name="value">section value</param> /// <param name="iniInfo">iniInfo instance</param> /// <param name="section">section </param> /// <param name="path">*.ini file path</param> /// <returns>inifile</returns> public static void ReconfigIniFile(IniInformation iniInfo, string section = "config", string path = null) { if (path == null) { path = Application.StartupPath + @"\config.ini"; } if (iniInfo == null) { throw new ArgumentNullException("iniInfo instance is null"); } iniInfo.ReconfigureIniFile(); }
public DatabaseBusiness(IniInformation iniFile) { HisDbConnectionString = string.Format(HisDbConnectionString, iniFile.DbIp, iniFile.DbName, iniFile.UserName, iniFile.UserPassword); MallDbConnectionString = string.Format(MallDbConnectionString, iniFile.MallDbIp, iniFile.MallDbName, iniFile.MallDbUserName, iniFile.MallDbUserPassword); }
/// <summary> /// Get patient details from his database /// </summary> /// <param name="iniInfo">iniIfo instance</param> /// <param name="patientCode">patient unique code</param> /// <returns>details</returns> public IDictionary<string, string> GetPatientDetailsFromHis(IniInformation iniInfo, string patientCode) { string sqlText = string.Format("select * from {0} where {1} = '{2}'", iniInfo.TableName, iniInfo.TableField.patientCode, patientCode); var sets = ReadDataBySqlReader(sqlText, iniInfo, patientCode); if (sets == null || sets.Count == 0) { throw new Exception("read the patient error"); } return sets; }
/// <summary> /// Read patient details from his database by patient unique code(maybe Outpatient No) /// </summary> /// <param name="sqlCommand">sql query text</param> /// <param name="iniInfo">IniInformation instance</param> /// <param name="patientCode">patient unique code</param> /// <returns>Dict for all of patient details include(name,age,sex)</returns> private IDictionary<string, string> ReadDataBySqlReader(string sqlCommand, IniInformation iniInfo, string patientCode) { IDictionary<string, string> patientDetails; string sqlText = string.Format("select * from {0} where {1} = '{2}'", iniInfo.TableName, iniInfo.TableField.patientCode, patientCode); using (var reader = SqlHelper.ExecuteReader(HisDbConnectionString, System.Data.CommandType.Text, sqlText)) { patientDetails = new Dictionary<string, string>(); patientDetails.Add(iniInfo.TableField.patientName, SafeReader(iniInfo.TableField.patientName)); patientDetails.Add(iniInfo.TableField.patientAge, SafeReader(iniInfo.TableField.patientAge)); patientDetails.Add(iniInfo.TableField.patientSex, SafeReader(iniInfo.TableField.patientSex)); } return patientDetails; }