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); }