Example #1
0
        private object delDevicePro(object param)
        {
            int num = 1;

            System.Collections.ArrayList arrayList = param as System.Collections.ArrayList;
            DBConn connection = DBConnPool.getConnection();

            for (int i = 0; i < arrayList.Count; i++)
            {
                string     value      = (string)arrayList[i];
                DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(value));
                int        num2       = DeviceOperation.DeleteDeviceByID(connection, System.Convert.ToInt32(value));
                if (num2 < 0)
                {
                    num = num2;
                }
                else
                {
                    string valuePair = ValuePairs.getValuePair("Username");
                    if (!string.IsNullOrEmpty(valuePair))
                    {
                        LogAPI.writeEventLog("0430001", new string[]
                        {
                            deviceByID.ModelNm,
                            deviceByID.Mac,
                            deviceByID.DeviceIP,
                            deviceByID.DeviceName,
                            valuePair
                        });
                    }
                    else
                    {
                        LogAPI.writeEventLog("0430001", new string[]
                        {
                            deviceByID.ModelNm,
                            deviceByID.Mac,
                            deviceByID.DeviceIP,
                            deviceByID.DeviceName
                        });
                    }
                }
            }
            connection.Close();
            DeviceOperation.RefreshDBCache(false);
            DeviceOperation.StartDBCleanupThread();
            return(num);
        }
Example #2
0
 public System.Collections.Generic.List <PropertiesMessage> Scan_ATEN(string startIp, string endIp)
 {
     System.Collections.Generic.List <string> list = this.countIp(startIp, endIp);
     if (list == null || list.Count < 1)
     {
         return(null);
     }
     this.total = list.Count;
     System.Collections.Generic.List <SnmpConfiger>      snmpConfigs     = this.createSnmpConfig(list);
     System.Collections.Generic.List <PropertiesMessage> properties_ATEN = new DefaultSnmpExecutors(snmpConfigs).GetProperties_ATEN();
     System.Collections.Generic.List <PropertiesMessage> list2           = new System.Collections.Generic.List <PropertiesMessage>();
     System.Collections.Generic.List <DevModelConfig>    list3           = new System.Collections.Generic.List <DevModelConfig>();
     if (properties_ATEN != null && properties_ATEN.Count > 0)
     {
         DBConn connection = DBConnPool.getConnection();
         foreach (PropertiesMessage current in properties_ATEN)
         {
             if (!current.ModelName.Equals("Null"))
             {
                 if (!string.IsNullOrEmpty(current.AutoBasicInfo) && !string.IsNullOrEmpty(current.AutoRatingInfo))
                 {
                     try
                     {
                         int num = this.cfg.updateAutoModelList2Database(connection, current.ModelName, current.FirwWareVersion, current.AutoBasicInfo, current.AutoRatingInfo);
                         if (num > 0)
                         {
                             list3.Add(new DevModelConfig(current.ModelName)
                             {
                                 modelName      = current.ModelName,
                                 firmwareVer    = current.FirwWareVersion,
                                 autoBasicInfo  = current.AutoBasicInfo,
                                 autoRatingInfo = current.AutoRatingInfo
                             });
                         }
                         else
                         {
                             if (num != 0 && num < 0)
                             {
                                 DebugCenter.GetInstance().appendToFile(string.Concat(new string[]
                                 {
                                     "Failed to update auto-detect info: ",
                                     current.ModelName,
                                     ", ",
                                     current.AutoBasicInfo,
                                     current.AutoRatingInfo
                                 }));
                                 continue;
                             }
                         }
                     }
                     catch (System.Exception)
                     {
                         DebugCenter.GetInstance().appendToFile(string.Concat(new string[]
                         {
                             "Exception when parsing auto-detect info: ",
                             current.ModelName,
                             ", ",
                             current.AutoBasicInfo,
                             current.AutoRatingInfo
                         }));
                         continue;
                     }
                 }
                 list2.Add(current);
             }
         }
         try
         {
             connection.Close();
         }
         catch
         {
         }
         if (DevDiscoverAPI._cbOnAutoModePost != null && list3.Count > 0)
         {
             DevDiscoverAPI._cbOnAutoModePost(list3);
         }
     }
     return(list2);
 }
