public ValidateResult Save() { var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证书籍。 var book = db.Documents.Find(this.DocumentId); if (!book.IsBook || !book.IsMain || book.IsAbstract) { return(new ValidateResult(false, "DocumentId", "不是书籍!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(book.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); if (book.ChildDocuments.Count() > 0) { return(new ValidateResult(false, "DocumentId", "有子项目时不允许删除!")); } //设置返回数据。 this.ReturnDocumentIdId = book.ParentDocumentId; //删除书籍。 db.Documents.Remove(book); db.SaveChanges(); } return(new ValidateResult(true)); }
public Details(Guid id) { var db = new Domains.MySQL.Entities.DMsDbContext(); var target = db.Documents.Find(id); this.Initial(target); }
public ValidateResult Save() { var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证信息。 var addition = db.Additions.Find(this.AdditionId); //if (this.TimeStamp != System.BitConverter.ToInt64(addition.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //检测节点。 var document = db.Documents.Find(addition.DocumentId); if (document == null) { return(new ValidateResult(false, "DocumentId", "节点不存在!")); } //删除信息。 db.Additions.Remove(addition); //修改节点。 document.UpdateTime = DateTime.Now; db.SaveChanges(); //回传参数。 this.DocumentId = document.DocumentId; } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (string.IsNullOrWhiteSpace(this.Title)) { return(new ValidateResult(false, "Title", "标题不可为空!")); } if (this.Priority < 0) { return(new ValidateResult(false, "Priority", "序号不可小于0!")); } var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证章节。 var chapter = db.Documents.Find(this.DocumentId); if (!chapter.IsBook || chapter.IsMain || chapter.IsAbstract) { return(new ValidateResult(false, "DocumentId", "不是章节!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(chapter.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //修改章节。 chapter.Title = this.Title; chapter.NodeName = this.Title; chapter.Priority = this.Priority; chapter.IsChecked = this.IsChecked; chapter.UpdateTime = DateTime.Now; //更新书籍。 var parent = db.Documents.Find(chapter.ParentDocumentId); do { if (parent.IsBook && parent.IsMain) { break; } parent = db.Documents.Find(parent.ParentDocumentId); } while (true); parent.UpdateTime = DateTime.Now; db.SaveChanges(); } return(new ValidateResult(true)); }
public Worker.ValidateResult Do() { var old_Db = new Domains.Entities.DMsDbContext(); var old_Shelves = old_Db.Documents.Where(c => c.IsBook && c.IsAbstract && !c.IsMain && c.ParentDocumentId == null); var new_Db = new Domains.MySQL.Entities.DMsDbContext(); foreach (var old_shelf in old_Shelves.ToList()) { this.Shelf(old_shelf, new_Db); } new_Db.SaveChanges(); return(new Worker.ValidateResult(false)); }
public ValidateResult Save() { var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证章节。 var chapter = db.Documents.Find(this.DocumentId); if (!chapter.IsBook || chapter.IsMain || chapter.IsAbstract) { return(new ValidateResult(false, "DocumentId", "Not Chapter!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(chapter.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "TimeStamp Not Match!"); if (chapter.ChildDocuments.Count() > 0) { return(new ValidateResult(false, "DocumentId", "Children Not Empty!")); } //设置返回数据。 if (chapter.ParentDocument.ChildDocuments.Count(c => c.Priority < chapter.Priority) > 0) { this.ReturnDocumentIdId = chapter.ParentDocument.ChildDocuments.OrderBy(c => c.Priority).Last(c => c.Priority < chapter.Priority).DocumentId; } else if (chapter.ParentDocument.ChildDocuments.Count(c => c.Priority > chapter.Priority) > 0) { this.ReturnDocumentIdId = chapter.ParentDocument.ChildDocuments.OrderBy(c => c.Priority).First(c => c.Priority > chapter.Priority).DocumentId; } else { this.ReturnDocumentIdId = chapter.ParentDocumentId; } //删除章节。 db.Documents.Remove(chapter); db.SaveChanges(); } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (string.IsNullOrWhiteSpace(this.Title)) { return(new ValidateResult(false, "Title", "标题不可为空!")); } if (this.Priority < 0) { return(new ValidateResult(false, "Priority", "序号不可小于0!")); } //构建书籍。 var book = new Domains.MySQL.Entities.Document { DocumentId = Guid.NewGuid(), ParentDocumentId = this.ParentDocumentId, Title = this.Title, NodeName = this.Title, Priority = this.Priority, UpdateTimeForHTTPGet = DateTime.Now, IsBook = true, IsMain = true, UpdateTime = DateTime.Now, }; var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //添加书籍。 db.Documents.Add(book); db.SaveChanges(); //回传参数。 this.DocumentId = book.DocumentId; } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (this.DocumentId == this.NewParentDocumentId) { return(new ValidateResult(false, "NewParentDocumentId", "目标节点不能为自身节点!")); } var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证书架。 var shelf = db.Documents.Find(this.DocumentId); if (!shelf.IsBook || !shelf.IsAbstract || shelf.IsMain) { return(new ValidateResult(false, "DocumentId", "不是书架!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(shelf.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //验证目标父书架。 if (this.NewParentDocumentId.HasValue) { var newParentShelf = db.Documents.Find(this.NewParentDocumentId.Value); if (!newParentShelf.IsBook || !newParentShelf.IsAbstract || newParentShelf.IsMain) { return(new ValidateResult(false, "NewParentDocumentId", "不是书架!")); } } //修改书架。 shelf.ParentDocumentId = NewParentDocumentId; shelf.UpdateTime = DateTime.Now; db.SaveChanges(); } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (string.IsNullOrWhiteSpace(this.Description)) { return(new ValidateResult(false, "Description", "不可为空!")); } //构建信息。 var addition = new Domains.MySQL.Entities.Addition { AdditionId = Guid.NewGuid(), AdditionCategoryId = this.AdditionCategoryId, DocumentId = this.DocumentId, Description = this.Description, UpdateTime = DateTime.Now, }; var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //检测节点。 var document = db.Documents.Find(this.DocumentId); if (document == null) { return(new ValidateResult(false, "DocumentId", "节点不存在!")); } //添加信息。 db.Additions.Add(addition); //修改节点。 document.UpdateTime = DateTime.Now; db.SaveChanges(); } return(new ValidateResult(true)); }
public void Shelf(Domains.Entities.Document old, Domains.MySQL.Entities.DMsDbContext new_Db) { var shelf = new Domains.MySQL.Entities.Document { DocumentId = old.DocumentId, ParentDocumentId = old.ParentDocumentId, Title = old.Title, NodeName = old.Title, Priority = old.Priority, UpdateTimeForHTTPGet = DateTime.Now, IsBook = true, IsAbstract = true, UpdateTime = old.UpdateTime, }; new_Db.Documents.Add(shelf); foreach (var old_shelf in old.ChildDocuments.Where(c => c.IsBook && c.IsAbstract && !c.IsMain)) { this.Shelf(old_shelf, new_Db); } }
public ValidateResult Save() { //验证参数。 if (string.IsNullOrWhiteSpace(this.Description)) { return(new ValidateResult(false, "Description", "不可为空!")); } var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证信息。 var addition = db.Additions.Find(this.AdditionId); //if (this.TimeStamp != System.BitConverter.ToInt64(addition.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //检测节点。 var document = db.Documents.Find(addition.DocumentId); if (document == null) { return(new ValidateResult(false, "DocumentId", "节点不存在!")); } //修改信息。 addition.Description = this.Description; addition.UpdateTime = DateTime.Now; //修改节点。 document.UpdateTime = DateTime.Now; db.SaveChanges(); this.DocumentId = document.DocumentId; } return(new ValidateResult(true)); }
public ValidateResult Save() { var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { var paste = db.Documents.Find(this.PasteDocumentId); if (paste == null) { return(new ValidateResult(false, "PasteDocumentId", "Not Exist!")); } if (!paste.IsBookBook && !paste.IsBookChapter) { return(new ValidateResult(false, "PasteDocumentId", "Not a Book or a Chapter!")); } var copy = db.Documents.Find(this.CopyDocumentId); if (copy == null) { return(new ValidateResult(false, "CopyDocumentId", "Not Exist!")); } if (!copy.IsBookBook && !copy.IsBookChapter) { return(new ValidateResult(false, "CopyDocumentId", "Not a Book or a Chapter!")); } if (copy.ChildDocuments.Count() == 0) { return(new ValidateResult(false, "CopyDocumentId", "No Children!")); } //复制。 this.CopyChildren(paste, copy, db); db.SaveChanges(); } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (this.DocumentId == this.NewParentDocumentId) { return(new ValidateResult(false, "NewParentDocumentId", "目标节点不能为自身节点!")); } var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证章节。 var chapter = db.Documents.Find(this.DocumentId); if (!chapter.IsBook || chapter.IsAbstract || chapter.IsMain) { return(new ValidateResult(false, "DocumentId", "不是章节!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(chapter.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //验证目标父章节或书籍。 var newParent = db.Documents.Find(this.NewParentDocumentId); if (!newParent.IsBook || newParent.IsAbstract) { return(new ValidateResult(false, "NewParentDocumentId", "不是书籍或章节!")); } //修改书架。 chapter.ParentDocumentId = NewParentDocumentId; chapter.UpdateTime = DateTime.Now; db.SaveChanges(); } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (string.IsNullOrWhiteSpace(this.Title)) { return(new ValidateResult(false, "Title", "标题不可为空!")); } if (this.Priority < 0) { return(new ValidateResult(false, "Priority", "序号不可小于0!")); } var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证书籍。 var book = db.Documents.Find(this.DocumentId); if (!book.IsBook || !book.IsMain || book.IsAbstract) { return(new ValidateResult(false, "DocumentId", "不是书籍!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(book.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //修改书籍。 book.Title = this.Title; book.NodeName = this.Title; book.Priority = this.Priority; book.IsChecked = this.IsChecked; book.UpdateTime = DateTime.Now; db.SaveChanges(); } return(new ValidateResult(true)); }
public ValidateResult Save() { var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //验证书籍。 var book = db.Documents.Find(this.DocumentId); if (!book.IsBook || !book.IsMain || book.IsAbstract) { return(new ValidateResult(false, "DocumentId", "不是书籍!")); } //if (this.TimeStamp != System.BitConverter.ToInt64(book.TimeStamp, 0)) // return new ValidateResult(false, "TimeStamp", "时间戳不吻合!"); //修改书籍。 book.IsChecked = true; book.UpdateTime = DateTime.Now; db.SaveChanges(); } return(new ValidateResult(true)); }
public ValidateResult Save() { //验证参数。 if (string.IsNullOrWhiteSpace(this.Title)) { return(new ValidateResult(false, "Title", "标题不可为空!")); } if (this.Priority < 0) { return(new ValidateResult(false, "Priority", "序号不可小于0!")); } //构建章节。 var chapter = new Domains.MySQL.Entities.Document { DocumentId = Guid.NewGuid(), ParentDocumentId = this.ParentDocumentId, Title = this.Title, NodeName = this.Title, Priority = this.Priority, UpdateTimeForHTTPGet = DateTime.Now, IsBook = true, UpdateTime = DateTime.Now, }; var db = new Domains.MySQL.Entities.DMsDbContext(); lock (Atom.GetInstance()) { //添加章节。 db.Documents.Add(chapter); //更新书籍。 var parent = db.Documents.Find(this.ParentDocumentId); do { if (parent.IsBook && parent.IsMain) { break; } parent = db.Documents.Find(parent.ParentDocumentId); } while (true); parent.UpdateTime = DateTime.Now; //设置章节完成。 if (this.CurrentDocumentIdToSetFinished.HasValue) { var currentDocumentToSetFinished = db.Documents.Find(this.CurrentDocumentIdToSetFinished); if (currentDocumentToSetFinished == null) { return(new ValidateResult(false, "CurrentDocumentIdToSetFinished", "当前设置完成的节点不存在!")); } if (!currentDocumentToSetFinished.IsBook || currentDocumentToSetFinished.IsAbstract || currentDocumentToSetFinished.IsMain) { return(new ValidateResult(false, "CurrentDocumentIdToSetFinished", "当前设置完成的节点类型错误!")); } currentDocumentToSetFinished.IsChecked = true; } db.SaveChanges(); //回传参数。 this.DocumentId = chapter.DocumentId; } return(new ValidateResult(true)); }
private void CopyChildren(Domains.MySQL.Entities.Document target, Domains.MySQL.Entities.Document origin, Domains.MySQL.Entities.DMsDbContext db) { foreach (var item in origin.ChildDocuments) { var newItem = new Domains.MySQL.Entities.Document { DocumentId = Guid.NewGuid(), ParentDocumentId = target.DocumentId, Title = item.Title, NodeName = item.NodeName, Priority = item.Priority, IsChecked = item.IsChecked, IsBook = true, UpdateTime = DateTime.Now, UpdateTimeForHTTPGet = DateTime.Now, }; target.ChildDocuments.Add(newItem); if (item.ChildDocuments.Count() > 0) { this.CopyChildren(newItem, item, db); } } }