Exemplo n.º 1
0
 public static void UI2Dev(int thflg, DeviceThreshold threshold)
 {
     if ((thflg & 1) != 0)
     {
         threshold.MinCurrentMT = -500f;
     }
     if ((thflg & 2) != 0)
     {
         threshold.MaxCurrentMT = -500f;
     }
     if ((thflg & 4) != 0)
     {
         threshold.MinVoltageMT = -500f;
     }
     if ((thflg & 8) != 0)
     {
         threshold.MaxVoltageMT = -500f;
     }
     if ((thflg & 16) != 0)
     {
         threshold.MinPowerMT = -500f;
     }
     if ((thflg & 32) != 0)
     {
         threshold.MaxPowerMT = -500f;
     }
     if ((thflg & 128) != 0)
     {
         threshold.MaxPowerDissMT = -500f;
     }
 }
Exemplo n.º 2
0
        public DeviceThreshold(DeviceThreshold other)
        {
            this.MaxHumidity = other.MaxHumidity;
            this.MinHumidity = other.MinHumidity;

            this.MaxPressure = other.MaxPressure;
            this.MinPressure = other.MinPressure;

            this.MaxTemperature = other.MaxTemperature;
            this.MinTemperature = other.MinTemperature;
        }
Exemplo n.º 3
0
        public System.Collections.Generic.List <string> SetDevThresholds(DeviceThreshold deviceThreshold)
        {
            System.Collections.Generic.List <string> list             = new System.Collections.Generic.List <string>();
            SystemThreadPool <SnmpConfiger, string>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, string>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                string arg = CultureTransfer.ToString(snmpConfiger.DeviceID);
                bool flag = false;
                try
                {
                    flag = snmpExecutor.SetDeviceThreshold(deviceThreshold);
                }
                catch (System.Exception)
                {
                }
                lock (col)
                {
                    ((System.Collections.Generic.List <string>)col).Add(arg + ":" + flag);
                }
            }));
        }
Exemplo n.º 4
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
            });
        }
