예제 #1
0
        public int refreshTree()
        {
            int      result      = 0;
            TreeNode treeNode    = this.tvDev.Nodes[0];
            int      refreshFlag = DeviceInfo.GetRefreshFlag();

            foreach (TreeNode treeNode2 in treeNode.Nodes)
            {
                string name     = treeNode2.Name;
                string arg_50_0 = (string)treeNode2.Tag;
                if (!ClientAPI.IsDeviceOnline(System.Convert.ToInt32(name)))
                {
                    treeNode2.ImageIndex         = 2;
                    treeNode2.SelectedImageIndex = 2;
                }
                else
                {
                    treeNode2.ImageIndex         = 3;
                    treeNode2.SelectedImageIndex = 3;
                }
                if (refreshFlag == 1)
                {
                    result = 1;
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(name));
                    string     text       = treeNode2.Text;
                    if (!text.Equals(deviceByID.DeviceName))
                    {
                        treeNode2.Text = deviceByID.DeviceName;
                    }
                }
            }
            DeviceInfo.SetRefreshFlag(2);
            return(result);
        }
예제 #2
0
        private void handleTheResult(FirmwareUpgrade.Upgrading upgrading, int status)
        {
            switch (status)
            {
            case 0:
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;

            case 2:
                upgrading(UpgradeStatus.Upgrading, this.m_devID, "");
                return;

            case 3:
                upgrading(UpgradeStatus.NoNeedToUpgrade, this.m_devID, "");
                return;

            case 4:
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;

            case 5:
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;
            }
            string text = string.Empty;
            DefaultSnmpExecutor defaultSnmpExecutor = null;

            try
            {
                DeviceInfo    deviceByID = DeviceOperation.getDeviceByID(this.m_devID);
                DevSnmpConfig sNMPpara   = commUtil.getSNMPpara(deviceByID);
                SnmpConfig    snmpConfig = DevAccessCfg.GetInstance().getSnmpConfig(sNMPpara);
                defaultSnmpExecutor = new DefaultSnmpExecutor(new SnmpConfiger(snmpConfig, 1));
            }
            catch (System.Exception)
            {
            }
            int num = 0;

            while (num++ < 20)
            {
                try
                {
                    PropertiesMessage properties_ATEN = defaultSnmpExecutor.GetProperties_ATEN();
                    text = properties_ATEN.FirwWareVersion;
                    break;
                }
                catch (System.Exception)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            if (text.Equals(string.Empty))
            {
                upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, "");
                return;
            }
            upgrading(UpgradeStatus.UpgradeSucceed, this.m_devID, text);
        }
예제 #3
0
        public void pageInit(DevManDevice pParent, int devID, string devName, bool onlinest)
        {
            this.m_ininit   = true;
            this.m_cleartab = true;
            this.tcDev.Controls.Clear();
            this.m_cleartab = false;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            if (deviceByID == null)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[]
                {
                    devName
                }));
                return;
            }
            this.m_onlinest = onlinest;
            this.m_curdevID = devID.ToString();
            this.tcDev.Controls.Add(this.tbDevice);
            this.propDev1.pageInit(pParent, devID, onlinest);
            if (deviceByID.GetPortInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbOutlet);
                this.propOutlet1.pageInit(devID, 0, onlinest);
            }
            if (deviceByID.GetBankInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbBank);
                this.propBank1.pageInit(devID, 0, onlinest);
            }
            if (deviceByID.GetLineInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbLine);
                this.propLine1.pageInit(devID, 0, onlinest);
            }
            if (deviceByID.GetSensorInfo().Count > 0)
            {
                this.tcDev.Controls.Add(this.tbSensor);
                this.propSensor1.pageInit(devID, onlinest);
            }
            if (DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion).popReading == 2)
            {
                this.tcDev.Controls.Add(this.tbPop);
                this.propPOP1.pageInit(devID, onlinest);
            }
            if (this.m_selectedTab == null || !this.tcDev.Contains(this.m_selectedTab))
            {
                this.m_selectedTab = this.tbDevice;
            }
            this.tcDev.SelectTab(this.m_selectedTab);
            this.m_ininit = false;
        }
예제 #4
0
        private void butBank_Click(object sender, System.EventArgs e)
        {
            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);

            this.bankConfigPageControlInit(deviceModelConfig);
            string value2 = ((Button)sender).Tag.ToString();

            ((Button)sender).BackColor = Color.DarkCyan;
            this.setBankConfigData(deviceByID, System.Convert.ToInt32(value2));
        }
예제 #5
0
        private void btbrowsedev_Click(object sender, System.EventArgs e)
        {
            int          devID        = System.Convert.ToInt32(this.lbECDevNm.Tag);
            FindDevDlg   findDevDlg   = new FindDevDlg(devID);
            DialogResult dialogResult = findDevDlg.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                int        devID2     = findDevDlg.DevID;
                DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID2);
                this.lbECDevNm.Text = deviceByID.DeviceName + " (IP:" + deviceByID.DeviceIP + ")";
                this.lbECDevNm.Tag  = devID2;
            }
        }
예제 #6
0
        private void initPage(string rackNm, string devIDs)
        {
            Program.m_IdleCounter = 0;
            int num = 212;

            this.labrackNm.Text = rackNm;
            using (Graphics graphics = base.CreateGraphics())
            {
                SizeF sizeF = graphics.MeasureString(rackNm, this.labrackNm.Font);
                int   num2  = (int)System.Math.Ceiling((double)sizeF.Width);
                if (num2 > 135)
                {
                    this.labrackNm.Width = (int)System.Math.Ceiling((double)(sizeF.Width + 5f));
                }
                else
                {
                    this.labrackNm.Width = 135;
                }
                if (num2 + 77 > num)
                {
                    num = num2 + 77;
                }
            }
            string[] array = devIDs.Split(new char[]
            {
                ','
            });
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                if (!text.Equals(string.Empty))
                {
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(text));
                    string     text2      = deviceByID.DeviceName + ":" + deviceByID.DeviceIP;
                    using (Graphics graphics2 = base.CreateGraphics())
                    {
                        int num2 = (int)System.Math.Ceiling((double)graphics2.MeasureString(text2, this.lbDevice.Font).Width);
                        if (num2 + 8 > num)
                        {
                            num = num2 + 8;
                        }
                    }
                    this.lbDevice.Items.Add(text2);
                }
            }
            this.lbDevice.Width = num - 8;
            base.Width          = num;
        }
