protected override int OnDelete() { //var rs = base.OnDelete(); var ori = Deleted; Deleted = !Deleted; var rs = base.OnUpdate(); TaskHistory.Add(ID, ori ? "恢复" : "删除", null, Name); FixChildCount(); // 子孙任务集体删除 if (!ori) { foreach (var item in Childs) { // 有些子任务已经被删除,这里先把它改为跟当前任务的原状态,方便一体化操作 item[__.Deleted] = ori; item.Delete(); } } else // 父任务集体恢复 { if (Parent != null) { Parent[__.Deleted] = ori; Parent.Delete(); } } return(rs); }
protected override int OnInsert() { var rs = base.OnInsert(); _bak = this.CloneEntity(); TaskHistory.Add(ID, "创建", null, Name); rs += OnUpdate(); return(rs); }
/// <summary>写任务历史</summary> void WriteHistory() { if (_bak == null) { throw new XException("非法更新任务{0}!", ID); } // 找到旧有数据 var entity = _bak; var names = new Field[] { _.Name, _.ParentID, _.ChildCount, _.Percent, _.PlanStartTime, _.PlanEndTime, _.Progress, _.Score, _.LockScore, _.LockPlanTime }; foreach (var item in names) { if (Dirtys[item.Name]) { TaskHistory.Add(ID, item.DisplayName, _bak[item.Name], this[item.Name], Name); } } if (Dirtys[__.Priority]) { TaskHistory.Add(ID, _.Priority.DisplayName, _bak.TaskPriority, this.TaskPriority, Name); } if (Dirtys[__.Status]) { TaskHistory.Add(ID, _.Status.DisplayName, _bak.TaskStatus, this.TaskStatus, Name); } if (Dirtys[__.MasterID]) { TaskHistory.Add(ID, _.MasterID.DisplayName, _bak.MasterName, this.MasterName, Name); } if (Dirtys[__.Content]) { TaskHistory.Add(ID, _.Content.DisplayName, _bak.Content, this.Content, Name); } }