Example #1
0
        public override ArticleAttachment CreateUpdateArticleAttachment(ArticleAttachment info, HHOnline.Framework.DataProviderAction action, out HHOnline.Framework.DataActionStatus status)
        {
            ELParameter[] parms = new ELParameter[]
            {
                action == DataProviderAction.Create ?
                new ELParameter("@AttachmentID", DbType.Int32, 4, ParameterDirection.Output) :
                new ELParameter("@AttachmentID", DbType.Int32, info.ID),
                new ELParameter("@AttachmentName", DbType.String, info.Name),
                new ELParameter("@AttachmentFile", DbType.String, info.FileName),
                new ELParameter("@ContentType", DbType.String, info.ContentType),
                new ELParameter("@ContentSize", DbType.Int32, info.ContentSize),
                new ELParameter("@IsRemote", DbType.Int32, info.IsRemote ? 1 : 0),
                new ELParameter("@ImageWidth", DbType.Int32, info.ImageWidth == null ? (object)DBNull.Value : (object)info.ImageWidth),
                new ELParameter("@ImageHeight", DbType.Int32, info.ImageHeight == null ? (object)DBNull.Value : (object)info.ImageHeight),
                new ELParameter("@AttachmentDesc", DbType.String, info.Desc),
                new ELParameter("@AttachmentMemo", DbType.String, info.Memo),
                new ELParameter("@AttachmentStatus", DbType.Int32, info.Status),
                new ELParameter("@User", DbType.Int32, GlobalSettings.GetCurrentUser().UserID),
                new ELParameter("@Action", DbType.Int32, action),
            };

            status = (DataActionStatus)Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleAttachment_CreateUpdate", parms));
            if (status == DataActionStatus.Success && action == DataProviderAction.Create)
            {
                info.ID = Convert.ToInt32(parms[0].Value);
            }

            return(info);
        }
        /// <summary>
        /// 创建或更新文章
        /// </summary>
        /// <param name="article"></param>
        /// <param name="action"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public override ArticleCategory CreateUpdateArticleCategory(ArticleCategory info, DataProviderAction action, out DataActionStatus status)
        {
            ELParameter[] parms = new ELParameter[]
            {
                action == DataProviderAction.Create ?
                new ELParameter("@CategoryID", DbType.Int32, 4, ParameterDirection.Output) :
                new ELParameter("@CategoryID", DbType.Int32, info.ID),
                new ELParameter("@CategoryName", DbType.String, info.Name),
                new ELParameter("@CategoryDesc", DbType.String, info.Description),
                new ELParameter("@CategoryMemo", DbType.String, info.Memo),
                new ELParameter("@ParentID", DbType.Int32, info.ParentID),
                new ELParameter("@DisplayOrder", DbType.Int32, info.DisplayOrder),
                new ELParameter("@CategoryStatus", DbType.Int32, info.Status),
                new ELParameter("@User", DbType.Int32, GlobalSettings.GetCurrentUser().UserID),
                new ELParameter("@Action", DbType.Int32, action),
            };

            status = (DataActionStatus)Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleCategory_CreateUpdate", parms));
            if (status == DataActionStatus.Success && action == DataProviderAction.Create)
            {
                info.ID = Convert.ToInt32(parms[0].Value);
            }

            return(info);
        }
