public static void ProcessNode(IndexWriter writer, IUDICO.Common.Models.Shared.Node node, ICourseService courseService) { Document document = new Document(); document.Add(new Field("Type", "Node", Field.Store.YES, Field.Index.NO)); document.Add(new Field("NodeID", node.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Name", node.Name, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); document.Add(new Field("NodeCourseID", node.CourseId.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("isFolder", node.IsFolder.ToString(), Field.Store.YES, Field.Index.ANALYZED)); if (node.IsFolder) { var nodes = courseService.GetNodes(node.CourseId, node.Id); foreach (IUDICO.Common.Models.Shared.Node childNode in nodes) { ProcessNode(writer, childNode, courseService); } } else { var content = courseService.GetNodeContents(node.Id); document.Add(new Field("Content", content, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); } writer.AddDocument(document); }
public NodeResult(Node node, string course, string text, string datetime) { this.node = node; this.text = text; this.course = course; this.dateTime = datetime; }
private void detach_Nodes(Node entity) { this.SendPropertyChanging(); entity.Course = null; }
private void attach_Nodes(Node entity) { this.SendPropertyChanging(); entity.Course = this; }
public void Update(string evt, params object[] data) { if (evt == LMSNotifications.ApplicationStart) { if (!isRun) { //mTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed); //mTimer.Start(); string root = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FullName; int index = root.IndexOf("\\Plugins"); root = root.Substring(0, index); serverPath = root.Insert(index, "\\Data\\Index"); RebuildIndex(data[0] as ILmsService); //var thread = new Thread(startMyTimer); //thread.Start(((IWindsorContainer)data[0]).Resolve<ILmsService>()); //isRun = true; } } if (evt == UserNotifications.UserCreate) { User user = (User)data[0]; Document document = new Document(); document.Add(new Field("Type", "User", Field.Store.YES, Field.Index.NO)); document.Add(new Field("UserID", user.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("User", user.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); AddToIndex(document); } if (evt == UserNotifications.UserEdit) { Update(UserNotifications.UserDelete, data[0]); Update(UserNotifications.UserCreate, data[1]); } if (evt == UserNotifications.UserDelete) { User user = (User)data[0]; Term term = new Term("UserID", user.Id.ToString()); DeleteFromIndex(term); } if (evt == DisciplineNotifications.DisciplineCreate) { Discipline discipline = (Discipline)data[0]; Document document = new Document(); document.Add(new Field("Type", "Discipline", Field.Store.YES, Field.Index.NO)); document.Add(new Field("DisciplineID", discipline.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Owner", discipline.Owner, Field.Store.YES, Field.Index.NO)); document.Add(new Field("Discipline", discipline.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); AddToIndex(document); } if (evt == DisciplineNotifications.DisciplineEdit) { Update(DisciplineNotifications.DisciplineDelete, data[0]); Update(DisciplineNotifications.DisciplineCreate, data[1]); } if (evt == DisciplineNotifications.DisciplineDelete) { Discipline discipline = (Discipline)data[0]; Term term = new Term("DisciplineID", discipline.Id.ToString()); DeleteFromIndex(term); } if (evt == DisciplineNotifications.TopicCreate) { Topic topic = (Topic)data[0]; Document document = new Document(); document = new Document(); document.Add(new Field("Type", "Topic", Field.Store.YES, Field.Index.NO)); document.Add(new Field("TopicID", topic.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Topic", topic.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); if (topic.TestCourseRef == null) { document.Add(new Field("CourseRef", "null", Field.Store.YES, Field.Index.NO)); } else { document.Add(new Field("CourseRef", topic.TestCourseRef.ToString(), Field.Store.YES, Field.Index.NO)); } AddToIndex(document); } if (evt == DisciplineNotifications.TopicEdit) { Update(DisciplineNotifications.TopicDelete, data[0]); Update(DisciplineNotifications.TopicCreate, data[1]); } if (evt == DisciplineNotifications.TopicDelete) { Topic topic = (Topic)data[0]; Term term = new Term("TopicID", topic.Id.ToString()); DeleteFromIndex(term); } if (evt == UserNotifications.GroupCreate) { Group group = (Group)data[0]; Document document = new Document(); document.Add(new Field("Type", "Group", Field.Store.YES, Field.Index.NO)); document.Add(new Field("GroupID", group.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Group", group.Name.ToString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); AddToIndex(document); } if (evt == UserNotifications.GroupEdit) { Update(UserNotifications.GroupDelete, data[0]); Update(UserNotifications.GroupCreate, data[1]); } if (evt == UserNotifications.GroupDelete) { Group group = (Group)data[0]; Term term = new Term("GroupID", group.Id.ToString()); DeleteFromIndex(term); } if (evt == CourseNotifications.NodeCreate) { Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(serverPath)); Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29); IndexWriter writer = new IndexWriter(directory, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED); ProcessNode(writer, (IUDICO.Common.Models.Shared.Node)data[0], (((IWindsorContainer)data[0]).Resolve <ILmsService>()).FindService <ICourseService>()); writer.Optimize(); writer.Close(); } if (evt == CourseNotifications.NodeEdit) { Update(CourseNotifications.NodeDelete, data[0]); Update(CourseNotifications.NodeCreate, data[1]); } if (evt == CourseNotifications.NodeDelete) { IUDICO.Common.Models.Shared.Node node = (IUDICO.Common.Models.Shared.Node)data[0]; Term term = new Term("NodeID", node.Id.ToString()); DeleteFromIndex(term); } if (evt == CourseNotifications.CourseCreate) { Course course = (Course)data[0]; Document document = new Document(); document.Add(new Field("Type", "Course", Field.Store.YES, Field.Index.NO)); document.Add(new Field("CourseID", course.Id.ToString(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Name", course.Name, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); document.Add(new Field("Owner", course.Owner, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES)); AddToIndex(document); } if (evt == CourseNotifications.CourseEdit) { Update(CourseNotifications.CourseDelete, data[0]); Update(CourseNotifications.CourseCreate, data[1]); } if (evt == CourseNotifications.CourseDelete) { Course course = (Course)data[0]; Term term = new Term("GroupID", course.Id.ToString()); DeleteFromIndex(term); } }