示例#1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <string> keys = GetSelectKeys();

            if (keys.Count == 0)
            {
                Response.Write("<script>alert('至少选中一项进行删除')</script>");
                return;
            }
            else
            {
                MSMQConfig            config      = this.TempConfig;
                List <MSMQConfigNode> removeNodes = new List <MSMQConfigNode>();
                foreach (string key in keys)
                {
                    foreach (MSMQConfigNode node in config.Nodes)
                    {
                        if (key == node.ToString())
                        {
                            removeNodes.Add(node);
                        }
                    }
                }
                if (removeNodes.Count > 0)
                {
                    removeNodes.ForEach(p => {
                        config.Nodes.Remove(p);
                    });

                    //更新session
                    TempConfig = config;
                    //保存config
                    XmlHelper.Enity2Xml(ConfigPath, config);
                    //刷新表格
                    BindGridView(config);
                    //clear
                    Clear();

                    //更新服务配置文件时间
                    MonitorExe.UpdateLastConfigTime();
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            gv.DataSource = MainExe.GetServiceState();
            gv.DataBind();

            //string mq = MainExe.GetMsg("msmq");
            //if (string.IsNullOrEmpty(mq) == false)
            //{
            //    string[] rows = mq.Split(new char[] { '|' });
            //    List<MqCount> mcs = new List<MqCount>();
            //    foreach (string row in rows)
            //    {

            //        if (string.IsNullOrEmpty(row) == false)
            //        {
            //            string[] fileds = row.Split(new char[] { '@' });
            //            if (fileds.Length > 2)
            //            {
            //                mcs.Add(new MqCount()
            //                {
            //                    Name = fileds[0],
            //                    Count = fileds[1],
            //                    Remark = fileds[2]
            //                });
            //            }
            //        }

            //        if (mcs.Count > 0)
            //        {
            //            //gvMq.DataSource = mcs;
            //            //gvMq.DataBind();

            //        }
            //    }
            //}


            gvMqRate.DataSource = MonitorExe.GetMsg();
            gvMqRate.DataBind();
        }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            string strOp  = context.Request.QueryString["op"];
            string strKey = context.Request.QueryString["key"];
            string strVal = context.Request.QueryString["val"];
            string strEn  = context.Request.QueryString["en"];

            if (string.IsNullOrEmpty(context.Request.Form["op"]) == false)
            {
                strOp = context.Request.Form["op"];
            }
            if (string.IsNullOrEmpty(context.Request.Form["key"]) == false)
            {
                strKey = context.Request.Form["key"];
            }
            if (string.IsNullOrEmpty(context.Request.Form["val"]) == false)
            {
                strVal = context.Request.Form["val"];
            }
            if (string.IsNullOrEmpty(context.Request.Form["en"]) == false)
            {
                strEn = context.Request.Form["en"];
            }

            if (string.IsNullOrEmpty(strEn) && CommonConfig.IsEncrypt)
            {
                Return(context, "数据必须进行加密");
                return;
            }
            else if (string.IsNullOrEmpty(strEn))
            {
                //直接继续
            }
            else
            {
                try
                {
                    //存在加密信息时,进行解密处理
                    string strRaw = EncryptAESHelper.Decrypt(strEn, CommonConfig.EncryptKey);
                    if (strRaw != (strOp + DateTime.Now.ToString("dd")))
                    {
                        Return(context, "密钥无法验证通过");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Return(context, "解密出错:" + ex.ToString());
                    return;
                }
            }


            if (string.IsNullOrEmpty(strOp))
            {
                Return(context, "Hello, here is main");
            }
            else
            {
                if (string.IsNullOrEmpty(strOp) == false)
                {
                    strOp = HttpUtility.UrlDecode(strOp);
                }
                if (string.IsNullOrEmpty(strKey) == false)
                {
                    strKey = HttpUtility.UrlDecode(strKey);
                }
                if (string.IsNullOrEmpty(strVal) == false)
                {
                    strVal = HttpUtility.UrlDecode(strVal);
                }
                switch (strOp)
                {
                case "isAlive":
                    Return(context, "1");
                    break;

                case "getBeatTime":
                    Return(context, MainExe.GetBeatTime(strKey));
                    break;

                case "beat":
                    Return(context, MainExe.Beat(strKey, strVal) ? "1" : "0");
                    break;

                case "isKeyAlived":
                    Return(context, MainExe.IsAlved(strKey) ? "1" : "0");
                    break;

                case "sendMsg":
                    MainExe.SendMsg(strKey, strVal);
                    Return(context, "1");
                    break;

                case "getMSMQConfig":
                    Return(context, MonitorExe.getMSMQConfig());
                    break;

                case "getLastConfigTime":
                    Return(context, MonitorExe.getLastConfigTime());
                    break;

                case "sendMonitorMsg":
                    MonitorExe.addMsg(strVal);
                    Return(context, "1");
                    break;
                }
            }
        }
示例#4
0
 protected void btnRefresh_Click(object sender, EventArgs e)
 {
     MonitorExe.CleanLoaclMsg();
     gvMqRate.DataSource = MonitorExe.GetMsg();
     gvMqRate.DataBind();
 }
示例#5
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //非空判断
            string ip       = txtIP.Text.Trim();
            string domain   = txtDomain.Text.Trim();
            string account  = txtAccount.Text.Trim();
            string pwd      = txtPwd.Text.Trim();
            string category = ddlCategory.SelectedValue;
            string counter  = ddlCounter.SelectedValue;
            string instance = txtInstance.Text.Trim();

            if (string.IsNullOrEmpty(ip))
            {
                Response.Write("<script>alert('IP必须填写')</script>");
                return;
            }
            if (string.IsNullOrEmpty(domain))
            {
                Response.Write("<script>alert('所属域必须填写')</script>");
                return;
            }
            if (string.IsNullOrEmpty(account))
            {
                Response.Write("<script>alert('账号必须填写')</script>");
                return;
            }
            if (string.IsNullOrEmpty(pwd))
            {
                Response.Write("<script>alert('密码必须填写')</script>");
                return;
            }
            if (string.IsNullOrEmpty(category))
            {
                Response.Write("<script>alert('监控类型必须选择')</script>");
                return;
            }
            if (string.IsNullOrEmpty(counter))
            {
                Response.Write("<script>alert('计数器必须选择')</script>");
                return;
            }
            if (category == "MSMQ Queue" && string.IsNullOrEmpty(instance))
            {
                Response.Write("<script>alert('实例必须填写')</script>");
                return;
            }

            MSMQConfig config = TempConfig;

            List <string> keys = GetSelectKeys();

            if (keys.Count == 0)
            {
                //新增

                string key = ip + category + counter + (instance ?? "");
                if (config.Nodes.Any(p => p.ToString() == key))
                {
                    //已经有这个配置
                    Response.Write("<script>alert('不能重复进行配置')</script>");
                    return;
                }
                else
                {
                    config.Nodes.Add(new MSMQConfigNode()
                    {
                        Domain       = ip,
                        CategoryName = category,
                        CounterName  = counter,
                        Instance     = instance
                    });
                }
            }
            else if (keys.Count == 1)
            {
                //修改情况
                MSMQConfigNode node = config.Nodes.Find(p => { return(p.ToString() == keys[0]); });
                if (node != null)
                {
                    node.Domain       = ip;
                    node.CategoryName = category;
                    node.CounterName  = counter;
                    node.Instance     = instance;
                }
            }
            else
            {
                //多个时不处理
                Response.Write("<script>alert('不能同时修改多个值')</script>");
                return;
            }
            //更新domain
            var    listDomains = config.Domains.Where(p => { return(p.Name == ip); }).ToList <ConfigDomain>();
            string domainValue = EncryptHelper.EncryptDES(ip + "|" + domain + "|" + account + "|" + pwd);

            if (listDomains.Count == 0)
            {
                //新增情况
                config.Domains.Add(new ConfigDomain()
                {
                    Name  = ip,
                    Value = domainValue
                });
            }
            else
            {
                //修改
                listDomains[0].Value = domainValue;
            }
            //更新session
            TempConfig = config;
            //保存config
            XmlHelper.Enity2Xml(ConfigPath, config);
            //刷新表格
            BindGridView(config);
            //clear
            Clear();

            //更新服务配置文件时间
            MonitorExe.UpdateLastConfigTime();
        }