예제 #1
0
        private void DevtreeInit()
        {
            this.tvDev.Nodes.Clear();
            System.GC.Collect();
            TreeNode treeNode = new TreeNode();

            treeNode.Text               = EcoLanguage.getMsg(LangRes.DevRoot, new string[0]);
            treeNode.Name               = "DevRoot";
            treeNode.Tag                = "DevRoot";
            treeNode.ImageIndex         = 0;
            treeNode.SelectedImageIndex = 0;
            this.tvDev.Nodes.Add(treeNode);
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            for (int i = 0; i < allDevice.Count; i++)
            {
                DeviceInfo deviceInfo = allDevice[i];
                string     deviceName = deviceInfo.DeviceName;
                TreeNode   treeNode2  = new TreeNode();
                treeNode2.Text = deviceName;
                treeNode2.Name = deviceInfo.DeviceID.ToString();
                treeNode2.Tag  = deviceInfo.Mac;
                if (!ClientAPI.IsDeviceOnline(deviceInfo.DeviceID))
                {
                    treeNode2.ImageIndex         = 2;
                    treeNode2.SelectedImageIndex = 2;
                }
                else
                {
                    treeNode2.ImageIndex         = 3;
                    treeNode2.SelectedImageIndex = 3;
                }
                treeNode.Nodes.Add(treeNode2);
            }
        }
예제 #2
0
        private int syncThreshold()
        {
            int result;

            try
            {
                System.Collections.Generic.List <DeviceInfo>    allDevice = DeviceOperation.GetAllDevice();
                System.Collections.Generic.List <DevSnmpConfig> list      = new System.Collections.Generic.List <DevSnmpConfig>();
                new System.Collections.Generic.List <System.Collections.Hashtable>();
                foreach (DeviceInfo current in allDevice)
                {
                    if (ClientAPI.IsDeviceOnline(current.DeviceID))
                    {
                        DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current);
                        list.Add(sNMPpara);
                    }
                }
                DevMonitorAPI devMonitorAPI = new DevMonitorAPI();
                System.Collections.Generic.List <ThresholdMessage> monitorThresholds = devMonitorAPI.GetMonitorThresholds(list);
                this.UpdateAllThresholds(monitorThresholds);
                result = 1;
            }
            catch (System.Exception)
            {
                result = -1;
            }
            return(result);
        }
예제 #3
0
 private void tvUserDeviceInit()
 {
     this.dgvAllDevices.Rows.Clear();
     string[] source = this.m_deviceIds.Split(new char[]
     {
         ','
     });
     System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
     for (int i = 0; i < allDevice.Count; i++)
     {
         DeviceInfo deviceInfo      = allDevice[i];
         string     deviceIP        = deviceInfo.DeviceIP;
         string     mac             = deviceInfo.Mac;
         string     deviceName      = deviceInfo.DeviceName;
         string     modelNm         = deviceInfo.ModelNm;
         RackInfo   rackByID        = RackInfo.getRackByID(deviceInfo.RackID);
         string     displayRackName = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
         string     text            = deviceInfo.DeviceID.ToString();
         if (source.Contains(text))
         {
             this.dgvAllDevices.Rows.Add(new object[]
             {
                 true,
                 deviceName,
                 mac,
                 deviceIP,
                 modelNm,
                 displayRackName,
                 text
             });
         }
         else
         {
             this.dgvAllDevices.Rows.Add(new object[]
             {
                 false,
                 deviceName,
                 mac,
                 deviceIP,
                 modelNm,
                 displayRackName,
                 text
             });
         }
     }
 }