Example #3
0
        public override DataActionStatus DeleteArticleAttachments(string ids)
        {
            ELParameter idParam = new ELParameter("@IDList", DbType.String);

            idParam.Value = ids;

            return((DataActionStatus)DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleAttachments_Delete", idParam));
        }
        /// <summary>
        /// 批量删除分类
        /// </summary>
        /// <param name="categoryIDList"></param>
        /// <returns></returns>
        public override DataActionStatus DeleteArticleCategories(string categoryIDList)
        {
            ELParameter idParam = new ELParameter("@CategoryIDList", DbType.String);

            idParam.Value = categoryIDList;

            return((DataActionStatus)DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleCategories_Delete", idParam));
        }
        /// <summary>
        /// 获取分类文章总数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public override int GetCategoryArticlesCount(int id)
        {
            ELParameter idParam = new ELParameter("@CategoryID", DbType.Int32, id);

            int result = Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleCategory_GetArticlesCount", idParam));

            return(result);
        }
Example #6
0
        public override DataActionStatus DeleteArticleAttachment(int id)
        {
            ELParameter idParam = new ELParameter("@AttachmentID", DbType.Int32);

            idParam.Value = id;

            DataActionStatus result = (DataActionStatus)Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleAttachment_Delete", idParam));

            return(result);
        }
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="article"></param>
        /// <returns></returns>
        public override DataActionStatus DeleteArticleCategory(int id)
        {
            ELParameter idParam = new ELParameter("@CategoryID", DbType.Int32);

            idParam.Value = id;

            DataActionStatus result = (DataActionStatus)DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_ArticleCategory_Delete", idParam);

            return(result);
        }
Example #8
0
        /// <summary>
        /// 增加访问率
        /// </summary>
        /// <returns></returns>
        public override int IncreaseHitTimes(int articleID)
        {
            ELParameter articleIDParam = new ELParameter("@ArticleID", DbType.Int32);

            articleIDParam.Value = articleID;

            int result = Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_Article_IncreaseHitTimes", articleIDParam));

            return(result);
        }
Example #9
0
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="article"></param>
        /// <returns></returns>
        public override DataActionStatus DeleteArticle(int articleID)
        {
            ELParameter articleIDParam = new ELParameter("@ArticleID", DbType.Int32);

            articleIDParam.Value = articleID;

            DataActionStatus result = (DataActionStatus)Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_Article_Delete", articleIDParam));

            return(result);
        }
        /// <summary>
        /// 获取制定文章
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public override ArticleCategory GetArticleCategory(int id)
        {
            ELParameter idParam = new ELParameter("@CategoryID", DbType.Int32);

            idParam.Value = id;

            using (IDataReader dr = DataHelper.ExecuteReader(CommandType.StoredProcedure, "sp_ArticleCategory_Get", idParam))
            {
                if (dr.Read())
                {
                    return(ArticleReaderConverter.ParseArticleCategory(dr));
                }

                return(null);
            }
        }
Example #11
0
        public override ArticleAttachment GetArticleAttachment(int id)
        {
            ELParameter idParam = new ELParameter("@AttachmentID", DbType.Int32);

            idParam.Value = id;

            using (IDataReader dr = DataHelper.ExecuteReader(CommandType.StoredProcedure, "sp_ArticleAttachment_Get", idParam))
            {
                ArticleAttachment result = null;
                if (dr.Read())
                {
                    result = ArticleReaderConverter.ParseArticleAttachment(dr);
                }

                return(result);
            }
        }
Example #12
0
        public override void SaveViewList(Hashtable views)
        {
            ELParameter paramArticleID = new ELParameter("@ArticleID", DbType.Int32);
            ELParameter paramViewCount = new ELParameter("@ViewCount", DbType.Int32);
            ViewCounter v = null;

            foreach (int articleID in views.Keys)
            {
                v = views[articleID] as ViewCounter;
                if (v != null)
                {
                    paramArticleID.Value = v.RelatedID;
                    paramViewCount.Value = v.Count;
                    DataHelper.ExecuteNonQuery(CommandType.StoredProcedure, "sp_Article_View_Add", paramArticleID, paramViewCount);
                }
            }
        }
Example #13
0
        public override List <ArticleAttachment> GetAllArticleAttachments(AttachmentQuery query, out int totalRecord)
        {
            ELParameter[] elParameters = new ELParameter[] {
                new ELParameter("@PageIndex", DbType.Int32, DataHelper.GetSafeSqlInt(query.PageIndex)),
                new ELParameter("@PageSize", DbType.Int32, DataHelper.GetSafeSqlInt(query.PageSize)),
                new ELParameter("@SqlPopulate", DbType.String, QueryGenerator.BuildAttachmentQuery(query))
            };

            using (IDataReader dr = DataHelper.ExecuteReader(CommandType.StoredProcedure, "sp_ArticleAttachments_Get", elParameters))
            {
                List <ArticleAttachment> attachmentList = new List <ArticleAttachment>();
                while (dr.Read())
                {
                    attachmentList.Add(ArticleReaderConverter.ParseArticleAttachment(dr));
                }

                dr.NextResult();
                dr.Read();
                totalRecord = DataRecordHelper.GetInt32(dr, 0);

                return(attachmentList);
            }
        }
Example #14
0
        /// <summary>
        /// 创建或更新文章
        /// </summary>
        /// <param name="article"></param>
        /// <param name="action"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public override Article CreateUpdateArticle(Article article, DataProviderAction action, out DataActionStatus status)
        {
            SerializerData data = article.GetSerializerData();

            ELParameter[] parms = new ELParameter[]
            {
                action == DataProviderAction.Create ?
                new ELParameter("@ArticleID", DbType.Int32, 4, ParameterDirection.Output) :
                new ELParameter("@ArticleID", DbType.Int32, article.ID),
                new ELParameter("@Action", DbType.Int32, action),
                new ELParameter("@ArticleTitle", DbType.String, article.Title),
                new ELParameter("@CategoryID", DbType.Int32, article.Category),
                new ELParameter("@ArticleStatus", DbType.Int32, article.Status),
                new ELParameter("@HitTimes", DbType.Int32, article.HitTimes),
                new ELParameter("@ArticleSubtitle", DbType.String, article.SubTitle),
                new ELParameter("@ArticleAbstract", DbType.String, article.Abstract),
                new ELParameter("@ArticleContent", DbType.String, article.Content),
                new ELParameter("@ArticleDate", DbType.DateTime, article.Date == null ? (object)DBNull.Value : (object)article.Date),
                new ELParameter("@ArticleCopyFrom", DbType.String, article.CopyFrom),
                new ELParameter("@ArticleAuthor", DbType.String, article.Author),
                new ELParameter("@ArticleKeywords", DbType.String, article.Keywords),
                new ELParameter("@ArticleImageID", DbType.Int32, article.Image),
                new ELParameter("@DisplayOrder", DbType.Int32, article.DisplayOrder),
                new ELParameter("@ArticleMemo", DbType.String, article.ArticleMemo),
                new ELParameter("@User", DbType.Int32, GlobalSettings.GetCurrentUser().UserID),
                new ELParameter("@PropertyNames", DbType.String, data.Keys),
                new ELParameter("@PropertyValues", DbType.String, data.Values),
            };

            status = (DataActionStatus)Convert.ToInt32(DataHelper.ExecuteScalar(CommandType.StoredProcedure, "sp_Article_CreateUpdate", parms));
            if (status == DataActionStatus.Success && action == DataProviderAction.Create)
            {
                article.ID = Convert.ToInt32(parms[0].Value);
            }

            return(article);
        }