예제 #7
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);
        }
예제 #8
0
 public void TimerProc(int haveThresholdChange)
 {
     if (this.m_ininit)
     {
         return;
     }
     foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dgvAllDevices.Rows)
     {
         DataGridViewCellCollection cells = dataGridViewRow.Cells;
         string value = cells["dgvtbcdeviceId"].Value.ToString();
         if (ClientAPI.IsDeviceOnline(System.Convert.ToInt32(value)))
         {
             cells["imgstatus"].Value       = this.imgon;
             cells["imgstatus"].ToolTipText = null;
         }
         else
         {
             if (ClientAPI.IsMACConflict(System.Convert.ToString(cells["dgvtbcMac"].Value)))
             {
                 cells["imgstatus"].Value       = this.imgConflict;
                 cells["imgstatus"].ToolTipText = EcoLanguage.getMsg(LangRes.tips_MACMismatch, new string[0]);
             }
             else
             {
                 cells["imgstatus"].Value       = this.imgoff;
                 cells["imgstatus"].ToolTipText = null;
             }
         }
         if (haveThresholdChange == 1)
         {
             DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(value));
             string     text       = cells["dgvtbDeviceNm"].Value.ToString();
             if (!text.Equals(deviceByID.DeviceName))
             {
                 cells["dgvtbDeviceNm"].Value = deviceByID.DeviceName;
             }
         }
     }
 }
예제 #9
0
        public static byte[] AppProtResponse_Srv(int protocal_ID, string para, int fromUID)
        {
            XmlDocument xmlDocument = null;

            if (protocal_ID == 1)
            {
                try
                {
                    List <int> list      = new List <int>();
                    DataTable  dataTable = DBTools.CreateDataTable(para);
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        for (int j = 0; j < dataTable.Columns.Count; j++)
                        {
                            if (dataTable.Rows[i].ItemArray[j] == DBNull.Value)
                            {
                                list.Add(i);
                                break;
                            }
                        }
                    }
                    if (list.Count > 0)
                    {
                        for (int k = list.Count - 1; k >= 0; k--)
                        {
                            dataTable.Rows.RemoveAt(list[k]);
                        }
                    }
                    dataTable.TableName = "RCI";
                    xmlDocument         = CustomXmlSerializer.Serialize(dataTable, 8, "RCI");
                    goto IL_59A;
                }
                catch (Exception ex)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RCI]: {0}", new string[]
                    {
                        ex.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 2)
            {
                try
                {
                    ArrayList curRacks            = DataSetManager.getCurRacks();
                    Dictionary <long, string> obj = AppData.LoadheatLoadDissipation(curRacks, Convert.ToInt32(para));
                    xmlDocument = CustomXmlSerializer.Serialize(obj, 8, "HEAT");
                    goto IL_59A;
                }
                catch (Exception ex2)
                {
                    Common.WriteLine("AppProtResponse_Srv---[HEAT]: {0}", new string[]
                    {
                        ex2.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 3)
            {
                try
                {
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(Convert.ToInt32(para));
                    xmlDocument = CustomXmlSerializer.Serialize(deviceByID, 8, "RemoteCall_getDeviceByID");
                    goto IL_59A;
                }
                catch (Exception ex3)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_getDeviceByID]: {0}", new string[]
                    {
                        ex3.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 4)
            {
                try
                {
                    DeviceInfo      deviceByID2 = DeviceOperation.getDeviceByID(Convert.ToInt32(para));
                    List <PortInfo> obj2        = null;
                    if (deviceByID2 != null)
                    {
                        obj2 = deviceByID2.GetPortInfo();
                    }
                    xmlDocument = CustomXmlSerializer.Serialize(obj2, 8, "RemoteCall_AllPort_in1Dev");
                    goto IL_59A;
                }
                catch (Exception ex4)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_AllPort_in1Dev]: {0}", new string[]
                    {
                        ex4.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 7)
            {
                try
                {
                    List <DeviceInfo> list2 = new List <DeviceInfo>();
                    string[]          array = para.Split(new string[]
                    {
                        ","
                    }, StringSplitOptions.RemoveEmptyEntries);
                    string[] array2 = array;
                    for (int l = 0; l < array2.Length; l++)
                    {
                        string text  = array2[l];
                        string value = text.Trim();
                        if (!string.IsNullOrEmpty(value))
                        {
                            DeviceInfo deviceByID3 = DeviceOperation.getDeviceByID(Convert.ToInt32(value));
                            if (deviceByID3 != null)
                            {
                                list2.Add(deviceByID3);
                            }
                        }
                    }
                    xmlDocument = CustomXmlSerializer.Serialize(list2, 8, "RemoteCall_getDeviceInfoList");
                    goto IL_59A;
                }
                catch (Exception ex5)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_getDeviceInfoList]: {0}", new string[]
                    {
                        ex5.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 100)
            {
                try
                {
                    string[] array3 = para.Split(new char[]
                    {
                        '\n'
                    });
                    switch (array3.Length)
                    {
                    case 1:
                        LogAPI.writeEventLog(array3[0], new string[0]);
                        break;

                    case 2:
                    {
                        string user       = SessionAPI.getUser((long)fromUID);
                        string remoteIP   = SessionAPI.getRemoteIP((long)fromUID);
                        string remoteType = SessionAPI.getRemoteType((long)fromUID);
                        if (array3[0].Equals("0230003", StringComparison.InvariantCultureIgnoreCase))
                        {
                            LogAPI.writeEventLog("0230003", new string[]
                                {
                                    user,
                                    remoteIP
                                });
                        }
                        else
                        {
                            if (!remoteType.Equals("remote", StringComparison.InvariantCultureIgnoreCase))
                            {
                                LogAPI.writeEventLog(array3[0], new string[]
                                    {
                                        array3[1]
                                    });
                            }
                        }
                        break;
                    }

                    case 3:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2]
                        });
                        break;

                    case 4:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3]
                        });
                        break;

                    case 5:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3],
                            array3[4]
                        });
                        break;

                    case 6:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3],
                            array3[4],
                            array3[5]
                        });
                        break;

                    case 7:
                        LogAPI.writeEventLog(array3[0], new string[]
                        {
                            array3[1],
                            array3[2],
                            array3[3],
                            array3[4],
                            array3[5],
                            array3[6]
                        });
                        break;
                    }
                    int num = 1;
                    xmlDocument = CustomXmlSerializer.Serialize(num, 8, "RemoteCall_writeEventLog");
                    goto IL_59A;
                }
                catch (Exception ex6)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_AllPort_in1Dev]: {0}", new string[]
                    {
                        ex6.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 101)
            {
                try
                {
                    int num2 = 1;
                    xmlDocument = CustomXmlSerializer.Serialize(num2, 8, "RemoteCall_setEventFlag");
                    goto IL_59A;
                }
                catch (Exception ex7)
                {
                    Common.WriteLine("AppProtResponse_Srv---[RemoteCall_setEventFlag]: {0}", new string[]
                    {
                        ex7.Message
                    });
                    goto IL_59A;
                }
            }
            if (protocal_ID == 102)
            {
                DataTable allSessions = SessionAPI.getAllSessions();
                xmlDocument = CustomXmlSerializer.Serialize(allSessions, 8, "Sessions");
            }
            else
            {
                if (protocal_ID == 103)
                {
                    string obj3 = "Success";
                    if (!SessionAPI.KillSessions(fromUID, para))
                    {
                        obj3 = "Failed";
                    }
                    xmlDocument = CustomXmlSerializer.Serialize(obj3, 8, "KillSession");
                }
                else
                {
                    if (protocal_ID == 104)
                    {
                        DateTime now = DateTime.Now;
                        xmlDocument = CustomXmlSerializer.Serialize(now, 8, "RemoteCall_getSrvDateTime");
                    }
                    else
                    {
                        if (protocal_ID == 8)
                        {
                            Dictionary <long, List <long> > dictionary = SessionAPI.getDeviceListClone((long)fromUID);
                            if (dictionary == null)
                            {
                                dictionary = new Dictionary <long, List <long> >();
                            }
                            xmlDocument = CustomXmlSerializer.Serialize(dictionary, 8, "RemoteCall_UACDev2Port");
                        }
                    }
                }
            }
