void BindSlabSource() { DataTable dt = CreateDataTable(); ArrayList items = null; try { items = MemCacheOperate.GetAllItems(serverList); if (items == null) { MessageBox.Show("服务器连接异常,正在尝试重新连接!"); return; } } catch (Exception ex) { MessageBox.Show("服务器连接异常!" + ex.Message.ToString()); return; } DataRow dr = null; items.Sort(); foreach (var s in items) { dr = dt.NewRow(); dr["key"] = "Slab:" + s; dr["value"] = s; dt.Rows.Add(dr); } this.cbSlabs.DisplayMember = "key"; this.cbSlabs.ValueMember = "value"; this.cbSlabs.DataSource = dt; }
private void btnSearchByKey_Click(object sender, EventArgs e) { DataTable dt = (DataTable)dgvkeysSource.DataSource; if (dt != null) { dt.Rows.Clear(); dgvkeysSource.DataSource = dt; } dt = CreateDataTable(); string searchKey = this.txtKeys.Text; List <string> keys = new List <string>(); if (!string.IsNullOrEmpty(searchKey)) { string[] allKeys = searchKey.Split(','); keys = new List <string>(allKeys); } Dictionary <string, object> dicSource = MemCacheOperate.Get(keys, serverList); DataRow dr; foreach (var s in dicSource) { dr = dt.NewRow(); dr["key"] = s.Key; dr["value"] = s.Value; dt.Rows.Add(dr); } this.dgvkeysSource.DataSource = dt; }
private void cbSlabs_SelectedIndexChanged(object sender, EventArgs e) { int item = Convert.ToInt32(this.cbSlabs.SelectedValue); int totalcount = MemCacheOperate.GetTotalCountBySlab(serverList, item); this.lblSlabCount.Text = "共" + totalcount + "条"; }
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); }
private void btnSearchItems_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtNum.Text)) { MessageBox.Show("请输入要查询的行数!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string server = this.cbMemServer.SelectedValue.ToString(); var num = Convert.ToInt32(this.txtNum.Text); int item = Convert.ToInt32(this.cbSlabs.SelectedValue); List <string> keys = MemCacheOperate.GetOneItemKey(serverList, item, num); Dictionary <string, object> dicSource = MemCacheOperate.Get(keys, serverList); DataTable dt = CreateDataTable(); DataRow dr; foreach (var s in dicSource) { dr = dt.NewRow(); dr["key"] = s.Key; dr["value"] = s.Value; dt.Rows.Add(dr); } this.dgvSource.DataSource = dt; }
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; }