private void FillTablesOriginalPhotosRecord(FileInfo info) { // use only with original photos byte[] imageData = UserControlUploadPhoto.GetFileContentFromInfo(info); // original photos table _tblOriginalPhotos = new Table_OriginalPhotosArchive { AlternateText = ucUploadPhoto1.textBoxPhotoDescription.Text, Caption = ucUploadPhoto1.textBoxPhotoCaption.Text, CategoryId = Lookup.GetLookupCategoryIdFromName(comboBoxCategory.SelectedText), Date = DateTime.Now, Description = ucUploadPhoto1.textBoxPhotoDescription.Text }; var pb = new PictureBox { Image = UserControlUploadPhoto.GetImageFromFileInfo(info) }; _tblOriginalPhotos.ImageData = imageData; string[] pathParts = ucUploadPhoto1.textBoxPhotoPath.Text.Split('\\', '/', '.'); _tblOriginalPhotos.Name = pathParts[pathParts.Length - 2].Trim('\\', '/', '.', ' '); _tblOriginalPhotos.Width = pb.Image.Width; _tblOriginalPhotos.Height = pb.Image.Height; // photos archive table _tblPhotos = new Table_PhotosArchive { LastTakId = 0, LastArticleId = 0, CssClass = "OriginalPhotoView", Date = DateTime.Now, ImageUrl = String.Format("~\\Photos\\Originals\\{0}\\{1}.jpg", _tblOriginalPhotos.CategoryId, ucUploadPhoto1.textBoxPhotoCaption.Text), OriginalPhotoId = _tblOriginalPhotos.PhotoId, GalleryId = null, PhotoTypeId = 1 }; _tblPhotos.UrlLink = _tblPhotos.ImageUrl; _tblPhotos.Width = _tblOriginalPhotos.Width; _tblPhotos.Height = _tblOriginalPhotos.Height; }
private void FillTablesOriginalPhotosRecord(FileInfo info) { // use only with original photos byte[] imageData = GetFileContentFromInfo(info); // original photos table FormEditArtical._tblOriginalPhotos = new Table_OriginalPhotosArchive(); FormEditArtical._tblOriginalPhotos.AlternateText = textBoxPhotoDescription.Text; FormEditArtical._tblOriginalPhotos.Caption = textBoxPhotoCaption.Text; FormEditArtical._tblOriginalPhotos.CategoryId = GetCetegoryIdFromName(comboBoxArticleCategory.SelectedText); FormEditArtical._tblOriginalPhotos.Date = DateTime.Now; FormEditArtical._tblOriginalPhotos.Description = textBoxPhotoDescription.Text; PictureBox pb = new PictureBox(); pb.Image = GetImageFromFileInfo(info); FormEditArtical._tblOriginalPhotos.ImageData = imageData; string[] pathParts = textBoxPhotoPath.Text.Split('\\', '/', '.'); FormEditArtical._tblOriginalPhotos.Name = pathParts[pathParts.Length - 2].Trim('\\', '/', '.', ' '); FormEditArtical._tblOriginalPhotos.Width = pb.Image.Width; FormEditArtical._tblOriginalPhotos.Height = pb.Image.Height; // photos archive table FormEditArtical._tblPhotos = new Table_PhotosArchive(); FormEditArtical._tblPhotos.LastTakId = 0; // - no use for original image FormEditArtical._tblPhotos.LastArticleId = 0; // - no use for original image FormEditArtical._tblPhotos.CssClass = "OriginalPhotoView"; //TBD FormEditArtical._tblPhotos.Date = DateTime.Now; FormEditArtical._tblPhotos.ImageUrl = String.Format("~\\Photos\\Originals\\{0}\\{1}.jpg", FormEditArtical._tblOriginalPhotos.CategoryId, this.textBoxPhotoCaption.Text); FormEditArtical._tblPhotos.OriginalPhotoId = FormEditArtical._tblOriginalPhotos.PhotoId; FormEditArtical._tblPhotos.GalleryId = null; FormEditArtical._tblPhotos.PhotoTypeId = 1; // 1 means original size FormEditArtical._tblPhotos.UrlLink = FormEditArtical._tblPhotos.ImageUrl; FormEditArtical._tblPhotos.Width = FormEditArtical._tblOriginalPhotos.Width; FormEditArtical._tblPhotos.Height = FormEditArtical._tblOriginalPhotos.Height; }
private static void SaveSmallPhotoCopyToPhotoArchive(string photoSizeAsString) { string[] splitStrings = {"x","×××× "}; string[] sizes = photoSizeAsString.Split(splitStrings, StringSplitOptions.RemoveEmptyEntries); int width = int.Parse(sizes[0]); int height = int.Parse(sizes[1]); //MessageBox.Show("width = " + width + " height = " + height); DateTime now = DateTime.Now; int typeId = DataAccess.Lookup.GetLookupPhotoTypeIdFromPhotoWidth(width); string url = String.Format("~\\Photos\\Thumbnail\\{0}\\{1}_{2}x{3}_KanNaim_{4}-{5}-{6}_{7}.jpg", _tblOriginalPhotos.CategoryId, _tblOriginalPhotos.Name, width, height, now.Day, now.Month, now.Year, typeId); var copyData = _tblPhotos; _tblPhotos = new Table_PhotosArchive { PhotoTypeId = typeId, OriginalPhotoId = copyData.OriginalPhotoId, ImageUrl = url, Width = width, Height = height, CssClass = copyData.CssClass, Date = DateTime.Now, GalleryId=null, LastArticleId = null }; try { Db.Table_PhotosArchives.InsertOnSubmit(_tblPhotos); Db.SubmitChanges(); } catch(Exception exception) { Messages.ExceptionMessage(exception); } }
private static bool FillTablesOriginalPhotosRecord(FileInfo info) { // use only with original photos byte[] imageData = UserControlUploadPhoto.GetFileContentFromInfo(info); // original photos table _tblOriginalPhotos = new Table_OriginalPhotosArchive { AlternateText = _singleton._ucUploadPhoto1.textBoxPhotoDescription.Text, Caption = _singleton._ucUploadPhoto1.textBoxPhotoCaption.Text, CategoryId = _tblArticle.CategoryId, Date = DateTime.Now, Description = _singleton._ucUploadPhoto1.textBoxPhotoDescription.Text }; var pb = new PictureBox { Image = UserControlUploadPhoto.GetImageFromFileInfo(info) }; _tblOriginalPhotos.ImageData = imageData; string[] pathParts = _singleton._ucUploadPhoto1.textBoxPhotoPath.Text.Split('\\', '/', '.'); _tblOriginalPhotos.Name = pathParts[pathParts.Length - 2].Trim('\\', '/', '.', ' '); _tblOriginalPhotos.Width = pb.Image.Width; _tblOriginalPhotos.Height = pb.Image.Height; // photos archive table _tblPhotos = new Table_PhotosArchive { LastTakId = 0, LastArticleId = 0, CssClass = "ArchivePhotoView", Date = DateTime.Now, ImageUrl = String.Format("~\\Photos\\Originals\\{0}\\{1}.jpg", _tblOriginalPhotos.CategoryId, _tblOriginalPhotos.Name), OriginalPhotoId = _tblOriginalPhotos.PhotoId, GalleryId = null, PhotoTypeId = 1 }; _tblPhotos.UrlLink = _tblPhotos.ImageUrl; _tblPhotos.Width = _tblOriginalPhotos.Width; _tblPhotos.Height = _tblOriginalPhotos.Height; bool returnValue = (_tblOriginalPhotos.Name != "") && (_tblOriginalPhotos.ImageData.Length > 0) && (_tblOriginalPhotos.Height > 0) && (_tblOriginalPhotos.Width > 0) && (_tblOriginalPhotos.CategoryId > 0) && (_tblPhotos.ImageUrl.Length > 20); return returnValue; }
private void detach_Table_PhotosArchives(Table_PhotosArchive entity) { this.SendPropertyChanging(); entity.Table_Article = null; }