IL_59A:
            if (xmlDocument == null)
            {
                return(null);
            }
            byte[] result;
            try
            {
                string outerXml = xmlDocument.OuterXml;
                byte[] bytes    = Encoding.UTF8.GetBytes(outerXml);
                result = bytes;
            }
            catch (Exception ex8)
            {
                Common.WriteLine("AppProtResponse_Srv: #{0}({1}), {2}", new string[]
                {
                    protocal_ID.ToString(),
                    para,
                    ex8.Message
                });
                result = null;
            }
            return(result);
        }
예제 #10
0
        private void Upgrade(UpgradeStatus us, int devID, string parameter)
        {
            string status = "";

            if (us == UpgradeStatus.UpgradeFailed)
            {
                ControlAccess.ConfigControl config = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_upgradefail, new string[0]);
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess = new ControlAccess(this, config);
                controlAccess.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.UpgradeSucceed)
            {
                ControlAccess.ConfigControl config2 = delegate(Control control, object param)
                {
                    DataGridView grid  = control as DataGridView;
                    string       value = param as string;
                    int          num   = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_upgradesucc, new string[0]);
                    string parameter2 = parameter;
                    this.changeUpgradeStatus(grid, num, status, parameter2);
                    DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num);
                    deviceByID.FWVersion = parameter2;
                    deviceByID.Update();
                };
                ControlAccess controlAccess2 = new ControlAccess(this, config2);
                controlAccess2.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.ServerUnconnected)
            {
                ControlAccess.ConfigControl config3 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_serverunconnected, new string[0]);
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess3 = new ControlAccess(this, config3);
                controlAccess3.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.Uploading)
            {
                ControlAccess.ConfigControl config4 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_uploading, new string[0]) + " " + parameter;
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess4 = new ControlAccess(this, config4);
                controlAccess4.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.Upgrading)
            {
                ControlAccess.ConfigControl config5 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_upgrading, new string[0]) + " " + parameter;
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess5 = new ControlAccess(this, config5);
                controlAccess5.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.WrongFile)
            {
                ControlAccess.ConfigControl config6 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_wrongfile, new string[0]);
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess6 = new ControlAccess(this, config6);
                controlAccess6.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.NoNeedToUpgrade)
            {
                ControlAccess.ConfigControl config7 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_noneedupgrade, new string[0]);
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess7 = new ControlAccess(this, config7);
                controlAccess7.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.ServerBusy)
            {
                ControlAccess.ConfigControl config8 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_serverbusy, new string[0]);
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess8 = new ControlAccess(this, config8);
                controlAccess8.Access(this.dgvFwDevice, devID.ToString());
                return;
            }
            if (us == UpgradeStatus.Starting)
            {
                ControlAccess.ConfigControl config9 = delegate(Control control, object param)
                {
                    DataGridView grid   = control as DataGridView;
                    string       value  = param as string;
                    int          devID2 = System.Convert.ToInt32(value);
                    status = EcoLanguage.getMsg(LangRes.FrwUpgradeST_starting, new string[0]);
                    this.changeUpgradeStatus(grid, devID2, status);
                };
                ControlAccess controlAccess9 = new ControlAccess(this, config9);
                controlAccess9.Access(this.dgvFwDevice, devID.ToString());
            }
        }
