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; } }
/// <summary> /// 更新安全行为属性 /// </summary> /// <param name="se"></param> public void UpdateSecurityActionProperties(string eventGuid, SecurityAction sa) { try { if (!m_rules.ContainsKey(eventGuid)) { throw new Exception(string.Format("安全事件的guid{0}不存在", eventGuid)); } SecurityEvent se = m_rules[eventGuid]; if (!se.ContainsAction(sa.ActionGuid)) { throw new Exception(string.Format("安全事件{0}中不存在安全行为{1}", eventGuid, sa.Name)); } m_manager.UpdateSecurityActionProperties(eventGuid, sa); se.GetSecurityAction(sa.ActionGuid).CopyFrom(sa); } catch (Exception ex) { throw new Exception("更新安全行为属性失败,错误消息为:" + ex.Message); } }
public frmEditEventProperty(SecurityEvent ev) { InitializeComponent(); this.txtDesc.Text = ev.Description; this.txtGuid.Text = ev.EventGuid; this.txtName.Text = ev.Name; }
/// <summary> /// 没有复制用户行为信息 /// </summary> /// <returns></returns> public SecurityEvent LowerClone() { SecurityEvent se = new SecurityEvent(); se.EventGuid = this.EventGuid; se.Description = this.Description; se.Name = this.Name; return(se); }
public static SecurityEvent CreateSecurityEvent(string name, string guid, string desc) { SecurityEvent se = new SecurityEvent(); se.Name = name; se.Description = desc; se.EventGuid = guid; return(se); }
public static SecurityEvent CreateNewSecurityEvent(string name, string desc) { SecurityEvent se = new SecurityEvent(); se.Name = name; se.Description = desc; se.EventGuid = Guid.NewGuid().ToString(); return(se); }
public object Clone() { SecurityEvent se = this.LowerClone(); //se.EventGuid = this.EventGuid; //se.Description = this.Description; //se.Name = this.Name; foreach (SecurityAction sa in this.SecurityActions) { se.SecurityActions.Add((SecurityAction)sa.Clone()); } return(se); }
/// <summary> /// 更新安全事件 /// </summary> /// <param name="sEvent"></param> /// <returns></returns> public void UpdateSecurityEvent(SecurityEvent sEvent) { try { if (!m_rules.ContainsKey(sEvent.EventGuid)) { throw new Exception(string.Format("要更新的安全事件{1}的不存在", sEvent.Name)); } m_manager.UpdateSecurityEventProperties(sEvent); m_rules[sEvent.EventGuid].CopyFrom(sEvent); } catch (Exception ex) { throw new Exception("更新安全事件属性失败,错误消息为:" + ex.Message); } }
/// <summary> /// 添加安全事件,如果已经存在事件Guid,则不予添加 /// </summary> /// <param name="sEvent"></param> /// <returns></returns> public void AddSecurityEvent(SecurityEvent sEvent) { try { if (sEvent == null || string.IsNullOrWhiteSpace(sEvent.EventGuid)) { throw new Exception("安全事件或者安全事件的guid不能为空"); } if (m_rules.ContainsKey(sEvent.EventGuid)) { throw new Exception(string.Format("安全事件{1}的guid已经存在", sEvent.Name)); } m_manager.CreateNewSecurityEvent(sEvent); m_rules.Add(sEvent.EventGuid, sEvent); } catch (Exception ex) { throw new Exception("添加安全事件失败,错误消息为:" + ex.Message); } }
/// <summary> /// 删除指定的安全行为,包含条件 /// </summary> /// <param name="eventGuid"></param> public void DeleteSecurityAction(string eventGuid, string actionGuid) { try { if (!m_rules.ContainsKey(eventGuid)) { throw new Exception(string.Format("安全事件的guid{0}不存在", eventGuid)); } SecurityEvent se = m_rules[eventGuid]; if (!se.ContainsAction(actionGuid)) { throw new Exception(string.Format("安全事件{0}中不存在安全行为{1}", eventGuid, actionGuid)); } m_manager.DeleteSecurityAction(eventGuid, actionGuid); se.DeleteAction(actionGuid); } catch (Exception ex) { throw new Exception("删除指定的安全行为失败,错误消息为:" + ex.Message); } }
/// <summary> /// 新建安全行为 /// </summary> /// <param name="se"></param> public void AddSecurityAction(string eventGuid, SecurityAction sa) { try { if (!m_rules.ContainsKey(eventGuid)) { throw new Exception(string.Format("安全事件的guid{0}不存在", eventGuid)); } SecurityEvent se = m_rules[eventGuid]; if (se.ContainsAction(sa.ActionGuid)) { throw new Exception(string.Format("安全事件{0}中已经存在安全行为{1}", eventGuid, sa.Name)); } m_manager.CreateNewSecurityAction(eventGuid, sa); se.AddSecurityAction(sa); } catch (Exception ex) { throw new Exception("新建安全行为失败,错误消息为:" + ex.Message); } }
public void CopyFrom(SecurityEvent se) { this.Name = se.Name; this.Description = se.Description; }
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; } }