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

            db.AddInParameter(dbCommand, "AttachmentID", DbType.Int64, AttachmentID);
            DataSet ds  = db.ExecuteDataSet(dbCommand);
            var     lst = XCLNetTools.Generic.ListHelper.DataTableToList <XCLCMS.Data.Model.Attachment>(ds.Tables[0]);

            return(null != lst && lst.Count > 0 ? lst[0] : null);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XCLCMS.Data.Model.Attachment GetModel(long AttachmentID)
        {
            XCLCMS.Data.Model.Attachment model = new XCLCMS.Data.Model.Attachment();
            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand("select * from Attachment WITH(NOLOCK)   where AttachmentID=@AttachmentID");

            db.AddInParameter(dbCommand, "AttachmentID", DbType.Int64, AttachmentID);
            using (var dr = db.ExecuteReader(dbCommand))
            {
                return(XCLNetTools.DataSource.DataReaderHelper.DataReaderToEntity <XCLCMS.Data.Model.Attachment>(dr));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 根据文件id,返回用于网站上显示的文件地址
        /// </summary>
        public static string GetAttachmentAbsoluteURL(long id)
        {
            if (id <= 0)
            {
                return(null);
            }
            XCLCMS.Data.Model.Attachment model = null;
            var request = XCLCMS.Lib.WebAPI.Library.CreateRequest <long>();

            request.Body = id;
            var response = XCLCMS.Lib.WebAPI.AttachmentAPI.Detail(request);

            if (null != response)
            {
                model = response.Body;
            }
            return(null != model?GetAttachmentAbsoluteURL(model.URL) : null);
        }
Beispiel #4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(XCLCMS.Data.Model.Attachment model)
        {
            Database  db        = base.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("sp_Attachment_Update");

            db.AddInParameter(dbCommand, "AttachmentID", DbType.Int64, model.AttachmentID);
            db.AddInParameter(dbCommand, "ParentID", DbType.Int64, model.ParentID);
            db.AddInParameter(dbCommand, "OriginFileName", DbType.AnsiString, model.OriginFileName);
            db.AddInParameter(dbCommand, "FileName", DbType.AnsiString, model.FileName);
            db.AddInParameter(dbCommand, "Title", DbType.String, model.Title);
            db.AddInParameter(dbCommand, "ViewType", DbType.AnsiString, model.ViewType);
            db.AddInParameter(dbCommand, "FormatType", DbType.AnsiString, model.FormatType);
            db.AddInParameter(dbCommand, "Ext", DbType.AnsiString, model.Ext);
            db.AddInParameter(dbCommand, "URL", DbType.AnsiString, model.URL);
            db.AddInParameter(dbCommand, "Description", DbType.String, model.Description);
            db.AddInParameter(dbCommand, "DownLoadCount", DbType.Int32, model.DownLoadCount);
            db.AddInParameter(dbCommand, "ViewCount", DbType.Int32, model.ViewCount);
            db.AddInParameter(dbCommand, "FileSize", DbType.Decimal, model.FileSize);
            db.AddInParameter(dbCommand, "ImgWidth", DbType.Int32, model.ImgWidth);
            db.AddInParameter(dbCommand, "ImgHeight", DbType.Int32, model.ImgHeight);
            db.AddInParameter(dbCommand, "FK_MerchantID", DbType.Int64, model.FK_MerchantID);
            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);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取与指定附件相关的附件列表(不包含该指定的附件id)
        /// </summary>
        public List <XCLCMS.Data.Model.Attachment> GetCorrelativeList(long attachmentID)
        {
            var model = this.GetModel(attachmentID);

            if (null == model)
            {
                return(null);
            }
            XCLCMS.Data.Model.Attachment        tempModel = null;
            List <XCLCMS.Data.Model.Attachment> temp      = null;
            List <XCLCMS.Data.Model.Attachment> result    = new List <Model.Attachment>();

            temp = this.GetListByParentID(model.AttachmentID);

            if (null != temp && temp.Count > 0)
            {
                result.AddRange(temp);
            }

            if (model.ParentID > 0)
            {
                temp = this.GetListByParentID(model.ParentID);
                if (null != temp && temp.Count > 0)
                {
                    result.AddRange(temp);
                }

                tempModel = this.GetModel(model.ParentID);
                if (null != tempModel)
                {
                    result.Add(tempModel);
                }
            }

            if (null != result && result.Count > 0)
            {
                result = result.Distinct().Where(k => k.AttachmentID != attachmentID).ToList();
            }

            return(result);
        }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(XCLCMS.Data.Model.Attachment model)
 {
     return(dal.Update(model));
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(XCLCMS.Data.Model.Attachment model)
 {
     return(dal.Add(model));
 }