예제 #4
0
        private void show_devTb()
        {
            this.m_ininit = true;
            DataGridViewColumn sortedColumn = this.dgvAllDevices.SortedColumn;

            this.dgvAllDevices.Rows.Clear();
            System.Collections.Generic.Dictionary <long, CommParaClass> deviceRackMapping = DeviceOperation.GetDeviceRackMapping();
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            foreach (TreeNode treeNode in this.m_rootNode.Nodes)
            {
                string     text       = treeNode.Text;
                long       num        = System.Convert.ToInt64(treeNode.Name);
                bool       flag       = false;
                DeviceInfo deviceInfo = null;
                for (int i = 0; i < allDevice.Count; i++)
                {
                    deviceInfo = allDevice[i];
                    if ((long)deviceInfo.DeviceID == num)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    string    text2     = "";
                    IPAddress iPAddress = IPAddress.Parse(deviceInfo.DeviceIP);
                    if (deviceRackMapping.ContainsKey(num))
                    {
                        text2 = deviceRackMapping[num].String_First;
                    }
                    string text3 = this.tbFilterKey.Text;
                    if (text3.Length <= 0 || text.Contains(text3) || deviceInfo.Mac.Contains(text3) || iPAddress.ToString().Contains(text3) || deviceInfo.Port.ToString().Contains(text3) || deviceInfo.ModelNm.Contains(text3) || text2.Contains(text3))
                    {
                        object[] values;
                        if (ClientAPI.IsDeviceOnline(deviceInfo.DeviceID))
                        {
                            values = new object[]
                            {
                                this.imgon,
                                text,
                                deviceInfo.Mac,
                                iPAddress,
                                deviceInfo.Port,
                                deviceInfo.ModelNm,
                                text2,
                                num.ToString()
                            };
                        }
                        else
                        {
                            if (ClientAPI.IsMACConflict(deviceInfo.Mac))
                            {
                                values = new object[]
                                {
                                    this.imgConflict,
                                    text,
                                    deviceInfo.Mac,
                                    iPAddress,
                                    deviceInfo.Port,
                                    deviceInfo.ModelNm,
                                    text2,
                                    num.ToString()
                                };
                            }
                            else
                            {
                                values = new object[]
                                {
                                    this.imgoff,
                                    text,
                                    deviceInfo.Mac,
                                    iPAddress,
                                    deviceInfo.Port,
                                    deviceInfo.ModelNm,
                                    text2,
                                    num.ToString()
                                };
                            }
                        }
                        this.dgvAllDevices.Rows.Add(values);
                    }
                }
            }
            foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dgvAllDevices.Rows)
            {
                DataGridViewCell dataGridViewCell = dataGridViewRow.Cells[0];
                if (dataGridViewCell.Value.Equals(this.imgConflict))
                {
                    dataGridViewCell.ToolTipText = EcoLanguage.getMsg(LangRes.tips_MACMismatch, new string[0]);
                }
            }
            if (sortedColumn != null)
            {
                ListSortDirection direction = (this.dgvAllDevices.SortOrder == SortOrder.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending;
                this.dgvAllDevices.Sort(sortedColumn, direction);
            }
            if (this.dgvAllDevices.Rows.Count == 0)
            {
                this.butDevicesDel.Enabled    = false;
                this.butDeviceSetup.Enabled   = false;
                this.butSyncThreshold.Enabled = false;
            }
            else
            {
                this.butDevicesDel.Enabled    = true;
                this.butDeviceSetup.Enabled   = true;
                this.butSyncThreshold.Enabled = true;
            }
            this.m_ininit = false;
        }
예제 #5
0
        private object initFWDevProc(object aaa)
        {
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            DevAccessCfg.GetInstance();
            foreach (DeviceInfo current in allDevice)
            {
                if (ClientAPI.IsDeviceOnline(current.DeviceID))
                {
                    string         text              = current.DeviceID.ToString();
                    string         modelNm           = current.ModelNm;
                    DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(modelNm, current.FWVersion);
                    if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDU_M2 && deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && deviceModelConfig.commonThresholdFlag != Constant.APC_PDU)
                    {
                        DevSnmpConfig  sNMPpara       = commUtil.getSNMPpara(current);
                        string         mac            = current.Mac;
                        DevAccessAPI   devAccessAPI   = new DevAccessAPI(sNMPpara);
                        DevServiceInfo devServiceInfo = devAccessAPI.GetDevServiceInfo(mac);
                        int            httpPort       = devServiceInfo.httpPort;
                        if (httpPort != 0)
                        {
                            string[] obj = new string[]
                            {
                                "1",
                                current.DeviceName,
                                current.DeviceIP,
                                current.ModelNm,
                                devServiceInfo.fwVersion,
                                "",
                                text,
                                httpPort.ToString()
                            };
                            ControlAccess.ConfigControl config = delegate(Control control, object param)
                            {
                                DataGridView dataGridView = control as DataGridView;
                                string[]     array        = param as string[];
                                dataGridView.Rows.Add(new object[]
                                {
                                    true,
                                    array[1],
                                    array[2],
                                    array[3],
                                    array[4],
                                    array[5],
                                    array[6],
                                    array[7]
                                });
                                this.m_allRows.Add(array);
                            };
                            ControlAccess controlAccess = new ControlAccess(this, config);
                            controlAccess.Access(this.dgvFwDevice, obj);
                        }
                    }
                }
            }
            ControlAccess.ConfigControl config2 = delegate(Control control, object param)
            {
                this.cbMainFw.Enabled  = true;
                this.butBrowse.Enabled = true;
                this.butUpdate.Enabled = true;
                this.cbsel.Enabled     = true;
            };
            ControlAccess controlAccess2 = new ControlAccess(this, config2);

            controlAccess2.Access(this.dgvFwDevice, null);
            return(0);
        }