예제 #11
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.gbPop2.Visible)
             {
                 if (this.pop2_cbOutlet.Visible)
                 {
                     deviceByID.OutletPOPMode = (this.pop2_cbOutlet.Checked ? 2 : 1);
                 }
                 if (this.pop2_cbBankLIFO.Visible)
                 {
                     deviceByID.BankPOPLIFOMode = (this.pop2_cbBankLIFO.Checked ? 2 : 1);
                 }
                 deviceByID.BankPOPPriorityMode = (this.pop2_cbBankPriority.Checked ? 2 : 1);
             }
             if (this.gbPOPBankPriority.Visible)
             {
                 string text2 = "";
                 int    num;
                 int    num2;
                 if (deviceModelConfig.bankNum == 0)
                 {
                     num  = 1;
                     num2 = deviceModelConfig.portNum;
                 }
                 else
                 {
                     num  = deviceModelConfig.bankOutlets[0].fromPort;
                     num2 = deviceModelConfig.bankOutlets[0].toPort;
                 }
                 for (int i = 0; i < this.dgvBank1_PList.Rows.Count; i++)
                 {
                     DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank1_PList.Rows[i].Cells[1];
                     string text3 = dataGridViewComboBoxCell.Value.ToString();
                     if (text3.Equals("N/A"))
                     {
                         text2 += "0,";
                     }
                     else
                     {
                         text3 = text3.Substring("Outlet ".Length);
                         text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ",";
                     }
                 }
                 for (int j = 0; j < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; j++)
                 {
                     text2 += "0,";
                 }
                 text2 = text2.Substring(0, text2.Length - 1);
                 if (this.dgvBank2_PList.Visible)
                 {
                     num    = deviceModelConfig.bankOutlets[1].fromPort;
                     num2   = deviceModelConfig.bankOutlets[1].toPort;
                     text2 += "#";
                     for (int k = 0; k < this.dgvBank2_PList.Rows.Count; k++)
                     {
                         DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank2_PList.Rows[k].Cells[1];
                         string text3 = dataGridViewComboBoxCell.Value.ToString();
                         if (text3.Equals("N/A"))
                         {
                             text2 += "0,";
                         }
                         else
                         {
                             text3 = text3.Substring("Outlet ".Length);
                             text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ",";
                         }
                     }
                     for (int l = 0; l < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; l++)
                     {
                         text2 += "0,";
                     }
                     text2 = text2.Substring(0, text2.Length - 1);
                 }
                 deviceByID.Bank_Priority = text2;
             }
             if (this.gbPop.Visible)
             {
                 if (!this.cbPopEnable.Checked)
                 {
                     deviceByID.POPEnableMode = 1;
                 }
                 else
                 {
                     deviceByID.POPEnableMode = 2;
                     if (this.rbPopMaxBankC.Checked)
                     {
                         deviceByID.POPThreshold = -0.1f;
                     }
                     else
                     {
                         deviceByID.POPThreshold = System.Convert.ToSingle(this.tbPopThreshold.Text);
                     }
                 }
             }
             string            mac               = deviceByID.Mac;
             DevSnmpConfig     sNMPpara          = commUtil.getSNMPpara(deviceByID);
             DevAccessAPI      devAccessAPI      = new DevAccessAPI(sNMPpara);
             DevicePOPSettings devicePOPSettings = new DevicePOPSettings();
             devicePOPSettings.PopEnableMode   = deviceByID.POPEnableMode;
             devicePOPSettings.PopThreshold    = deviceByID.POPThreshold;
             devicePOPSettings.PopModeOutlet   = deviceByID.OutletPOPMode;
             devicePOPSettings.PopModeLIFO     = deviceByID.BankPOPLIFOMode;
             devicePOPSettings.PopModePriority = deviceByID.BankPOPPriorityMode;
             devicePOPSettings.PopPriorityList = deviceByID.Bank_Priority;
             if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDevicePOPSettings(devicePOPSettings, 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("0630005", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP,
                         valuePair
                     });
                 }
                 else
                 {
                     LogAPI.writeEventLog("0630005", new string[]
                     {
                         deviceByID.DeviceName,
                         deviceByID.Mac,
                         deviceByID.DeviceIP
                     });
                 }
                 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]));
     }
 }
