Esempio n. 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();
        }
Esempio n. 2
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();
        }