Exemplo n.º 1
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);
        }
Exemplo n.º 2
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]));
        }