Пример #1
0
        /// <summary>
        /// 产生附件
        /// </summary>
        /// <param name="attachmentinfo">附件描述类</param>
        /// <returns>附件id</returns>
        public static int CreateAttachments(AttachmentInfo attachmentinfo)
        {
            attachmentinfo.Aid = DatabaseProvider.GetInstance().CreateAttachment(attachmentinfo);

            if (appDBCache)
                IAttachmentService.CreateAttachments(attachmentinfo);

            return attachmentinfo.Aid;
        }
Пример #2
0
        /// <summary>
        /// 将单个附件DataRow转换为AttachmentInfo类
        /// </summary>
        /// <param name="drAttach">单个附件DataRow</param>
        /// <param name="drAttach">是否返回原始路径</param>
        /// <returns>AttachmentInfo类</returns>
        private static AttachmentInfo LoadSingleAttachmentInfo(IDataReader drAttach, bool isOriginalFilename)
        {
            AttachmentInfo attach = new AttachmentInfo();
            if (drAttach.Read())
            {
                attach.Aid = TypeConverter.ObjectToInt(drAttach["aid"]);
                attach.Pid = TypeConverter.ObjectToInt(drAttach["pid"]);
                attach.Postdatetime = drAttach["postdatetime"].ToString();

                if (isOriginalFilename)
                {
                    attach.Filename = drAttach["filename"].ToString();
                }
                else if (drAttach["filename"].ToString().Trim().ToLower().IndexOf("http") < 0)
                {
                    attach.Filename = BaseConfigs.GetForumPath + "upload/" + drAttach["filename"].ToString().Trim().Replace("\\", "/");
                }
                else
                {
                    attach.Filename = drAttach["filename"].ToString().Trim().Replace("\\", "/");
                }
                attach.Description = drAttach["description"].ToString().Trim();
                attach.Filetype = drAttach["filetype"].ToString().Trim();
                attach.Attachment = drAttach["attachment"].ToString().Trim();
                attach.Filesize = TypeConverter.ObjectToInt(drAttach["filesize"]);
                attach.Downloads = TypeConverter.ObjectToInt(drAttach["downloads"]);
            }
            drAttach.Close();
            return attach;
        }
Пример #3
0
        /// <summary>
        /// 更新附件信息
        /// </summary>
        /// <param name="attachmentInfo">附件对象</param>
        /// <returns>返回被更新的数量</returns>
        public static int UpdateAttachment(AttachmentInfo attachmentInfo)
        {
            if (appDBCache)
                IAttachmentService.UpdateAttachment(attachmentInfo);

            return DatabaseProvider.GetInstance().UpdateAttachment(attachmentInfo);
        }
Пример #4
0
 private static AttachmentInfo LoadAttachmentInfo(IDataReader reader)
 {
     AttachmentInfo attach = new AttachmentInfo();
     attach.Aid = TypeConverter.ObjectToInt(reader["aid"]);
     attach.Pid = TypeConverter.ObjectToInt(reader["pid"]);
     attach.Postdatetime = reader["postdatetime"].ToString();
     attach.Filename = reader["filename"].ToString();
     attach.Description = reader["description"].ToString().Trim();
     attach.Filetype = reader["filetype"].ToString().Trim();
     attach.Attachment = reader["attachment"].ToString().Trim();
     attach.Filesize = TypeConverter.ObjectToInt(reader["filesize"]);
     attach.Downloads = TypeConverter.ObjectToInt(reader["downloads"]);
     return attach;
 }
Пример #5
0
 /// <summary>
 /// 获取当前编辑帖子的附件id列表的附件信息列表
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="aidList"></param>
 /// <returns></returns>
 public static List<AttachmentInfo> GetEditPostAttachList(int userid, string aidList)
 {
     IDataReader reader = DatabaseProvider.GetInstance().GetEditPostAttachList(userid,aidList);
     List<AttachmentInfo> attachmentList = new List<AttachmentInfo>();
     while (reader.Read())
     {
         AttachmentInfo attach = new AttachmentInfo();
         attach.Aid = TypeConverter.ObjectToInt(reader["aid"]);
         attach.Pid = TypeConverter.ObjectToInt(reader["pid"]);
         attach.Postdatetime = reader["postdatetime"].ToString();
         attach.Filename = reader["filename"].ToString();
         attach.Description = reader["description"].ToString().Trim();
         attach.Filetype = reader["filetype"].ToString().Trim();
         attach.Attachment = reader["attachment"].ToString().Trim();
         attach.Filesize = TypeConverter.ObjectToInt(reader["filesize"]);
         attach.Downloads = TypeConverter.ObjectToInt(reader["downloads"]);
         attachmentList.Add(attach);
     }
     reader.Close();
     return attachmentList;
 }