예제 #1
0
 public ConceptViewData(LMPlatform.Models.Concept concept, Boolean buildTree)
     : this(concept)
 {
     if (buildTree)
     {
         Children = new List <ConceptViewData>();
         InitTree(concept, concept.Children);
     }
 }
예제 #2
0
 private void FindRootId(Concept concept, out Int32 elementId)
 {
     var c = GetById(concept.ParentId.GetValueOrDefault());
     if (!concept.ParentId.HasValue)
     {
         elementId = concept.Id;
         return;
     }
     else
         FindRootId(c, out elementId);
 }
예제 #3
0
 private void InitTree(LMPlatform.Models.Concept concept, ICollection <LMPlatform.Models.Concept> ch)
 {
     if (ch != null && ch.Any())
     {
         Children = ch.Select(c => new ConceptViewData(c, true)).ToList();
     }
     else
     {
         return;
     }
 }
예제 #4
0
 public ConceptViewData(LMPlatform.Models.Concept concept)
 {
     Id        = concept.Id;
     Name      = concept.Name;
     ShortName = concept.Name.Length <= 20 ? concept.Name : String.Format("{0}...", concept.Name.Substring(0, 20));
     Container = concept.Container;
     ParentId  = concept.ParentId.GetValueOrDefault();
     IsGroup   = concept.IsGroup;
     Published = (concept.IsGroup && concept.Children.Any() && concept.Children.All(c => c.Published)) || (!concept.IsGroup && concept.Published);
     ReadOnly  = concept.ReadOnly;
     HasData   = !String.IsNullOrEmpty(Container);
 }
 private void InitSourceConcept()
 {
     SourceConcept = new Concept()
     {
         Id = this.Id,
         Name = this.Name,
         Container = this.Container,
         IsGroup = this.IsGroup,
         Published = this.Published,
         ReadOnly = this.ReadOnly,
         SubjectId = this.SelectedSubjectId,
         UserId = this.Author,
         ParentId = this.ParentId,
         PrevConcept = this.Prev,
         NextConcept = this.Next
     };
 }
예제 #6
0
 private void InitPractChild(Concept parent, LmPlatformRepositoriesContainer repositoriesContainer)
 {
     var sub = SubjectManagementService.GetSubject(parent.SubjectId);
     if (sub.SubjectModules.Any(m => m.Module.ModuleType == ModuleType.Practical))
         foreach (var item in sub.Practicals.OrderBy(s=>s.Order))
         {
             var concept = new Concept(item.Theme, parent.Author, parent.Subject, true, false);
             concept.ParentId = parent.Id;
             repositoriesContainer.ConceptRepository.Save(concept);
         }
     else if (sub.SubjectModules.Any(m => m.Module.ModuleType == ModuleType.Labs))
         foreach (var item in sub.Labs.OrderBy(s => s.Order))
         {
             var concept = new Concept(item.Theme, parent.Author, parent.Subject, true, false);
             concept.ParentId = parent.Id;
             repositoriesContainer.ConceptRepository.Save(concept);
         }
 }
예제 #7
0
 private void InitLectChild(Concept parent, LmPlatformRepositoriesContainer repositoriesContainer)
 {
     var sub = SubjectManagementService.GetSubject(parent.SubjectId);
     foreach (var item in sub.Lectures.OrderBy(s => s.Order))
     {
         var concept = new Concept(item.Theme, parent.Author, parent.Subject, true, false);
         concept.ParentId = parent.Id;
         repositoriesContainer.ConceptRepository.Save(concept);
     }
 }
예제 #8
0
        private void InitBaseChildrens(Concept parent, LmPlatformRepositoriesContainer repositoriesContainer)
        {
            var concept1 = new Concept("Титульный экран", parent.Author, parent.Subject, false, false);
            concept1.ParentId = parent.Id;
            concept1.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept1);

            var concept2 = new Concept("Программа курса", parent.Author, parent.Subject, false, false);
            concept2.ParentId = parent.Id;
            concept2.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept2);

            var concept3 = new Concept(LectSectionName, parent.Author, parent.Subject, true, false);
            concept3.ParentId = parent.Id;
            concept3.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept3);
            InitLectChild(concept3, repositoriesContainer);

            var concept4 = new Concept(LabSectionName, parent.Author, parent.Subject, true, false);
            concept4.ParentId = parent.Id;
            concept4.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept4);
            InitPractChild(concept4, repositoriesContainer);

            var concept5 = new Concept("Блок контроля знаний", parent.Author, parent.Subject, true, false);
            concept5.ParentId = parent.Id;
            concept5.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept5);
            repositoriesContainer.ApplyChanges();
        }
 private void InitNeighborConcept(Concept concept, LmPlatformRepositoriesContainer repositoriesContainer)
 {
     var siblings = repositoriesContainer.ConceptRepository.GetByParentId(concept.ParentId.Value);
     var sibling = siblings.OrderByDescending(t => t.Id).FirstOrDefault(c=>c.Id!=concept.Id);
     if(sibling!=null)
     {
         concept.PrevConcept = sibling.Id;
     }
 }
