Exemplo n.º 1
0
        DataTable GetServerDetials()
        {
            dicDetials = new Dictionary <string, string>();
            if (serverList == null || serverList.Count == 0)
            {
                return(null);
            }
            ArrayList list = MemCacheOperate.GetMemServerDetials(serverList);

            if (list == null)
            {
                MessageBox.Show("连接到服务器失败!请稍候重试!正在切换服务器~!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                BindMemServer();
                if (t != null)
                {
                    t.Stop();
                }
                return(null);
            }
            DataTable  dt  = new DataTable();
            DataColumn dtc = new DataColumn("value", typeof(string));

            dt.Columns.Add(dtc);
            dtc = new DataColumn("zh-cn", typeof(string));
            dt.Columns.Add(dtc);
            dtc = new DataColumn("en-us", typeof(string));
            dt.Columns.Add(dtc);
            string[] tempStr = new string[2];
            DataRow  dr;

            foreach (var s in list)
            {
                tempStr = s.ToString().Split(':');
                foreach (var t in listDetials)
                {
                    if (t.en == tempStr[0])
                    {
                        dicDetials.Add(tempStr[0], tempStr[1]);
                        dr = dt.NewRow();
                        if (t.en == "limit_maxbytes" || t.en == "bytes" || t.en == "bytes_written" || t.en == "bytes_read")
                        {
                            dr["value"] = Help.GetFileSize(long.Parse(tempStr[1]));
                        }
                        else
                        {
                            dr["value"] = tempStr[1];
                        }
                        dr["zh-cn"] = t.cn;
                        dr["en-us"] = tempStr[0];
                        dt.Rows.Add(dr);
                    }
                }
            }
            return(dt);
        }
Exemplo n.º 2
0
        void BindAllMemServerDetials()
        {
            ArrayList delialsList;
            ArrayList serverList = new ArrayList();

            string[]  cols = { "serverid", "pid", "uptime", "version", "curr_connections", "cmd_get", "cmd_set", "cmd_flush", "delete_hits", "bytes_read", "bytes_written", "limit_maxbytes", "threads", "bytes" };
            DataTable dt   = CreateTalbe(cols);
            DataRow   dr;

            foreach (var server in list)
            {
                serverList = new ArrayList();
                serverList.Add(server.ServerID);
                delialsList = MemCacheOperate.GetMemServerDetials(serverList);
                if (delialsList == null)
                {
                    MessageBox.Show(serverList[0] + "连接到服务器失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    continue;
                }
                string[] tempStr = new string[2];
                dr = dt.NewRow();
                foreach (var t in delialsList)
                {
                    tempStr        = t.ToString().Split(':');
                    dr["serverid"] = server.ServerID;
                    if (tempStr[0] == "pid")
                    {
                        dr["pid"] = tempStr[1];
                    }
                    if (tempStr[0] == "uptime")
                    {
                        dr["uptime"] = tempStr[1];
                    }
                    if (tempStr[0] == "version")
                    {
                        dr["version"] = tempStr[1];
                    }
                    if (tempStr[0] == "curr_connections")
                    {
                        dr["curr_connections"] = tempStr[1];
                    }
                    if (tempStr[0] == "cmd_get")
                    {
                        dr["cmd_get"] = tempStr[1];
                    }
                    if (tempStr[0] == "cmd_set")
                    {
                        dr["cmd_set"] = tempStr[1];
                    }
                    if (tempStr[0] == "cmd_flush")
                    {
                        dr["cmd_flush"] = tempStr[1];
                    }
                    if (tempStr[0] == "delete_hits")
                    {
                        dr["delete_hits"] = tempStr[1];
                    }
                    if (tempStr[0] == "bytes_read")
                    {
                        dr["bytes_read"] = Help.GetFileSize(long.Parse(tempStr[1]));
                    }
                    if (tempStr[0] == "bytes_written")
                    {
                        dr["bytes_written"] = Help.GetFileSize(long.Parse(tempStr[1]));
                    }
                    if (tempStr[0] == "limit_maxbytes")
                    {
                        dr["limit_maxbytes"] = Help.GetFileSize(long.Parse(tempStr[1]));
                    }
                    if (tempStr[0] == "threads")
                    {
                        dr["threads"] = tempStr[1];
                    }
                    if (tempStr[0] == "bytes")
                    {
                        dr["bytes"] = Help.GetFileSize(long.Parse(tempStr[1]));
                    }
                }
                dt.Rows.Add(dr);
            }
            this.dgvAllServerDetials.DataSource = dt;
        }