IEntityDocumentShell.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using InABox.Clients;
  3. using InABox.Core;
  4. namespace InABox.Mobile
  5. {
  6. public interface IEntityDocumentShell : IShell
  7. {
  8. Guid ID { get; }
  9. Guid ParentID { get; set; }
  10. Guid DocumentID { get; set; }
  11. String FileName { get; set; }
  12. byte[] Thumbnail { get; set; }
  13. }
  14. public static class EntityDocumentUtils
  15. {
  16. public static T SaveDocument<T>(MobileDocument image, Func<T> shell, string auditmessage) where T : IEntityDocumentShell
  17. {
  18. T result = default(T);
  19. Document doc = new Document()
  20. {
  21. FileName = image.FileName,
  22. Data = image.Data,
  23. CRC = CoreUtils.CalculateCRC(image.Data),
  24. TimeStamp = DateTime.Now
  25. };
  26. new Client<Document>().Save(doc, auditmessage);
  27. result = shell();
  28. result.DocumentID = doc.ID;
  29. result.FileName = doc.FileName;
  30. result.Thumbnail = MobileUtils.ImageTools.CreateThumbnail(doc.Data, 128, 128);
  31. result.Save(auditmessage);
  32. return result;
  33. }
  34. }
  35. }