예제 #10
0
        private void AttachFolderToSection(String folderName, Int32 userId, Int32 subjectId, String sectionName)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var parent = repositoriesContainer.ConceptRepository.GetBy(
                    new Query<Concept>()
                    .AddFilterClause(f => f.SubjectId == subjectId)
                    .AddFilterClause(f => f.UserId == userId)
                    .AddFilterClause(f => String.Compare(f.Name.Trim(), sectionName.Trim(), true) == 0)
                    .Include(c => c.Author)
                    .Include(c => c.Subject));

                var concept = new Concept(folderName, parent.Author, parent.Subject, true, false);
                concept.ParentId = parent.Id;
                repositoriesContainer.ConceptRepository.Save(concept);
            }
        }
예제 #11
0
        public Concept SaveConcept(Concept concept, IList<Attachment> attachments)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                //attachments = ProcessWordAttachmentsIfExist(attachments);
                if (!string.IsNullOrEmpty(concept.Container))
                {
                    var deleteFiles =
                        repositoriesContainer.AttachmentRepository.GetAll(
                            new Query<Attachment>(e => e.PathName == concept.Container)).ToList().Where(e => attachments.All(x => x.Id != e.Id)).ToList();

                    foreach (var attachment in deleteFiles)
                    {
                        FilesManagementService.DeleteFileAttachment(attachment);
                    }
                }
                else
                {
                    concept.Container = GetGuidFileName();
                }

                FilesManagementService.SaveFiles(attachments.Where(e => e.Id == 0), concept.Container);

                foreach (var attachment in attachments)
                {
                    if (attachment.Id == 0)
                    {
                        attachment.PathName = concept.Container;

                        repositoriesContainer.AttachmentRepository.Save(attachment);
                    }
                }
                concept.Published = attachments.Any();
                Concept source = null;
                if (concept.Id != 0)
                    source = GetById(concept.Id);
                repositoriesContainer.ConceptRepository.Save(concept);
                repositoriesContainer.ApplyChanges();
                BindNeighborConcept(concept, source, repositoriesContainer);
                TryPublishParent(concept.ParentId, repositoriesContainer);
                return concept;
            }
        }
예제 #12
0
        private void BindNeighborConcept(Concept concept, Concept sourceConcept, LmPlatformRepositoriesContainer repositoriesContainer)
        {
            if (concept.PrevConcept.HasValue)
            {
                var leftConcept = repositoriesContainer.ConceptRepository.GetById(concept.PrevConcept.Value);
                leftConcept.NextConcept = concept.Id;
                repositoriesContainer.ConceptRepository.Save(leftConcept);
                repositoriesContainer.ApplyChanges();
            }
            if (!concept.PrevConcept.HasValue && sourceConcept != null && sourceConcept.PrevConcept.HasValue)
            {
                var leftConcept = repositoriesContainer.ConceptRepository.GetById(sourceConcept.PrevConcept.Value);
                leftConcept.NextConcept = null;
                repositoriesContainer.ConceptRepository.Save(leftConcept);
                repositoriesContainer.ApplyChanges();
            }

            if (concept.NextConcept.HasValue)
            {
                var rightConcept = repositoriesContainer.ConceptRepository.GetById(concept.NextConcept.Value);
                rightConcept.PrevConcept = concept.Id;
                repositoriesContainer.ConceptRepository.Save(rightConcept);
                repositoriesContainer.ApplyChanges();
            }
            if (!concept.NextConcept.HasValue && sourceConcept != null && sourceConcept.NextConcept.HasValue)
            {
                var rightConcept = repositoriesContainer.ConceptRepository.GetById(sourceConcept.NextConcept.Value);
                rightConcept.PrevConcept = null;
                repositoriesContainer.ConceptRepository.Save(rightConcept);
                repositoriesContainer.ApplyChanges();
            }
        }
