Esempio n. 1
0
        /// <summary>
        /// 批量添加
        /// </summary>
        public bool Add(long articleID, List <long> articleTypeIDList, XCLCMS.Data.Model.Custom.ContextModel context = null)
        {
            if (null == articleTypeIDList || articleTypeIDList.Count == 0)
            {
                return(true);
            }
            articleTypeIDList = articleTypeIDList.Distinct().ToList();

            DateTime dtNow = DateTime.Now;
            var      lst   = new List <XCLCMS.Data.Model.ArticleType>();

            articleTypeIDList.ForEach(id =>
            {
                var model = new XCLCMS.Data.Model.ArticleType();
                if (null != context)
                {
                    model.CreaterID   = context.UserInfoID;
                    model.CreaterName = context.UserName;
                    model.UpdaterID   = context.UserInfoID;
                    model.UpdaterName = context.UserName;
                }
                model.CreateTime   = dtNow;
                model.UpdateTime   = dtNow;
                model.FK_TypeID    = id;
                model.FK_ArticleID = articleID;
                model.RecordState  = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.N.ToString();
                lst.Add(model);
            });

            return(this.Add(lst));
        }
Esempio n. 2
0
        /// <summary>
        /// 批量删除
        /// </summary>
        public bool Delete(List <long> idLst, XCLCMS.Data.Model.Custom.ContextModel context)
        {
            if (null == idLst || idLst.Count == 0)
            {
                return(true);
            }
            DateTime dtNow = DateTime.Now;

            using (var scope = new TransactionScope())
            {
                foreach (var id in idLst)
                {
                    var model = this.GetModel(id);
                    if (null == model)
                    {
                        continue;
                    }
                    //删除当前记录
                    model.UpdaterID   = context.UserInfoID;
                    model.UpdaterName = context.UserName;
                    model.UpdateTime  = dtNow;
                    model.RecordState = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.D.ToString();
                    if (!this.Update(model))
                    {
                        return(false);
                    }
                    //更新子记录的parentid为0
                    var subLst = this.GetListByParentID(id);
                    if (null != subLst && subLst.Count > 0)
                    {
                        foreach (var subModel in subLst)
                        {
                            subModel.ParentID    = 0;
                            subModel.UpdaterID   = context.UserInfoID;
                            subModel.UpdaterName = context.UserName;
                            subModel.UpdateTime  = dtNow;
                            if (!this.Update(subModel))
                            {
                                return(false);
                            }
                        }
                    }
                }
                scope.Complete();
            }
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// 批量删除商户数据
        /// </summary>
        public bool Delete(List <long> idLst, XCLCMS.Data.Model.Custom.ContextModel context)
        {
            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("sp_Merchant_Del");

            dbCommand.Parameters.Add(new SqlParameter("@MerchantID", SqlDbType.Structured)
            {
                TypeName  = "TVP_IDTable",
                Direction = ParameterDirection.Input,
                Value     = XCLNetTools.DataSource.DataTableHelper.ToSingleColumnDataTable <long, long>(idLst)
            });
            dbCommand.Parameters.Add(new SqlParameter("@Context", SqlDbType.Structured)
            {
                TypeName  = "TVP_Context",
                Direction = ParameterDirection.Input,
                Value     = XCLNetTools.DataSource.DataTableHelper.ToDataTable(new List <XCLCMS.Data.Model.Custom.ContextModel>()
                {
                    context
                })
            });

            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);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 批量添加(先删再加)
 /// </summary>
 public bool Add(XCLCMS.Data.CommonHelper.EnumType.ObjectTypeEnum objectType, long objectID, List <long> ProductIDList, XCLCMS.Data.Model.Custom.ContextModel context = null)
 {
     return(dal.Add(objectType, objectID, ProductIDList, context));
 }
Esempio n. 5
0
        /// <summary>
        /// 批量添加(先删再加)
        /// </summary>
        public bool Add(XCLCMS.Data.CommonHelper.EnumType.ObjectTypeEnum objectType, long objectID, List <long> tagIDList, XCLCMS.Data.Model.Custom.ContextModel context = null)
        {
            var dtNow = DateTime.Now;

            if (null == tagIDList || tagIDList.Count == 0)
            {
                return(true);
            }
            tagIDList = tagIDList.Distinct().ToList();

            if (!this.Delete(objectType, objectID))
            {
                return(false);
            }

            tagIDList.ForEach(id =>
            {
                var model = new XCLCMS.Data.Model.ObjectTag();
                if (null != context)
                {
                    model.CreaterID   = context.UserInfoID;
                    model.CreaterName = context.UserName;
                    model.UpdaterID   = context.UserInfoID;
                    model.UpdaterName = context.UserName;
                }
                model.CreateTime  = dtNow;
                model.UpdateTime  = dtNow;
                model.FK_TagsID   = id;
                model.FK_ObjectID = objectID;
                model.ObjectType  = objectType.ToString();
                model.RecordState = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.N.ToString();
                this.Add(model);
            });

            return(true);
        }
        /// <summary>
        /// 批量添加(先删再加)
        /// </summary>
        public bool Add(XCLCMS.Data.CommonHelper.EnumType.ObjectTypeEnum objectType, long objectID, List <long> attachmentIDList, XCLCMS.Data.Model.Custom.ContextModel context = null)
        {
            if (null == attachmentIDList || attachmentIDList.Count == 0)
            {
                return(true);
            }
            attachmentIDList = attachmentIDList.Distinct().ToList();

            if (!this.Delete(CommonHelper.EnumType.ObjectTypeEnum.ART, objectID))
            {
                return(false);
            }

            DateTime dtNow = DateTime.Now;
            var      lst   = new List <XCLCMS.Data.Model.ObjectAttachment>();

            attachmentIDList.ForEach(id =>
            {
                var model = new XCLCMS.Data.Model.ObjectAttachment();
                if (null != context)
                {
                    model.CreaterID   = context.UserInfoID;
                    model.CreaterName = context.UserName;
                    model.UpdaterID   = context.UserInfoID;
                    model.UpdaterName = context.UserName;
                }
                model.CreateTime      = dtNow;
                model.UpdateTime      = dtNow;
                model.FK_AttachmentID = id;
                model.FK_ObjectID     = objectID;
                model.ObjectType      = objectType.ToString();
                model.RecordState     = XCLCMS.Data.CommonHelper.EnumType.RecordStateEnum.N.ToString();
                lst.Add(model);
            });

            return(this.Add(lst));
        }
Esempio n. 7
0
 /// <summary>
 /// 批量添加
 /// </summary>
 public bool Add(long articleID, List <long> articleTypeIDList, XCLCMS.Data.Model.Custom.ContextModel context = null)
 {
     return(dal.Add(articleID, articleTypeIDList, context));
 }
Esempio n. 8
0
 /// <summary>
 /// 批量添加
 /// </summary>
 public bool Add(long keyValueInfoID, List <long> keyValueInfoTypeIDList, XCLCMS.Data.Model.Custom.ContextModel context = null)
 {
     return(dal.Add(keyValueInfoID, keyValueInfoTypeIDList, context));
 }
Esempio n. 9
0
 /// <summary>
 /// 批量删除商户数据
 /// </summary>
 public bool Delete(List <long> idLst, XCLCMS.Data.Model.Custom.ContextModel context)
 {
     return(dal.Delete(idLst, context));
 }