예제 #1
0
        public Details(Guid id)
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(id);

            this.Initial(target);
        }
예제 #2
0
        public bool Save()
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(this.DocumentId);

            if (target == null)
            {
                return(false);
            }

            //修改目标项目优先级。
            target.Priority  = this.TargetPriority;
            target.TimeStamp = this.TimeStamp;

            //处理所有后续项目,优先度顺接的均递增1。(处理所有隔空项目)
            var postSilbings = db.Documents.Where(c => c.ParentDocumentId == target.ParentDocumentId && c.Priority >= this.TargetPriority && c.DocumentId != this.DocumentId).OrderBy(c => c.Priority).ToList();

            foreach (var silbing in postSilbings)
            {
                silbing.Priority += 1;
            }

            try
            {
                db.SaveChanges();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public static int GetPriority(Guid?parentId)
        {
            int?priority;

            var db     = new Domains.Entities.DMsDbContext();
            var parent = db.Documents.Find(parentId);

            if (parent == null)
            {
                priority = db.Documents.Where(c => c.ParentDocumentId == null).Max(c => c.Priority);
            }
            else
            {
                priority = parent.ChildDocuments.Max(c => c.Priority);
            }

            if (priority == null)
            {
                priority = 1;
            }
            else
            {
                priority = priority + 1;
            }
            return(priority.Value);
        }
예제 #4
0
        public InsertPriority(Guid id)
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(id);

            this.DocumentId     = id;
            this.TargetPriority = target.Priority == null ? 0 : target.Priority.Value;
            this.TimeStamp      = target.TimeStamp;
        }
        public Children(Guid id)
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(id);

            this.DocumentId       = id;
            this.ParentDocumentId = target.ParentDocumentId;
            this.List             = target.ChildDocuments.Where(c => c.IsBookBook || c.IsBookChapter || c.IsBookBookShelf).OrderBy(c => c.Priority).ToList().Select(c => new Item(c)).ToList();
        }
        public void Initial(Domains.Entities.Document target)
        {
            var db = new Domains.Entities.DMsDbContext();

            this.ParentDocumentId = target.ParentDocumentId;
            this.DocumentId       = target.DocumentId;
            {
                if (target.ParentDocumentId != null)
                {
                    this.PreSilbingDocumentId = target.ParentDocument.ChildDocuments.Where(c => c.IsBook && c.Priority < target.Priority).OrderBy(c => c.Priority).LastOrDefault()?.DocumentId;
                }
                else
                {
                    this.PreSilbingDocumentId = db.Documents.Where(c => c.IsBook && c.ParentDocumentId == null && c.Priority < target.Priority).OrderBy(c => c.Priority).ToList().LastOrDefault()?.DocumentId;
                }
            }
            {
                if (target.ParentDocumentId != null)
                {
                    this.PostSilbingDocumentId = target.ParentDocument.ChildDocuments.Where(c => c.IsBook && c.Priority > target.Priority).OrderBy(c => c.Priority).FirstOrDefault()?.DocumentId;
                }
                else
                {
                    this.PostSilbingDocumentId = db.Documents.Where(c => c.IsBook && c.ParentDocumentId == null && c.Priority > target.Priority).OrderBy(c => c.Priority).ToList().FirstOrDefault()?.DocumentId;
                }
            }
            this.IsBookAbstract = target.IsBookBookShelf;
            this.IsBookMain     = target.IsBookBook;
            this.IsBookNormal   = target.IsBookChapter;

            this.NodeName = target.NodeName;
            this.Priority = target.Priority;
            this.Remarks  = target.Remarks;

            if (this.IsBookMain)
            {
                this.Main      = new Main();
                this.Main.Url  = target.Url;
                this.Main.ISBN = target.ISBN;
            }

            if (!this.IsBookAbstract)
            {
                this.Concrete              = new Concrete();
                this.Concrete.DocumentId   = this.DocumentId;
                this.Concrete.IsChecked    = target.IsChecked;
                this.Concrete.IsBookmarked = target.IsBookmarked;
            }
            else
            {
                this.Abstract = new Abstract();
            }
        }
        /// <summary>
        /// 初始化。
        /// </summary>
        /// <param name="parentDocumentId">父文档文档ID。留空即为根文档。</param>
        public Create(Guid?parentDocumentId)
        {
            this.ParentDocumentId = parentDocumentId;

            var db           = new Domains.Entities.DMsDbContext();
            var targetParent = db.Documents.Find(parentDocumentId);

            this.Priority = targetParent?.ChildDocuments.Max(c => c.Priority) + 1;
            if (this.Priority == null)
            {
                this.Priority = 1;
            }
        }
        public bool Save(Domains.Entities.Document target)
        {
            var db = new Domains.Entities.DMsDbContext();

            db.Documents.Add(target);
            try
            {
                db.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
예제 #9
0
        public Index()
        {
            var db = new Domains.Entities.DMsDbContext();

            var query = db.Documents.Where(c => c.ParentDocumentId == null);

            var queryOrdered = query.OrderBy(c => c.Priority).ThenBy(c => c.DocumentId);

            var list = queryOrdered.ToList();

            list = list.Where(c => c.IsBookBookShelf || c.IsBookBook).ToList();

            this.List = new List <Item>();

            this.CreateItems(list, 0);
        }
        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));
        }