예제 #13
0
        public Concept SaveConcept(Concept concept)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                Concept source = null;
                if (concept.Id != 0)
                    source = GetById(concept.Id);

                repositoriesContainer.ConceptRepository.Save(concept);
                repositoriesContainer.ApplyChanges();
                BindNeighborConcept(concept, source, repositoriesContainer);
                return concept;
            }
        }
 private void InitLectChild(Concept parent, LmPlatformRepositoriesContainer repositoriesContainer)
 {
     var sub = SubjectManagementService.GetSubject(parent.SubjectId);
     Concept prev = null;
     foreach (var item in sub.Lectures.OrderBy(s => s.Order))
     {
         var concept = new Concept(item.Theme, parent.Author, parent.Subject, true, false);
         concept.ParentId = parent.Id;
         concept.LectureId = item.Id;
         repositoriesContainer.ConceptRepository.Save(concept);
         if (prev != null)
         {
             concept.PrevConcept = prev.Id;
             prev.NextConcept = concept.Id;
             repositoriesContainer.ConceptRepository.Save(prev);
             repositoriesContainer.ConceptRepository.Save(concept);
         }
         prev = concept;
     }
 }
        private void InitBaseChildrens(Concept parent, LmPlatformRepositoriesContainer repositoriesContainer)
        {
            var concept1 = new Concept(TitlePageSectionName, parent.Author, parent.Subject, false, false);
            concept1.ParentId = parent.Id;
            concept1.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept1);

            var concept2 = new Concept(ProgramSectionName, parent.Author, parent.Subject, false, false);
            concept2.ParentId = parent.Id;
            concept2.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept2);

            concept1.NextConcept = concept2.Id;
            concept2.PrevConcept = concept1.Id;

            var concept3 = new Concept(LectSectionName, parent.Author, parent.Subject, true, false);
            concept3.ParentId = parent.Id;
            concept3.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept3);
            InitLectChild(concept3, repositoriesContainer);

            concept2.NextConcept = concept3.Id;
            concept3.PrevConcept = concept2.Id;

            var concept4 = new Concept(LabSectionName, parent.Author, parent.Subject, true, false);
            concept4.ParentId = parent.Id;
            concept4.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept4);
            InitPractChild(concept4, repositoriesContainer);

            concept3.NextConcept = concept4.Id;
            concept4.PrevConcept = concept3.Id;

            var concept5 = new Concept(TestSectionName, parent.Author, parent.Subject, true, false);
            concept5.ParentId = parent.Id;
            concept5.ReadOnly = true;
            repositoriesContainer.ConceptRepository.Save(concept5);

            concept5.PrevConcept = concept4.Id;
            concept4.NextConcept = concept5.Id;
            repositoriesContainer.ApplyChanges();

            
        }
예제 #16
0
        public Concept CreateRootConcept(String name, Int32 authorId, Int32 subjectId)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                var author = repositoriesContainer.UsersRepository.GetBy(new Query<User>().AddFilterClause(u => u.Id == authorId));
                var subject = repositoriesContainer.SubjectRepository.GetBy(new Query<Subject>().AddFilterClause(s => s.Id == subjectId));
                var concept = new Concept(name, author, subject, true, false);

                repositoriesContainer.ConceptRepository.Save(concept);
                repositoriesContainer.ApplyChanges();
                InitBaseChildrens(concept, repositoriesContainer);
                return repositoriesContainer.ConceptRepository.GetBy
                    (new Query<Concept>()
                    .AddFilterClause(c => c.Id == concept.Id));
            }
        }
        public Concept SaveConcept(Concept concept)
        {
            using (var repositoriesContainer = new LmPlatformRepositoriesContainer())
            {
                Concept lastSibling = null;
                if (concept.IsNew)
                {
                    lastSibling = GetLastSibling(concept.ParentId.GetValueOrDefault());
                    if (lastSibling!=null)
                        concept.PrevConcept = lastSibling.Id;
                }

                repositoriesContainer.ConceptRepository.Save(concept);
                if(lastSibling!=null)
                {
                    lastSibling.NextConcept = concept.Id;
                    repositoriesContainer.ConceptRepository.Save(lastSibling);
                }
                repositoriesContainer.ApplyChanges();
                //BindNeighborConcept(concept, source, repositoriesContainer);
                return concept;
            }
        }