예제 #6
0
        private void FillList()
        {
            this.dgvGpmember.DataSource = null;
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("objID", typeof(string));
            switch (this.cboType.SelectedIndex)
            {
            case 0:
            {
                dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string));
                System.Collections.ArrayList   allZone    = ZoneInfo.getAllZone();
                System.Collections.IEnumerator enumerator = allZone.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        ZoneInfo zoneInfo = (ZoneInfo)enumerator.Current;
                        string   text     = zoneInfo.ZoneID.ToString();
                        string[] values   = new string[]
                        {
                            text,
                            zoneInfo.ZoneName
                        };
                        dataTable.Rows.Add(values);
                    }
                    goto IL_46A;
                }
                finally
                {
                    System.IDisposable disposable = enumerator as System.IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                break;
            }

            case 1:
                break;

            case 2:
                goto IL_285;

            case 3:
                goto IL_36E;

            default:
                goto IL_46A;
            }
            dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string));
            dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string));
            System.Collections.ArrayList   allZone2        = ZoneInfo.getAllZone();
            System.Collections.ArrayList   allRack_NoEmpty = RackInfo.GetAllRack_NoEmpty();
            System.Collections.IEnumerator enumerator2     = allRack_NoEmpty.GetEnumerator();
            try
            {
                while (enumerator2.MoveNext())
                {
                    RackInfo rackInfo        = (RackInfo)enumerator2.Current;
                    string   displayRackName = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
                    string   text2           = rackInfo.RackID.ToString();
                    bool     flag            = false;
                    string   text3           = "";
                    foreach (ZoneInfo zoneInfo2 in allZone2)
                    {
                        text3 = zoneInfo2.ZoneName;
                        string[] source = zoneInfo2.RackInfo.Split(new char[]
                        {
                            ','
                        });
                        if (source.Contains(text2))
                        {
                            flag = true;
                            break;
                        }
                    }
                    string[] values;
                    if (flag)
                    {
                        values = new string[]
                        {
                            text2,
                            displayRackName,
                            text3
                        };
                    }
                    else
                    {
                        values = new string[]
                        {
                            text2,
                            displayRackName,
                            ""
                        };
                    }
                    dataTable.Rows.Add(values);
                }
                goto IL_46A;
            }
            finally
            {
                System.IDisposable disposable3 = enumerator2 as System.IDisposable;
                if (disposable3 != null)
                {
                    disposable3.Dispose();
                }
            }
IL_285:
            dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string));
            dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string));
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            using (System.Collections.Generic.List <DeviceInfo> .Enumerator enumerator4 = allDevice.GetEnumerator())
            {
                while (enumerator4.MoveNext())
                {
                    DeviceInfo current          = enumerator4.Current;
                    string     deviceName       = current.DeviceName;
                    string     text4            = current.DeviceID.ToString();
                    RackInfo   rackByID         = RackInfo.getRackByID(current.RackID);
                    string     displayRackName2 = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
                    string[]   values           = new string[]
                    {
                        text4,
                        deviceName,
                        displayRackName2
                    };
                    dataTable.Rows.Add(values);
                }
                goto IL_46A;
            }
IL_36E:
            dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMOutlet, new string[0]), typeof(string));
            dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string));
            allDevice = DeviceOperation.GetAllDevice();
            foreach (DeviceInfo current2 in allDevice)
            {
                System.Collections.Generic.List <PortInfo> portInfo = current2.GetPortInfo();
                foreach (PortInfo current3 in portInfo)
                {
                    string[] values = new string[]
                    {
                        current3.ID.ToString(),
                                  current3.PortName,
                                  current2.DeviceName
                    };
                    dataTable.Rows.Add(values);
                }
            }
IL_46A:
            this.dgvGpmember.DataSource = dataTable;
            this.dgvGpmember.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.dgvGpmember.Columns[0].Visible = false;
            int selectedIndex = this.cboType.SelectedIndex;

            if (selectedIndex == 0)
            {
                this.dgvGpmember.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                return;
            }
            this.dgvGpmember.Columns[1].Width        = 140;
            this.dgvGpmember.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
        }
