Пример #1
0
        public static GeneretedResult GenerateImages(this HttpPostedFile file, ImagesSetting setting, DateTime uploadDate,
                                                     GenerateIdentityForImageHandler generateIdentityForImageHandler)
        {
            GeneretedResult generatedResult = new GeneretedResult();

            ImagesEditor imgEditor = new ImagesEditor(setting);

            generatedResult.Message = imgEditor.GetValidateMessage(file.InputStream);

            if (generatedResult.Message != "")
            {
                return(generatedResult);
            }
            try
            {
                string identity = ImagesEditor.CreateImageIdentity();
                if (generateIdentityForImageHandler != null)
                {
                    identity = generateIdentityForImageHandler(setting.Name, uploadDate);
                }


                if (setting.FixSourceExtention)
                {
                    setting.OutputImageFormat = file.FileName.Substring(file.FileName.LastIndexOf('.') + 1);
                }

                var mainImagePath = ImagesEditor.GetRealImagePath(setting.Path, "Main", uploadDate, identity, setting.OutputImageFormat.ToString());

                file.SaveAs(mainImagePath);

                imgEditor.SaveAndGetPaths(mainImagePath, identity, uploadDate);

                generatedResult.IsSuccessfull = true;
                generatedResult.Identity      = identity;
            }
            catch (Exception ex)
            {
                generatedResult.Message       = ex.Message;
                generatedResult.IsSuccessfull = false;
                generatedResult.Identity      = string.Empty;
            }

            return(generatedResult);
        }
Пример #2
0
 public static string GetPath(this string id, ImagesSetting setting, string size, DateTime uploadedDate)
 {
     return(ImagesEditor.GetImagePath(setting.Path, size, uploadedDate, id, setting.OutputImageFormat));
 }