Exemplo n.º 1
0
        /// <summary>
        /// 获取用户附件列表
        /// </summary>
        /// <param name="uid">用户ID</param>
        /// <param name="typeid">附件类型</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">页面大小</param>
        /// <returns>用户附件列表</returns>
        public static List <MyAttachmentInfo> GetAttachmentByUid(int uid, int typeid, int pageIndex, int pageSize, string extNamelist)
        {
            List <MyAttachmentInfo> myattachment = new List <MyAttachmentInfo>();

            IDataReader reader;

            if (typeid == 0)
            {
                reader = DatabaseProvider.GetInstance().GetAttachmentByUid(uid, pageIndex, pageSize);
            }
            else
            {
                reader = DatabaseProvider.GetInstance().GetAttachmentByUid(uid, extNamelist, pageIndex, pageSize);
            }

            while (reader.Read())
            {
                MyAttachmentInfo info = new MyAttachmentInfo();

                info.Uid          = TypeConverter.ObjectToInt(reader["uid"]);
                info.Aid          = TypeConverter.ObjectToInt(reader["aid"]);
                info.Postdatetime = reader["postdatetime"].ToString();
                info.Filename     = reader["filename"].ToString().StartsWith("http://") ? reader["filename"].ToString() : "upload/" + reader["filename"].ToString().Replace("\\", "/");
                info.Description  = reader["description"].ToString();
                info.Attachment   = reader["attachment"].ToString();
                info.SimpleName   = Utils.ConvertSimpleFileName(reader["attachment"].ToString(), "...", 6, 3, 15);
                info.Downloads    = TypeConverter.ObjectToInt(reader["downloads"]);

                myattachment.Add(info);
            }
            reader.Close();
            return(myattachment);
        }
Exemplo n.º 2
0
        public static Discuz.Common.Generic.List <MyAttachmentInfo> GetAttachmentByUid(int uid, int typeid, int pageIndex, int pageSize)
        {
            Discuz.Common.Generic.List <MyAttachmentInfo> myattachment = new Discuz.Common.Generic.List <MyAttachmentInfo>();
            if (pageIndex <= 0)
            {
                return(myattachment);
            }
            else
            {
                IDataReader reader;
                if (typeid == 0)
                {
                    reader = DatabaseProvider.GetInstance().GetAttachmentByUid(uid, pageIndex, pageSize);
                }
                else
                {
                    reader = DatabaseProvider.GetInstance().GetAttachmentByUid(uid, SetExtNamelist(typeid), pageIndex, pageSize);
                }

                while (reader.Read())
                {
                    MyAttachmentInfo info = new MyAttachmentInfo();

                    info.Uid          = Int32.Parse(reader["uid"].ToString());
                    info.Aid          = Int32.Parse(reader["aid"].ToString());
                    info.Postdatetime = reader["postdatetime"].ToString();
                    info.Filename     = reader["filename"].ToString().StartsWith("http://") ? reader["filename"].ToString() : "upload/" + reader["filename"].ToString().Replace("\\", "/");
                    info.Description  = reader["description"].ToString();
                    info.Attachment   = reader["attachment"].ToString();
                    info.SimpleName   = Utils.ConvertSimpleFileName(reader["attachment"].ToString(), "...", 6, 3, 15);
                    info.Downloads    = Int32.Parse(reader["downloads"].ToString());

                    myattachment.Add(info);
                }
                reader.Close();

                return(myattachment);
            }
        }