Exemplo n.º 5
0
 private void butAssign_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (this.devConfigCheck())
         {
             DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyAll, new string[0]), MessageBoxButtons.OKCancel);
             if (dialogResult != DialogResult.Cancel)
             {
                 string         text              = this.labDevModel.Text;
                 string         value             = this.labDevModel.Tag.ToString();
                 int            l_id              = System.Convert.ToInt32(value);
                 DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(l_id);
                 DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion);
                 System.Collections.Generic.List <DeviceInfo> allDeviceByModel = DeviceOperation.GetAllDeviceByModel(text);
                 string fWVersion = deviceByID.FWVersion;
                 System.Collections.Generic.List <DeviceInfo> list = new System.Collections.Generic.List <DeviceInfo>();
                 foreach (DeviceInfo current in allDeviceByModel)
                 {
                     if (current.DeviceID != deviceByID.DeviceID)
                     {
                         if (!DevAccessCfg.GetInstance().isAutodectDev(current.ModelNm, current.FWVersion))
                         {
                             list.Add(current);
                         }
                         else
                         {
                             if (current.FWVersion.Equals(fWVersion))
                             {
                                 list.Add(current);
                             }
                         }
                     }
                 }
                 if (this.tbRefVoltage.Visible)
                 {
                     deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text);
                 }
                 deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0);
                 deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0);
                 deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0);
                 deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0);
                 deviceByID.Min_power   = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0);
                 if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f)
                 {
                     deviceByID.Min_power *= 1000f;
                 }
                 deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0);
                 if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f)
                 {
                     deviceByID.Max_power *= 1000f;
                 }
                 deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0);
                 deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0);
                 if (deviceModelConfig.doorReading == 2)
                 {
                     deviceByID.DoorSensor = 0;
                     if (this.rbPhoto_1.Checked)
                     {
                         deviceByID.DoorSensor = 1;
                     }
                     else
                     {
                         if (this.rbInductive_2.Checked)
                         {
                             deviceByID.DoorSensor = 2;
                         }
                         else
                         {
                             if (this.rbReed_3.Checked)
                             {
                                 deviceByID.DoorSensor = 3;
                             }
                         }
                     }
                 }
                 DeviceInfo      item            = new DeviceInfo(-1, "", "", "", "", "", "", "", 0, 0, "", 161, 1, "", deviceByID.Max_voltage, deviceByID.Min_voltage, deviceByID.Max_power_diss, deviceByID.Min_power_diss, deviceByID.Max_power, deviceByID.Min_power, deviceByID.Max_current, deviceByID.Min_current, -1L, "", -500, -500f, deviceByID.DoorSensor, 0f, -500, -500, -500, "", -500f);
                 int             thflg           = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev");
                 DeviceThreshold deviceThreshold = new DeviceThreshold();
                 deviceThreshold.MinCurrentMT   = deviceByID.Min_current;
                 deviceThreshold.MaxCurrentMT   = deviceByID.Max_current;
                 deviceThreshold.MinVoltageMT   = deviceByID.Min_voltage;
                 deviceThreshold.MaxVoltageMT   = deviceByID.Max_voltage;
                 deviceThreshold.MinPowerMT     = deviceByID.Min_power;
                 deviceThreshold.MaxPowerMT     = deviceByID.Max_power;
                 deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss;
                 ThresholdUtil.UI2Dev(thflg, deviceThreshold);
                 deviceThreshold.PopEnableMode   = -500;
                 deviceThreshold.PopThreshold    = -500f;
                 deviceThreshold.PopModeOutlet   = -500;
                 deviceThreshold.PopModeLIFO     = -500;
                 deviceThreshold.PopModePriority = -500;
                 deviceThreshold.DoorSensorType  = -500;
                 System.Collections.Generic.List <DevSnmpConfig> list2 = new System.Collections.Generic.List <DevSnmpConfig>();
                 foreach (DeviceInfo current2 in list)
                 {
                     if (ClientAPI.IsDeviceOnline(current2.DeviceID))
                     {
                         DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current2);
                         list2.Add(sNMPpara);
                     }
                 }
                 bool   flag  = false;
                 string text2 = "";
                 if (list.Count > 0)
                 {
                     System.Collections.Generic.List <object> list3 = new System.Collections.Generic.List <object>();
                     list3.Add(deviceThreshold);
                     list3.Add(item);
                     list3.Add(list2);
                     list3.Add(list);
                     Program.IdleTimer_Pause(1);
                     System.Collections.Generic.List <object> list4;
                     if (list2.Count > 50)
                     {
                         progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_setDevThreshold, new string[0]), null, new progressPopup.ProcessInThread(this.SetDeviceThresholdProc), list3, 0);
                         progressPopup.ShowDialog();
                         list4 = (progressPopup.Return_V as System.Collections.Generic.List <object>);
                     }
                     else
                     {
                         list4 = (this.SetDeviceThresholdProc(list3) as System.Collections.Generic.List <object>);
                     }
                     flag  = (bool)list4[0];
                     text2 = (string)list4[1];
                 }
                 if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                 {
                     DevSnmpConfig sNMPpara2    = commUtil.getSNMPpara(deviceByID);
                     DevAccessAPI  devAccessAPI = new DevAccessAPI(sNMPpara2);
                     deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage;
                     deviceThreshold.DoorSensorType      = deviceByID.DoorSensor;
                     if (devAccessAPI.SetDeviceThreshold(deviceThreshold, deviceByID.Mac))
                     {
                         flag = true;
                     }
                     else
                     {
                         text2 = "HAVE EXCEPTION!";
                     }
                 }
                 Program.IdleTimer_Run(1);
                 if (flag)
                 {
                     EcoGlobalVar.setDashBoardFlg(2uL, "", 2);
                     string valuePair = ValuePairs.getValuePair("Username");
                     if (!string.IsNullOrEmpty(valuePair))
                     {
                         LogAPI.writeEventLog("0630001", new string[]
                         {
                             text,
                             valuePair
                         });
                     }
                     else
                     {
                         LogAPI.writeEventLog("0630001", new string[]
                         {
                             text
                         });
                     }
                 }
                 if (text2.Length > 0)
                 {
                     if (text2.Equals("HAVE EXCEPTION!"))
                     {
                         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
                     }
                     else
                     {
                         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail_1, new string[]
                         {
                             text2
                         }));
                     }
                 }
                 else
                 {
                     EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message);
         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
     }
 }
