public static ArrayList getAllZone() { List <ZoneInfo> list = new List <ZoneInfo>(); try { Hashtable zoneCache = DBCache.GetZoneCache(); if (zoneCache != null && zoneCache.Count > 0) { ICollection values = zoneCache.Values; foreach (ZoneInfo item in values) { list.Add(item); } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get all zone error : " + ex.Message + "\n" + ex.StackTrace); } list.Sort((ZoneInfo x, ZoneInfo y) => x.z_name.CompareTo(y.z_name)); ArrayList arrayList = new ArrayList(); foreach (ZoneInfo current in list) { arrayList.Add(current); } return(arrayList); }
public SMTPSetting() { try { SMTPSetting sMTPSetting = DBCache.GetSMTPSetting(); if (sMTPSetting != null) { this.smtp_enable = sMTPSetting.Status; this.smtp_server = sMTPSetting.ServerIP; this.smtp_port = sMTPSetting.Port; this.smtp_from = sMTPSetting.Sender; this.smtp_to = sMTPSetting.Receiver; this.smtp_event = sMTPSetting.EVENT; this.smtp_auth = sMTPSetting.AuthenticationFlag; this.smtp_account = sMTPSetting.AccountName; this.smtp_pwd = sMTPSetting.AccountPwd; } else { this.smtp_enable = 0; this.smtp_server = ""; this.smtp_port = 25; this.smtp_from = ""; this.smtp_to = ""; this.smtp_event = ""; this.smtp_auth = 0; this.smtp_account = ""; this.smtp_pwd = ""; } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
private void FillCitationCounts() { var topicEx = FeatureRegex.TopicNum; var messageEx = FeatureRegex.MessageNum; foreach (var message in DBCache.GetPostMessagesFromDB(buhOnlineContext)) { foreach (Match match in topicEx.Matches(message)) { var topicId = int.Parse(match.Groups[1].Value); if (!TopicCitedCounts.ContainsKey(topicId)) { TopicCitedCounts[topicId] = 0; } TopicCitedCounts[topicId]++; } foreach (Match match in messageEx.Matches(message)) { var messageId = int.Parse(match.Groups[1].Value); if (!MessageCitedCounts.ContainsKey(messageId)) { MessageCitedCounts[messageId] = 0; } MessageCitedCounts[messageId]++; } } }
public static List <GroupInfo> GetPartGroup(int i_selectflag) { List <GroupInfo> list = new List <GroupInfo>(); try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0) { ICollection values = groupCache.Values; foreach (GroupInfo groupInfo in values) { if (i_selectflag == 2) { GroupInfo item = new GroupInfo(groupInfo); list.Add(item); } else { if (groupInfo.SelectedFlag == i_selectflag) { GroupInfo item2 = new GroupInfo(groupInfo); list.Add(item2); } } } } list.Sort((GroupInfo x, GroupInfo y) => x.group_name.CompareTo(y.group_name)); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } return(list); }
public static bool CheckColor(long l_id, int i_color) { try { Hashtable zoneCache = DBCache.GetZoneCache(); if (zoneCache != null && zoneCache.Count > 0) { ICollection values = zoneCache.Values; foreach (ZoneInfo zoneInfo in values) { long zoneID = zoneInfo.ZoneID; string zoneColor = zoneInfo.ZoneColor; if (zoneColor.Equals(string.Concat(i_color))) { bool result; if (zoneID == l_id) { result = true; return(result); } result = false; return(result); } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } return(true); }
public static bool CheckGroupName(long l_gid, string str_gname) { try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0) { ICollection values = groupCache.Values; foreach (GroupInfo groupInfo in values) { if (groupInfo.group_name.Equals(str_gname)) { bool result; if (groupInfo.id == l_gid) { result = true; return(result); } result = false; return(result); } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); bool result = false; return(result); } return(true); }
public static DataTable GetMemberNameInfo(long l_gid) { DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn("memberid"); dataColumn.DataType = Type.GetType("System.Int64"); dataTable.Columns.Add(dataColumn); DataColumn dataColumn2 = new DataColumn("name"); dataColumn2.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn2); DataColumn dataColumn3 = new DataColumn("parentname"); dataColumn3.DataType = Type.GetType("System.String"); dataTable.Columns.Add(dataColumn3); try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0 && groupCache.ContainsKey(l_gid)) { GroupInfo groupInfo = (GroupInfo)groupCache[l_gid]; string groupType; if ((groupType = groupInfo.GroupType) != null) { if (< PrivateImplementationDetails > { DC6F5227 - DF66 - 41C5 - 8461 - C47389EE7A9A }.$$method0x60000f3 - 1 == null) {
public void Close() { try { this.bNotInUse = true; this.con.Close(); if (this.DBSource_Type == 1) { DBCache.CloseSysDB(this.GetHashCode()); } else { if (this.DBSource_Type == 2) { DBCache.CloseDataDB(this.GetHashCode()); } else { if (this.DBSource_Type == 3) { DBCache.CloseThermalDB(this.GetHashCode()); } } } } catch (Exception) { } }
private static void GetThanksPositionsInTopics() { var featuresContext = (FeaturesContext)FeaturesDBConnection.GetInstance().GetContext; var topicIds = buhOnlineContext.yaf_Topic.Select(p => p.TopicID).ToArray(); var thankDict = FileProcessing.MessageIdAndIsThankPost.ToDictionary(); foreach (var topicId in topicIds) { var messages = DBCache.GetTopicMessages(topicId, buhOnlineContext); var posts = messages.Where(m => thankDict[m.MessageID] == 1).Select(m => m.Position); ThanksPositionsInTopics.Add(topicId, new HashSet <int>(posts)); } }
public PortInfo(int l_did, int i_portnum) { try { Hashtable devicePortMap = DBCache.GetDevicePortMap(); Hashtable portCache = DBCache.GetPortCache(); if (devicePortMap != null && devicePortMap.Count > 0 && portCache != null && portCache.Count > 0 && devicePortMap.ContainsKey(l_did)) { List <int> list = (List <int>)devicePortMap[l_did]; if (list != null) { foreach (int current in list) { PortInfo portInfo = (PortInfo)portCache[current]; if (portInfo != null && portInfo.PortNum == i_portnum) { this.id = portInfo.ID; this.device_id = portInfo.DeviceID; this.port_num = portInfo.PortNum; this.port_nm = portInfo.PortName; this.max_voltage = portInfo.Max_voltage; this.min_voltage = portInfo.Min_voltage; this.max_power_diss = portInfo.Max_power_diss; this.min_power_diss = portInfo.Min_power_diss; this.max_power = portInfo.Max_power; this.min_power = portInfo.Min_power; this.max_current = portInfo.Max_current; this.min_current = portInfo.Min_current; this.port_confirmation = portInfo.OutletConfirmation; this.port_ondelay_time = portInfo.OutletOnDelayTime; this.port_offdelay_time = portInfo.OutletOffDelayTime; this.shutdown_method = portInfo.OutletShutdownMethod; try { this.port_mac = portInfo.OutletMAC; } catch { this.port_mac = ""; } } } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
static CheckedQuestionViewModel Build(CheckedQuestion model, short poolid) { var db = new DBCache(); var answers = db.GetCheckedAnswers(poolid); var q = new CheckedQuestionViewModel(model); var answersVMs = new List <CheckedAnswerViewModel>(); var a = answers.Single(x => x.Key == model.ID); foreach (var item in a) { answersVMs.Add(new CheckedAnswerViewModel(item, q)); } q.Answers = answersVMs; return(q); }
public static GroupInfo GetGroupByID(long l_id) { try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.ContainsKey(l_id)) { GroupInfo gp_scr = (GroupInfo)groupCache[l_id]; return(new GroupInfo(gp_scr)); } } catch (Exception) { } return(null); }
public static ZoneInfo getZoneByID(long l_id) { ZoneInfo result = null; try { Hashtable zoneCache = DBCache.GetZoneCache(); if (zoneCache != null && zoneCache.Count > 0 && zoneCache.ContainsKey(l_id)) { result = (ZoneInfo)zoneCache[l_id]; } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get all zone error : " + ex.Message + "\n" + ex.StackTrace); } return(result); }
public LogSetting() { try { Hashtable sysParameterCache = DBCache.GetSysParameterCache(); if (sysParameterCache != null && sysParameterCache.Count > 0) { object obj = sysParameterCache["LIMITTYPE"]; if (obj != null) { this.maintenance = (int)Convert.ToInt16(obj); } obj = sysParameterCache["DAYLIMIT"]; if (obj != null) { this.days = Convert.ToInt32(obj); } obj = sysParameterCache["RECORDSLIMIT"]; if (obj != null) { this.recordNum = Convert.ToInt32(obj); } obj = sysParameterCache["PAGESIZE"]; if (obj != null) { this.pageSize = Convert.ToInt32(obj); } obj = sysParameterCache["SAVERANGE"]; if (obj != null) { this.saveRange = Convert.ToInt32(obj); } } else { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get LogSetting Error : Could not get system parameter"); } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get LogSetting Error : " + ex.Message + "\n" + ex.StackTrace); } }
public BankInfo(int l_did, int i_banknum) { try { Hashtable deviceBankMap = DBCache.GetDeviceBankMap(); Hashtable bankCache = DBCache.GetBankCache(); if (deviceBankMap != null && deviceBankMap.Count > 0 && bankCache != null && bankCache.Count > 0 && deviceBankMap.ContainsKey(l_did)) { List <int> list = (List <int>)deviceBankMap[l_did]; if (list != null) { foreach (int current in list) { BankInfo bankInfo = (BankInfo)bankCache[current]; if (bankInfo != null && bankInfo.PortLists.Equals(string.Concat(i_banknum))) { this.id = bankInfo.ID; this.device_id = bankInfo.DeviceID; this.voltage = bankInfo.Voltage; this.portlists = bankInfo.PortLists; this.bank_nm = bankInfo.BankName; this.max_voltage = bankInfo.Max_voltage; this.min_voltage = bankInfo.Min_voltage; this.max_power_diss = bankInfo.Max_power_diss; this.min_power_diss = bankInfo.Min_power_diss; this.max_power = bankInfo.Max_power; this.min_power = bankInfo.Min_power; this.max_current = bankInfo.Max_current; this.min_current = bankInfo.Min_current; } } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
public static List <GroupInfo> GetAllGroup() { List <GroupInfo> list = new List <GroupInfo>(); try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0) { ICollection values = groupCache.Values; foreach (GroupInfo gp_scr in values) { GroupInfo item = new GroupInfo(gp_scr); list.Add(item); } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } return(list); }
public SensorInfo(int l_did, int i_sensortype) { try { Hashtable deviceSensorMap = DBCache.GetDeviceSensorMap(); Hashtable sensorCache = DBCache.GetSensorCache(); if (deviceSensorMap != null && deviceSensorMap.Count > 0 && sensorCache != null && sensorCache.Count > 0 && deviceSensorMap.ContainsKey(l_did)) { List <int> list = (List <int>)deviceSensorMap[l_did]; if (list != null) { foreach (int current in list) { SensorInfo sensorInfo = (SensorInfo)sensorCache[current]; if (sensorInfo != null && sensorInfo.Type == i_sensortype) { this.id = sensorInfo.ID; this.device_id = sensorInfo.Device_ID; this.sensor_nm = sensorInfo.SensorName; this.sensor_locationtype = sensorInfo.Location; this.sensor_type = sensorInfo.Type; this.max_humidity = sensorInfo.Max_humidity; this.min_humidity = sensorInfo.Min_humidity; this.max_temperature = sensorInfo.Max_temperature; this.min_temperature = sensorInfo.Min_temperature; this.max_press = sensorInfo.Max_press; this.min_press = sensorInfo.Min_press; } } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
public static GroupInfo GetGroupByName(string str_name) { GroupInfo result = null; try { Hashtable groupCache = DBCache.GetGroupCache(); if (groupCache != null && groupCache.Count > 0) { ICollection values = groupCache.Values; foreach (GroupInfo groupInfo in values) { if (groupInfo.GroupName.Equals(str_name)) { return(new GroupInfo(groupInfo)); } } } } catch (Exception) { } return(result); }
public LineInfo(int l_did, int i_linenum) { try { Hashtable deviceLineMap = DBCache.GetDeviceLineMap(); Hashtable lineCache = DBCache.GetLineCache(); if (deviceLineMap != null && deviceLineMap.Count > 0 && lineCache != null && lineCache.Count > 0 && deviceLineMap.ContainsKey(l_did)) { List <int> list = (List <int>)deviceLineMap[l_did]; if (list != null) { foreach (int current in list) { LineInfo lineInfo = (LineInfo)lineCache[current]; if (lineInfo != null && lineInfo.LineNumber == i_linenum) { this.id = lineInfo.ID; this.device_id = lineInfo.DeviceID; this.line_name = lineInfo.LineName; this.line_number = lineInfo.LineNumber; this.max_voltage = lineInfo.Max_voltage; this.min_voltage = lineInfo.Min_voltage; this.max_power = lineInfo.Max_power; this.min_power = lineInfo.Min_power; this.max_current = lineInfo.Max_current; this.min_current = lineInfo.Min_current; } } } } } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } }
static void Main(string[] args) { if (args.Length < 2) { throw new ArgumentException("Need DBCache.bin location and DBef dir location!"); } var actuallyV8 = false; var dumpKeys = false; if (args.Length == 3 && args[2] == "true") { dumpKeys = true; } var hotfixFile = args[0]; if (!File.Exists(hotfixFile)) { throw new FileNotFoundException("File " + hotfixFile + " not found!"); } var definitionDir = args[1]; if (!Directory.Exists(definitionDir)) { throw new FileNotFoundException("DBD definition directory " + definitionDir + " not found!"); } var tableHashes = new Dictionary <uint, string>(); foreach (var file in Directory.GetFiles(definitionDir)) { var dbName = Path.GetFileNameWithoutExtension(file); tableHashes.Add(Utils.Hash(dbName.ToUpper()), dbName); } var xfthMagic = 'X' << 0 | 'F' << 8 | 'T' << 16 | 'H' << 24; uint build; var hotfixes = new List <DBCacheEntry>(); using (var ms = new MemoryStream(File.ReadAllBytes(hotfixFile))) using (var bin = new BinaryReader(ms)) { if (bin.ReadUInt32() != xfthMagic) { throw new Exception("Invalid hotfix file!"); } var version = bin.ReadUInt32(); if (version != 7 && version != 8) { throw new Exception("Unsupported version: " + version); } build = bin.ReadUInt32(); var hash = bin.ReadBytes(32); // --- Temporary code to detect if DBCache is actually V8 or not by checking if next hotfix magic is in the right spot or not if (version == 8) { var prePos = bin.BaseStream.Position; if (bin.ReadUInt32() != xfthMagic) { throw new Exception("Invalid hotfix entry magic!"); } bin.ReadUInt32(); // PushID bin.ReadUInt32(); // UniqueID but also maybe not! bin.ReadUInt32(); // TableHash bin.ReadUInt32(); // RecordID var dataSize = bin.ReadInt32(); // DataSize bin.ReadBytes(dataSize + 4); if (bin.ReadUInt32() != xfthMagic) { actuallyV8 = false; } else { actuallyV8 = true; } bin.BaseStream.Position = prePos; } // -- End of temp code while (bin.BaseStream.Length > bin.BaseStream.Position) { var hotfix = new DBCacheEntry(); hotfix.header = new DBCacheEntryHeader(); hotfix.header.magic = bin.ReadUInt32(); hotfix.header.pushID = bin.ReadInt32(); if (actuallyV8) { hotfix.header.uniqueID = bin.ReadUInt32(); } hotfix.header.tableHash = bin.ReadUInt32(); hotfix.header.recordID = bin.ReadUInt32(); hotfix.header.dataSize = bin.ReadInt32(); hotfix.header.isValid = bin.ReadByte(); hotfix.header.pad0 = bin.ReadByte(); hotfix.header.pad1 = bin.ReadByte(); hotfix.header.pad2 = bin.ReadByte(); //hotfix.header = bin.Read<DBCacheEntryHeader>(); if (hotfix.header.magic != xfthMagic) { throw new Exception("Invalid hotfix entry magic!"); } if (tableHashes.ContainsKey(hotfix.header.tableHash)) { hotfix.tableName = tableHashes[hotfix.header.tableHash]; } else { hotfix.tableName = "UNKNOWN " + hotfix.header.tableHash.ToString("X8"); } hotfix.data = bin.ReadBytes(hotfix.header.dataSize); hotfixes.Add(hotfix); } } var dbdCache = new Dictionary <string, DBDefinition>(); var filteredList = new List <HotfixEntry>(); foreach (var hotfix in hotfixes) { var hotfixDataMD5 = ""; if (hotfix.data.Length > 0) { using (var md5 = System.Security.Cryptography.MD5.Create()) { md5.TransformFinalBlock(hotfix.data, 0, hotfix.data.Length); hotfixDataMD5 = BitConverter.ToString(md5.Hash).Replace("-", string.Empty).ToLower(); } } filteredList.Add(new HotfixEntry { pushID = hotfix.header.pushID, recordID = hotfix.header.recordID, isValid = hotfix.header.isValid, tableName = hotfix.tableName, dataMD5 = hotfixDataMD5 }); if (dumpKeys) { if (!dbdCache.ContainsKey(hotfix.tableName) && File.Exists(Path.Combine(definitionDir, hotfix.tableName + ".dbd"))) { var reader = new DBDReader(); var dbd = reader.Read(Path.Combine(definitionDir, hotfix.tableName + ".dbd")); dbdCache.Add(hotfix.tableName, dbd); } if (dbdCache.ContainsKey(hotfix.tableName) && hotfix.header.isValid == 1) { var dbd = dbdCache[hotfix.tableName]; VersionDefinitions?versionToUse = null; var buildFound = false; foreach (var definition in dbd.versionDefinitions) { foreach (var versionBuild in definition.builds) { if (versionBuild.build == build) { versionToUse = definition; buildFound = true; } } } if (buildFound) { long dataLength = 0; var versionDef = (VersionDefinitions)versionToUse; //Console.WriteLine(hotfix.header.pad0 + " " + hotfix.header.pad1 + " " + hotfix.header.pad2 + " " + hotfix.tableName + " " + hotfix.header.recordID); try { using (var dataBin = new BinaryReader(new MemoryStream(hotfix.data))) { foreach (var field in versionDef.definitions) { if (dataBin.BaseStream.Position == dataBin.BaseStream.Length) { continue; } if (field.isNonInline && field.isID) { continue; } if (field.arrLength > 0) { for (var i = 0; i < field.arrLength; i++) { if (dataBin.BaseStream.Position == dataBin.BaseStream.Length) { continue; } if (field.size == 0) { if (dbd.columnDefinitions[field.name].type == "float") { dataBin.ReadSingle(); dataLength += 4; } else { var prevPos = dataBin.BaseStream.Position; dataBin.ReadCString(); dataLength += dataBin.BaseStream.Position - prevPos; } } else { dataLength += field.size / 8; dataBin.ReadBytes(field.size / 8); } } } else { if (field.size == 0) { if (dbd.columnDefinitions[field.name].type == "float") { dataBin.ReadSingle(); dataLength += 4; } else { var prevPos = dataBin.BaseStream.Position; dataBin.ReadCString(); dataLength += dataBin.BaseStream.Position - prevPos; } } else { dataLength += field.size / 8; dataBin.ReadBytes(field.size / 8); } } } if (dataBin.BaseStream.Length != dataBin.BaseStream.Position) { var tableHash = dataBin.ReadUInt32(); if (tableHash == 0) { continue; } if (!tableHashes.ContainsKey(tableHash)) { Console.WriteLine("Encountered an extra " + tableHash.ToString("X8") + " (unk table) record of " + (dataBin.BaseStream.Length - dataBin.BaseStream.Position) + " bytes in " + hotfix.tableName + " ID " + hotfix.header.recordID); } else { Console.WriteLine("Encountered an extra " + tableHashes[tableHash] + " record of " + (dataBin.BaseStream.Length - dataBin.BaseStream.Position) + " bytes in " + hotfix.tableName + " ID " + hotfix.header.recordID); if (tableHashes[tableHash] == "TactKey") { var lookup = dataBin.ReadUInt64(); var keyBytes = dataBin.ReadBytes(16); Console.WriteLine(lookup.ToString("X8").PadLeft(16, '0') + " " + BitConverter.ToString(keyBytes).Replace("-", "")); } } } } } catch (Exception e) { Console.WriteLine("Encountered exception while reading record data:" + e.Message); } } } } } var cache = new DBCache(); cache.build = build; cache.entries = filteredList.ToArray(); if (!dumpKeys) { Console.WriteLine(JsonConvert.SerializeObject(cache, Formatting.None)); } }
/// <summary> /// Gets all items for the given <paramref name="app_form"/> bases on the given culture. /// <para/>If the given culture does not exist the FallBackCulture is used. /// </summary> /// <param name="app_form">A combination of the applications assembly name and /// <para/>the underlying form / window name.</param> /// <param name="ci">A culture to use for getting the form / window items.</param> public void RunDBCachePostgreSQL(string app_form, CultureInfo ci) { // Let's not use database connection if already cached. if (DBCacheHolder.ListContains(app_form, DBCache)) { foreach (GuiObject go in this) { try { DBCacheHolder dc = DBCache.First(first => first.PropertyName == go.PropertyName && first.Item == go.Item && first.AppForm == app_form); if (dc != null) { if (dc.ValueType == "System.String") { go.Value = dc.Value; } } } catch { // something wrong? } } return; } List <string> handled = new List <string>(); using (NpgsqlCommand command = new NpgsqlCommand(SelectDBCache(app_form, ci), PostgreConnection)) { using (NpgsqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { string item = dr.GetString(3); string propertyName = dr.GetString(2); string valueType = dr.GetString(0); string value = dr.GetString(1); foreach (GuiObject go in this) { if (go.PropertyName == propertyName && go.Item == item) { if (handled.Contains(go.PropertyName + "." + go.Item)) { continue; } try { DBCache.Add(new DBCacheHolder(dr)); } catch { // Database connection error or internal logic failure? Well we can't let the application fall. } handled.Add(go.PropertyName + "." + go.Item); if (valueType == "System.String") { go.Value = value; } } } } } } }
private static double QuotientPostLengthToAvarageInTopic(yaf_Message item) { var avgLen = DBCache.GetTopicMessages(item.TopicID, buhOnlineContext).Average(p => p.Message.Length); return(item.GetText().Length / avgLen); }
private static string GetAuthorProfession(yaf_Message item) { var authorData = DBCache.GetUserPersonalData(item.UserID, buhOnlineContext); return(authorData == null || authorData.Profession == null ? "" : authorData.Profession.ToLower()); }
public static DBConn getConnection() { DBConn result; lock (DBConnPool._locksysdb) { string str = ""; if (DBUrl.SERVERMODE) { try { DBConn dBConn = new DBConn(); string cONNECT_STRING = DBUrl.CONNECT_STRING; string[] array = cONNECT_STRING.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); dBConn.con = new MySqlConnection(string.Concat(new string[] { "Database=eco", DBUrl.SERVERID, ";Data Source=", array[0], ";Port=", array[1], ";User Id=", array[2], ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;" })); dBConn.con.Open(); dBConn.setInUse(); result = dBConn; return(result); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get SysDB Connection Error : " + ex.Message + "\n" + ex.StackTrace); result = null; return(result); } } bool flag2 = false; try { DBConn dBConn2 = new DBConn(); try { dBConn2.con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "sysdb.mdb;Jet OLEDB:Database Password=^tenec0Sensor"); dBConn2.con.Open(); flag2 = true; } catch (Exception ex2) { str = ex2.Message + "\r\n" + ex2.StackTrace; int i = 0; while (i < 4) { Thread.Sleep(10); i++; try { dBConn2.con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "sysdb.mdb;Jet OLEDB:Database Password=^tenec0Sensor"); dBConn2.con.Open(); flag2 = true; break; } catch (Exception ex3) { str = ex3.Message + "\r\n" + ex3.StackTrace; } } } if (flag2) { dBConn2.setInUse(); dBConn2.DBSource_Type = 1; try { StackTrace stackTrace = new StackTrace(); MethodBase method = stackTrace.GetFrame(1).GetMethod(); DBCache.OpenSysDB(dBConn2.GetHashCode(), method.Name); DBCache.PrintSysDB(); } catch { } result = dBConn2; } else { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get SysDB Connection Error : " + str); DBCache.PrintSysDB(); result = null; } } catch (Exception ex4) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get SysDB Connection Error : " + ex4.Message + "\n" + ex4.StackTrace); DBCache.PrintSysDB(); result = null; } } return(result); }
public static DBConn getDynaConnection(DateTime dt_inserttime, bool b_create) { DBConn result; lock (DBConnPool._lockdatadb) { string str = ""; if (DBUrl.SERVERMODE) { try { DBConn dBConn = new DBConn(); string cONNECT_STRING = DBUrl.CONNECT_STRING; string[] array = cONNECT_STRING.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); dBConn.con = new MySqlConnection(string.Concat(new string[] { "Database=eco", DBUrl.SERVERID, ";Data Source=", array[0], ";Port=", array[1], ";User Id=", array[2], ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;" })); dBConn.con.Open(); dBConn.setInUse(); DebugCenter.GetInstance().clearStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true); result = dBConn; return(result); } catch (Exception e) { DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true); DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e, false, " ")); result = null; return(result); } } if (DBUrl.DB_CURRENT_TYPE.ToUpperInvariant().Equals("MYSQL")) { try { DBConn dBConn2 = new DBConn(); dBConn2.con = new MySqlConnection(string.Concat(new object[] { "Database=", DBUrl.DB_CURRENT_NAME, ";Data Source=", DBUrl.CURRENT_HOST_PATH, ";Port=", DBUrl.CURRENT_PORT, ";User Id=", DBUrl.CURRENT_USER_NAME, ";Password="******";Pooling=true;Min Pool Size=0;Max Pool Size=150;Default Command Timeout=0;charset=utf8;" })); dBConn2.con.Open(); dBConn2.setInUse(); DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_Success, false); result = dBConn2; return(result); } catch (Exception e2) { DebugCenter.GetInstance().setLastStatusCode(DebugCenter.ST_MYSQLCONNECT_LOST, true); DebugCenter.GetInstance().appendToFile("Could not create MySQL connection : \r\n" + CommonAPI.ReportException(0, e2, false, " ")); result = null; return(result); } } try { string text = AppDomain.CurrentDomain.BaseDirectory + "datadb"; if (text[text.Length - 1] != Path.DirectorySeparatorChar) { text += Path.DirectorySeparatorChar; } if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } DateTime.Now.ToString("yyyyMMdd"); dt_inserttime.ToString("yyyyMMdd"); string text2 = text + "datadb_" + dt_inserttime.ToString("yyyyMMdd") + ".mdb"; if (!File.Exists(text2) && b_create) { string sourceFileName = text + "datadb.org"; File.Copy(sourceFileName, text2, true); } bool flag2 = false; try { DBConn dBConn3 = new DBConn(); try { dBConn3.con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text2 + ";Jet OLEDB:Database Password=root"); dBConn3.con.Open(); flag2 = true; } catch (Exception ex) { str = ex.Message + "\r\n" + ex.StackTrace; int i = 0; while (i < 4) { Thread.Sleep(10); i++; try { dBConn3.con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text2 + ";Jet OLEDB:Database Password=root"); dBConn3.con.Open(); flag2 = true; break; } catch (Exception ex2) { str = ex2.Message + "\r\n" + ex2.StackTrace; } } } if (flag2) { dBConn3.setInUse(); dBConn3.DBSource_Type = 2; try { StackTrace stackTrace = new StackTrace(); MethodBase method = stackTrace.GetFrame(1).GetMethod(); DBCache.OpenDataDB(dBConn3.GetHashCode(), method.Name); DBCache.PrintDataDB(); } catch { } result = dBConn3; } else { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get DynaDB Connection Error : " + str); result = null; } } catch (Exception ex3) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get DynaDB Connection Error : " + ex3.Message + "\n" + ex3.StackTrace); result = null; } } catch (Exception ex4) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get DynaDB Connection Error : " + ex4.Message + "\n" + ex4.StackTrace); result = null; } } return(result); }
private static int LocalConsole_cfg() { DebugCenter instance = DebugCenter.GetInstance(); int lastStatusCode = instance.getLastStatusCode(); if (lastStatusCode == DebugCenter.ST_Unknown) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFailUnknown, new string[] { lastStatusCode.ToString("X4") })); Program.ExitApp(); return(-1); } if (lastStatusCode == DebugCenter.ST_DiskFull) { if (EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.srvFailDiskFull, new string[0]), MessageBoxButtons.YesNo) == DialogResult.No) { Program.ExitApp(); return(-1); } progressPopup progressPopup = new progressPopup("Service Checker", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_startsrv, new string[0]), Resources.login_background, new progressPopup.ProcessInThread(Program.StartService), null, 0); progressPopup.StartPosition = FormStartPosition.CenterScreen; progressPopup.ShowDialog(); object return_V = progressPopup.Return_V; int? num = return_V as int?; if (num == -1 || num == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0])); Program.ExitApp(); return(-1); } return(-2); } else { if ((lastStatusCode & DebugCenter.ST_fatalMask) == 0) { ServiceController serviceController = new ServiceController(EcoGlobalVar.gl_ServiceName); if (serviceController.Status.Equals(ServiceControllerStatus.Stopped)) { progressPopup progressPopup2 = new progressPopup("Service Checker", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_startsrv, new string[0]), Resources.login_background, new progressPopup.ProcessInThread(Program.StartService), null, 0); progressPopup2.StartPosition = FormStartPosition.CenterScreen; progressPopup2.ShowDialog(); object return_V2 = progressPopup2.Return_V; int? num2 = return_V2 as int?; if (num2 == -1 || num2 == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0])); Program.ExitApp(); return(-1); } return(-2); } else { if (!Program.isService_initfinish()) { int num3 = Program.waitService_initfinish(); if (num3 == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0])); Program.ExitApp(); return(-1); } return(-2); } else { if (lastStatusCode == DebugCenter.ST_Success) { return(0); } DBUrl.RUNMODE = 1; DBCacheStatus.DBSyncEventInit(false); DBCacheEventProcess.StartRefreshThread(false); DBCache.DBCacheInit(false); if ((lastStatusCode & DebugCenter.ST_MYSQLCONNECT_LOST) != 0) { string text = "Lost DB connection. Please check your MySQL database service."; EcoMessageBox.ShowWarning(text, MessageBoxButtons.OK); } if (lastStatusCode == DebugCenter.ST_MYSQLCONNECT_LOST) { return(0); } registrySettings registrySettings = new registrySettings(lastStatusCode); registrySettings.ShowDialog(); return(0); } } } else { if (lastStatusCode == DebugCenter.ST_DbUpgrade || lastStatusCode == DebugCenter.ST_SysdbNotExist || lastStatusCode == DebugCenter.ST_LogdbNotExist || lastStatusCode == DebugCenter.ST_DatadbNotExist || lastStatusCode == DebugCenter.ST_SysdbNotMatch || lastStatusCode == DebugCenter.ST_ImportDatabase_ERROR) { restoredb restoredb = new restoredb(1); DialogResult dialogResult = restoredb.ShowDialog(); if (dialogResult != DialogResult.OK) { commUtil.ShowInfo_DEBUG("restoredbdlg.ShowDialog() result is not DialogResult.OK!!!!!"); } } else { DBUrl.RUNMODE = 1; registrySettings registrySettings = new registrySettings(lastStatusCode); DialogResult dialogResult2 = registrySettings.ShowDialog(); if (dialogResult2 != DialogResult.OK) { Program.ExitApp(); return(-1); } } progressPopup progressPopup3 = new progressPopup("Service Checker", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_startsrv, new string[0]), Resources.login_background, new progressPopup.ProcessInThread(Program.StartService), null, 0); progressPopup3.StartPosition = FormStartPosition.CenterScreen; progressPopup3.ShowDialog(); object return_V3 = progressPopup3.Return_V; int? num4 = return_V3 as int?; if (num4 == -1 || num4 == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0])); Program.ExitApp(); return(-1); } return(-2); } } }
public static DataTable GetEventList() { DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn(); dataColumn.DataType = Type.GetType("System.String"); dataColumn.ColumnName = "eventid"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = Type.GetType("System.Int32"); dataColumn.ColumnName = "logflag"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = Type.GetType("System.Int32"); dataColumn.ColumnName = "mailflag"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = Type.GetType("System.Int64"); dataColumn.ColumnName = "reserve"; dataTable.Columns.Add(dataColumn); try { Hashtable eventLogCache = DBCache.GetEventLogCache(); Hashtable eventMailCache = DBCache.GetEventMailCache(); if (eventLogCache != null && eventLogCache.Count > 0) { ICollection keys = eventLogCache.Keys; IEnumerator enumerator = keys.GetEnumerator(); try { while (enumerator.MoveNext()) { string text = (string)enumerator.Current; DataRow dataRow = dataTable.NewRow(); dataRow[0] = text; dataRow[1] = Convert.ToInt32(eventLogCache[text]); dataRow[2] = Convert.ToInt32(eventMailCache[text]); dataTable.Rows.Add(dataRow); } goto IL_17B; } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get LogEventList Error : Could not get data from DBCache"); IL_17B :; } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Get LogEventList Error : " + ex.Message + "\n" + ex.StackTrace); } dataTable = new DataView(dataTable) { Sort = "eventid ASC" }.ToTable(); return(dataTable); }
private bool UpdateAllThresholds(System.Collections.Generic.List <ThresholdMessage> thresholdMessageList) { bool result = false; DBConn dBConn = null; System.Collections.Hashtable deviceCache = DBCache.GetDeviceCache(); System.Collections.Hashtable portCache = DBCache.GetPortCache(); System.Collections.Hashtable bankCache = DBCache.GetBankCache(); System.Collections.Hashtable sensorCache = DBCache.GetSensorCache(); System.Collections.Hashtable deviceBankMap = DBCache.GetDeviceBankMap(); System.Collections.Hashtable devicePortMap = DBCache.GetDevicePortMap(); System.Collections.Hashtable deviceSensorMap = DBCache.GetDeviceSensorMap(); if (dBConn == null) { dBConn = DBConnPool.getConnection(); } foreach (ThresholdMessage current in thresholdMessageList) { if (current != null && current.DeviceReplyMac.Equals(current.DeviceMac)) { if (!string.IsNullOrEmpty(current.AutoBasicInfo) && !string.IsNullOrEmpty(current.AutoRatingInfo)) { try { DevAccessCfg.GetInstance().updateAutoModelList2Database(dBConn, current.ModelName, current.DeviceFWVer, current.AutoBasicInfo, current.AutoRatingInfo); } catch (System.Exception) { } } if (deviceCache != null && deviceCache.Count >= 1 && deviceCache.ContainsKey(current.DeviceID)) { DeviceInfo deviceInfo = (DeviceInfo)deviceCache[current.DeviceID]; if (deviceInfo != null) { deviceInfo.FWVersion = current.DeviceFWVer; deviceInfo.DeviceName = current.DeviceName; if (current.DeviceThreshold.MaxCurrentMT != -500f) { deviceInfo.Max_current = current.DeviceThreshold.MaxCurrentMT; } if (current.DeviceThreshold.MaxPowerMT != -500f) { deviceInfo.Max_power = current.DeviceThreshold.MaxPowerMT; } if (current.DeviceThreshold.MaxPowerDissMT != -500f) { deviceInfo.Max_power_diss = current.DeviceThreshold.MaxPowerDissMT; } if (current.DeviceThreshold.MaxVoltageMT != -500f) { deviceInfo.Max_voltage = current.DeviceThreshold.MaxVoltageMT; } if (current.DeviceThreshold.MinCurrentMT != -500f) { deviceInfo.Min_current = current.DeviceThreshold.MinCurrentMT; } if (current.DeviceThreshold.MinPowerMT != -500f) { deviceInfo.Min_power = current.DeviceThreshold.MinPowerMT; } if (current.DeviceThreshold.MinVoltageMT != -500f) { deviceInfo.Min_voltage = current.DeviceThreshold.MinVoltageMT; } deviceInfo.POPThreshold = current.DeviceThreshold.PopThreshold; deviceInfo.POPEnableMode = current.DeviceThreshold.PopEnableMode; deviceInfo.OutletPOPMode = current.DeviceThreshold.PopModeOutlet; deviceInfo.BankPOPLIFOMode = current.DeviceThreshold.PopModeLIFO; deviceInfo.BankPOPPriorityMode = current.DeviceThreshold.PopModePriority; if (current.DeviceThreshold.DoorSensorType != -500) { deviceInfo.DoorSensor = current.DeviceThreshold.DoorSensorType; } deviceInfo.UpdateDeviceThreshold(dBConn); if (current.SensorThreshold != null && current.SensorThreshold.Count > 0) { if (sensorCache == null || sensorCache.Count < 1 || deviceSensorMap == null || deviceSensorMap.Count < 1 || !deviceSensorMap.ContainsKey(current.DeviceID)) { continue; } System.Collections.Generic.IEnumerator <int> enumerator2 = current.SensorThreshold.Keys.GetEnumerator(); while (enumerator2.MoveNext()) { SensorThreshold sensorThreshold = current.SensorThreshold[enumerator2.Current]; SensorInfo sensor = this.getSensor(sensorCache, (System.Collections.Generic.List <int>)deviceSensorMap[current.DeviceID], enumerator2.Current); if (sensor != null) { if (sensorThreshold.MaxHumidityMT != -500f) { sensor.Max_humidity = sensorThreshold.MaxHumidityMT; } if (sensorThreshold.MaxPressMT != -500f) { sensor.Max_press = sensorThreshold.MaxPressMT; } if (sensorThreshold.MaxTemperatureMT != -500f) { sensor.Max_temperature = sensorThreshold.MaxTemperatureMT; } if (sensorThreshold.MinHumidityMT != -500f) { sensor.Min_humidity = sensorThreshold.MinHumidityMT; } if (sensorThreshold.MinPressMT != -500f) { sensor.Min_press = sensorThreshold.MinPressMT; } if (sensorThreshold.MinTemperatureMT != -500f) { sensor.Min_temperature = sensorThreshold.MinTemperatureMT; } sensor.UpdateSensorThreshold(dBConn); } } } if (current.OutletThreshold != null && current.OutletThreshold.Count > 0) { if (portCache == null || portCache.Count < 1 || devicePortMap == null || devicePortMap.Count < 1 || !devicePortMap.ContainsKey(current.DeviceID)) { continue; } System.Collections.Generic.IEnumerator <int> enumerator3 = current.OutletThreshold.Keys.GetEnumerator(); while (enumerator3.MoveNext()) { OutletThreshold outletThreshold = current.OutletThreshold[enumerator3.Current]; PortInfo port = this.getPort(portCache, (System.Collections.Generic.List <int>)devicePortMap[current.DeviceID], enumerator3.Current); if (port != null) { port.PortName = outletThreshold.OutletName; if (outletThreshold.MaxCurrentMT != -500f) { port.Max_current = outletThreshold.MaxCurrentMT; } if (outletThreshold.MaxPowerMT != -500f) { port.Max_power = outletThreshold.MaxPowerMT; } if (outletThreshold.MaxPowerDissMT != -500f) { port.Max_power_diss = outletThreshold.MaxPowerDissMT; } if (outletThreshold.MaxVoltageMT != -500f) { port.Max_voltage = outletThreshold.MaxVoltageMT; } if (outletThreshold.MinCurrentMt != -500f) { port.Min_current = outletThreshold.MinCurrentMt; } if (outletThreshold.MinPowerMT != -500f) { port.Min_power = outletThreshold.MinPowerMT; } if (outletThreshold.MinVoltageMT != -500f) { port.Min_voltage = outletThreshold.MinVoltageMT; } port.OutletConfirmation = (int)outletThreshold.Confirmation; port.OutletOffDelayTime = outletThreshold.OffDelayTime; port.OutletOnDelayTime = outletThreshold.OnDelayTime; port.OutletShutdownMethod = (int)outletThreshold.ShutdownMethod; port.OutletMAC = outletThreshold.MacAddress; port.UpdatePortThreshold(dBConn); } } } if (current.BankThreshold != null && current.BankThreshold.Count > 0 && bankCache != null && bankCache.Count >= 1 && deviceBankMap != null && deviceBankMap.Count >= 1 && deviceBankMap.ContainsKey(current.DeviceID)) { System.Collections.Generic.IEnumerator <int> enumerator4 = current.BankThreshold.Keys.GetEnumerator(); while (enumerator4.MoveNext()) { BankThreshold bankThreshold = current.BankThreshold[enumerator4.Current]; BankInfo bank = this.getBank(bankCache, (System.Collections.Generic.List <int>)deviceBankMap[current.DeviceID], enumerator4.Current); if (bank != null) { bank.BankName = bankThreshold.BankName; if (bankThreshold.MaxCurrentMT != -500f) { bank.Max_current = bankThreshold.MaxCurrentMT; } if (bankThreshold.MinCurrentMt != -500f) { bank.Min_current = bankThreshold.MinCurrentMt; } if (bankThreshold.MaxVoltageMT != -500f) { bank.Max_voltage = bankThreshold.MaxVoltageMT; } if (bankThreshold.MinVoltageMT != -500f) { bank.Min_voltage = bankThreshold.MinVoltageMT; } if (bankThreshold.MaxPowerMT != -500f) { bank.Max_power = bankThreshold.MaxPowerMT; } if (bankThreshold.MinPowerMT != -500f) { bank.Min_power = bankThreshold.MinPowerMT; } if (bankThreshold.MaxPowerDissMT != -500f) { bank.Max_power_diss = bankThreshold.MaxPowerDissMT; } bank.UpdateBankThreshold(dBConn); } } } } } } } if (dBConn != null) { dBConn.close(); } return(result); }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); System.Security.Principal.WindowsPrincipal windowsPrincipal = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()); if (!windowsPrincipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.NeedPrivilege, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); System.Environment.Exit(0); return; } EcoGlobalVar.nullcontextMenuStrip = new ContextMenuStrip(); EcoGlobalVar.ECOAppRunMode = 1; AppInterProcess.OpenInterProcessShared(); int processID = AppInterProcess.getProcessID(Program.program_uid, Program.program_serverid, EcoGlobalVar.ECOAppRunMode); if (processID != 0) { AppInterProcess.CloseShared(); string processOwner = Program.GetProcessOwner(processID); string processOwner2 = Program.GetProcessOwner(Process.GetCurrentProcess().Id); if (processOwner.Equals(processOwner2)) { Program.setTopMost(processID); } else { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.APPRunbyuser, new string[] { processOwner }), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } System.Environment.Exit(0); return; } AppInterProcess.setMyProcessID(Program.program_uid, Program.program_serverid, EcoGlobalVar.ECOAppRunMode); Program.setTopMost(Process.GetCurrentProcess().Id); int mySQLUseMajorVersionOnly = DevAccessCfg.GetInstance().getMySQLUseMajorVersionOnly(); DBMaintain.SetMySQLVersionRole(mySQLUseMajorVersionOnly); while (Program.LocalConsole_cfg() == -2) { } DBUrl.RUNMODE = 1; ClientAPI.SetBroadcastCallback(new CommonAPI.CommonAPI.DelegateOnBroadcast(EcoGlobalVar.receiveDashBoardFlgProc)); ClientAPI.SetClosedCallback(new CommonAPI.CommonAPI.DelegateOnClosed(EcoGlobalVar.ServerClosedProc)); Login.Login login = new Login.Login(); login.Icon = null; login.ShowDialog(); if (login.UserName == null) { Program.ExitApp(); return; } EcoGlobalVar.gl_StartProcessfThread(true); Application.CurrentCulture = System.Globalization.CultureInfo.CurrentUICulture; if (EcoGlobalVar.ECOAppRunMode == 1) { DBCacheStatus.DBSyncEventInit(false); DBCacheEventProcess.StartRefreshThread(false); DBCache.DBCacheInit(false); } if (ClientAPI.WaitDatasetReady(40000u) < 0) { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); Program.ExitApp(); return; } EcoGlobalVar.DCLayoutType = ClientAPI.getRackLayout(); EcoGlobalVar.gl_maxZoneNum = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxZoneNum")); EcoGlobalVar.gl_maxRackNum = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxRackNum")); EcoGlobalVar.gl_maxDevNum = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxDevNum")); EcoGlobalVar.gl_supportISG = (CultureTransfer.ToInt32(ClientAPI.getKeyValue("SupportISG")) > 0); EcoGlobalVar.gl_supportBP = (CultureTransfer.ToInt32(ClientAPI.getKeyValue("SupportBP")) > 0); EcoGlobalVar.TempUnit = CultureTransfer.ToInt32(ClientAPI.getKeyValue("TempUnit")); EcoGlobalVar.CurCurrency = ClientAPI.getKeyValue("CurCurrency"); EcoGlobalVar.co2kg = CultureTransfer.ToSingle(ClientAPI.getKeyValue("co2kg")); EcoGlobalVar.flgEnablePower = AppData.getDB_flgEnablePower(); EcoGlobalVar.RackFullNameFlag = CultureTransfer.ToInt32(ClientAPI.getKeyValue("RackFullNameFlag")); EcoGlobalVar.gl_PeakPowerMethod = DevAccessCfg.GetInstance().getPowerPeakMethod(); string valuePair = ValuePairs.getValuePair("UserID"); long l_id = System.Convert.ToInt64(valuePair); string valuePair2 = ValuePairs.getValuePair("UserName"); valuePair = ValuePairs.getValuePair("UserType"); int i_type = System.Convert.ToInt32(valuePair); valuePair = ValuePairs.getValuePair("UserRight"); int i_right = System.Convert.ToInt32(valuePair); string valuePair3 = ValuePairs.getValuePair("UserPortNM"); string valuePair4 = ValuePairs.getValuePair("UserDevice"); string valuePair5 = ValuePairs.getValuePair("UserGroup"); valuePair = ValuePairs.getValuePair("UserStatus"); ValuePairs.getValuePair("trial"); ValuePairs.getValuePair("remaining_days"); int i_status = System.Convert.ToInt32(valuePair); UserInfo userInfo = new UserInfo(l_id, valuePair2, "", i_status, i_type, i_right, valuePair3, valuePair4, valuePair5); EcoGlobalVar.gl_LoginUser = userInfo; EcoGlobalVar.gl_LoginUserUACDev2Port = (System.Collections.Generic.Dictionary <long, System.Collections.Generic.List <long> >)ClientAPI.RemoteCall(8, 1, "", 10000); if (EcoGlobalVar.gl_LoginUserUACDev2Port == null) { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); Program.ExitApp(); return; } string para = "0230000\n" + userInfo.UserName; ClientAPI.RemoteCall(100, 1, para, 10000); MainForm.MainForm mainForm = new MainForm.MainForm(userInfo); EcoGlobalVar.gl_mainForm = mainForm; if (!EcoGlobalVar.gl_supportISG) { EcoGlobalVar.gl_monitorCtrl.FreshFlg_ISGPower = 0; EcoGlobalVar.gl_DashBoardCtrl.FreshFlg_ISGPower = 0; } EcoGlobalVar.gl_StopProcessfThread(); Program.IdleTimer_init(); Application.ApplicationExit += new System.EventHandler(Program.Application_ApplicationExit); System.AppDomain.CurrentDomain.ProcessExit += new System.EventHandler(Program.CurrentDomain_ProcessExit); Application.Run(mainForm); }
public static int InsertNewLog(ref int mailflag, string str_eventid, params string[] str_parameters) { int result = -1; int num = 1; int num2 = 1; try { Hashtable eventLogCache = DBCache.GetEventLogCache(); Hashtable eventMailCache = DBCache.GetEventMailCache(); if (eventLogCache != null && eventLogCache.Count > 0) { object obj = eventLogCache[str_eventid]; if (obj != null) { num = Convert.ToInt32(obj); } obj = eventMailCache[str_eventid]; if (obj != null) { num2 = Convert.ToInt32(obj); } } else { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Insert New Log Error : Could not get event log flag from DBCache"); } mailflag = num2; if (num < 1) { return(1); } if (LogInfo.lp_thread == null) { LogInfo.lp_thread = new LogProcess(); LogInfo.lp_thread.Start(); } List <string> list = new List <string>(); list.Add(str_eventid); list.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string str = ""; for (int i = 0; i < str_parameters.Length; i++) { list.Add(str_parameters[i]); if (i == str_parameters.Length - 1) { str += str_parameters[i]; } else { str = str + str_parameters[i] + "^|^"; } } LogInfo.lp_thread.PutLog(list); } catch (Exception ex) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~Insert New Log Error : " + ex.Message + "\n" + ex.StackTrace); } return(result); }