private void FilterSearchComputers() { string key = ""; if (!this.buttonEdit1.Text.Equals(this.buttonEdit1.Properties.NullText)) { key = this.buttonEdit1.Text; } COMPUTERSTATUS status = COMPUTERSTATUS.无; if (this.comboBoxEdit1.SelectedIndex > 0) { Enum.TryParse <COMPUTERSTATUS>(this.comboBoxEdit1.Text, out status); } int areaId = -1; if (this.comboBoxEdit2.SelectedIndex > 0) { AreaTypeModel model = this.areas[this.comboBoxEdit2.SelectedIndex - 1]; areaId = model.areaId; } HomePageMessageManage.GetFilterComputers(status, areaId, key); }
private void InitUI() { //初始化ComboBoxEdit ComboBoxEdit[] edits = { this.comboBoxEdit1, this.comboBoxEdit2 }; SetupCombox(edits, false); this.ListViewButton.Appearance.BackColor = SEL_BACK_COLOR; //设置电脑状态Combox foreach (string name in Enum.GetNames(typeof(COMPUTERSTATUS))) { this.comboBoxEdit1.Properties.Items.Add(name); } //刷新区域 RefreshAreaCombox(); //添加视图UI AddHomePageListView(); //添加刷新区域下拉 HomePageMessageManage.AddRefreshAreaComBox(RefreshAreaCombox); //添加消息回调 HomePageMessageManage.Manage().AddMsgNumDelegate(null, null, UpdateStatusNum); //获取账户信息 ManagerManage.Manage().GetAccountInfo(GetAccountInfoResult); }
public void GetHomePageListResult(bool success) { HomePageMessageManage.Manage().RemoveResultHandel(GetHomePageListResult); if (success) { } }
private void AddHomePageComputerView() { if (this.panel1.Controls.Contains(this.homePageComputerView)) { return; } //移除代理 if (this.panel1.Controls.Contains(this.homePageListView)) { HomePageMessageManage.RemoveUpdateDataEvent(this.homePageListView.UpdateHomePageData, this.homePageListView.UpdateHomePageArea, null, this.homePageListView.FilterComputers); this.panel1.Controls.Remove(this.homePageListView); } if (this.homePageComputerView == null) { this.homePageComputerView = new HomePageComputerView(); } else { this.homePageComputerView.FilterComputers(); } this.panel1.Controls.Add(this.homePageComputerView); this.homePageComputerView.Location = new Point(0, 0); this.homePageComputerView.Size = this.panel1.Size; this.homePageComputerView.Dock = DockStyle.Fill; this.homePageComputerView.BringToFront(); HomePageMessageManage.AddUpdateDataEvent(this.homePageComputerView.UpdateHomePageData, null, this.homePageComputerView.UpdateHomePageArea, this.homePageComputerView.FilterComputers); }
/// <summary> /// 更新首页的电脑区域 /// </summary> /// <param name="areaId"></param> /// <param name="setting"></param> public void UpateHomePageComputerArea(int areaId, AREA_SETTING setting) { if (setting == AREA_SETTING.ADD) { HomePageMessageManage.UpdateHomePageComputerArea(null, setting); return; } var returnChanges = this.allComputers.Where(com => com.Area.Equals(areaId.ToString())).ToList <StructRealTime>(); if (setting == AREA_SETTING.DELETE) { //修改所有数组和改变过的字典 foreach (StructRealTime changeCom in returnChanges) { int index = this.allComputers.FindIndex(com => com.Computerid == changeCom.Computerid); StructRealTime.Builder newCom = new StructRealTime.Builder(this.allComputers[index]); newCom.Area = "0"; this.allComputers[index] = newCom.Build(); } var changeds = this.changeComDict.Values.Where(com => com.Area.Equals(areaId.ToString())).ToList <StructRealTime>(); foreach (StructRealTime changed in changeds) { StructRealTime.Builder newChanged = new StructRealTime.Builder(changed); newChanged.Area = "0"; this.changeComDict[newChanged.Computerid] = newChanged.Build(); } } HomePageMessageManage.UpdateHomePageComputerArea(returnChanges, setting); }
private void InitTableView() { //获取数据字典 areaComsDict = HomePageMessageManage.GetAreaComsDict(); int num = areaComsDict.Count(); this.tableLayoutPanel1.RowCount = num % COLUMN_NUM == 0 ? num / COLUMN_NUM : num / COLUMN_NUM + 1; this.tableLayoutPanel1.ColumnCount = COLUMN_NUM; this.tableLayoutPanel1.Height = this.tableLayoutPanel1.RowCount * this.comsBg.Height / 2; //创建行 for (int row = 0; row < this.tableLayoutPanel1.RowCount; row++) { this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, this.comsBg.Height / 2)); } for (int column = 0; column < this.tableLayoutPanel1.ColumnCount; column++) { this.tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, this.tableLayoutPanel1.Width / 2)); } int i = 0; foreach (string areaId in areaComsDict.Keys) { AreaComsView areaComsView = new AreaComsView(areaComsDict[areaId], SysManage.GetAreaName(areaId), ComView_Paint); areaComsView.Dock = DockStyle.Fill; areaComsView.Name = string.Format("area_{0}", areaId); this.tableLayoutPanel1.Controls.Add(areaComsView); this.tableLayoutPanel1.SetRow(areaComsView, i / COLUMN_NUM); this.tableLayoutPanel1.SetColumn(areaComsView, i % COLUMN_NUM); i++; } }
//更新电脑显示数据 public void UpdateHomePageData(StructRealTime com) { this.Invoke(new RefreshUIHandle(delegate { int index = HomePageMessageManage.GetComputerIndex(com.Computerid, this.coms); if (index < 0) { return; } this.coms[index] = com; DataRow row = this.mainDataTable.Rows[index]; AddNewRow(com, row); })); }
private void SearchButton_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { //获取所有在线设备 HomePageMessageManage.GetStatusComputers(out onlines, COMPUTERSTATUS.在线); if (!this.buttonEdit1.Text.Equals(buttonEdit1.Properties.NullText)) { string key = this.buttonEdit1.Text; //进行过滤 this.onlines = this.onlines.Where(com => com.Ip.Contains(key) || com.Computer.Contains(key) || com.Mac.Contains(key)).ToList <StructRealTime>(); } RefreshGridControl(); }
// 获取账户信息的回调 public void GetAccountInfoResult(ResultModel result) { if (result.pack.Cmd != Cmd.CMD_ACCOUNT_INFO) { return; } NetMessageManage.RemoveResultBlock(GetAccountInfoResult); if (result.pack.Content.MessageType == 1) { //获取首页数据 HomePageMessageManage.Manage().GetHomePageList(GetHomePageListResult); } }
// 刷新电脑状态(开机。下机。认证) public void UpdateHomePageData(StructRealTime com) { this.Invoke(new RefreshUIHandle(delegate { //获取所对应的电脑 List <StructRealTime> coms = new List <StructRealTime>(); if (areaComsDict.Keys.Contains(com.Area)) { coms = areaComsDict[com.Area]; } else { coms = areaComsDict["-1"]; } //获取电脑所在数组的索引 int comIndex = -1; try { comIndex = coms.Select((StructRealTime tem, int index) => new { tem, index }).Where(a => a.tem.Computerid == com.Computerid).First().index; } catch (Exception exc) { comIndex = -1; } //通过索引获取电脑 if (comIndex < 0) { return; } Control[] res = this.comsBg.Controls.Find(string.Format("name_{0}", com.Computerid), true); if (res.Count() > 0) { coms[comIndex] = com; AreaComView updateComView = res.First() as AreaComView; updateComView.Tag = com; COMPUTERSTATUS status = COMPUTERSTATUS.无; Enum.TryParse <COMPUTERSTATUS>(com.Status, out status); updateComView.ComStatus = status; } //修改过滤数组的值 int comindex = HomePageMessageManage.GetComputerIndex(com.Computerid, this.filterComs); if (comindex < 0) { return; } this.filterComs[comindex] = com; this.comsBg.Refresh(); })); }
public void UpateHomePageComputerArea() { foreach (StructRealTime change in this.changeComDict.Values) { int index = this.allComputers.FindIndex(com => com.Computerid == change.Computerid); StructRealTime ori = this.allComputers[index]; //修改电脑 if (!ori.Area.Equals(change.Area) || !ori.Computer.Equals(change.Computer)) { this.allComputers[index] = change; } } HomePageMessageManage.UpdateHomePageComputerArea(this.changeComDict.Values.ToList <StructRealTime>(), AREA_SETTING.NONE); this.changeComDict.Clear(); }
private void InitUI() { //初始化ComboBoxEdit DevExpress.XtraEditors.ComboBoxEdit[] edits = { this.comboBoxEdit1, }; SetupCombox(edits, false); ToolsManage.SetGridView(this.gridView1, GridControlType.UserNetRecord, out this.mainDataTable); this.gridControl1.DataSource = this.mainDataTable; this.dateNavigator.UpdateDateTimeWhenNavigating = false; this.dateNavigator.UpdateSelectionWhenNavigating = false; this.dateNavigator.SyncSelectionWithEditValue = false; //获取设备编号 this.comboBoxEdit1.Properties.Items.Add("无"); HomePageMessageManage.GetComputers(out this.computers); foreach (StructRealTime com in this.computers) { this.comboBoxEdit1.Properties.Items.Add(com.Computer); } }
//更新单个电脑区域数据 public void UpdateHomePageArea(StructRealTime com) { this.Invoke(new RefreshUIHandle(delegate { int index = HomePageMessageManage.GetComputerIndex(com.Computerid, this.coms); if (index < 0) { return; } //判断一下区域id和获取的名称是否相同 StructRealTime ori = this.coms[index]; DataRow row = this.mainDataTable.Rows[index]; string areaName = row[TitleList.Area.ToString()] as string; string newAreaName = SysManage.GetAreaName(com.Area); if (com.Area.Equals(ori.Area) && newAreaName.Equals(areaName)) { System.Console.WriteLine("更新的电脑没有改变"); return; } this.coms[index] = com; row[TitleList.Area.ToString()] = newAreaName; })); }
private void AddMsgDelegate() { HomePageMessageManage.Manage().AddMsgNumDelegate(UpdateMsgNumResult, UpdateDailyDataResult, UpdateStatusNum); }
/// <summary> /// 初始化方法获取所有电脑 /// </summary> public AreaSettingManage() { //获取所有电脑数据 HomePageMessageManage.GetComputers(out allComputers); }
private void GetOnLineList() { HomePageMessageManage.GetStatusComputers(out onlines, COMPUTERSTATUS.在线); RefreshGridControl(); }