예제 #12
0
        public void pageInit(int devID, bool onlinest)
        {
            this.butSave.Enabled = onlinest;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            this.labDevNm.Text    = deviceByID.DeviceName;
            this.labDevModel.Text = deviceByID.ModelNm;
            this.labDevModel.Tag  = devID.ToString();
            string text = deviceByID.ModelNm;

            if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
            {
                text = text + " (F/W: " + deviceByID.FWVersion + ")";
            }
            this.toolTip1.SetToolTip(this.labDevModel, text);
            this.labDevIp.Text = deviceByID.DeviceIP;
            this.labDevIp.Tag  = deviceByID.FWVersion;
            this.labDevNm.Text = deviceByID.DeviceName;
            RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID);

            this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);

            if (deviceModelConfig.popReading != 2)
            {
                this.gbPop.Hide();
                this.gbPop2.Hide();
                this.gbPOPBankPriority.Hide();
                return;
            }
            if (deviceModelConfig.popNewRule == Constant.YES)
            {
                this.gbPop.Hide();
                this.gbPop2.Show();
                if (deviceModelConfig.perportreading == Constant.NO)
                {
                    this.pop2_cbOutlet.Hide();
                    this.pop2_cbBankLIFO.Hide();
                }
                else
                {
                    this.pop2_cbOutlet.Show();
                    this.pop2_cbBankLIFO.Show();
                }
                if (deviceByID.OutletPOPMode == 1)
                {
                    this.pop2_cbOutlet.Checked = false;
                }
                else
                {
                    this.pop2_cbOutlet.Checked = true;
                }
                if (deviceByID.BankPOPLIFOMode == 1)
                {
                    this.pop2_cbBankLIFO.Checked = false;
                }
                else
                {
                    this.pop2_cbBankLIFO.Checked = true;
                }
                if (deviceByID.BankPOPPriorityMode == 1)
                {
                    this.pop2_cbBankPriority.Checked = false;
                }
                else
                {
                    this.pop2_cbBankPriority.Checked = true;
                }
                if (deviceModelConfig.popPrioritySupport == Constant.NO)
                {
                    this.gbPOPBankPriority.Hide();
                    return;
                }
                this.gbPOPBankPriority.Show();
                string[] array = deviceByID.Bank_Priority.Split(new char[]
                {
                    '#'
                });
                string[] array2 = array[0].Split(new char[]
                {
                    ','
                });
                string[] array3 = null;
                if (array.Length >= 2)
                {
                    array3 = array[1].Split(new char[]
                    {
                        ','
                    });
                }
                this.dgvBank1_PList.Rows.Clear();
                DataGridViewComboBoxColumn dataGridViewComboBoxColumn = (DataGridViewComboBoxColumn)this.dgvBank1_PList.Columns[1];
                this.m_Bank1_Priority_ComboStrings = new System.Collections.Generic.List <string>();
                dataGridViewComboBoxColumn.Items.Clear();
                dataGridViewComboBoxColumn.Items.Add("N/A");
                this.m_Bank1_Priority_ComboStrings.Add("N/A");
                int num;
                int num2;
                if (deviceModelConfig.bankNum == 0)
                {
                    num  = 1;
                    num2 = deviceModelConfig.portNum;
                }
                else
                {
                    num  = deviceModelConfig.bankOutlets[0].fromPort;
                    num2 = deviceModelConfig.bankOutlets[0].toPort;
                }
                for (int i = num; i <= num2; i++)
                {
                    if (deviceModelConfig.isOutletSwitchable(i - 1))
                    {
                        dataGridViewComboBoxColumn.Items.Add("Outlet " + i.ToString());
                        this.m_Bank1_Priority_ComboStrings.Add("Outlet " + i.ToString());
                    }
                }
                int num3 = 0;
                for (int j = num; j <= num2; j++)
                {
                    if (deviceModelConfig.isOutletSwitchable(j - 1))
                    {
                        if (array2[num3].Equals("0"))
                        {
                            this.dgvBank1_PList.Rows.Add(new object[]
                            {
                                "Priority" + (num3 + 1).ToString(),
                                "N/A"
                            });
                        }
                        else
                        {
                            string text2 = "Outlet " + System.Convert.ToInt16(array2[num3]).ToString();
                            if (this.m_Bank1_Priority_ComboStrings.Contains(text2))
                            {
                                this.dgvBank1_PList.Rows.Add(new object[]
                                {
                                    "Priority" + (num3 + 1).ToString(),
                                    text2
                                });
                            }
                            else
                            {
                                this.dgvBank1_PList.Rows.Add(new object[]
                                {
                                    "Priority" + (num3 + 1).ToString(),
                                    "N/A"
                                });
                            }
                        }
                        num3++;
                    }
                }
                if (deviceModelConfig.bankNum >= 2)
                {
                    this.lbbank2.Visible        = true;
                    this.dgvBank2_PList.Visible = true;
                    this.dgvBank2_PList.Rows.Clear();
                    dataGridViewComboBoxColumn         = (DataGridViewComboBoxColumn)this.dgvBank2_PList.Columns[1];
                    this.m_Bank2_Priority_ComboStrings = new System.Collections.Generic.List <string>();
                    dataGridViewComboBoxColumn.Items.Clear();
                    dataGridViewComboBoxColumn.Items.Add("N/A");
                    this.m_Bank2_Priority_ComboStrings.Add("N/A");
                    for (int k = deviceModelConfig.bankOutlets[1].fromPort; k <= deviceModelConfig.bankOutlets[1].toPort; k++)
                    {
                        if (deviceModelConfig.isOutletSwitchable(k - 1))
                        {
                            dataGridViewComboBoxColumn.Items.Add("Outlet " + k.ToString());
                            this.m_Bank2_Priority_ComboStrings.Add("Outlet " + k.ToString());
                        }
                    }
                    num3 = 0;
                    for (int l = deviceModelConfig.bankOutlets[1].fromPort; l <= deviceModelConfig.bankOutlets[1].toPort; l++)
                    {
                        if (deviceModelConfig.isOutletSwitchable(l - 1))
                        {
                            if (array3[num3].Equals("0"))
                            {
                                this.dgvBank2_PList.Rows.Add(new object[]
                                {
                                    "Priority" + (num3 + 1).ToString(),
                                    "N/A"
                                });
                            }
                            else
                            {
                                string text2 = "Outlet " + System.Convert.ToInt16(array3[num3]).ToString();
                                if (this.m_Bank2_Priority_ComboStrings.Contains(text2))
                                {
                                    this.dgvBank2_PList.Rows.Add(new object[]
                                    {
                                        "Priority" + (num3 + 1).ToString(),
                                        text2
                                    });
                                }
                                else
                                {
                                    this.dgvBank2_PList.Rows.Add(new object[]
                                    {
                                        "Priority" + (num3 + 1).ToString(),
                                        "N/A"
                                    });
                                }
                            }
                            num3++;
                        }
                    }
                    return;
                }
                this.lbbank2.Visible        = false;
                this.dgvBank2_PList.Visible = false;
                return;
            }
            else
            {
                if (deviceByID.POPThreshold == -500f)
                {
                    this.gbPop.Hide();
                    this.gbPop2.Hide();
                    this.gbPOPBankPriority.Hide();
                    return;
                }
                this.gbPop.Show();
                this.gbPop2.Hide();
                this.gbPOPBankPriority.Hide();
                this.rbPopMaxBankC.Text = this.PopMaxBank_txt + " " + deviceModelConfig.popDefault.ToString("F1") + "A";
                if (deviceByID.POPEnableMode == 1)
                {
                    this.cbPopEnable.Checked   = false;
                    this.rbPopMaxBankC.Checked = true;
                    this.tbPopThreshold.Text   = "";
                    this.cbPopEnable_CheckedChanged(this.cbPopEnable, null);
                    return;
                }
                if (deviceByID.POPThreshold < 0f)
                {
                    this.cbPopEnable.Checked   = true;
                    this.rbPopMaxBankC.Checked = true;
                    this.tbPopThreshold.Text   = "";
                    return;
                }
                this.cbPopEnable.Checked = true;
                this.rbPopUsrdef.Checked = true;
                this.tbPopThreshold.Text = deviceByID.POPThreshold.ToString("F1");
                return;
            }
        }
