예제 #1
0
 protected override void OnSave()
 {
     if (IsNew)
     {
         string targetFolder = Server.MapPath(Utils.GaleryImagePath);
         foreach (UploadedFile af in auFile.UploadedFiles)
         {
             string newGUID = Guid.NewGuid().ToString();
             string newFileName = newGUID + ".jpg";
             string path = Path.Combine(targetFolder, newFileName);
             af.SaveAs(path, true);
             Gallery g = new Gallery();
             g.AddNew();
             g.CategoryID = CategoryID;
             g.PhotoName = newFileName;
             g.IsCover = false;
             g.ShowCommon = false;
             g.Save();
             try
             {
                 System.IO.FileStream fs = System.IO.File.OpenRead(Path.Combine(targetFolder, newFileName));
                 byte[] b = new byte[fs.Length];
                 fs.Read(b, 0, b.Length);
                 newFileName = newGUID + "_s.jpg";
                 Utils.ResizeAndSaveJpgImage(b, 2000, 150, Path.Combine(targetFolder, newFileName), false);
             }
             catch { }
         }
         Response.Redirect("Office.aspx?content=CategoryEdit&CategoryID=" + CategoryID);
     }
     else
     {
         base.OnSave();
     }
 }