Esempio n. 1
0
        public IList <SitePictureInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select Id,UserId,FileName,FileSize,FileExtension,FileDirectory,RandomFolder,FunType,LastUpdatedDate 
			            from SitePicture
					    order by LastUpdatedDate "                    );

            IList <SitePictureInfo> list = new List <SitePictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        SitePictureInfo model = new SitePictureInfo();
                        model.Id              = reader.GetGuid(0);
                        model.UserId          = reader.GetGuid(1);
                        model.FileName        = reader.GetString(2);
                        model.FileSize        = reader.GetInt32(3);
                        model.FileExtension   = reader.GetString(4);
                        model.FileDirectory   = reader.GetString(5);
                        model.RandomFolder    = reader.GetString(6);
                        model.FunType         = reader.GetString(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Esempio n. 2
0
        public int Update(SitePictureInfo model)
        {
            StringBuilder sb = new StringBuilder(500);

            sb.Append(@"update SitePicture set UserId = @UserId,FileName = @FileName,FileSize = @FileSize,FileExtension = @FileExtension,FileDirectory = @FileDirectory,RandomFolder = @RandomFolder,FunType = @FunType,LastUpdatedDate = @LastUpdatedDate 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier),
                new SqlParameter("@FileName",        SqlDbType.NVarChar,          100),
                new SqlParameter("@FileSize",        SqlDbType.Int),
                new SqlParameter("@FileExtension",   SqlDbType.VarChar,            50),
                new SqlParameter("@FileDirectory",   SqlDbType.NVarChar,          100),
                new SqlParameter("@RandomFolder",    SqlDbType.VarChar,            20),
                new SqlParameter("@FunType",         SqlDbType.VarChar,            50),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.UserId;
            parms[2].Value = model.FileName;
            parms[3].Value = model.FileSize;
            parms[4].Value = model.FileExtension;
            parms[5].Value = model.FileDirectory;
            parms[6].Value = model.RandomFolder;
            parms[7].Value = model.FunType;
            parms[8].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Esempio n. 3
0
        public SitePictureInfo GetModel(string url)
        {
            SitePictureInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,UserId,FileName,FileSize,FileExtension,FileDirectory,RandomFolder,FunType,LastUpdatedDate 
			            from SitePicture
						where (FileDirectory+FileName) = @Url "                        );
            var parm = new SqlParameter("@Url", SqlDbType.NVarChar, 256);

            parm.Value = url;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        model                 = new SitePictureInfo();
                        model.Id              = reader.GetGuid(0);
                        model.UserId          = reader.GetGuid(1);
                        model.FileName        = reader.GetString(2);
                        model.FileSize        = reader.GetInt32(3);
                        model.FileExtension   = reader.GetString(4);
                        model.FileDirectory   = reader.GetString(5);
                        model.RandomFolder    = reader.GetString(6);
                        model.FunType         = reader.GetString(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);
                    }
                }
            }

            return(model);
        }
Esempio n. 4
0
        private void UploadSitePicture(HttpContext context, string funType)
        {
            HttpFileCollection files = context.Request.Files;

            if (files.Count == 0)
            {
                context.Response.Write("{\"success\": false,\"message\": \"未找到任何可上传的文件,请检查!\"}");
                return;
            }

            var          userId = WebCommon.GetUserId();
            int          effect = 0;
            ImagesHelper ih     = new ImagesHelper();

            using (TransactionScope scope = new TransactionScope())
            {
                foreach (string item in files.AllKeys)
                {
                    HttpPostedFile file = files[item];
                    if (file == null || file.ContentLength == 0)
                    {
                        continue;
                    }

                    int fileSize       = file.ContentLength;
                    int uploadFileSize = int.Parse(WebConfigurationManager.AppSettings["UploadFileSize"]);
                    if (fileSize > uploadFileSize)
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】大小超出字节" + uploadFileSize + ",无法上传,请正确操作!");
                    }
                    if (!UploadFilesHelper.IsFileValidated(file.InputStream, fileSize))
                    {
                        throw new ArgumentException("文件【" + file.FileName + "】为受限制的文件,请正确操作!");
                    }

                    //string fileName = file.FileName;
                    var bll = new SitePicture();
                    //if (bll.IsExist(userId, file.FileName, fileSize)) throw new ArgumentException("文件【" + file.FileName + "】已存在,请勿重复上传!");

                    string originalUrl = UploadFilesHelper.UploadOriginalFile(file, "SitePicture");

                    var model = new SitePictureInfo(Guid.Empty, userId, VirtualPathUtility.GetFileName(originalUrl), fileSize, VirtualPathUtility.GetExtension(originalUrl).ToLower(), VirtualPathUtility.GetDirectory(originalUrl.Replace("~", "")), Path.GetFileNameWithoutExtension(context.Server.MapPath(originalUrl)), funType, DateTime.Now);
                    CreateThumbnailImage(context, ih, context.Server.MapPath(originalUrl));

                    bll.Insert(model);
                    effect++;
                }

                scope.Complete();
            }

            if (effect > 0)
            {
                context.Response.Write("{\"success\": true,\"message\": \"已成功上传文件数:" + effect + "个\"}");
            }
            else
            {
                context.Response.Write("{\"success\": false,\"message\": \"上传失败,请检查!\"}");
            }
        }