예제 #7
0
        private void pageInit()
        {
            this.dgvAllDevices.Rows.Clear();
            System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
            int     num     = -1;
            DataSet dataSet = ClientAPI.getDataSet(0);
            int     num2    = 0;
            int     num3    = 0;
            int     num4    = 0;

            for (int i = 0; i < allDevice.Count; i++)
            {
                DeviceInfo deviceInfo = allDevice[i];
                string     deviceName = deviceInfo.DeviceName;
                if (!deviceInfo.ModelNm.Equals("EC1000") && !deviceInfo.ModelNm.Equals("EC2004"))
                {
                    num4++;
                    DataRow[] array;
                    if (dataSet == null)
                    {
                        array = null;
                    }
                    else
                    {
                        array = dataSet.Tables[0].Select("device_id = " + System.Convert.ToString(deviceInfo.DeviceID));
                    }
                    string text = "";
                    if (ClientAPI.IsDeviceOnline(deviceInfo.DeviceID))
                    {
                        num3++;
                        try
                        {
                            text = System.Convert.ToSingle(array[0]["voltage_value"]).ToString("F2");
                            goto IL_FE;
                        }
                        catch
                        {
                            goto IL_FE;
                        }
                    }
                    if (this.rbonlinedev.Checked)
                    {
                        goto IL_19E;
                    }
IL_FE:
                    RackInfo rackByID = RackInfo.getRackByID(deviceInfo.RackID);
                    string[] values = new string[]
                    {
                        deviceName,
                        deviceInfo.Mac,
                        deviceInfo.DeviceIP,
                        deviceInfo.Port.ToString(),
                        deviceInfo.ModelNm,
                        text,
                        rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag),
                        deviceInfo.DeviceID.ToString()
                    };
                    this.dgvAllDevices.Rows.Add(values);
                    if (deviceInfo.DeviceID == this.m_devID)
                    {
                        num = num2;
                    }
                    num2++;
                }
                IL_19E :;
            }
            this.rbonlinedev.Text = this.stronlineDevText + " (" + num3.ToString() + ")";
            this.rballev.Text     = this.strallDevText + " (" + num4.ToString() + ")";
            if (num >= 0)
            {
                this.dgvAllDevices.CurrentCell = this.dgvAllDevices.Rows[num].Cells[0];
            }
        }
예제 #8
0
        private void init_Avail_data()
        {
            System.Collections.Generic.Dictionary <long, string> dictionary = new System.Collections.Generic.Dictionary <long, string>();
            if (this.m_groupID >= 0L)
            {
                GroupInfo groupByID  = GroupInfo.GetGroupByID(this.m_groupID);
                string    memberList = groupByID.GetMemberList();
                if (memberList != null && memberList.Length > 0)
                {
                    string[] array = memberList.Split(new string[]
                    {
                        ","
                    }, System.StringSplitOptions.RemoveEmptyEntries);
                    string[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string value = array2[i];
                        long   key   = (long)System.Convert.ToInt32(value);
                        dictionary.Add(key, "");
                    }
                }
            }
            this.dgvAvail.DataSource = null;
            this.Avail_tb            = new DataTable();
            this.Avail_tb.Columns.Add("objID", typeof(string));
            this.Avail_tb.PrimaryKey = new DataColumn[]
            {
                this.Avail_tb.Columns[0]
            };
            string groupType;

            if ((groupType = this.m_groupType) != null)
            {
                if (cct == null)
                {
                    cct = new System.Collections.Generic.Dictionary <string, int>(7)
                    {
                        {
                            "zone",
                            0
                        },

                        {
                            "rack",
                            1
                        },

                        {
                            "allrack",
                            2
                        },

                        {
                            "dev",
                            3
                        },

                        {
                            "alldev",
                            4
                        },

                        {
                            "outlet",
                            5
                        },

                        {
                            "alloutlet",
                            6
                        }
                    };
                }
                int num;
                if (cct.TryGetValue(groupType, out num))
                {
                    switch (num)
                    {
                    case 0:
                    {
                        this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string));
                        System.Collections.ArrayList   allZone    = ZoneInfo.getAllZone();
                        System.Collections.IEnumerator enumerator = allZone.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                ZoneInfo zoneInfo = (ZoneInfo)enumerator.Current;
                                string   text     = zoneInfo.ZoneID.ToString();
                                if (!dictionary.ContainsKey(zoneInfo.ZoneID))
                                {
                                    string[] values = new string[]
                                    {
                                        text,
                                        zoneInfo.ZoneName
                                    };
                                    this.Avail_tb.Rows.Add(values);
                                }
                            }
                            return;
                        }
                        finally
                        {
                            System.IDisposable disposable = enumerator as System.IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        break;
                    }

                    case 1:
                    case 2:
                        break;

                    case 3:
                    case 4:
                        goto IL_401;

                    case 5:
                    case 6:
                        goto IL_50F;

                    default:
                        return;
                    }
                    this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string));
                    this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string));
                    System.Collections.ArrayList   allZone2        = ZoneInfo.getAllZone();
                    System.Collections.ArrayList   allRack_NoEmpty = RackInfo.GetAllRack_NoEmpty();
                    System.Collections.IEnumerator enumerator2     = allRack_NoEmpty.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            RackInfo rackInfo = (RackInfo)enumerator2.Current;
                            if (!dictionary.ContainsKey(rackInfo.RackID))
                            {
                                string displayRackName = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
                                string text2           = rackInfo.RackID.ToString();
                                bool   flag            = false;
                                string text3           = "";
                                foreach (ZoneInfo zoneInfo2 in allZone2)
                                {
                                    text3 = zoneInfo2.ZoneName;
                                    string[] source = zoneInfo2.RackInfo.Split(new char[]
                                    {
                                        ','
                                    });
                                    if (source.Contains(text2))
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                                string[] values;
                                if (flag)
                                {
                                    values = new string[]
                                    {
                                        text2,
                                        displayRackName,
                                        text3
                                    };
                                }
                                else
                                {
                                    values = new string[]
                                    {
                                        text2,
                                        displayRackName,
                                        ""
                                    };
                                }
                                this.Avail_tb.Rows.Add(values);
                            }
                        }
                        return;
                    }
                    finally
                    {
                        System.IDisposable disposable3 = enumerator2 as System.IDisposable;
                        if (disposable3 != null)
                        {
                            disposable3.Dispose();
                        }
                    }
