Beispiel #1
0
        public void Delete()
        {
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                SqlTransaction transaction;
                cn.Open();
                transaction = cn.BeginTransaction();
                try {
                    SqlCommand cmd = new SqlCommand("DELETE FROM cms_DocumentLink WHERE DocumentSerial = @DocumentSerial", cn, transaction);
                    cmd.Parameters.Add("@DocumentSerial", SqlDbType.Int).Value = _DocumentSerial;
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "DELETE FROM cms_Document WHERE DocumentSerial = @DocumentSerial";
                    cmd.ExecuteNonQuery();
                    transaction.Commit();
                } catch (SqlException sqlError) {
                    transaction.Rollback();
                    Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(sqlError));
                }
                cn.Close();
            }

            // Remove from Lucene search index
            Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
            li.CreateIndexWriter();
            li.Delete(DocumentID.ToString());
            li.Close();
        }
Beispiel #2
0
 private void UpdateIndex()
 {
     // Update Lucene search index
     Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
     li.CreateIndexWriter();
     li.UpdateWebPage(NewsID.ToString(), URL, Headline, Content ?? "", "News");
     li.Close();
     li.IndexWords();
 }
Beispiel #3
0
 private void UpdateIndex()
 {
     // Update Lucene search index
     Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
     li.CreateIndexWriter();
     li.UpdateWebPage(EventSerial.ToString(), URL, Headline, FullDescription ?? "", "Events");
     li.Close();
     li.IndexWords();
 }
Beispiel #4
0
 private void UpdateIndex()
 {
     // Update Lucene search index
     Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
     li.CreateIndexWriter();
     li.UpdateWebPage(ContentID.ToString(), URL, PageTitle, Contents, "Page");
     li.Close();
     li.IndexWords();
 }
Beispiel #5
0
        public int Add(Document document)
        {
            int DocumentSerial = 0;

            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                using (SqlCommand cmd = new SqlCommand("INSERT INTO cms_Document (ModuleID, Locale, DocumentCategorySerial, DocumentTitle, Description, SortOrder) OUTPUT Inserted.DocumentSerial VALUES (@ModuleID, @Locale, @DocumentCategorySerial, @DocumentTitle, @Description, @SortOrder)", cn)) {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("ModuleID", SqlDbType.UniqueIdentifier).Value  = _ModuleID;
                    cmd.Parameters.Add("Locale", SqlDbType.VarChar, 10).Value         = _Locale;
                    cmd.Parameters.Add("DocumentCategorySerial", SqlDbType.Int).Value = document.DocumentCategorySerial > 0 ? document.DocumentCategorySerial : SqlInt32.Null;
                    cmd.Parameters.Add("DocumentTitle", SqlDbType.NVarChar).Value     = document.DocumentTitle;
                    cmd.Parameters.Add("Description", SqlDbType.NVarChar).Value       = document.Description;
                    cmd.Parameters.Add("SortOrder", SqlDbType.Int).Value = document.SortOrder;

                    cmd.Connection.Open();
                    DocumentSerial = (int)cmd.ExecuteScalar();
                    cmd.Connection.Close();
                }
                using (SqlCommand cmd = new SqlCommand("INSERT INTO cms_DocumentLink (DocumentSerial, DocumentLink, FileName, LinkText, DocumentSize, IconFilename) VALUES (@DocumentSerial, @DocumentLink, @FileName, @LinkText, @DocumentSize, @IconFilename)", cn)) {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("DocumentSerial", SqlDbType.Int).Value         = DocumentSerial;
                    cmd.Parameters.Add("DocumentLink", SqlDbType.NVarChar, 350).Value = document.DocumentLink.Length > 0 ? document.DocumentLink : SqlString.Null;
                    cmd.Parameters.Add("FileName", SqlDbType.NVarChar, 250).Value     = document.Filename.Length > 0 ? document.Filename : SqlString.Null;
                    cmd.Parameters.Add("LinkText", SqlDbType.NVarChar, 250).Value     = document.LinkText.Length > 0 ? document.LinkText : SqlString.Null;
                    cmd.Parameters.Add("DocumentSize", SqlDbType.BigInt).Value        = document.Size > 0 ? document.Size : SqlInt64.Null;
                    cmd.Parameters.Add("IconFilename", SqlDbType.NVarChar, 250).Value = document.IconFilename.Length > 0 ? document.IconFilename : SqlString.Null;;

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

            // insert into Lucene search index
            Document newDoc = new Document(DocumentSerial);

            Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
            li.CreateIndexWriter();
            if (!string.IsNullOrEmpty(newDoc.DocumentTitle))
            {
                li.UpdateWebPage(newDoc.DocumentID.ToString(), newDoc.URL, newDoc.DocumentTitle, newDoc.Description, "Document");
            }
            else
            {
                li.UpdateWebPage(newDoc.DocumentID.ToString(), newDoc.URL, newDoc.LinkText, newDoc.Description, "Document");
            }
            li.Close();
            li.IndexWords();

            return(DocumentSerial);
        }
Beispiel #6
0
 private void UpdateIndex()
 {
     // Update Lucene search index
     Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
     li.CreateIndexWriter();
     if (!string.IsNullOrEmpty(DocumentTitle))
     {
         li.UpdateWebPage(DocumentID.ToString(), URL, DocumentTitle, Description, "Document");
     }
     else
     {
         li.UpdateWebPage(DocumentID.ToString(), URL, LinkText, Description, "Document");
     }
     li.Close();
     li.IndexWords();
 }
Beispiel #7
0
        public int Add(EventViewModel data)
        {
            int EventSerial = 0;

            if (_ModuleID != Guid.Empty)
            {
                Guid EventID = Guid.NewGuid();
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                    string SQL = "INSERT INTO [cms_Event] ([EventID],[ModuleID],[Headline],[ShortDescription],[FullDescription],[PreEventDescription],[EventDate],[EventLocation],[EventTimespan],[EventLink],[IconFilename],[IconFilename2],[EventPlayback]) " +
                                 "OUTPUT INSERTED.EventSerial " +
                                 "VALUES (@EventID, @ModuleID, @Headline, @ShortDescription, @FullDescription, @PreEventDescription, @EventDate, @EventLocation, @EventTimespan, @EventLink, @IconFilename, @IconFilename2, @EventPlayback)";
                    using (SqlCommand cmd = new SqlCommand(SQL, cn)) {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Add("@EventID", SqlDbType.UniqueIdentifier).Value     = EventID;
                        cmd.Parameters.Add("@ModuleID", SqlDbType.UniqueIdentifier).Value    = _ModuleID;
                        cmd.Parameters.Add("@Headline", SqlDbType.NVarChar).Value            = data.Headline + "";
                        cmd.Parameters.Add("@ShortDescription", SqlDbType.NVarChar).Value    = data.ShortDescription + "";
                        cmd.Parameters.Add("@FullDescription", SqlDbType.NVarChar).Value     = data.FullDescription + "";
                        cmd.Parameters.Add("@PreEventDescription", SqlDbType.NVarChar).Value = data.PreEventDescription + "";
                        cmd.Parameters.Add("@EventDate", SqlDbType.Date).Value             = data.EventDate + "";
                        cmd.Parameters.Add("@EventLocation", SqlDbType.NVarChar).Value     = data.EventLocation + "";
                        cmd.Parameters.Add("@EventTimespan", SqlDbType.NVarChar).Value     = data.EventTimespan + "";
                        cmd.Parameters.Add("@EventLink", SqlDbType.NVarChar, 500).Value    = data.EventLink + "";
                        cmd.Parameters.Add("@IconFilename", SqlDbType.VarChar, 250).Value  = data.IconFileName + "";
                        cmd.Parameters.Add("@IconFilename2", SqlDbType.VarChar, 250).Value = data.IconFileName2 + "";
                        cmd.Parameters.Add("@EventPlayback", SqlDbType.NVarChar).Value     = data.EventPlayback + "";

                        cmd.Connection.Open();
                        EventSerial = (int)cmd.ExecuteScalar();
                        cmd.Connection.Close();
                    }
                }

                // Update Lucene search index
                Event newEvent = new Event(EventID);
                EventSerial = newEvent.EventSerial;
                Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
                li.CreateIndexWriter();
                li.UpdateWebPage(EventID.ToString(), newEvent.URL, newEvent.Headline, newEvent.FullDescription, "Event");
                li.Close();
                li.IndexWords();
            }
            return(EventSerial);
        }
