| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | 
							- using Comal.Classes;
 
- using Comal.Stores;
 
- using InABox.Core;
 
- using System;
 
- using System.Linq;
 
- using System.IO;
 
- using Syncfusion.Pdf.Parsing;
 
- using System.Drawing;
 
- using System.Drawing.Imaging;
 
- namespace PRSStores
 
- {
 
-     public abstract class EntityDocumentStore<TEntityDocument, TEntity, TEntityLink> : BaseStore<TEntityDocument>
 
-         where TEntityDocument : EntityDocument<TEntityLink>, new()
 
-         where TEntityLink : EntityLink<TEntity>, new()
 
-          where TEntity : Entity, new()
 
-     {
 
-         protected override void BeforeSave(TEntityDocument entity)
 
-         {
 
-             SaveThumbnail(entity); //current size for saved thumbnails is 256*256
 
-             base.BeforeSave(entity);           
 
-         }
 
-         private void SaveThumbnail(TEntityDocument entity)
 
-         {
 
-             var stopwatch = new System.Diagnostics.Stopwatch();
 
-             stopwatch.Start();
 
-             if (entity.DocumentLink.ID == Guid.Empty)
 
-                 return;
 
-             CoreTable table = Provider.Query<Document>(new Filter<Document>(x => x.ID).IsEqualTo(entity.DocumentLink.ID),
 
-                 new Columns<Document>(x => x.Data, x => x.FileName));
 
-             if (table.Rows.Count == 0)
 
-                 return;
 
-             Document doc = table.Rows.FirstOrDefault().ToObject<Document>();
 
-             if (!doc.FileName.ToLower().EndsWith("pdf"))
 
-                 return;
 
-             PdfLoadedDocument loadeddoc = new PdfLoadedDocument(doc.Data);
 
-             Bitmap image = loadeddoc.ExportAsImage(0, new SizeF(256, 256), true);
 
-             MemoryStream stream = new MemoryStream();
 
-             image.Save(stream, ImageFormat.Jpeg);
 
-             entity.Thumbnail = stream.ToArray();
 
-             stopwatch.Stop();
 
-             Logger.Send(LogType.Information, UserID, "Time taken to compress thumbnail " + stopwatch.ElapsedMilliseconds + " milliseconds");
 
-         }
 
-     }
 
-     //In order to have BeforeSave active for a specific EntityDocument, it has to be concretized as below
 
-     public class JobDocumentSetSetMileStoneFileStore : EntityDocumentStore<JobDocumentSetMileStoneFile, JobDocumentSetMileStone, JobDocumentSetMileStoneLink>
 
-     {
 
-     }
 
-     
 
-     public class MeetingItemDocumentStore : EntityDocumentStore<MeetingItemDocument, MeetingItem, MeetingItemLink>
 
-     {
 
-     }
 
- }
 
 
  |