IL_401:
                    this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string));
                    this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string));
                    System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice();
                    using (System.Collections.Generic.List <DeviceInfo> .Enumerator enumerator4 = allDevice.GetEnumerator())
                    {
                        while (enumerator4.MoveNext())
                        {
                            DeviceInfo current = enumerator4.Current;
                            if (!dictionary.ContainsKey((long)current.DeviceID))
                            {
                                string   deviceName       = current.DeviceName;
                                string   text4            = current.DeviceID.ToString();
                                RackInfo rackByID         = RackInfo.getRackByID(current.RackID);
                                string   displayRackName2 = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag);
                                string[] values           = new string[]
                                {
                                    text4,
                                    deviceName,
                                    displayRackName2
                                };
                                this.Avail_tb.Rows.Add(values);
                            }
                        }
                        return;
                    }
IL_50F:
                    this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMOutlet, new string[0]), typeof(string));
                    this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string));
                    allDevice = DeviceOperation.GetAllDevice();
                    foreach (DeviceInfo current2 in allDevice)
                    {
                        System.Collections.Generic.List <PortInfo> portInfo = current2.GetPortInfo();
                        foreach (PortInfo current3 in portInfo)
                        {
                            if (!dictionary.ContainsKey((long)current3.ID))
                            {
                                string[] values = new string[]
                                {
                                    current3.ID.ToString(),
                                          current3.PortName,
                                          current2.DeviceName
                                };
                                this.Avail_tb.Rows.Add(values);
                            }
                        }
                    }
                }
            }
        }
