private void MainWindow_Load(object sender, EventArgs e) { //首页获取搜索栏 Dictionary <string, string> pm = new Dictionary <string, string>(); pm.Add("email", loginUserEmail); pm.Add("timestamp", SecurityUtil.GetTimestamp()); string sign = SecurityUtil.CreateSign(pm); pm.Add("sign", sign); string result = HttpUtil.SendGet(ConstantUrl.agentConditionUrl, pm); if (!string.IsNullOrEmpty(result)) { IDictionary <string, List <string> > data = JsonConvert.DeserializeObject <IDictionary <string, List <string> > >(result); List <string> mainNameList = new List <string>(); mainNameList.Add("一级分类"); mainNameList.AddRange(data["mainNameList"]); this.mainNameBox.DataSource = mainNameList; this.mainNameBox.SelectedIndex = 0; List <string> subNameList = new List <string>(); subNameList.Add("二级分类"); subNameList.AddRange(data["subNameList"]); this.subNameBox.DataSource = subNameList; this.subNameBox.SelectedIndex = 0; List <string> managerList = new List <string>(); managerList.Add("管理员"); managerList.AddRange(data["managerList"]); this.managerBox.DataSource = managerList; this.managerBox.SelectedIndex = 0; this.searchTypeBox.SelectedIndex = 0; } else { MessageBox.Show("查询异常,请联系管理员!", "提示"); return; } Dictionary <string, string> pm2 = new Dictionary <string, string>(); pm2.Add("email", loginUserEmail); pm2.Add("timestamp", SecurityUtil.GetTimestamp()); string sign2 = SecurityUtil.CreateSign(pm2); pm2.Add("sign", sign2); string result2 = HttpUtil.SendGet(ConstantUrl.agentListUrl, pm2); if (!string.IsNullOrEmpty(result2)) { List <AgentInfo> data2 = JsonConvert.DeserializeObject <List <AgentInfo> >(result2); DataTable dt = DataTableExtensions.ToDataTable(data2); this.agentDataGrid.DataSource = dt; } else { MessageBox.Show("查询异常,请联系管理员!", "提示"); } }
private void MainWindow_Load(object sender, EventArgs e) { //首页获取搜索栏 Dictionary <string, string> pm = new Dictionary <string, string>(); pm.Add("email", Login.EMAIL); pm.Add("timestamp", SecurityUtil.GetTimestamp()); string sign = SecurityUtil.CreateSign(pm, Login.PWDKEY); pm.Add("sign", sign); try { string result = HttpUtil.SendGet(ConstantUrl.agentConditionUrl, pm); if (!string.IsNullOrEmpty(result)) { IDictionary <string, List <string> > data = JsonConvert.DeserializeObject <IDictionary <string, List <string> > >(result); List <string> mainNameList = new List <string>(); mainNameList.Add("一级分类"); mainNameList.AddRange(data["mainNameList"]); this.mainNameBox.DataSource = mainNameList; this.mainNameBox.SelectedIndex = 0; List <string> subNameList = new List <string>(); subNameList.Add("二级分类"); subNameList.AddRange(data["subNameList"]); this.subNameBox.DataSource = subNameList; this.subNameBox.SelectedIndex = 0; List <string> managerList = new List <string>(); managerList.Add("负责人"); managerList.AddRange(data["managerList"]); this.managerBox.DataSource = managerList; this.managerBox.SelectedIndex = 0; this.searchTypeBox.SelectedIndex = 0; } else { MessageBox.Show("获取搜索表单异常,数据返回为空!", "提示"); return; } } catch (Exception ee) { MessageBox.Show("获取搜索表单异常(" + ee.Message + ")", "提示"); return; } Dictionary <string, string> pm2 = new Dictionary <string, string>(); pm2.Add("email", Login.EMAIL); pm2.Add("timestamp", SecurityUtil.GetTimestamp()); string sign2 = SecurityUtil.CreateSign(pm2, Login.PWDKEY); pm2.Add("sign", sign2); int cnt = 0; try { string result2 = HttpUtil.SendGet(ConstantUrl.agentListUrl, pm2); if (!string.IsNullOrEmpty(result2)) { List <AgentInfo> data2 = JsonConvert.DeserializeObject <List <AgentInfo> >(result2); //foreach data2 DataTable dt = DataTableExtensions.ToDataTable(data2); //dt.Columns.Add("rflag", typeof(String)); //dt.Columns.Add("Result", typeof(String)); this.agentDataGrid.DataSource = dt; cnt = data2.Count; } } catch (Exception ee) { MessageBox.Show("默认服务器列表获取异常!(" + ee.Message + ")", "提示"); } this.serverlist.Text = "服务器列表 总数:" + cnt.ToString() + ""; }
private void button2_Click(object sender, EventArgs e) { //搜索 Dictionary <string, string> pm = new Dictionary <string, string>(); pm.Add("timestamp", SecurityUtil.GetTimestamp()); pm.Add("email", loginUserEmail); string mainName = mainNameBox.Text; if (!"一级分类".Equals(mainName) && !"".Equals(mainName)) { pm.Add("mainName", mainName); } string subName = subNameBox.Text; if (!"二级分类".Equals(subName) && !"".Equals(subName)) { pm.Add("subName", subName); } string manager = managerBox.Text; if (!"管理员".Equals(manager) && !"".Equals(manager)) { pm.Add("manager", manager); } string searchType = searchTypeBox.Text; string searchContent = searchContentTxt.Text; if (!"".Equals(searchContent)) { if ("IP".Equals(searchType)) { pm.Add("agentIp", searchContent); } else if ("资产名称".Equals(searchType)) { pm.Add("agentName", searchContent); } else if ("资产号".Equals(searchType)) { pm.Add("asset", searchContent); } else { //不搜索 } } string sign = SecurityUtil.CreateSign(pm); pm.Add("sign", sign); string result = HttpUtil.SendPost(ConstantUrl.agentListUrl, pm); if (!string.IsNullOrEmpty(result)) { List <AgentInfo> data2 = JsonConvert.DeserializeObject <List <AgentInfo> >(result); DataTable dt = DataTableExtensions.ToDataTable(data2); this.agentDataGrid.DataSource = dt; } else { MessageBox.Show("查询异常,请联系管理员!", "提示"); this.agentDataGrid.DataSource = null; } }
private void searchbtn_Click(object sender, EventArgs e) { //搜索 Dictionary <string, string> pm = new Dictionary <string, string>(); pm.Add("timestamp", SecurityUtil.GetTimestamp()); pm.Add("email", Login.EMAIL); string mainName = mainNameBox.Text; if (!"一级分类".Equals(mainName) && !"".Equals(mainName)) { pm.Add("mainName", mainName); } string subName = subNameBox.Text; if (!"二级分类".Equals(subName) && !"".Equals(subName)) { pm.Add("subName", subName); } string manager = managerBox.Text; if (!"负责人".Equals(manager) && !"".Equals(manager)) { pm.Add("manager", manager); } string searchType = searchTypeBox.Text; string searchContent = searchContentTxt.Text; if (!"".Equals(searchContent)) { if ("IP".Equals(searchType)) { pm.Add("agentIp", searchContent); } else if ("应用".Equals(searchType)) { pm.Add("agentName", searchContent); } else if ("资产号".Equals(searchType)) { pm.Add("asset", searchContent); } else { MessageBox.Show("请选择搜索条件!", "提示"); } } string sign = SecurityUtil.CreateSign(pm, Login.PWDKEY); pm.Add("sign", sign); int cnt = 0; try { string result = HttpUtil.SendPost(ConstantUrl.agentListUrl, pm); if (!string.IsNullOrEmpty(result)) { List <AgentInfo> data2 = JsonConvert.DeserializeObject <List <AgentInfo> >(result); DataTable dt = DataTableExtensions.ToDataTable(data2); //dt.Columns.Add("rflag", typeof(String)); //dt.Columns.Add("Result", typeof(String)); this.agentDataGrid.DataSource = dt; cnt = data2.Count; } else { MessageBox.Show("查询异常,未返回查询结果!", "提示"); this.agentDataGrid.DataSource = null; } } catch (Exception ee) { MessageBox.Show("查询异常!(" + ee.Message + ")", "提示"); this.agentDataGrid.DataSource = null; } this.serverlist.Text = "服务器列表 总数:" + cnt.ToString() + ""; //succcnt = 0;failcnt = 0; execStatus.Text = "执行中:0,成功:0,失败:0"; }