Example #1
0
        public void Add(Faq faq)
        {
            if (_ModuleID != Guid.Empty)
            {
                Guid FaqID = Guid.NewGuid();
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                    using (SqlCommand cmd = new SqlCommand("INSERT INTO cms_FAQ (FaqID, ModuleID, Locale, FAQCategorySerial, Question, Answer, SortOrder) VALUES (@FaqID, @ModuleID, @Locale, @FAQCategorySerial, @Question, @Answer, @SortOrder)", cn)) {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Add("FaqID", SqlDbType.UniqueIdentifier).Value    = FaqID;
                        cmd.Parameters.Add("ModuleID", SqlDbType.UniqueIdentifier).Value = _ModuleID;
                        cmd.Parameters.Add("Locale", SqlDbType.VarChar, 10).Value        = _Locale;
                        cmd.Parameters.Add("FAQCategorySerial", SqlDbType.Int).Value     = faq.FAQCategorySerial > 0 ? faq.FAQCategorySerial : SqlInt32.Null;
                        cmd.Parameters.Add("Question", SqlDbType.VarChar).Value          = faq.Question;
                        cmd.Parameters.Add("Answer", SqlDbType.VarChar).Value            = faq.Answer;
                        cmd.Parameters.Add("SortOrder", SqlDbType.Int).Value             = faq.SortOrder;

                        cmd.Connection.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                    }
                }

                // Update Lucene search index
                Faq           newFaq = new Faq(FaqID);
                LuceneIndexer li     = new LuceneIndexer();
                li.CreateIndexWriter();
                li.UpdateWebPage(FaqID.ToString(), newFaq.URL, newFaq.Question, newFaq.Question + " " + newFaq.Answer, "FAQ");
                li.Close();
                li.IndexWords();
            }
        }
Example #2
0
        private void UpdateIndex()
        {
            // Update Lucene search index
            LuceneIndexer li = new LuceneIndexer();

            li.CreateIndexWriter();
            li.UpdateWebPage(FaqID.ToString(), URL, Question, Question + " " + Answer, "FAQ");
            li.Close();
            li.IndexWords();
        }
        public ActionResult Index(FormCollection data)
        {
            LuceneIndexer li = new LuceneIndexer();

            li.DeleteIndex(false);
            li.CreateIndexWriter();

            //Index blog posts
            BlogPosts blogPosts = new BlogPosts("en-US");

            foreach (BlogPostViewModel blogPost in blogPosts.EveryPost())
            {
                li.AddWebPage(blogPost.PostID.ToString(), blogPost.URL, blogPost.Title, blogPost.PostContent, "Blog");
            }

            ////Index Documents
            //DocumentSet docs = new DocumentSet("en-US");
            //foreach (TKS.Document doc in docs.Documents()) {
            //	if (!string.IsNullOrEmpty(doc.DocumentTitle)) {
            //		li.AddWebPage(doc.DocumentID.ToString(), doc.URL, doc.DocumentTitle, doc.Description, "Document");
            //	} else {
            //		li.AddWebPage(doc.DocumentID.ToString(), doc.URL, doc.LinkText, doc.Description, "Document");
            //	}
            //}

            ////Index FAQs
            //FaqSet faqs = new FaqSet("en-US");
            //foreach (Faq faq in faqs.FAQs()) {
            //	li.AddWebPage(faq.FaqID.ToString(), faq.URL, faq.Question, faq.Question + " " + faq.Answer, "FAQ");
            //}

            ////Index News
            //NewsSet newsSet = new NewsSet();
            //foreach (News news in newsSet.News()) {
            //	li.AddWebPage(news.NewsID.ToString(), news.URL, news.Headline, news.Content, "News");
            //}

            //Index Content Blocks
            ContentTextSet contentSet = new ContentTextSet("en-US");

            foreach (ContentText content in contentSet.AllContentTextBlocks())
            {
                li.AddWebPage(content.ContentID.ToString(), content.URL, content.PageTitle, content.Contents, "Page");
            }

            li.Close();
            li.IndexWords();

            return(View());
        }
Example #4
0
        public void Delete()
        {
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                using (SqlCommand cmd = new SqlCommand("DELETE FROM cms_FAQ WHERE FaqSerial = @FaqSerial", cn)) {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("FaqSerial", SqlDbType.Int).Value = _FaqSerial;
                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
            }

            // Remove from Lucene search index
            LuceneIndexer li = new LuceneIndexer();

            li.CreateIndexWriter();
            li.Delete(FaqID.ToString());
            li.Close();
        }