예제 #9
0
        private void butSysparaSave_Click(object sender, System.EventArgs e)
        {
            if (!this.sysparaCheck())
            {
                return;
            }
            int num = System.Convert.ToInt32(this.tbSysTrapPort.Text);

            if (num != this.m_pSyspara.TrapPort)
            {
                bool flag = NetworkShareAccesser.UDPPortInUse(num);
                if (flag)
                {
                    this.tbSysTrapPort.Focus();
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[]
                    {
                        this.tbSysTrapPort.Text
                    }));
                    return;
                }
            }
            this.m_pSyspara.username = this.tbSysUserNm.Text;
            this.m_pSyspara.timeout  = System.Convert.ToInt32(this.tbSysTimeOut.Text);
            this.m_pSyspara.port     = System.Convert.ToInt32(this.tbSysPort.Text);
            this.m_pSyspara.retry    = System.Convert.ToInt32(this.tbSysRetry.Text);
            int num2 = System.Convert.ToInt32(((Combobox_item)this.cbSnmpV.SelectedItem).getKey());

            this.m_pSyspara.SnmpVersion = num2;
            this.m_pSyspara.authen      = "None";
            this.m_pSyspara.authenpwd   = string.Empty;
            this.m_pSyspara.privacy     = "None";
            this.m_pSyspara.privacypwd  = string.Empty;
            if (num2 == 3)
            {
                this.m_pSyspara.authen = this.cbSysAuthen.SelectedItem.ToString();
                if (!this.m_pSyspara.authen.Equals("None"))
                {
                    this.m_pSyspara.authenpwd  = this.tbSysAuthenPw.Text;
                    this.m_pSyspara.privacy    = this.cbSysPrivacy.SelectedItem.ToString();
                    this.m_pSyspara.privacypwd = this.tbSysPrivacyPw.Text;
                }
            }
            Sys_Para sys_Para = new Sys_Para();
            bool     flag2    = false;

            sys_Para.TrapUserName = this.tbSysTrapUserNm.Text;
            sys_Para.TrapPort     = System.Convert.ToInt32(this.tbSysTrapPort.Text);
            num2 = System.Convert.ToInt32(((Combobox_item)this.cbTrapSnmpV.SelectedItem).getKey());
            sys_Para.TrapSnmpVersion = num2;
            sys_Para.TrapAuthen      = "None";
            sys_Para.TrapAuthenPwd   = string.Empty;
            sys_Para.TrapPrivacy     = "None";
            sys_Para.TrapPrivacyPwd  = string.Empty;
            if (num2 == 2)
            {
                sys_Para.TrapAuthen = this.cbSysTrapAuthen.SelectedItem.ToString();
                if (!sys_Para.TrapAuthen.Equals("None"))
                {
                    sys_Para.TrapAuthenPwd  = this.tbSysTrapAuthenPw.Text;
                    sys_Para.TrapPrivacy    = this.cbSysTrapPrivacy.SelectedItem.ToString();
                    sys_Para.TrapPrivacyPwd = this.tbSysTrapPrivacyPw.Text;
                }
            }
            if (!this.m_pSyspara.TrapUserName.Equals(sys_Para.TrapUserName) || this.m_pSyspara.TrapPort != sys_Para.TrapPort || this.m_pSyspara.TrapSnmpVersion != sys_Para.TrapSnmpVersion || !this.m_pSyspara.TrapAuthen.Equals(sys_Para.TrapAuthen) || !this.m_pSyspara.TrapAuthenPwd.Equals(sys_Para.TrapAuthenPwd) || !this.m_pSyspara.TrapPrivacy.Equals(sys_Para.TrapPrivacy) || !this.m_pSyspara.TrapPrivacyPwd.Equals(sys_Para.TrapPrivacyPwd))
            {
                this.m_pSyspara.TrapUserName    = sys_Para.TrapUserName;
                this.m_pSyspara.TrapPort        = sys_Para.TrapPort;
                this.m_pSyspara.TrapSnmpVersion = sys_Para.TrapSnmpVersion;
                this.m_pSyspara.TrapAuthen      = sys_Para.TrapAuthen;
                this.m_pSyspara.TrapAuthenPwd   = sys_Para.TrapAuthenPwd;
                this.m_pSyspara.TrapPrivacy     = sys_Para.TrapPrivacy;
                this.m_pSyspara.TrapPrivacyPwd  = sys_Para.TrapPrivacyPwd;
                flag2 = true;
            }
            this.m_pSyspara.update();
            string valuePair = ValuePairs.getValuePair("Username");

            if (!string.IsNullOrEmpty(valuePair))
            {
                LogAPI.writeEventLog("0130022", new string[]
                {
                    valuePair
                });
            }
            else
            {
                LogAPI.writeEventLog("0130022", new string[0]);
            }
            if (flag2)
            {
                System.Collections.Generic.List <DeviceInfo>    allDevice = DeviceOperation.GetAllDevice();
                System.Collections.Generic.List <DevSnmpConfig> list      = new System.Collections.Generic.List <DevSnmpConfig>();
                foreach (DeviceInfo current in allDevice)
                {
                    if (ClientAPI.IsDeviceOnline(current.DeviceID))
                    {
                        DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current);
                        list.Add(sNMPpara);
                    }
                }
                try
                {
                    DevMonitorAPI devMonitorAPI = new DevMonitorAPI();
                    devMonitorAPI.SetTrapReceiver(list, this.m_pSyspara);
                }
                catch (System.Exception)
                {
                }
            }
            EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0]));
        }