private void richEditControl1_ContentChanged(object sender, EventArgs e) { //DocumentImageCollection imageCollection = richEditControl1.Document.Images; if (imageCollection.Count > count) { DocumentImage image = imageCollection[imageCollection.Count - 1]; var a = image.Image.NativeImage; if (!System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\Slike\\" + task.id_task.ToString() + "\\" + tempid.ToString())) { System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\\Slike\\" + task.id_task.ToString() + "\\" + tempid.ToString()); } string uri = System.Windows.Forms.Application.StartupPath + "\\Slike\\" + task.id_task.ToString() + "\\" + tempid.ToString() + "\\" + count.ToString() + ".bmp"; a.Save(uri); DocumentRange b = image.Range; richEditControl1.Document.Delete(b); var c = AbacusSUPP.Helper.ResizeImage(a, 350, 350 * a.Height / a.Width); imageCollection.Insert(richEditControl1.Document.CaretPosition, c); var d = imageCollection[imageCollection.Count - 1]; b = d.Range; Hyperlink hyperlink = richEditControl1.Document.CreateHyperlink(b); hyperlink.NavigateUri = uri; count++; } if (imageCollection.Count < count) { count--; } }
public ActionResult Edit(EditDocumentViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var document = db.Documents.Include(x => x.Images).FirstOrDefault(x => x.Id == model.Id); if (document == null) { throw new HttpException(404, "Не найдено"); } document.DocumentName = model.DocumentName; //Загружаем изображение, если есть if (model.UploadedImage != null && model.UploadedImage.ContentLength > 0) { var image = new DocumentImage() { ImageUrl = FileUploader.UploadFile(model.UploadedImage) }; document.Images.Add(image); } //Сохраняем изменения db.Entry(document).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit", "AdminDocuments", new { id = model.Id })); }
public IActionResult Delete(int imgid) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DocumentImage image = _context.DocumentImage.SingleOrDefault(x => x.DocumentImageID == imgid); if (image == null) { return(NotFound()); } _context.DocumentImage.Remove(image); try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(StatusCode(500)); } return(Ok()); }
public async Task <JsonResponse> Post([FromBody] DocumentImage newdocumentimage) { JsonResponse response = new JsonResponse { Success = false, Message = "Bad Request" }; if (newdocumentimage == null) { return(response); } _context.DocumentImage.Add(newdocumentimage); try { await _context.SaveChangesAsync(); } catch { response.Success = false; response.Message = "There was a database error. Please try again."; return(response); } response.Success = true; response.Message = "Added successfully"; return(response); }
public static bool ConvertImageToPdf(Image image, string naziv, RevizijaAPI.Models.Database.dms_file folderOstalo, int id_operater) { using (RichEditDocumentServer server = new RichEditDocumentServer()) { try { //Insert an image DocumentImage docImage = server.Document.Images.Append(DocumentImageSource.FromImage(image)); //Adjust the page width and height to the image's size server.Document.Sections[0].Page.Width = docImage.Size.Width + server.Document.Sections[0].Margins.Right + server.Document.Sections[0].Margins.Left; server.Document.Sections[0].Page.Height = docImage.Size.Height + server.Document.Sections[0].Margins.Top + server.Document.Sections[0].Margins.Bottom; var result = Upload2DMS(folderOstalo, naziv, image, id_operater); if (result.result) { using (FileStream fs = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath($"~\\Uploads\\{result.guid}"), FileMode.OpenOrCreate)) { server.ExportToPdf(fs); } return(true); } else { return(false); } } catch (Exception ex) { return(false); } } }
public JsonResult AddDocuments(Login login) { CallStatus status = new CallStatus(); try { string[] fileList = Directory.GetFiles(ConfigurationManager.AppSettings["DocumentPath"], ConfigurationManager.AppSettings["DocumentType"]); for (int i = 0; i < fileList.Length; i++) { var imageData = GenericHelper.ImageToByteArray(fileList[i]); using (var context = new SpiralDomeDbContext()) { DocumentImage obj = new DocumentImage() { ImageData = imageData, Name = fileList[i].Split('\\')[fileList[i].Split('\\').Length - 1], LoginId = login.LoginId }; context.DocumentImages.Add(obj); context.SaveChanges(); } } status.IsSuccess = true; } catch (Exception ex) { status.IsSuccess = false; status.Message = ex.Message; } return(Json(status)); }
private void richEditControl1_ContentChanged(object sender, EventArgs e) { DocumentImageCollection collection = richEditControl1.Document.GetImages(richEditControl1.Document.Range); if (collection.Count > 0) { DocumentImage image = collection[collection.Count - 1]; richEditControl1.Document.Sections[0].Page.Width = image.Size.Width + richEditControl1.Document.Sections[0].Margins.Left + richEditControl1.Document.Sections[0].Margins.Right; } }
async void Save(object sender, System.EventArgs e) { if (_file == null) { await DisplayAlert("Oops!", "Take a photo first", "OK"); return; } DocumentImage newdocumentimage = new DocumentImage { DocumentID = _document.DocumentID, FilePath = _file.Path, DateCreated = DateTime.Today, PageNumber = 1 }; var response = App.APIService.SaveNewPhoto(newdocumentimage); await Navigation.PopModalAsync(); }
private void InsertCaptions(Document document) { #region #MarkEntries richEditControl1.LoadDocument("Documents//Table of Contents.docx"); document.BeginUpdate(); for (int i = 0; i < document.Images.Count; i++) { DocumentImage shape = document.Images[i]; Paragraph paragraph = document.Paragraphs.Insert(shape.Range.End); //Insert caption to every image in the document DocumentRange range = document.InsertText(paragraph.Range.Start, "Image "); //Mark the captions with the SEQ fields Field field = document.Fields.Create(range.End, "SEQ Image \\*ARABIC"); } document.Fields.Update(); document.EndUpdate(); #endregion #MarkEntries }
public async Task <JsonResponse> SaveNewPhoto(DocumentImage newImage) { var uri = new Uri(string.Format(_keys.SafeHavenAPI + "/documentimage/post", string.Empty)); try { var jsonRequest = JsonConvert.SerializeObject(newImage); var fullRequest = new StringContent(jsonRequest, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PostAsync(uri, fullRequest); var JSONstring = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <JsonResponse>(JSONstring)); } catch { return(new JsonResponse { Message = "Our database is down at the moment, please try again later", Success = false }); } }
public IActionResult Put(int imgid, [FromBody] DocumentImage image) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (imgid != image.DocumentImageID) { return(BadRequest()); } _context.DocumentImage.Update(image); try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(StatusCode(500)); } return(Ok()); }
// Method runs on startup to initialize dummy data. public static void Initialize(IServiceProvider serviceProvider) { using (var context = new SafeHavenContext(serviceProvider.GetRequiredService <DbContextOptions <SafeHavenContext> >())) { // Look for any Customers. if (context.User.Any()) { return; // DB has been seeded, the rest of this method doesn't need to run. } // Creating new instances of User var users = new User[] { new User { FirstName = "Jill", LastName = "Smith", Email = "*****@*****.**", Password = "******", Street = "111 Bob St.", ZIP = 38101, State = "TN" }, new User { FirstName = "Nigel", LastName = "Johnson", Email = "*****@*****.**", Password = "******", Street = "222 Saint St.", ZIP = 39881, State = "CA" }, new User { FirstName = "Mark", LastName = "Jones", Email = "*****@*****.**", Password = "******", Street = "333 Thomas St.", ZIP = 12938, State = "NY" } }; // Adds each new user into the context foreach (User i in users) { context.User.Add(i); } // Saves to DB context.SaveChanges(); var documentTypes = new DocumentType[] { new DocumentType { Title = "Insurance" }, new DocumentType { Title = "Estate/Will" }, new DocumentType { Title = "Medical" }, new DocumentType { Title = "Taxes" }, new DocumentType { Title = "Birth/Death" }, new DocumentType { Title = "Marriage/Divorce" }, new DocumentType { Title = "Military" }, new DocumentType { Title = "Pension" }, new DocumentType { Title = "Real Estate/Mortgage" }, new DocumentType { Title = "Deed/Title" }, new DocumentType { Title = "Education" }, new DocumentType { Title = "Checking/Savings Accounts" }, new DocumentType { Title = "Investment Accounts" }, new DocumentType { Title = "Retirement Accounts" }, new DocumentType { Title = "Credit/Loans" }, new DocumentType { Title = "Identification" }, new DocumentType { Title = "Other" } }; foreach (DocumentType p in documentTypes) { context.DocumentType.Add(p); } context.SaveChanges(); var documents = new Document[] { new Document { Title = "My Emergency Contacts", DateCreated = new DateTime(2017, 04, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Other").DocumentTypeID, PhysicalLocation = "Basement Safe", Notes = "Call Bill first!", UserID = context.User.Single(x => x.FirstName == "Jill").UserID }, new Document { Title = "Health Insurance 2017", DateCreated = new DateTime(2017, 03, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Insurance").DocumentTypeID, PhysicalLocation = "Bedroom Closet", Notes = "Cigna Health", UserID = context.User.Single(x => x.FirstName == "Jill").UserID }, new Document { Title = "SunTrust Annuity", DateCreated = new DateTime(2017, 06, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Pension").DocumentTypeID, PhysicalLocation = "SunTrust Safe Deposit Box", Notes = "Code on deposit box is 201938", UserID = context.User.Single(x => x.FirstName == "Jill").UserID }, new Document { Title = "Ben's Driver's License", DateCreated = new DateTime(2017, 06, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Identification").DocumentTypeID, PhysicalLocation = "In his wallet", Notes = "Expires 2021", UserID = context.User.Single(x => x.FirstName == "Jill").UserID }, new Document { Title = "Mortgage details", DateCreated = new DateTime(2017, 04, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Deed/Title").DocumentTypeID, PhysicalLocation = "Basement Safe", Notes = "30 year fixed", UserID = context.User.Single(x => x.FirstName == "Nigel").UserID }, new Document { Title = "BoA Safe Deposit Box Contract", DateCreated = new DateTime(2017, 03, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Checking/Savings Accounts").DocumentTypeID, PhysicalLocation = "Bedroom Closet", Notes = "Paid for five years until 2022", UserID = context.User.Single(x => x.FirstName == "Nigel").UserID }, new Document { Title = "My Medications List", DateCreated = new DateTime(2017, 06, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Medical").DocumentTypeID, PhysicalLocation = "Filing cabinet in my office", Notes = "I'm allergic to penicillin", UserID = context.User.Single(x => x.FirstName == "Nigel").UserID }, new Document { Title = "American Express Credit Card", DateCreated = new DateTime(2017, 04, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Credit/Loans").DocumentTypeID, PhysicalLocation = "Basement Safe", Notes = "Paid in full each month", UserID = context.User.Single(x => x.FirstName == "Mark").UserID }, new Document { Title = "Car Insurance 2017", DateCreated = new DateTime(2017, 03, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Insurance").DocumentTypeID, PhysicalLocation = "Bedroom Closet", Notes = "Geico", UserID = context.User.Single(x => x.FirstName == "Mark").UserID }, new Document { Title = "My Estate Plan", DateCreated = new DateTime(2017, 06, 28), DocumentTypeID = context.DocumentType.Single(x => x.Title == "Estate/Will").DocumentTypeID, PhysicalLocation = "Bedroom closet", Notes = "Don't forget the eulogy", UserID = context.User.Single(x => x.FirstName == "Mark").UserID } }; foreach (Document t in documents) { context.Document.Add(t); } context.SaveChanges(); var images = new DocumentImage[] { new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "My Emergency Contacts").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_40.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "Health Insurance 2017").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_50.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "SunTrust Annuity").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_45.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "Ben's Driver's License").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_58.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "Mortgage details").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_49.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "BoA Safe Deposit Box Contract").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_47.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "My Medications List").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_41.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "American Express Credit Card").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_48.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "Car Insurance 2017").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_51.jpg", PageNumber = 1 }, new DocumentImage { DateCreated = new DateTime(2017, 06, 28), DocumentID = context.Document.Single(x => x.Title == "My Estate Plan").DocumentID, FilePath = "/var/mobile/Containers/Data/Application/7B2810CA-2AE5-400F-A198-7170DAFC538F/Documents/Sample/test_50.jpg", PageNumber = 1 } }; foreach (DocumentImage p in images) { context.DocumentImage.Add(p); } context.SaveChanges(); var accessrights = new AccessRight[] { new AccessRight { GrantorID = context.User.Single(x => x.FirstName == "Jill").UserID, AccessorID = context.User.Single(x => x.FirstName == "Mark").UserID }, new AccessRight { GrantorID = context.User.Single(x => x.FirstName == "Jill").UserID, AccessorID = context.User.Single(x => x.FirstName == "Nigel").UserID }, new AccessRight { GrantorID = context.User.Single(x => x.FirstName == "Nigel").UserID, AccessorID = context.User.Single(x => x.FirstName == "Mark").UserID }, new AccessRight { GrantorID = context.User.Single(x => x.FirstName == "Nigel").UserID, AccessorID = context.User.Single(x => x.FirstName == "Jill").UserID }, new AccessRight { GrantorID = context.User.Single(x => x.FirstName == "Mark").UserID, AccessorID = context.User.Single(x => x.FirstName == "Nigel").UserID }, new AccessRight { GrantorID = context.User.Single(x => x.FirstName == "Mark").UserID, AccessorID = context.User.Single(x => x.FirstName == "Jill").UserID } }; foreach (AccessRight ar in accessrights) { context.AccessRight.Add(ar); } context.SaveChanges(); } }
private static SizeF GetImageSizeF(DocumentImage img, RichEditControl richEditContrl) { float pageWidth = richEditContrl.Document.Sections[0].Page.Width - richEditContrl.Document.Sections[0].Margins.Left - richEditContrl.Document.Sections[0].Margins.Right; float pageHeight = richEditContrl.Document.Sections[0].Page.Height - richEditContrl.Document.Sections[0].Margins.Top - richEditContrl.Document.Sections[0].Margins.Bottom; float imgHeight = img.Size.Height; float imgWidth = img.Size.Width; if (imgWidth > pageWidth || imgHeight > pageHeight) { float ratio = Math.Min(imgWidth / pageWidth, imgHeight / pageHeight); ratio = ratio > 1 ? 1 / (Math.Max(imgWidth / pageWidth, imgHeight / pageHeight)) : ratio; return new SizeF(imgWidth * ratio, imgHeight * ratio); } return img.Size; }
private void copyImageToClipboard(DocumentImage documentImage) { var image = new Metafile(documentImage.Image.GetImageBytesStreamSafe(OfficeImageFormat.Emf)); _clipboardTask.PutEnhMetafileOnClipboard(_control, image); }
/// <summary> /// This method demonstrates how to add an image embedded inside the component into the report /// </summary> private void AddImage() { var image = new DocumentImage(new Uri(@"pack://application:,,,/ExtensibleStorageDocumentation;component/Images/Image.png")); this.docReport.Main.Elements.Add(image); }