Beispiel #8
0
        public void Delete()
        {
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                using (SqlCommand cmd = new SqlCommand("DELETE FROM cms_News WHERE NewsSerial = @NewsSerial", cn)) {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add("@NewsSerial", SqlDbType.Int).Value = _NewsSerial;

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

            // Remove from Lucene search index
            Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
            li.CreateIndexWriter();
            li.Delete(NewsID.ToString());
            li.Close();
        }
Beispiel #9
0
        public int Add(NewsModel news)
        {
            int NewsSerial = 0;

            if (_ModuleID != Guid.Empty)
            {
                Guid NewsID = Guid.NewGuid();
                using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) {
                    string SQL = "INSERT INTO cms_News (NewsID, ModuleID, Headline, HeaderImage, ShortDescription, Content, AttachedArticle, LinkedArticle, IsFeatured, IsPublished, DateReleased) " +
                                 "VALUES (@NewsID, @ModuleID, @Headline, @HeaderImage, @ShortDescription, @Content, @AttachedArticle, @LinkedArticle, @IsFeatured, @IsPublished, @DateReleased)";
                    using (SqlCommand cmd = new SqlCommand(SQL, cn)) {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Add("@NewsID", SqlDbType.UniqueIdentifier).Value   = NewsID;
                        cmd.Parameters.Add("@ModuleID", SqlDbType.UniqueIdentifier).Value = _ModuleID;
                        cmd.Parameters.Add("@Headline", SqlDbType.NVarChar).Value         = news.Headline;
                        cmd.Parameters.Add("@HeaderImage", SqlDbType.NVarChar).Value      = news.HeaderImage ?? SqlString.Null;
                        cmd.Parameters.Add("@ShortDescription", SqlDbType.NVarChar).Value = news.ShortDescription ?? SqlString.Null;
                        cmd.Parameters.Add("@Content", SqlDbType.NVarChar).Value          = news.Content ?? SqlString.Null;
                        cmd.Parameters.Add("@AttachedArticle", SqlDbType.NVarChar).Value  = news.AttachedArticle ?? SqlString.Null;
                        cmd.Parameters.Add("@LinkedArticle", SqlDbType.NVarChar).Value    = news.LinkedArticle ?? SqlString.Null;
                        cmd.Parameters.Add("@IsFeatured", SqlDbType.Bit).Value            = news.IsFeatured ? 1 : 0;
                        cmd.Parameters.Add("@IsPublished", SqlDbType.Bit).Value           = news.IsPublished ? 1 : 0;
                        cmd.Parameters.Add("@DateReleased", SqlDbType.Date).Value         = news.DateReleased;

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

                // Update Lucene search index
                News newNews = new News(NewsID);
                NewsSerial = newNews.NewsSerial;
                Indexer.LuceneIndexer li = new Indexer.LuceneIndexer();
                li.CreateIndexWriter();
                li.UpdateWebPage(NewsID.ToString(), newNews.URL, newNews.Headline, newNews.Content, "News");
                li.Close();
                li.IndexWords();
            }
            return(NewsSerial);
        }