예제 #11
0
        /// <summary>
        /// 初始化。
        /// </summary>
        /// <param name="target">源域对象。</param>
        public Details(Models.Domains.Entities.Document target)
        {
            var db = new Domains.Entities.DMsDbContext();

            this.DocumentId       = target.DocumentId;
            this.ParentDocumentId = target.ParentDocumentId;
            if (this.ParentDocumentId != null)
            {
                this.PreSilbingDocumentId = target.ParentDocument.ChildDocuments.Where(c => c.Priority < target.Priority).OrderBy(c => c.Priority).LastOrDefault()?.DocumentId;
            }
            else
            {
                this.PreSilbingDocumentId = db.Documents.Where(c => c.ParentDocumentId == null && c.Priority < target.Priority).OrderBy(c => c.Priority).ToList().LastOrDefault()?.DocumentId;
            }
            if (this.ParentDocumentId != null)
            {
                this.PostSilbingDocumentId = target.ParentDocument?.ChildDocuments.OrderBy(c => c.Priority).FirstOrDefault(c => c.Priority > target.Priority)?.DocumentId;
            }
            else
            {
                this.PostSilbingDocumentId = db.Documents.Where(c => c.ParentDocumentId == null && c.Priority > target.Priority).OrderBy(c => c.Priority).FirstOrDefault()?.DocumentId;
            }

            this.IsFinished = target.IsFinished;

            this.Title     = target.Title;
            this.NodeName  = target.NodeName;
            this.Priority  = target.Priority;
            this.IsChecked = target.IsChecked;
            //this.IsNoted = target.IsNoted;
            this.IsGetAllChildren = target.IsGetAllChildren;
            this.IsGetAllChapters = target.IsGetAllChapters;
            this.Url                = target.Url;
            this.DocumentTime       = target.DocumentTime;
            this.Remarks            = target.Remarks;
            this.MinutesToRead      = target.MinutesToRead;
            this.TotalMinutesToRead = target.TotalMinutesToRead;
            this.IsBookmarked       = target.IsBookmarked;
            this.IsBook             = target.IsBook;
            this.IsAbstract         = target.IsAbstract;
            this.IsMain             = target.IsMain;

            this.ListChildDocuments = target.ChildDocuments.OrderBy(c => c.Priority).ThenBy(c => c.DocumentId).Select(c => new ItemChildDocument(c)).ToList();

            this.ListChapters = target.Chapters.OrderBy(c => c.Priority).ThenBy(c => c.ChapterId).Select(c => new ItemChapter(c)).ToList();
        }
        public Create(Guid?parentDocumentId)
        {
            this.ParentDocumentId = parentDocumentId;

            var db             = new Domains.Entities.DMsDbContext();
            var parentDocument = db.Documents.Find(parentDocumentId);

            if (parentDocument == null)
            {
                this.Priority = db.Documents.Where(c => c.ParentDocumentId == null).Max(c => c.Priority) + 1;
            }
            else
            {
                this.Priority = parentDocument.ChildDocuments.Max(c => c.Priority) + 1;
            }
            if (this.Priority == null)
            {
                this.Priority = 1;
            }
        }
        public bool Do()
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(this.DocumentId);

            if (target == null)
            {
                return(false);
            }
            target.ParentDocumentId = NewParentId;
            target.UpdateTime       = DateTime.Now;
            try
            {
                db.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
예제 #14
0
        public Directory(Guid id)
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(id);

            while (!target.IsBookBook)
            {
                if (target.ParentDocument != null)
                {
                    target = target.ParentDocument;
                }
                else
                {
                    target = null;
                    break;
                }
            }
            ;

            this.Initial(target, id);
        }
예제 #15
0
        public bool SaveBookNormal()
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = db.Documents.Find(this.DocumentId);

            target.Title      = this.NodeName;
            target.NodeName   = this.NodeName;
            target.Priority   = this.Priority;
            target.Remarks    = this.Remarks;
            target.TimeStamp  = this.TimeStamp;
            target.UpdateTime = DateTime.Now;

            try
            {
                db.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
예제 #16
0
        public Tuple <bool, string> CreateChapter()
        {
            var db     = new Domains.Entities.DMsDbContext();
            var target = new Domains.Entities.Document();

            target.DocumentId       = this.DocumentId;
            target.ParentDocumentId = this.ParentDocumentId;
            target.Title            = this.Title;
            target.NodeName         = this.Title;
            target.Priority         = this.Priority;
            target.IsChecked        = false;
            target.Url                  = null;
            target.Remarks              = null;
            target.IsBook               = true;
            target.ISBN                 = null;
            target.IsAbstract           = false;
            target.IsMain               = false;
            target.UpdateTime           = DateTime.Now;
            target.UpdateTimeForHTTPGet = DateTime.Now;
            db.Documents.Add(target);
            db.SaveChanges();
            return(new Tuple <bool, string>(true, null));
        }