private void menuNewUserAction_Click(object sender, EventArgs e) { try { if (tvEvents.SelectedNode == null) { MessageBox.Show("请先选择安全行为所属安全事件"); return; } string eventGuid = string.Empty; if (tvEvents.SelectedNode.Level == EventLevel) { eventGuid = Convert.ToString(tvEvents.SelectedNode.Tag); } else if (tvEvents.SelectedNode.Level == UserActionLevel) { eventGuid = Convert.ToString(tvEvents.SelectedNode.Parent.Tag); } this.Cursor = Cursors.WaitCursor; frmEditUserActionProperty fe = new frmEditUserActionProperty(); fe.Text = "编辑安全行为属性"; if (CGeneralFuncion.ShowWindow(this, fe, true) == System.Windows.Forms.DialogResult.OK) { SecurityAction sa = SecurityAction.CreateNewSecurityAction( fe.ActionName, fe.ActionDesc, fe.ActionResultGuid); CreateNewUserActionCommand cmd = new CreateNewUserActionCommand(eventGuid, sa); cmd.UndoDone += new UndoRedoEventHandler(RemoveActionFromTree); cmd.RedoDone += new UndoRedoEventHandler(AddAction2Tree); cmd.Execute(); AddCommand(cmd); AddAction2Tree(eventGuid, sa.ActionGuid, sa.Name); } } catch (Exception ex) { MessageBox.Show("创建新安全行为失败,错误消息为:" + ex.Message); } }
private void cmProperties_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { if (tvEvents.SelectedNode.Level == EventLevel) { SecurityEvent se = SecurityEventService.Instance.GetSecurityEvent(Convert.ToString(tvEvents.SelectedNode.Tag)); frmEditEventProperty fe = new frmEditEventProperty(se); fe.Text = "编辑安全事件属性"; if (CGeneralFuncion.ShowWindow(this, fe, true) == System.Windows.Forms.DialogResult.OK) { SecurityEvent newSe = SecurityEvent.CreateSecurityEvent(fe.EventName, se.EventGuid, fe.Description); UpdateSecurityEventCommand cmd = new UpdateSecurityEventCommand(newSe); cmd.UndoDone += new UndoRedoEventHandler(RefreshEventTree); cmd.RedoDone += new UndoRedoEventHandler(RefreshEventTree); cmd.Execute(); AddCommand(cmd); RefreshEventTree(se.Name, se.EventGuid); } } else if (tvEvents.SelectedNode.Level == UserActionLevel) { string eventGuid = Convert.ToString(tvEvents.SelectedNode.Parent.Tag); SecurityAction sa = SecurityEventService.Instance.GetSecurityAction( eventGuid, Convert.ToString(tvEvents.SelectedNode.Tag)); frmEditUserActionProperty fe = new frmEditUserActionProperty(sa); fe.Text = "编辑安全行为属性"; if (CGeneralFuncion.ShowWindow(this, fe, true) == System.Windows.Forms.DialogResult.OK) { SecurityAction newData = SecurityAction.CreateSecurityAction(fe.ActionName, sa.ActionGuid, fe.ActionDesc, fe.ActionResultGuid); UpdateSecurityActionCommand cmd = new UpdateSecurityActionCommand(eventGuid, newData); cmd.UndoDone += new UndoRedoEventHandler(RefreshActionNodeName); cmd.RedoDone += new UndoRedoEventHandler(RefreshActionNodeName); cmd.Execute(); AddCommand(cmd); RefreshActionNodeName(eventGuid, newData.ActionGuid, newData.Name); } } } catch (Exception ex) { MessageBox.Show("修改属性信息失败,错误消息为:" + ex.Message); } finally { this.Cursor = Cursors.Default; } }