Beispiel #1
0
 /// <summary>
 /// 调用存储过程增加一个
 /// </summary>
 /// <param name="info">实体对象</param>
 /// <returns>正常返回大于 0 的自增id, 0代表重复,否则返回-1</returns>
 public static int ArticleAdd(Entity.Article info)
 {
     SqlParameter[] prams =
     {
         SqlDB.MakeInParam("@CategoryId",      SqlDbType.Int,         4, info.CategoryId),
         SqlDB.MakeInParam("@Icon",            SqlDbType.NVarChar,  200, info.Icon),
         SqlDB.MakeInParam("@Title",           SqlDbType.NVarChar,  200, info.Title),
         SqlDB.MakeInParam("@ShortTitle",      SqlDbType.NVarChar,  200, info.ShortTitle),
         SqlDB.MakeInParam("@MetaTitle",       SqlDbType.NVarChar,  200, info.MetaTitle),
         SqlDB.MakeInParam("@MetaKeyWords",    SqlDbType.NVarChar,  500, info.MetaKeyWords),
         SqlDB.MakeInParam("@MetaDescription", SqlDbType.NVarChar,  300, info.MetaDescription),
         SqlDB.MakeInParam("@Summary",         SqlDbType.NVarChar, 2000, info.Summary),
         SqlDB.MakeInParam("@Content",         SqlDbType.NVarChar,    0, info.Content),
         SqlDB.MakeInParam("@IsPause",         SqlDbType.Int,         4, info.IsPause),
         SqlDB.MakeInParam("@IsTuiJian",       SqlDbType.Int,         4, info.IsTuiJian),
         SqlDB.MakeInParam("@IsNew",           SqlDbType.Int,         4, info.IsNew),
         SqlDB.MakeInParam("@IsZhiDing",       SqlDbType.Int,         4, info.IsZhiDing),
         SqlDB.MakeInParam("@ZhiDingTime",     SqlDbType.DateTime,    8, info.ZhiDingTime),
         SqlDB.MakeInParam("@PublishTime",     SqlDbType.DateTime,    8, info.PublishTime),
         SqlDB.MakeInParam("@AddTime",         SqlDbType.DateTime,    8, info.AddTime),
         SqlDB.MakeInParam("@AddWid",          SqlDbType.Int,         4, info.AddWid),
         SqlDB.MakeInParam("@IsCheck",         SqlDbType.Int,         4, info.IsCheck),
         SqlDB.MakeInParam("@CheckTime",       SqlDbType.DateTime,    8, info.CheckTime),
         SqlDB.MakeInParam("@CheckWid",        SqlDbType.Int,         4, info.CheckWid),
         SqlDB.MakeInParam("@ClickNum",        SqlDbType.Int,         4, info.ClickNum),
     };
     return(Basic.Utils.StrToInt(SqlDB.ExecuteScalar(CommandType.StoredProcedure, "ArticleAdd", prams).ToString(), -1));
 }
