/// <summary> /// 取得設定檔的值 /// </summary> /// <param name="session"></param> /// <param name="key"></param> /// <returns></returns> public static string GetConfig(string session, string key) { LogTool.Info(ini_path, "GetConfig", "GetConfig"); string line = "", head = "", result = ""; try { StreamReader sr = new StreamReader(ini_path, Encoding.Default); //String[] value; char[] spChr = { '=' }; while ((line = sr.ReadLine()) != null) { if (line.IndexOf("[") != -1 && line.IndexOf("]") != -1) { head = line.Replace("[", "").Replace("]", ""); continue; } else { if (head == session) { if (line.StartsWith(key)) { result = line.Substring(line.IndexOf("=") + 1); break; } } else { continue; } } } sr.Close(); line = null; head = null; spChr = null; sr = null; } catch (Exception ex) { LogTool.Fatal(ini_path, "GetConfig", "GetConfig"); } LogTool.Info(result, "GetConfig", "GetConfig"); return(result); }
public Global() { string actioName = "Global"; #region egg_info_list 取得蛋知識 this.egg_info_list = new List <EGG_INFO_Q_MST>(); try { DBLink link = new DBLink(); LogTool.Info(link.dbPath, actioName, this.csName); string sql = "SELECT * FROM EGG_INFO_Q_MST"; this.egg_info_list = link.DBA.getSqlDataTable <EGG_INFO_Q_MST>(sql); if (link.DBA.hasLastError) { LogTool.Fatal(link.DBA.lastError, actioName, this.csName); } } catch (Exception ex) { LogTool.Fatal(ex, actioName, this.csName); } #endregion #region egg_event_list 取得蛋事件 this.egg_event_list = new List <EGG_EVENT_DATA>(); try { DBLink link = new DBLink(); LogTool.Info(link.dbPath, actioName, this.csName); string sql = "SELECT * FROM EGG_EVENT_DATA WHERE EVENT_IMAGE <> '0'"; this.egg_event_list = link.DBA.getSqlDataTable <EGG_EVENT_DATA>(sql); if (link.DBA.hasLastError) { LogTool.Fatal(link.DBA.lastError, actioName, this.csName); } } catch (Exception ex) { LogTool.Fatal(ex, actioName, this.csName); } #endregion }