Example #3
0
        private void butBankAssign_Click(object sender, System.EventArgs e)
        {
            bool   flag   = false;
            DBConn dBConn = null;
            string text   = this.labDevModel.Tag.ToString();

            try
            {
                int            num               = System.Convert.ToInt32(text);
                DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(num);
                DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);
                if (this.bankCheck(deviceModelConfig))
                {
                    DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyBank, new string[0]), MessageBoxButtons.OKCancel);
                    if (dialogResult != DialogResult.Cancel)
                    {
                        string        text2         = this.tbBankNm.Text;
                        string        text3         = this.labBankNo.Text;
                        int           num2          = System.Convert.ToInt32(text3);
                        BankInfo      bankInfo      = new BankInfo(num, num2);
                        DevSnmpConfig sNMPpara      = commUtil.getSNMPpara(deviceByID);
                        BankThreshold bankThreshold = new BankThreshold(1);
                        if (this.gbThreshold.Visible)
                        {
                            bankInfo.Min_current    = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0);
                            bankInfo.Max_current    = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0);
                            bankInfo.Min_voltage    = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0);
                            bankInfo.Max_voltage    = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0);
                            bankInfo.Min_power      = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0);
                            bankInfo.Max_power      = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0);
                            bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0);
                            bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0);
                            int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank");
                            bankThreshold.MinCurrentMt   = bankInfo.Min_current;
                            bankThreshold.MaxCurrentMT   = bankInfo.Max_current;
                            bankThreshold.MinVoltageMT   = bankInfo.Min_voltage;
                            bankThreshold.MaxVoltageMT   = bankInfo.Max_voltage;
                            bankThreshold.MinPowerMT     = bankInfo.Min_power;
                            bankThreshold.MaxPowerMT     = bankInfo.Max_power;
                            bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss;
                            ThresholdUtil.UI2Dev(thflg, bankThreshold);
                        }
                        DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara);
                        string       myMac        = deviceByID.Mac;
                        System.Collections.Generic.List <BankInfo> bankInfo2 = deviceByID.GetBankInfo();
                        dBConn = DBConnPool.getConnection();
                        foreach (BankInfo current in bankInfo2)
                        {
                            BankThreshold bankThreshold2 = new BankThreshold(System.Convert.ToInt32(current.PortLists));
                            if (num2 == System.Convert.ToInt32(current.PortLists))
                            {
                                current.BankName = text2;
                            }
                            bankThreshold2.BankName = current.BankName;
                            if (this.gbThreshold.Visible)
                            {
                                bankThreshold2.MaxCurrentMT   = bankThreshold.MaxCurrentMT;
                                bankThreshold2.MinCurrentMt   = bankThreshold.MinCurrentMt;
                                bankThreshold2.MaxPowerMT     = bankThreshold.MaxPowerMT;
                                bankThreshold2.MinPowerMT     = bankThreshold.MinPowerMT;
                                bankThreshold2.MaxVoltageMT   = bankThreshold.MaxVoltageMT;
                                bankThreshold2.MinVoltageMT   = bankThreshold.MinVoltageMT;
                                bankThreshold2.MaxPowerDissMT = bankThreshold.MaxPowerDissMT;
                            }
                            bool flag2 = true;
                            if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                            {
                                flag2 = devAccessAPI.SetBankThreshold(bankThreshold2, myMac);
                            }
                            if (!flag2)
                            {
                                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
                                return;
                            }
                            if (this.gbThreshold.Visible)
                            {
                                current.CopyThreshold(bankInfo);
                            }
                            current.UpdateBankThreshold(dBConn);
                            flag  = true;
                            myMac = "";
                        }
                        if (dBConn != null)
                        {
                            dBConn.close();
                        }
                        string valuePair = ValuePairs.getValuePair("Username");
                        if (!string.IsNullOrEmpty(valuePair))
                        {
                            LogAPI.writeEventLog("0630011", new string[]
                            {
                                deviceByID.ModelNm,
                                deviceByID.DeviceIP,
                                deviceByID.DeviceName,
                                valuePair
                            });
                        }
                        else
                        {
                            LogAPI.writeEventLog("0630011", new string[]
                            {
                                deviceByID.ModelNm,
                                deviceByID.DeviceIP,
                                deviceByID.DeviceName
                            });
                        }
                        EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine("butBankAssign_Click Exception" + ex.Message);
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
            }
            finally
            {
                if (dBConn != null)
                {
                    dBConn.close();
                }
                DeviceOperation.RefreshDBCache(false);
                if (flag)
                {
                    EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + text + ":B*;", 2);
                }
            }
        }
Example #4
0
        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);
        }
Example #5
0
        private object SetDeviceThresholdProc(object param)
        {
            DBConn dBConn = null;
            bool   flag   = false;
            string text   = "";

            try
            {
                System.Collections.Generic.List <object> list = (System.Collections.Generic.List <object>)param;
                DeviceThreshold deviceThreshold = (DeviceThreshold)list[0];
                DeviceInfo      tmp_di          = (DeviceInfo)list[1];
                System.Collections.Generic.List <DevSnmpConfig> configs = (System.Collections.Generic.List <DevSnmpConfig>)list[2];
                System.Collections.Generic.List <DeviceInfo>    list2   = (System.Collections.Generic.List <DeviceInfo>)list[3];
                DeviceInfo     deviceInfo        = list2[0];
                DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceInfo.ModelNm, deviceInfo.FWVersion);
                System.Collections.Generic.Dictionary <string, bool> dictionary = null;
                if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                {
                    AppDevAccess appDevAccess = new AppDevAccess();
                    dictionary = appDevAccess.SetDeviceThresholds(configs, deviceThreshold);
                }
                dBConn = DBConnPool.getConnection();
                foreach (DeviceInfo current in list2)
                {
                    string key = CultureTransfer.ToString(current.DeviceID);
                    bool   flag2;
                    if (dictionary == null)
                    {
                        flag2 = true;
                    }
                    else
                    {
                        if (!dictionary.ContainsKey(key))
                        {
                            continue;
                        }
                        flag2 = dictionary[key];
                    }
                    if (flag2)
                    {
                        current.CopyThreshold(tmp_di);
                        current.UpdateDeviceThreshold(dBConn);
                        flag = true;
                    }
                    else
                    {
                        text = text + current.DeviceIP + ",";
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message);
                text = "HAVE EXCEPTION!";
            }
            if (dBConn != null)
            {
                dBConn.close();
            }
            DeviceOperation.RefreshDBCache(false);
            return(new System.Collections.Generic.List <object>
            {
                flag,
                text
            });
        }