Beispiel #2
0
        /// <summary>
        /// 暂停该值
        /// </summary>
        /// <param name="Id">自增id的值</param>
        /// <returns>暂停成功返回ture,否则返回false</returns>
        public static bool ArticlePause(Entity.Article info)
        {
            int intReturnValue = 0;

            intReturnValue = SqlDB.ExecuteNonQuery(CommandType.Text, "UPDATE [Article] SET IsPause = " + info.IsPause + "  WHERE Id =  " + info.Id);
            if (intReturnValue == 1)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        public void Update_Article(int p_Article_ID, int p_Article_ClassID, int p_Article_LanguageID, string p_Article_Content)
        {
            Entity.Article e_Article = new Entity.Article();

            e_Article.Article_ID = p_Article_ID;
            e_Article.Article_ClassID = p_Article_ClassID;
            e_Article.Article_LanguageID = p_Article_LanguageID;
            e_Article.Article_Content = FilterUtility.FilterSQL(p_Article_Content);
            e_Article.Article_AddTime = DateTime.Now;

            d_Article.Update_Article(e_Article);
        }
Beispiel #4
0
        public Entity.Article Select_Article(int p_Article_ClassID, int p_Article_LanguageID)
        {
            DataTable o_DataTable = d_Article.Select_Article(p_Article_ClassID, p_Article_LanguageID);
            if (o_DataTable == null)
                return null;
            else
            {
                Entity.Article e_Article = new Entity.Article();

                e_Article.Article_ID = Convert.ToInt32(o_DataTable.Rows[0]["Article_ID"].ToString());
                e_Article.Article_ClassID = Convert.ToInt32(o_DataTable.Rows[0]["Article_ClassID"].ToString());
                e_Article.Article_LanguageID = Convert.ToInt32(o_DataTable.Rows[0]["Article_LanguageID"].ToString());
                e_Article.Article_Content = o_DataTable.Rows[0]["Article_Content"].ToString();
                e_Article.Article_AddTime = DateTime.Parse(o_DataTable.Rows[0]["Article_AddTime"].ToString());

                return e_Article;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取某一个实体
        /// </summary>
        /// <param name="Id">标识</param>
        /// <returns>返回Entity</returns>
        public static Entity.Article ArticleEntityGet(int Id)
        {
            Entity.Article info = new Entity.Article();
            DataTable      dt   = SqlDB.ExecuteDataset(CommandType.Text, "SELECT * FROM [Article] WHERE Id = " + Id + ";").Tables[0];

            if (dt.Rows.Count > 0)
            {
                info.Id              = Basic.Utils.StrToInt(dt.Rows[0]["Id"].ToString(), 0);
                info.CategoryId      = Basic.Utils.StrToInt(dt.Rows[0]["CategoryId"].ToString(), 0);
                info.Icon            = dt.Rows[0]["Icon"].ToString();
                info.Title           = dt.Rows[0]["Title"].ToString();
                info.ShortTitle      = dt.Rows[0]["ShortTitle"].ToString();
                info.MetaTitle       = dt.Rows[0]["MetaTitle"].ToString();
                info.MetaKeyWords    = dt.Rows[0]["MetaKeyWords"].ToString();
                info.MetaDescription = dt.Rows[0]["MetaDescription"].ToString();
                info.Summary         = dt.Rows[0]["Summary"].ToString();
                info.Content         = dt.Rows[0]["Content"].ToString();
                info.IsPause         = Basic.Utils.StrToInt(dt.Rows[0]["IsPause"].ToString(), 0);
                info.IsTuiJian       = Basic.Utils.StrToInt(dt.Rows[0]["IsTuiJian"].ToString(), 0);
                info.IsNew           = Basic.Utils.StrToInt(dt.Rows[0]["IsNew"].ToString(), 0);
                info.IsZhiDing       = Basic.Utils.StrToInt(dt.Rows[0]["IsZhiDing"].ToString(), 0);
                info.AddWid          = Basic.Utils.StrToInt(dt.Rows[0]["AddWid"].ToString(), 0);
                info.IsCheck         = Basic.Utils.StrToInt(dt.Rows[0]["IsCheck"].ToString(), 0);
                info.CheckWid        = Basic.Utils.StrToInt(dt.Rows[0]["CheckWid"].ToString(), 0);
                info.ClickNum        = Basic.Utils.StrToInt(dt.Rows[0]["ClickNum"].ToString(), 0);
                info.AddTime         = Basic.Utils.StrToDateTime(dt.Rows[0]["AddTime"].ToString());
                info.CheckTime       = Basic.Utils.StrToDateTime(dt.Rows[0]["CheckTime"].ToString());
                info.PublishTime     = Basic.Utils.StrToDateTime(dt.Rows[0]["PublishTime"].ToString());
                info.ZhiDingTime     = Basic.Utils.StrToDateTime(dt.Rows[0]["ZhiDingTime"].ToString());

                return(info);
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 调用存储过程修改一个
        /// </summary>
        /// <param name="info">实体对象</param>
        /// <returns>更新成功返回ture,否则返回false</returns>
        public static bool ArticleEdit(Entity.Article info)
        {
            SqlParameter[] prams =
            {
                SqlDB.MakeInParam("@Id",              SqlDbType.Int,         4, info.Id),
                SqlDB.MakeInParam("@CategoryId",      SqlDbType.Int,         4, info.CategoryId),
                SqlDB.MakeInParam("@Icon",            SqlDbType.NVarChar,  200, info.Icon),
                SqlDB.MakeInParam("@Title",           SqlDbType.NVarChar,  200, info.Title),
                SqlDB.MakeInParam("@ShortTitle",      SqlDbType.NVarChar,  200, info.ShortTitle),
                SqlDB.MakeInParam("@MetaTitle",       SqlDbType.NVarChar,  200, info.MetaTitle),
                SqlDB.MakeInParam("@MetaKeyWords",    SqlDbType.NVarChar,  500, info.MetaKeyWords),
                SqlDB.MakeInParam("@MetaDescription", SqlDbType.NVarChar,  300, info.MetaDescription),
                SqlDB.MakeInParam("@Summary",         SqlDbType.NVarChar, 2000, info.Summary),
                SqlDB.MakeInParam("@Content",         SqlDbType.NVarChar,    0, info.Content),
                SqlDB.MakeInParam("@IsPause",         SqlDbType.Int,         4, info.IsPause),
                SqlDB.MakeInParam("@IsTuiJian",       SqlDbType.Int,         4, info.IsTuiJian),
                SqlDB.MakeInParam("@IsNew",           SqlDbType.Int,         4, info.IsNew),
                SqlDB.MakeInParam("@IsZhiDing",       SqlDbType.Int,         4, info.IsZhiDing),
                SqlDB.MakeInParam("@ZhiDingTime",     SqlDbType.DateTime,    8, info.ZhiDingTime),
                SqlDB.MakeInParam("@PublishTime",     SqlDbType.DateTime,    8, info.PublishTime),
                SqlDB.MakeInParam("@AddTime",         SqlDbType.DateTime,    8, info.AddTime),
                SqlDB.MakeInParam("@AddWid",          SqlDbType.Int,         4, info.AddWid),
                SqlDB.MakeInParam("@IsCheck",         SqlDbType.Int,         4, info.IsCheck),
                SqlDB.MakeInParam("@CheckTime",       SqlDbType.DateTime,    8, info.CheckTime),
                SqlDB.MakeInParam("@CheckWid",        SqlDbType.Int,         4, info.CheckWid),
                SqlDB.MakeInParam("@ClickNum",        SqlDbType.Int,         4, info.ClickNum),
            };
            int intReturnValue = 0;

            intReturnValue = SqlDB.ExecuteNonQuery(CommandType.StoredProcedure, "ArticleEdit", prams);
            if (intReturnValue == 1)
            {
                return(true);
            }
            return(false);
        }
Beispiel #7
0
        private int InsertIntoArticle(DataAccess dac, Article art, Catch info)
        {
            //插入数据库
               var counter = 0;
            try
            {
                     counter = dac.ExecuteNonQuery(DataAccess.ConnManagementMode.Manual, false,
                                        @"DECLARE @article_id INT
            SELECT  @article_id = id
            FROM    dbo.sf_Article
            WHERE   url = @url
            OR title = @title
            IF @article_id IS NULL
            BEGIN
            INSERT  INTO [sf_Article]
                ( [guid] ,
                  [title] ,
                  [body] ,
                  [site] ,
                  [url] ,
                  [publish_time] ,
                  [create_time]
                )
            VALUES  ( @guid ,
                  @title ,
                  @body ,
                  @site ,
                  @url ,
                  @publish_time ,
                  @create_time
                )
            SET @article_id = SCOPE_IDENTITY()
            END
            ELSE
             BEGIN
            UPDATE  [sf_Article]
                  SET [guid]=@guid ,
                  [title]=@title ,
                  [body] =@body ,
                  [site] =@site ,
                  [url]=@url ,
                  [publish_time] =@publish_time ,
                  [create_time]=@create_time
            WHERE id=@article_id
            END
            IF NOT EXISTS ( SELECT  1
                FROM    dbo.sf_Map_ArtCls
                WHERE   article_id = @article_id
                        AND class_id = @class_id )
            BEGIN
            INSERT  INTO [sf_Map_ArtCls]
                ( [guid] ,
                  [article_id] ,
                  [class_id] ,
                  [display_order]

                )
            VALUES  ( @guid2 ,
                  @article_id ,
                  @class_id ,
                  @display_order

                )
            END
                 ",
                                        dac.CreateParameter("@guid", art.Guid), dac.CreateParameter("@title", art.Title),
                                        dac.CreateParameter("@body", art.Body), dac.CreateParameter("@site", art.Site),
                                        dac.CreateParameter("@url", art.Url), dac.CreateParameter("@publish_time", art.PublishTime),
                                        dac.CreateParameter("@create_time", art.CreateTime),
                                        dac.CreateParameter("@guid2", Guid.NewGuid()), dac.CreateParameter("@class_id", info.ClassId),
                                        dac.CreateParameter("@display_order", 0));
            }
            catch
            {
                counter = 0;
            }
            if (counter < 0)
                counter = 0;
            return counter;
        }
Beispiel #8
0
        private int CreateArticleIndex(Article art)
        {
            int createcount=0;
            try
            {
                StockFooAnalyzer analyzer = new StockFooAnalyzer(System.Configuration.ConfigurationManager.AppSettings["AnalyzerPath"].ToString());

                FSDirectory dy = FSDirectory.Open(new DirectoryInfo(System.Configuration.ConfigurationManager.AppSettings["IndexDirectory"].ToString()));
                IndexWriter writer = new IndexWriter(dy, analyzer, false, IndexWriter.MaxFieldLength.LIMITED);
                AddDocument(writer, art.Title, art.Url, art.Site, art.Body.Length>300?art.Body.Substring(0,300):art.Body, art.PublishTime.ToString());
                writer.Optimize();
                writer.Close();
                createcount = 1;
            }
            catch
            {
                createcount = 0;
            }
            return createcount;
        }