Exemplo n.º 6
0
 private void butSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         if (this.devConfigCheck())
         {
             string         text              = this.labDevModel.Text;
             string         value             = this.labDevModel.Tag.ToString();
             int            l_id              = System.Convert.ToInt32(value);
             DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(l_id);
             DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion);
             if (this.tbRefVoltage.Visible)
             {
                 deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text);
             }
             deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0);
             deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0);
             deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0);
             deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0);
             deviceByID.Min_power   = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0);
             if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f)
             {
                 deviceByID.Min_power *= 1000f;
             }
             deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0);
             if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f)
             {
                 deviceByID.Max_power *= 1000f;
             }
             deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0);
             deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0);
             if (deviceModelConfig.doorReading == 2)
             {
                 deviceByID.DoorSensor = 0;
                 if (this.rbPhoto_1.Checked)
                 {
                     deviceByID.DoorSensor = 1;
                 }
                 else
                 {
                     if (this.rbInductive_2.Checked)
                     {
                         deviceByID.DoorSensor = 2;
                     }
                     else
                     {
                         if (this.rbReed_3.Checked)
                         {
                             deviceByID.DoorSensor = 3;
                         }
                     }
                 }
             }
             string          mac             = deviceByID.Mac;
             DevSnmpConfig   sNMPpara        = commUtil.getSNMPpara(deviceByID);
             DevAccessAPI    devAccessAPI    = new DevAccessAPI(sNMPpara);
             DeviceThreshold deviceThreshold = new DeviceThreshold();
             int             thflg           = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev");
             deviceThreshold.MinCurrentMT   = deviceByID.Min_current;
             deviceThreshold.MaxCurrentMT   = deviceByID.Max_current;
             deviceThreshold.MinVoltageMT   = deviceByID.Min_voltage;
             deviceThreshold.MaxVoltageMT   = deviceByID.Max_voltage;
             deviceThreshold.MinPowerMT     = deviceByID.Min_power;
             deviceThreshold.MaxPowerMT     = deviceByID.Max_power;
             deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss;
             ThresholdUtil.UI2Dev(thflg, deviceThreshold);
             deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage;
             deviceThreshold.PopEnableMode       = -500;
             deviceThreshold.PopThreshold        = -500f;
             deviceThreshold.PopModeOutlet       = -500;
             deviceThreshold.PopModeLIFO         = -500;
             deviceThreshold.PopModePriority     = -500;
             deviceThreshold.DoorSensorType      = deviceByID.DoorSensor;
             if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDeviceThreshold(deviceThreshold, mac))
             {
                 EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
             }
             else
             {
                 deviceByID.Update();
                 string valuePair = ValuePairs.getValuePair("Username");
                 if (!string.IsNullOrEmpty(valuePair))
                 {
                     LogAPI.writeEventLog("0630000", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP,
                         valuePair
                     });
                 }
                 else
                 {
                     LogAPI.writeEventLog("0630000", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP
                     });
                 }
                 EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + deviceByID.DeviceID + ":;", 2);
                 EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine("PropDev Exception" + ex.Message);
         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
     }
 }
Exemplo n.º 7
0
        public System.Collections.Generic.Dictionary <string, bool> SetDeviceThresholds(System.Collections.Generic.List <DevSnmpConfig> configs, DeviceThreshold deviceThreshold)
        {
            DevAccessCfg instance = DevAccessCfg.GetInstance();

            System.Collections.Generic.List <SnmpConfiger> list = new System.Collections.Generic.List <SnmpConfiger>();
            foreach (DevSnmpConfig current in configs)
            {
                DevModelConfig deviceModelConfig = instance.getDeviceModelConfig(current.modelName, current.fmwareVer);
                SnmpConfiger   item = new SnmpConfiger(instance.getSnmpConfig(current), deviceModelConfig, current.devMac, current.devID);
                list.Add(item);
            }
            System.Collections.Generic.List <string>             list2      = new AppSnmpExecutors(list).SetDevThresholds(deviceThreshold);
            System.Collections.Generic.Dictionary <string, bool> dictionary = new System.Collections.Generic.Dictionary <string, bool>();
            foreach (string current2 in list2)
            {
                string[] array = current2.Split(new char[]
                {
                    ':'
                });
                dictionary.Add(array[0], System.Convert.ToBoolean(array[1]));
            }
            return(dictionary);
        }