예제 #13
0
        private bool sysparaCheck()
        {
            bool flag          = false;
            int  selectedIndex = this.cbDClayout.SelectedIndex;

            if (selectedIndex < EcoGlobalVar.DCLayoutType)
            {
                int num  = DevManFloorGrids.get_DCRows(selectedIndex);
                int num2 = DevManFloorGrids.get_DCColumns(selectedIndex);
                System.Collections.ArrayList allRack = RackInfo.getAllRack();
                foreach (RackInfo rackInfo in allRack)
                {
                    if (rackInfo.StartPoint_X + 1 > num || rackInfo.EndPoint_X + 1 > num)
                    {
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Rack_OutRange, new string[]
                        {
                            rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag)
                        }));
                        bool result = false;
                        return(result);
                    }
                    if (rackInfo.StartPoint_Y + 1 > num2 || rackInfo.EndPoint_Y + 1 > num2)
                    {
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Rack_OutRange, new string[]
                        {
                            rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag)
                        }));
                        bool result = false;
                        return(result);
                    }
                }
                System.Collections.ArrayList allZone = ZoneInfo.getAllZone();
                foreach (ZoneInfo zoneInfo in allZone)
                {
                    if (zoneInfo.StartPointX + 1 > num || zoneInfo.EndPointX + 1 > num)
                    {
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Zone_OutRange, new string[]
                        {
                            zoneInfo.ZoneName
                        }));
                        bool result = false;
                        return(result);
                    }
                    if (zoneInfo.StartPointY + 1 > num2 || zoneInfo.EndPointY + 1 > num2)
                    {
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Zone_OutRange, new string[]
                        {
                            zoneInfo.ZoneName
                        }));
                        bool result = false;
                        return(result);
                    }
                }
            }
            if (this.rbEC1.Checked)
            {
                Ecovalidate.checkTextIsNull(this.tbECVoltage, ref flag);
                if (flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.rbEC1.Text
                    }));
                    return(false);
                }
                if (!Ecovalidate.Rangeint(this.tbECVoltage, 90, 260))
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[]
                    {
                        this.rbEC1.Text,
                        "90",
                        "260"
                    }));
                    return(false);
                }
            }
            if (this.rbEC2.Checked)
            {
                try
                {
                    int l_id = System.Convert.ToInt32(this.lbECDevNm.Tag.ToString());
                    if (DeviceOperation.getDeviceByID(l_id) == null)
                    {
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                        {
                            this.rbEC2.Text
                        }));
                        bool result = false;
                        return(result);
                    }
                }
                catch (System.Exception)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.rbEC2.Text
                    }));
                    bool result = false;
                    return(result);
                }
            }
            if (this.txtco2_elec.Text.Length > 0 && !Ecovalidate.NumberFormat_double(this.txtco2_elec))
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_invalidNumber, new string[0]));
                return(false);
            }
            if (this.txtprice_elec.Text.Length > 0 && !Ecovalidate.NumberFormat_double(this.txtprice_elec))
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_invalidNumber, new string[0]));
                return(false);
            }
            if (this.txtprice_co2.Text.Length > 0 && !Ecovalidate.NumberFormat_double(this.txtprice_co2))
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_invalidNumber, new string[0]));
                return(false);
            }
            return(true);
        }
예제 #14
0
 private void butBankSave_Click(object sender, System.EventArgs e)
 {
     try
     {
         string         value             = this.labDevModel.Tag.ToString();
         int            num               = System.Convert.ToInt32(value);
         DeviceInfo     deviceByID        = DeviceOperation.getDeviceByID(num);
         DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);
         if (this.bankCheck(deviceModelConfig))
         {
             string        text          = this.tbBankNm.Text;
             string        text2         = this.labBankNo.Text;
             int           num2          = System.Convert.ToInt32(text2);
             BankInfo      bankInfo      = new BankInfo(num, num2);
             DevSnmpConfig sNMPpara      = commUtil.getSNMPpara(deviceByID);
             BankThreshold bankThreshold = new BankThreshold(num2);
             bankThreshold.BankName = text;
             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);
             }
             bool flag = true;
             if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
             {
                 DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara);
                 flag = devAccessAPI.SetBankThreshold(bankThreshold, deviceByID.Mac);
             }
             if (flag)
             {
                 if (bankInfo != null)
                 {
                     bankInfo.BankName = text;
                     bankInfo.Update();
                     EcoGlobalVar.setDashBoardFlg(128uL, string.Concat(new object[]
                     {
                         "#UPDATE#D",
                         bankInfo.DeviceID,
                         ":B",
                         bankInfo.ID,
                         ";"
                     }), 2);
                     string valuePair = ValuePairs.getValuePair("Username");
                     if (!string.IsNullOrEmpty(valuePair))
                     {
                         LogAPI.writeEventLog("0630010", new string[]
                         {
                             bankInfo.BankName,
                             bankInfo.PortLists,
                             deviceByID.DeviceIP,
                             deviceByID.DeviceName,
                             valuePair
                         });
                     }
                     else
                     {
                         LogAPI.writeEventLog("0630010", new string[]
                         {
                             bankInfo.BankName,
                             bankInfo.PortLists,
                             deviceByID.DeviceIP,
                             deviceByID.DeviceName
                         });
                     }
                 }
                 EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0]));
             }
             else
             {
                 EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
             }
         }
     }
     catch (System.Exception ex)
     {
         System.Console.WriteLine("PropBank Exception" + ex.Message);
         EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0]));
     }
 }
