public DataGroupModifyDlg(DataGroup parent, long groupID) { this.InitializeComponent(); this.tbname.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbAvlKey.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbMemberKey.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.m_Parent2 = parent; this.m_groupID = groupID; this.cboType.Items.Clear(); this.cboType.Items.Add(EcoLanguage.getMsg(LangRes.Group_TPZone, new string[0])); this.cboType.Items.Add(EcoLanguage.getMsg(LangRes.Group_TPRack, new string[0])); this.cboType.Items.Add(EcoLanguage.getMsg(LangRes.Group_TPDev, new string[0])); this.cboType.Items.Add(EcoLanguage.getMsg(LangRes.Group_TPOutlet, new string[0])); if (this.m_groupID >= 0L) { GroupInfo groupByID = GroupInfo.GetGroupByID(this.m_groupID); this.m_groupType = groupByID.GroupType; this.tbname.Text = groupByID.GroupName; this.cboType.Enabled = false; string groupType; switch (groupType = groupByID.GroupType) { case "zone": this.cboType.SelectedIndex = 0; break; case "rack": case "allrack": this.cboType.SelectedIndex = 1; break; case "dev": case "alldev": this.cboType.SelectedIndex = 2; break; case "outlet": case "alloutlet": this.cboType.SelectedIndex = 3; break; } this.cboType.Enabled = false; return; } this.cboType.SelectedIndex = 0; this.cboType.Enabled = true; }
private void btnSave_Click(object sender, System.EventArgs e) { bool flag = false; Ecovalidate.checkTextIsNull(this.tbname, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbname.Text })); this.tbname.Focus(); return; } string text = this.tbname.Text; if (!GroupInfo.CheckGroupName(this.m_groupID, text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Group_nmdup, new string[] { text })); this.tbname.Focus(); return; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); System.Collections.Generic.List <long> list = new System.Collections.Generic.List <long>(); string text2; foreach (DataRow dataRow in this.member_tb.Rows) { text2 = (string)dataRow[0]; stringBuilder.Append(text2 + ","); list.Add((long)System.Convert.ToInt32(text2)); } text2 = stringBuilder.ToString(); if (text2.Length == 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_selectneed, new string[0])); return; } if (this.m_groupID >= 0L) { GroupInfo groupByID = GroupInfo.GetGroupByID(this.m_groupID); groupByID.GroupName = text; groupByID.Members = text2; switch (groupByID.Update()) { case -2: case -1: EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; case 0: break; case 1: LogAPI.writeEventLog("0430032", new string[] { groupByID.GroupName, groupByID.GroupType, EcoGlobalVar.gl_LoginUser.UserName }); EcoGlobalVar.setDashBoardFlg(520uL, "", 64); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); base.DialogResult = DialogResult.OK; base.Close(); return; default: return; } } else { int num = GroupInfo.CreateNewGroup(text, this.m_groupType, "", list); if (num == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Group_nmdup, new string[] { text })); return; } if (num < 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } LogAPI.writeEventLog("0430030", new string[] { text, this.m_groupType, EcoGlobalVar.gl_LoginUser.UserName }); EcoGlobalVar.setDashBoardFlg(512uL, "", 64); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); base.DialogResult = DialogResult.OK; base.Close(); } }
private void init_Avail_data() { System.Collections.Generic.Dictionary <long, string> dictionary = new System.Collections.Generic.Dictionary <long, string>(); if (this.m_groupID >= 0L) { GroupInfo groupByID = GroupInfo.GetGroupByID(this.m_groupID); string memberList = groupByID.GetMemberList(); if (memberList != null && memberList.Length > 0) { string[] array = memberList.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string value = array2[i]; long key = (long)System.Convert.ToInt32(value); dictionary.Add(key, ""); } } } this.dgvAvail.DataSource = null; this.Avail_tb = new DataTable(); this.Avail_tb.Columns.Add("objID", typeof(string)); this.Avail_tb.PrimaryKey = new DataColumn[] { this.Avail_tb.Columns[0] }; string groupType; if ((groupType = this.m_groupType) != null) { if (cct == null) { cct = new System.Collections.Generic.Dictionary <string, int>(7) { { "zone", 0 }, { "rack", 1 }, { "allrack", 2 }, { "dev", 3 }, { "alldev", 4 }, { "outlet", 5 }, { "alloutlet", 6 } }; } int num; if (cct.TryGetValue(groupType, out num)) { switch (num) { case 0: { this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string)); System.Collections.ArrayList allZone = ZoneInfo.getAllZone(); System.Collections.IEnumerator enumerator = allZone.GetEnumerator(); try { while (enumerator.MoveNext()) { ZoneInfo zoneInfo = (ZoneInfo)enumerator.Current; string text = zoneInfo.ZoneID.ToString(); if (!dictionary.ContainsKey(zoneInfo.ZoneID)) { string[] values = new string[] { text, zoneInfo.ZoneName }; this.Avail_tb.Rows.Add(values); } } return; } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } break; } case 1: case 2: break; case 3: case 4: goto IL_401; case 5: case 6: goto IL_50F; default: return; } this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string)); this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string)); System.Collections.ArrayList allZone2 = ZoneInfo.getAllZone(); System.Collections.ArrayList allRack_NoEmpty = RackInfo.GetAllRack_NoEmpty(); System.Collections.IEnumerator enumerator2 = allRack_NoEmpty.GetEnumerator(); try { while (enumerator2.MoveNext()) { RackInfo rackInfo = (RackInfo)enumerator2.Current; if (!dictionary.ContainsKey(rackInfo.RackID)) { string displayRackName = rackInfo.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag); string text2 = rackInfo.RackID.ToString(); bool flag = false; string text3 = ""; foreach (ZoneInfo zoneInfo2 in allZone2) { text3 = zoneInfo2.ZoneName; string[] source = zoneInfo2.RackInfo.Split(new char[] { ',' }); if (source.Contains(text2)) { flag = true; break; } } string[] values; if (flag) { values = new string[] { text2, displayRackName, text3 }; } else { values = new string[] { text2, displayRackName, "" }; } this.Avail_tb.Rows.Add(values); } } return; } finally { System.IDisposable disposable3 = enumerator2 as System.IDisposable; if (disposable3 != null) { disposable3.Dispose(); } } IL_401: this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string)); this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string)); System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice(); using (System.Collections.Generic.List <DeviceInfo> .Enumerator enumerator4 = allDevice.GetEnumerator()) { while (enumerator4.MoveNext()) { DeviceInfo current = enumerator4.Current; if (!dictionary.ContainsKey((long)current.DeviceID)) { string deviceName = current.DeviceName; string text4 = current.DeviceID.ToString(); RackInfo rackByID = RackInfo.getRackByID(current.RackID); string displayRackName2 = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag); string[] values = new string[] { text4, deviceName, displayRackName2 }; this.Avail_tb.Rows.Add(values); } } return; } IL_50F: this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMOutlet, new string[0]), typeof(string)); this.Avail_tb.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string)); allDevice = DeviceOperation.GetAllDevice(); foreach (DeviceInfo current2 in allDevice) { System.Collections.Generic.List <PortInfo> portInfo = current2.GetPortInfo(); foreach (PortInfo current3 in portInfo) { if (!dictionary.ContainsKey((long)current3.ID)) { string[] values = new string[] { current3.ID.ToString(), current3.PortName, current2.DeviceName }; this.Avail_tb.Rows.Add(values); } } } } } }