Пример #1
0
        /// <summary>
        /// 获取单个附件
        /// </summary>
        /// <param name="itemId">关联编号</param>
        /// <param name="itemType">关联类型</param>
        /// <returns>附件实体</returns>
        public IList <MComAttach> GetModelList(string itemId, EyouSoft.Model.EnumType.ComStructure.AttachItemType itemType)
        {
            IList <MComAttach> list = new List <MComAttach>();
            string             sql  = "SELECT ItemId,ItemType,[Name],FilePath,Size,Downloads FROM tbl_ComAttach WHERE ItemId = @ItemId AND ItemType = @ItemType";
            DbCommand          comm = this._db.GetSqlStringCommand(sql);

            this._db.AddInParameter(comm, "@ItemId", DbType.AnsiStringFixedLength, itemId);
            this._db.AddInParameter(comm, "@ItemType", DbType.Byte, (int)itemType);

            using (IDataReader reader = DbHelper.ExecuteReader(comm, this._db))
            {
                while (reader.Read())
                {
                    list.Add(new MComAttach()
                    {
                        ItemId    = reader["ItemId"].ToString(),
                        ItemType  = (AttachItemType)Enum.Parse(typeof(AttachItemType), reader["ItemType"].ToString()),
                        Name      = reader.IsDBNull(reader.GetOrdinal("Name")) ? string.Empty : reader["Name"].ToString(),
                        FilePath  = reader.IsDBNull(reader.GetOrdinal("FilePath")) ? string.Empty : reader["FilePath"].ToString(),
                        Size      = (int)reader["Size"],
                        Downloads = (int)reader["Downloads"]
                    });
                }
            }
            return(list);
        }
Пример #2
0
        /// <summary>
        /// 增加附件下载次数
        /// </summary>
        /// <param name="itemId">关联编号</param>
        /// <param name="itemType">关联类型</param>
        public void AddDownloads(string itemId, EyouSoft.Model.EnumType.ComStructure.AttachItemType itemType)
        {
            string    sql  = "UPDATE tbl_ComAttach SET Downloads = Downloads + 1 WHERE ItemId = @ItemId AND ItemType = @ItemType";
            DbCommand comm = this._db.GetSqlStringCommand(sql);

            this._db.AddInParameter(comm, "@ItemId", DbType.AnsiStringFixedLength, itemId);
            this._db.AddInParameter(comm, "@ItemType", DbType.Byte, (int)itemType);

            DbHelper.ExecuteSql(comm, this._db);
        }