예제 #15
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]));
     }
 }
예제 #16
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]));
     }
 }
예제 #17
0
        public void pageInit(int devID, bool onlinest)
        {
            this.butSave.Enabled = onlinest;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            this.labDevNm.Text    = deviceByID.DeviceName;
            this.labDevModel.Text = deviceByID.ModelNm;
            this.labDevModel.Tag  = devID.ToString();
            string text = deviceByID.ModelNm;

            if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
            {
                text = text + " (F/W: " + deviceByID.FWVersion + ")";
            }
            this.toolTip1.SetToolTip(this.labDevModel, text);
            this.labDevIp.Text = deviceByID.DeviceIP;
            this.labDevIp.Tag  = deviceByID.FWVersion;
            this.labDevNm.Text = deviceByID.DeviceName;
            RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID);

            this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);

            if (deviceByID.ModelNm.Equals("EC1000"))
            {
                this.lbRefVoltage.Visible     = true;
                this.tbRefVoltage.Visible     = true;
                this.lbRefVoltageUnit.Visible = true;
                if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
                {
                    this.tbRefVoltage.Enabled = true;
                    if (deviceByID.ReferenceVoltage == -500f || deviceByID.ReferenceVoltage == -300f)
                    {
                        this.tbRefVoltage.Text = "";
                    }
                    else
                    {
                        this.tbRefVoltage.Text = System.Convert.ToString(deviceByID.ReferenceVoltage);
                    }
                }
                else
                {
                    this.tbRefVoltage.Enabled = false;
                    this.tbRefVoltage.Text    = System.Convert.ToString(Sys_Para.GetEnergyValue());
                }
            }
            else
            {
                this.lbRefVoltage.Visible     = false;
                this.tbRefVoltage.Visible     = false;
                this.lbRefVoltageUnit.Visible = false;
            }
            int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev");

            ThresholdUtil.SetUIEdit(this.tbMinVoltage, (num & 4) == 0, deviceByID.Min_voltage, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbMaxVoltage, (num & 8) == 0, deviceByID.Max_voltage, 0, "F1");
            this.labMaxVoltageBound.Text = ((!this.tbMinVoltage.ReadOnly || !this.tbMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "dev", 0) : "");
            if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU)
            {
                ThresholdUtil.SetUIEdit(this.tbMinCurrent, (num & 1) == 0, deviceByID.Min_current, 0, "F0");
                ThresholdUtil.SetUIEdit(this.tbMaxCurrent, (num & 2) == 0, deviceByID.Max_current, 0, "F0");
                this.labMaxCurrentBound.Text = ((!this.tbMinCurrent.ReadOnly || !this.tbMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "dev", 0, "F0") : "");
                this.lbunitPower.Text        = "kW";
                ThresholdUtil.SetUIEdit(this.tbMinPower, (num & 16) == 0, deviceByID.Min_power / 1000f, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbMaxPower, (num & 32) == 0, deviceByID.Max_power / 1000f, 0, "F1");
                this.labMaxPowerBound.Text = ((!this.tbMinPower.ReadOnly || !this.tbMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "dev", 0, 1000.0) : "");
            }
            else
            {
                ThresholdUtil.SetUIEdit(this.tbMinCurrent, (num & 1) == 0, deviceByID.Min_current, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbMaxCurrent, (num & 2) == 0, deviceByID.Max_current, 0, "F1");
                this.labMaxCurrentBound.Text = ((!this.tbMinCurrent.ReadOnly || !this.tbMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "dev", 0, "F1") : "");
                this.lbunitPower.Text        = "W";
                ThresholdUtil.SetUIEdit(this.tbMinPower, (num & 16) == 0, deviceByID.Min_power, 0, "F1");
                ThresholdUtil.SetUIEdit(this.tbMaxPower, (num & 32) == 0, deviceByID.Max_power, 0, "F1");
                this.labMaxPowerBound.Text = ((!this.tbMinPower.ReadOnly || !this.tbMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "dev", 0, 1.0) : "");
            }
            ThresholdUtil.SetUIEdit(this.tbMinPowerDiss, (num & 64) == 0, deviceByID.Min_power_diss, 0, "F1");
            ThresholdUtil.SetUIEdit(this.tbMaxPowerDiss, (num & 128) == 0, deviceByID.Max_power_diss, 0, "F1");
            this.labMaxPowerDisBound.Text = ((!this.tbMinPowerDiss.ReadOnly || !this.tbMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "dev", 0) : "");
            if (deviceModelConfig.doorReading != 2)
            {
                this.gbDoorSS.Hide();
                return;
            }
            this.gbDoorSS.Show();
            switch (deviceByID.DoorSensor)
            {
            case 0:
                this.rbNoInstall_0.Checked = true;
                return;

            case 1:
                this.rbPhoto_1.Checked = true;
                return;

            case 2:
                this.rbInductive_2.Checked = true;
                return;

            case 3:
                this.rbReed_3.Checked = true;
                return;

            default:
                return;
            }
        }
