public IList <ValidationResult> CollectBeforePersistValidationResults(PhotoResourceDto photoResourceDto) { List <ValidationResult> validationResults = new List <ValidationResult>(); validationResults.AddRange(IsFileOverlimit(photoResourceDto)); validationResults.AddRange(IsMaximumPhotoLimitReached(photoResourceDto)); validationResults.AddRange(IsImage(photoResourceDto)); return(validationResults); }
private IList <ValidationResult> IsFileOverlimit(PhotoResourceDto photoResourceDto) { IList <ValidationResult> validationResults = new List <ValidationResult>(); if (MAXIMUM_PHOTO_FILE_SIZE < photoResourceDto.Stream.Length / 1024) { validationResults.Add(new ValidationResult(MessageKeyConstants.VALIDATION_FILE_IS_OVERSIZED_MESSAGE, photoResourceDto.Name, MAXIMUM_PHOTO_FILE_SIZE / 1024)); } return(validationResults); }
private IList <ValidationResult> IsMaximumPhotoLimitReached(PhotoResourceDto photoResourceDto) { IList <ValidationResult> validationResults = new List <ValidationResult>(); int maximumPhotoLimit = PhotoThumbnailInfoProvider.GetDefault(photoResourceDto.OwnerType).MaximumPhotos; int currentPhotoCount = _genericDao.Count <Resource>(x => x.UserDefinableId == photoResourceDto.UserDefinableId); if (currentPhotoCount >= maximumPhotoLimit) { validationResults.Add(new ValidationResult(MessageKeyConstants.VALIDATION_MAXIMUM_RESOURCES_REACHED_MESSAGE, maximumPhotoLimit)); } return(validationResults); }
private void GeneratePaintingImage(Document document, Painting painting, Cell cell) { Gallery gallery = _galleryDao.FindSingle(new GalleryFilterDto() { OwnerId = painting.Id }); if (gallery == null) { return; } if (gallery.CoverPhotoId == null) { return; } Resource resource = gallery.CoverPhoto; string imagePath = PhotoResourceDto.GetAbsoluteThumbnailFilePath(resource.Path, resource.Name); InlineShape inlineShape = cell.Range.InlineShapes.AddPicture(imagePath); inlineShape.LockAspectRatio = MsoTriState.msoTrue; inlineShape.Width = 180f; }
private IList <ValidationResult> IsImage(PhotoResourceDto photoResourceDto) { IList <ValidationResult> validationResults = new List <ValidationResult>(); try { using (Image image = Image.FromStream(photoResourceDto.Stream, false, false)) { PhotoThumbnailInfo photoThumbnailInfo = PhotoThumbnailInfoProvider.GetDefault(photoResourceDto.OwnerType); if (photoThumbnailInfo.MinimumHeight < image.Height || photoThumbnailInfo.MinimumWidth < image.Width) { validationResults.Add(new ValidationResult(MessageKeyConstants.VALIDATION_IMAGE_MINIMUM_SIZE_MESSAGE, image.Width, image.Height, photoThumbnailInfo.MinimumWidth, photoThumbnailInfo.MinimumHeight)); } return(validationResults); } } catch { validationResults.Add(new ValidationResult(MessageKeyConstants.VALIDATION_FILE_IS_IN_WRONG_FORMAT_MESSAGE, "Image")); } return(validationResults); }
public virtual ActionResult FileReferenceConfirmed(DialogDto dialogDto, HttpPostedFileBase file) { // TODO change the implementation string fileName = null; Stream stream = null; if (file != null) { fileName = file.FileName; stream = file.InputStream; } try { GetUnitOfWork().StartTransaction(); PhotoResourceDto photoResourceDto = null;// (PhotoResourceDto)GetService().UploadFile(dialogDto.Id, typeof(T), fileName, stream); GetUnitOfWork().EndTransaction(); return(Json(new JsonFileSelectDialogResult(true, photoResourceDto.GetRelativeThumbnailFile(), photoResourceDto.GetRelativeFilePath(), JsonRefreshMode.IMAGE_TO_RICHTEXTBOX))); } catch (ValidationException ex) { return(Json(new JsonDialogResult(false, HtmlConstants.DIALOG_VALIDATION_SUMMARY, ValidationSummaryExtensions.CustomValidationSummary(ex.Message).ToString()))); } }
public PaintingDto() { Date = DateTime.Now; ProfileGalleryDto = new ProfileGalleryDto(GetType()); CoverPhotoResourceDto = new PhotoResourceDto(); }