Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCLCMS.Data.Model.Article GetModel(long ArticleID)
        {
            XCLCMS.Data.Model.Article model = new XCLCMS.Data.Model.Article();
            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand("select * from Article WITH(NOLOCK)   where ArticleID=@ArticleID");

            db.AddInParameter(dbCommand, "ArticleID", DbType.Int64, ArticleID);
            using (var dr = db.ExecuteReader(dbCommand))
            {
                return(XCLNetTools.DataSource.DataReaderHelper.DataReaderToEntity <XCLCMS.Data.Model.Article>(dr));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCLCMS.Data.Model.Article GetModel(long ArticleID)
        {
            XCLCMS.Data.Model.Article model = new XCLCMS.Data.Model.Article();
            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand("select * from Article where ArticleID=@ArticleID");

            db.AddInParameter(dbCommand, "ArticleID", DbType.Int64, ArticleID);
            DataSet ds = db.ExecuteDataSet(dbCommand);

            var lst = XCLNetTools.Generic.ListHelper.DataTableToList <XCLCMS.Data.Model.Article>(ds.Tables[0]);

            return(null != lst && lst.Count > 0 ? lst[0] : null);
        }
Exemplo n.º 3
0
        public async Task <APIResponseEntity <bool> > IsExistCode([FromUri] APIRequestEntity <XCLCMS.Data.WebAPIEntity.RequestEntity.Article.IsExistCodeEntity> request)
        {
            return(await Task.Run(() =>
            {
                #region 初始化

                var response = new APIResponseEntity <bool>()
                {
                    IsSuccess = true,
                    Message = "该唯一标识可以使用!"
                };
                request.Body.Code = (request.Body.Code ?? "").Trim();
                XCLCMS.Data.Model.Article model = null;

                #endregion 初始化

                #region 数据校验

                if (string.IsNullOrEmpty(request.Body.Code))
                {
                    response.Message = "请指定Code参数!";
                    response.IsSuccess = false;
                    return response;
                }

                #endregion 数据校验

                #region 构建response

                if (request.Body.ArticleID > 0)
                {
                    model = articleBLL.GetModel(request.Body.ArticleID);
                    if (null != model && string.Equals(request.Body.Code, model.Code, StringComparison.OrdinalIgnoreCase))
                    {
                        return response;
                    }
                }

                if (articleBLL.IsExistCode(request.Body.Code))
                {
                    response.IsSuccess = false;
                    response.Message = "该唯一标识已被占用!";
                    return response;
                }
                return response;

                #endregion 构建response
            }));
        }
Exemplo n.º 4
0
        public APIResponseEntity <bool> IsExistCode([FromUri] string json)
        {
            #region 初始化

            var request  = Newtonsoft.Json.JsonConvert.DeserializeObject <APIRequestEntity <XCLCMS.Data.WebAPIEntity.RequestEntity.Article.IsExistCodeEntity> >(System.Web.HttpUtility.UrlDecode(json));
            var response = new APIResponseEntity <bool>()
            {
                IsSuccess = true,
                Message   = "该唯一标识可以使用!"
            };
            request.Body.Code = (request.Body.Code ?? "").Trim();
            XCLCMS.Data.Model.Article model = null;

            #endregion 初始化

            #region 数据校验

            if (string.IsNullOrEmpty(request.Body.Code))
            {
                response.Message   = "请指定Code参数!";
                response.IsSuccess = false;
                return(response);
            }

            #endregion 数据校验

            #region 构建response

            if (request.Body.ArticleID > 0)
            {
                model = articleBLL.GetModel(request.Body.ArticleID);
                if (null != model && string.Equals(request.Body.Code, model.Code, StringComparison.OrdinalIgnoreCase))
                {
                    return(response);
                }
            }

            if (articleBLL.IsExistCode(request.Body.Code))
            {
                response.IsSuccess = false;
                response.Message   = "该唯一标识已被占用!";
                return(response);
            }
            return(response);

            #endregion 构建response
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(XCLCMS.Data.Model.Article model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(XCLCMS.Data.Model.Article model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 7
0
        public override ActionResult UpdateSubmit(FormCollection fm)
        {
            XCLNetTools.Message.MessageModel msgModel = new XCLNetTools.Message.MessageModel();

            var viewModel = this.GetViewModel(fm);
            var model     = new XCLCMS.Data.Model.Article();

            model.ArticleID = viewModel.Article.ArticleID;

            model.RecordState        = viewModel.Article.RecordState;
            model.ArticleContentType = viewModel.Article.ArticleContentType;
            model.ArticleState       = viewModel.Article.ArticleState;
            model.AuthorName         = viewModel.Article.AuthorName;
            model.BadCount           = viewModel.Article.BadCount;
            if (string.IsNullOrWhiteSpace(viewModel.Article.Code))
            {
                model.Code = model.ArticleID.ToString();
            }
            else
            {
                model.Code = viewModel.Article.Code;
            }

            model.CommentCount     = viewModel.Article.CommentCount;
            model.Comments         = viewModel.Article.Comments;
            model.Contents         = viewModel.Article.Contents;
            model.FromInfo         = viewModel.Article.FromInfo;
            model.GoodCount        = viewModel.Article.GoodCount;
            model.HotCount         = viewModel.Article.HotCount;
            model.IsCanComment     = viewModel.Article.IsCanComment;
            model.IsEssence        = viewModel.Article.IsEssence;
            model.IsRecommend      = viewModel.Article.IsRecommend;
            model.IsTop            = viewModel.Article.IsTop;
            model.KeyWords         = viewModel.Article.KeyWords;
            model.LinkUrl          = viewModel.Article.LinkUrl;
            model.MainImage1       = viewModel.Article.MainImage1;
            model.MainImage2       = viewModel.Article.MainImage2;
            model.MainImage3       = viewModel.Article.MainImage3;
            model.MiddleCount      = viewModel.Article.MiddleCount;
            model.PublishTime      = viewModel.Article.PublishTime;
            model.SubTitle         = viewModel.Article.SubTitle;
            model.Summary          = viewModel.Article.Summary;
            model.Tags             = viewModel.Article.Tags;
            model.Title            = viewModel.Article.Title;
            model.TopBeginTime     = viewModel.Article.TopBeginTime;
            model.TopEndTime       = viewModel.Article.TopEndTime;
            model.UpdaterID        = base.UserID;
            model.UpdaterName      = base.CurrentUserModel.UserName;
            model.UpdateTime       = DateTime.Now;
            model.URLOpenType      = viewModel.Article.URLOpenType;
            model.VerifyState      = viewModel.Article.VerifyState;
            model.ViewCount        = viewModel.Article.ViewCount;
            model.FK_MerchantAppID = viewModel.Article.FK_MerchantAppID;
            model.FK_MerchantID    = viewModel.Article.FK_MerchantID;

            var request = XCLCMS.Lib.WebAPI.Library.CreateRequest <XCLCMS.Data.WebAPIEntity.RequestEntity.Article.AddOrUpdateEntity>(base.UserToken);

            request.Body         = new Data.WebAPIEntity.RequestEntity.Article.AddOrUpdateEntity();
            request.Body.Article = model;
            request.Body.ArticleAttachmentIDList = viewModel.AttachmentIDList;
            request.Body.ArticleTypeIDList       = viewModel.ArticleTypeIDList;
            var response = XCLCMS.Lib.WebAPI.ArticleAPI.Update(request);

            return(Json(response));
        }
Exemplo n.º 8
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(XCLCMS.Data.Model.Article model)
        {
            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("sp_Article_Update");

            db.AddInParameter(dbCommand, "ArticleID", DbType.Int64, model.ArticleID);
            db.AddInParameter(dbCommand, "Code", DbType.AnsiString, model.Code);
            db.AddInParameter(dbCommand, "Title", DbType.String, model.Title);
            db.AddInParameter(dbCommand, "SubTitle", DbType.String, model.SubTitle);
            db.AddInParameter(dbCommand, "AuthorName", DbType.String, model.AuthorName);
            db.AddInParameter(dbCommand, "FromInfo", DbType.String, model.FromInfo);
            db.AddInParameter(dbCommand, "ArticleContentType", DbType.AnsiString, model.ArticleContentType);
            db.AddInParameter(dbCommand, "Contents", DbType.String, model.Contents);
            db.AddInParameter(dbCommand, "Summary", DbType.String, model.Summary);
            db.AddInParameter(dbCommand, "MainImage1", DbType.Int64, model.MainImage1);
            db.AddInParameter(dbCommand, "MainImage2", DbType.Int64, model.MainImage2);
            db.AddInParameter(dbCommand, "MainImage3", DbType.Int64, model.MainImage3);
            db.AddInParameter(dbCommand, "ViewCount", DbType.Int32, model.ViewCount);
            db.AddInParameter(dbCommand, "IsCanComment", DbType.AnsiString, model.IsCanComment);
            db.AddInParameter(dbCommand, "CommentCount", DbType.Int32, model.CommentCount);
            db.AddInParameter(dbCommand, "GoodCount", DbType.Int32, model.GoodCount);
            db.AddInParameter(dbCommand, "MiddleCount", DbType.Int32, model.MiddleCount);
            db.AddInParameter(dbCommand, "BadCount", DbType.Int32, model.BadCount);
            db.AddInParameter(dbCommand, "HotCount", DbType.Int32, model.HotCount);
            db.AddInParameter(dbCommand, "URLOpenType", DbType.AnsiString, model.URLOpenType);
            db.AddInParameter(dbCommand, "ArticleState", DbType.AnsiString, model.ArticleState);
            db.AddInParameter(dbCommand, "VerifyState", DbType.AnsiString, model.VerifyState);
            db.AddInParameter(dbCommand, "IsRecommend", DbType.AnsiString, model.IsRecommend);
            db.AddInParameter(dbCommand, "IsEssence", DbType.AnsiString, model.IsEssence);
            db.AddInParameter(dbCommand, "IsTop", DbType.AnsiString, model.IsTop);
            db.AddInParameter(dbCommand, "TopBeginTime", DbType.DateTime, model.TopBeginTime);
            db.AddInParameter(dbCommand, "TopEndTime", DbType.DateTime, model.TopEndTime);
            db.AddInParameter(dbCommand, "KeyWords", DbType.String, model.KeyWords);
            db.AddInParameter(dbCommand, "Tags", DbType.String, model.Tags);
            db.AddInParameter(dbCommand, "Comments", DbType.String, model.Comments);
            db.AddInParameter(dbCommand, "LinkUrl", DbType.AnsiString, model.LinkUrl);
            db.AddInParameter(dbCommand, "PublishTime", DbType.DateTime, model.PublishTime);
            db.AddInParameter(dbCommand, "FK_MerchantID", DbType.Int64, model.FK_MerchantID);
            db.AddInParameter(dbCommand, "FK_MerchantAppID", DbType.Int64, model.FK_MerchantAppID);
            db.AddInParameter(dbCommand, "RecordState", DbType.AnsiString, model.RecordState);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime);
            db.AddInParameter(dbCommand, "CreaterID", DbType.Int64, model.CreaterID);
            db.AddInParameter(dbCommand, "CreaterName", DbType.String, model.CreaterName);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, model.UpdateTime);
            db.AddInParameter(dbCommand, "UpdaterID", DbType.Int64, model.UpdaterID);
            db.AddInParameter(dbCommand, "UpdaterName", DbType.String, model.UpdaterName);

            db.AddOutParameter(dbCommand, "ResultCode", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "ResultMessage", DbType.String, 1000);
            db.ExecuteNonQuery(dbCommand);

            var result = XCLCMS.Data.DAL.Common.Common.GetProcedureResult(dbCommand.Parameters);

            if (result.IsSuccess)
            {
                return(true);
            }
            else
            {
                throw new Exception(result.ResultMessage);
            }
        }