예제 #18
0
        public void pageInit(int devID, int bankID, bool onlinest)
        {
            this.butBankAssign.Enabled = onlinest;
            this.butBankSave.Enabled   = onlinest;
            DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID);

            this.labDevIp.Text    = deviceByID.DeviceIP;
            this.labDevIp.Tag     = deviceByID.FWVersion;
            this.labDevModel.Text = deviceByID.ModelNm;
            this.labDevModel.Tag  = devID.ToString();
            this.labDevNm.Text    = deviceByID.DeviceName;
            string text = deviceByID.ModelNm;

            if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion))
            {
                text = text + " (F/W: " + deviceByID.FWVersion + ")";
            }
            this.toolTip1.SetToolTip(this.labDevModel, text);
            RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID);

            this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
            DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion);

            this.butBank1.Visible = false;
            this.butBank2.Visible = false;
            this.butBank3.Visible = false;
            this.butBank4.Visible = false;
            this.butBank5.Visible = false;
            this.butBank6.Visible = false;
            this.butBank7.Visible = false;
            this.butBank8.Visible = false;
            System.Collections.Generic.List <BankInfo> bankInfo = deviceByID.GetBankInfo();
            foreach (BankInfo current in bankInfo)
            {
                string portLists = current.PortLists;
                switch (System.Convert.ToInt32(portLists))
                {
                case 1:
                    this.butBank1.Visible = true;
                    this.butBank1.Tag     = current.ID.ToString();
                    break;

                case 2:
                    this.butBank2.Visible = true;
                    this.butBank2.Tag     = current.ID.ToString();
                    break;

                case 3:
                    this.butBank3.Visible = true;
                    this.butBank3.Tag     = current.ID.ToString();
                    break;

                case 4:
                    this.butBank4.Visible = true;
                    this.butBank4.Tag     = current.ID.ToString();
                    break;

                case 5:
                    this.butBank5.Visible = true;
                    this.butBank5.Tag     = current.ID.ToString();
                    break;

                case 6:
                    this.butBank6.Visible = true;
                    this.butBank6.Tag     = current.ID.ToString();
                    break;

                case 7:
                    this.butBank7.Visible = true;
                    this.butBank7.Tag     = current.ID.ToString();
                    break;

                case 8:
                    this.butBank8.Visible = true;
                    this.butBank8.Tag     = current.ID.ToString();
                    break;
                }
            }
            this.bankConfigPageControlInit(deviceModelConfig);
            if (bankID == 0)
            {
                this.setBankConfigData(deviceByID, System.Convert.ToInt32(this.butBank1.Tag));
                return;
            }
            this.setBankConfigData(deviceByID, bankID);
        }
예제 #19
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);
                }
            }
        }
예제 #20
0
        public void pageInit()
        {
            int serviceDelay = Sys_Para.GetServiceDelay();

            if (serviceDelay == 30)
            {
                this.cbReadDelay.SelectedIndex = 0;
            }
            else
            {
                if (serviceDelay == 60)
                {
                    this.cbReadDelay.SelectedIndex = 1;
                }
                else
                {
                    if (serviceDelay == 180)
                    {
                        this.cbReadDelay.SelectedIndex = 2;
                    }
                    else
                    {
                        if (serviceDelay == 300)
                        {
                            this.cbReadDelay.SelectedIndex = 3;
                        }
                        else
                        {
                            if (serviceDelay == 600)
                            {
                                this.cbReadDelay.SelectedIndex = 4;
                            }
                            else
                            {
                                if (serviceDelay == 900)
                                {
                                    this.cbReadDelay.SelectedIndex = 5;
                                }
                                else
                                {
                                    this.cbReadDelay.SelectedIndex = 1;
                                }
                            }
                        }
                    }
                }
            }
            this.cbDClayout.SelectedIndex = Sys_Para.GetResolution();
            EcoGlobalVar.TempUnit         = Sys_Para.GetTemperatureUnit();
            EcoGlobalVar.CurCurrency      = Sys_Para.GetCurrency();
            EcoGlobalVar.co2kg            = Sys_Para.GetCO2KG();
            switch (Sys_Para.GetEnergyType())
            {
            case 0:
                this.rbEC1.Checked    = true;
                this.tbECVoltage.Text = Sys_Para.GetEnergyValue().ToString("F0");
                this.lbECDevNm.Text   = "N/A";
                this.lbECDevNm.Tag    = -1;
                break;

            case 1:
            {
                this.rbEC2.Checked = true;
                int        referenceDevice = Sys_Para.GetReferenceDevice();
                DeviceInfo deviceByID      = DeviceOperation.getDeviceByID(referenceDevice);
                if (deviceByID == null)
                {
                    this.lbECDevNm.Text = "N/A";
                    this.lbECDevNm.Tag  = -1;
                }
                else
                {
                    this.lbECDevNm.Text = deviceByID.DeviceName + " (IP:" + deviceByID.DeviceIP + ")";
                    this.lbECDevNm.Tag  = deviceByID.DeviceID;
                }
                break;
            }

            case 2:
                this.rbEC3.Checked  = true;
                this.lbECDevNm.Text = "N/A";
                this.lbECDevNm.Tag  = -1;
                break;
            }
            float cO2KG = Sys_Para.GetCO2KG();

            if (cO2KG < 0f)
            {
                this.txtco2_elec.Text = "";
            }
            else
            {
                this.txtco2_elec.Text = cO2KG.ToString("F2");
            }
            float eLECTRICITYCOST = Sys_Para.GetELECTRICITYCOST();

            if (eLECTRICITYCOST < 0f)
            {
                this.txtprice_elec.Text = "";
            }
            else
            {
                this.txtprice_elec.Text = eLECTRICITYCOST.ToString("F2");
            }
            float cO2COST = Sys_Para.GetCO2COST();

            if (eLECTRICITYCOST < 0f)
            {
                this.txtprice_co2.Text = "";
            }
            else
            {
                this.txtprice_co2.Text = cO2COST.ToString("F2");
            }
            if (EcoGlobalVar.TempUnit == 0)
            {
                this.TempUnitC.Checked = true;
            }
            else
            {
                this.TempUnitF.Checked = true;
            }
            this.cbCurrency.SelectedItem = EcoGlobalVar.CurCurrency;
            this.lbElec_unit.Text        = EcoGlobalVar.CurCurrency + this.m_ElecUnit;
            this.lbCO2_unit.Text         = EcoGlobalVar.CurCurrency + this.m_CO2Unit;
            if (Sys_Para.GetRackFullNameflag() == 1)
            {
                this.cbERackFNm.Checked = true;
            }
            else
            {
                this.cbERackFNm.Checked = false;
            }
            this.cbERPower.Checked = Sys_Para.GetEnablePowerControlFlag();
        }