Пример #1
0
        public ActionResult Process()
        {
            GetCoursesMessage message = new GetCoursesMessage();

            MvcContrib.Bus.Send(message);

            List <Course> courses = (message.Result.Data as List <Course>);

            if (courses == null)
            {
                return(RedirectToAction("Index"));
            }

            Directory   directory = FSDirectory.Open(new System.IO.DirectoryInfo(Server.MapPath("~/Data/Index")));
            Analyzer    analyzer  = new StandardAnalyzer(Version.LUCENE_29);
            IndexWriter writer    = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
            Document    document;

            try
            {
                foreach (Course course in courses)
                {
                    document = new Document();

                    document.Add(new Field("Type", "Course", Field.Store.YES, Field.Index.NO));
                    document.Add(new Field("ID", course.Id.ToString(), Field.Store.YES, Field.Index.NO));
                    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));

                    writer.AddDocument(document);

                    GetNodesMessage courseMessage = new GetNodesMessage {
                        Input = new GetNodesInput {
                            CourseId = course.Id
                        }
                    };
                    MvcContrib.Bus.Send(courseMessage);

                    List <Node> nodes = (courseMessage.Result.Data as List <Node>);

                    foreach (Node node in nodes)
                    {
                        ProcessNode(writer, node);
                    }
                }
            }
            catch (Exception e)
            {
                writer.Optimize();
                writer.Close();

                throw e;
            }

            writer.Optimize();
            writer.Close();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public List <Course> GetCourses()
        {
            GetCoursesMessage message = new GetCoursesMessage {
            };

            MvcContrib.Bus.Send(message);

            return(message.Result.Data as List <Course>);
            //ICourseManagment m = LMS.GetService(typeof(ICourseManagment)) as ICourseManagment;
            //return m.getCources();
        }
Пример #3
0
        public ActionResult Process()
        {
            GetCoursesMessage message = new GetCoursesMessage();
            MvcContrib.Bus.Send(message);

            List<Course> courses = (message.Result.Data as List<Course>);

            if (courses == null)
                return RedirectToAction("Index");

            Directory directory = FSDirectory.Open(new System.IO.DirectoryInfo(Server.MapPath("~/Data/Index")));
            Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
            IndexWriter writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
            Document document;

            try
            {

                foreach (Course course in courses)
                {
                    document = new Document();

                    document.Add(new Field("Type", "Course", Field.Store.YES, Field.Index.NO));
                    document.Add(new Field("ID", course.Id.ToString(), Field.Store.YES, Field.Index.NO));
                    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));

                    writer.AddDocument(document);

                    GetNodesMessage courseMessage = new GetNodesMessage { Input = new GetNodesInput { CourseId = course.Id } };
                    MvcContrib.Bus.Send(courseMessage);

                    List<Node> nodes = (courseMessage.Result.Data as List<Node>);

                    foreach (Node node in nodes)
                    {
                        ProcessNode(writer, node);
                    }
                }
            }
            catch (Exception e)
            {
                writer.Optimize();
                writer.Close();

                throw e;
            }

            writer.Optimize();
            writer.Close();

            return RedirectToAction("Index");
        }
Пример #4
0
        public List<Course> GetCourses()
        {
            GetCoursesMessage message = new GetCoursesMessage { };
            MvcContrib.Bus.Send(message);

            return message.Result.Data as List<Course>;
            //ICourseManagment m = LMS.GetService(typeof(ICourseManagment)) as ICourseManagment;
            //return m.getCources();
        }