Esempio n. 5
0
        public IList <SitePictureInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(500);

            sb.Append(@"select count(*) from SitePicture ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <SitePictureInfo>());
            }

            sb.Clear();
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate) as RowNumber,
			          Id,UserId,FileName,FileSize,FileExtension,FileDirectory,RandomFolder,FunType,LastUpdatedDate
					  from SitePicture "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <SitePictureInfo> list = new List <SitePictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        SitePictureInfo model = new SitePictureInfo();
                        model.Id              = reader.GetGuid(1);
                        model.UserId          = reader.GetGuid(2);
                        model.FileName        = reader.GetString(3);
                        model.FileSize        = reader.GetInt32(4);
                        model.FileExtension   = reader.GetString(5);
                        model.FileDirectory   = reader.GetString(6);
                        model.RandomFolder    = reader.GetString(7);
                        model.FunType         = reader.GetString(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Esempio n. 6
0
        public IList <SitePictureInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(500);

            sb.Append(@"select Id,UserId,FileName,FileSize,FileExtension,FileDirectory,RandomFolder,FunType,LastUpdatedDate
                        from SitePicture ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.Append("order by LastUpdatedDate ");

            IList <SitePictureInfo> list = new List <SitePictureInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        SitePictureInfo model = new SitePictureInfo();
                        model.Id              = reader.GetGuid(0);
                        model.UserId          = reader.GetGuid(1);
                        model.FileName        = reader.GetString(2);
                        model.FileSize        = reader.GetInt32(3);
                        model.FileExtension   = reader.GetString(4);
                        model.FileDirectory   = reader.GetString(5);
                        model.RandomFolder    = reader.GetString(6);
                        model.FunType         = reader.GetString(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Esempio n. 7
0
        public SitePictureInfo GetModel(Guid id)
        {
            SitePictureInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,UserId,FileName,FileSize,FileExtension,FileDirectory,RandomFolder,FunType,LastUpdatedDate 
			            from SitePicture
						where Id = @Id "                        );
            SqlParameter[] parms =
            {
                new SqlParameter("@Id", SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = id;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.AspnetDbConnString, CommandType.Text, sb.ToString(), parms))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        model                 = new SitePictureInfo();
                        model.Id              = reader.GetGuid(0);
                        model.UserId          = reader.GetGuid(1);
                        model.FileName        = reader.GetString(2);
                        model.FileSize        = reader.GetInt32(3);
                        model.FileExtension   = reader.GetString(4);
                        model.FileDirectory   = reader.GetString(5);
                        model.RandomFolder    = reader.GetString(6);
                        model.FunType         = reader.GetString(7);
                        model.LastUpdatedDate = reader.GetDateTime(8);
                    }
                }
            }

            return(model);
        }
Esempio n. 8
0
 public int Update(SitePictureInfo model)
 {
     return(dal.Update(model));
 }
Esempio n. 9
0
 public int InsertByOutput(SitePictureInfo model)
 {
     return(dal.InsertByOutput(model));
 }
Esempio n. 10
0
 public int Insert(SitePictureInfo model)
 {
     throw new NotImplementedException();
 }
Esempio n. 11
0
 public int Update(SitePictureInfo model)
 {
     throw new NotImplementedException();
 }