예제 #1
0
        private void menuNewEvent_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                frmEditEventProperty fe = new frmEditEventProperty();
                fe.Text = "编辑安全事件属性";

                if (CGeneralFuncion.ShowWindow(this, fe, true) == System.Windows.Forms.DialogResult.OK)
                {
                    SecurityEvent se = SecurityEvent.CreateNewSecurityEvent(fe.EventName, fe.Description);

                    CreateNewSecurityEventCommand cmd = new CreateNewSecurityEventCommand(se);
                    cmd.UndoDone += new UndoRedoEventHandler(RemoveEventFromTree);
                    cmd.RedoDone += new UndoRedoEventHandler(AddEvent2Tree);
                    cmd.Execute();
                    AddCommand(cmd);
                    AddEvent2Tree(se.Name, se.EventGuid);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建新安全事件失败,错误消息为:" + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
예제 #2
0
        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;
            }
        }