| 
					
				 | 
			
			
				@@ -4,15 +4,21 @@ using InABox.Clients; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using InABox.Core; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using InABox.DynamicGrid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using javax.print.attribute.standard; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using Microsoft.Exchange.WebServices.Data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using Microsoft.Win32; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using Syncfusion.Pdf.Parsing; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using Syncfusion.UI.Xaml.Grid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Collections.Generic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using System.Drawing; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.IO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Linq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Text; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Threading.Tasks; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Windows; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Windows.Controls; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using System.Drawing.Imaging; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using net.sf.mpxj.common; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -20,13 +26,16 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<string> _existingFileNames = new List<string>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Job> _jobs = new List<Job>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        string _setoutsFolder = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public StagingSetoutGrid() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HiddenColumns.Add(x => x.Setout.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HiddenColumns.Add(x => x.JobLink.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HiddenColumns.Add(x => x.Group.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HiddenColumns.Add(x => x.Group.OptimizationDocument.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HiddenColumns.Add(x => x.Locked); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HiddenColumns.Add(x => x.SavePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HiddenColumns.Add(x => x.LockedBy.ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Options.Add(DynamicGridOption.FilterRows); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Options.Add(DynamicGridOption.SelectColumns); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Options.Add(DynamicGridOption.RecordCount); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -61,10 +70,10 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var group = new SetoutGroup(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             var page = new DynamicDataGrid<SetoutGroup>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            page.OnAfterSave += (editor, items) =>  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            page.OnAfterSave += (editor, items) => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 foreach (var staging in list) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                {  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     staging.Group.ID = group.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 new Client<StagingSetout>().Save(list, "Updated group"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -73,9 +82,13 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return page.EditItems(new[] { group }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private void Page_OnAfterSave(IDynamicEditorForm editor, BaseObject[] items) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void DoAdd(bool OpenEditorOnDirectEdit = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var dlg = new OpenFileDialog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dlg.Multiselect = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dlg.Title = "Add Staging Files"; ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (dlg.ShowDialog() == true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ScanFiles(dlg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void LoadJobs() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -86,30 +99,24 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     _jobs.Add(row.ToObject<Job>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        public void ScanFiles(string setoutsfolder) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void ScanFiles(OpenFileDialog dlg) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            _setoutsFolder = setoutsfolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (!Directory.Exists(_setoutsFolder)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                MessageBox.Show("Invalid Setouts Folder - please configure settings"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            IEnumerable<FileInfo> files = GetFiles(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //this will load any which are not archived yet to compare with the files being added 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             LoadExistingStaging(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<Document> documents = new List<Document>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<StagingSetoutDocument> stagingdocs = new List<StagingSetoutDocument>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            foreach (var file in files) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            foreach (var file in dlg.FileNames) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!file.FullName.EndsWith(".pdf")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (!Path.GetExtension(file).Equals(".pdf")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (CheckStagingSetoutExists(file)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (CheckStagingSetoutExists(Path.GetFileNameWithoutExtension(file))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //UpdateStagingDocument(file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 documents.Add(ReadFile(file)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -120,8 +127,8 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             foreach (var doc in documents) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 var stagingsetout = new StagingSetout(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                stagingsetout.Number = doc.FileName.Substring(0, doc.FileName.Length - 4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                stagingsetout.JobLink.ID = FindJob(doc.FileName.Substring(0, 4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stagingsetout.Number = Path.GetFileNameWithoutExtension(doc.FileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stagingsetout.JobLink.ID = TryFindJob(doc.FileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 new Client<StagingSetout>().Save(stagingsetout, "Created from sync setout function"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 var stagingsetoutdoc = new StagingSetoutDocument(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -137,11 +144,29 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 MessageBox.Show("Job(s) not found for the following document(s): " + string.Join("," + Environment.NewLine, messages), "Warning"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             new Client<StagingSetoutDocument>().Save(stagingdocs, "Created from sync setout function"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Refresh(false, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private Guid FindJob(string filePreFix) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void UpdateStagingDocument(string file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var job = _jobs.FirstOrDefault(x => x.JobNumber.Equals(filePreFix)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CoreTable table = new Client<StagingSetoutDocument>().Query(new Filter<StagingSetoutDocument>(x => x.DocumentLink.FileName).IsEqualTo(Path.GetFileName(file))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (table.Rows.Any()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var stagingSetoutDoc = table.Rows.FirstOrDefault().ToObject<StagingSetoutDocument>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var doc = ReadFile(file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Client<Document>().Save(doc, "Created from Staging Setout Screen"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stagingSetoutDoc.DocumentLink.ID = doc.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Client<StagingSetoutDocument>().Save(stagingSetoutDoc, "Updated from Staging Setout Screen"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Guid TryFindJob(string filePreFix) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var job = _jobs.FirstOrDefault(x => x.JobNumber.Equals(filePreFix.Substring(0,4))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (job == null)   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                job = _jobs.FirstOrDefault(x => x.JobNumber.Equals(filePreFix.Substring(0, 5)));            
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (job == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return Guid.Empty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -149,46 +174,28 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 return job.ID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private Document ReadFile(FileInfo file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// Requires the fully qualified file name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// </summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="file"></param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <returns></returns> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private Document ReadFile(string file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Document doc = new Document(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            doc.FileName = file.Name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            doc.FileName = Path.GetFileName(file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             doc.Data = GetData(file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private byte[] GetData(FileInfo file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private byte[] GetData(string file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Stream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Stream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             byte[] pdfData = new byte[stream.Length]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             stream.Read(pdfData, 0, Convert.ToInt32(pdfData.Length)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             stream.Dispose(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return pdfData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private IEnumerable<FileInfo> GetFiles() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            string folder = _setoutsFolder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var dir = new DirectoryInfo(folder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return dir.GetFiles(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        public void ReloadFile(IEntityDocument document) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var files = GetFiles(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            foreach (var file in files) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (file.Name == document.DocumentLink.FileName) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    CoreTable table = new Client<Document>().Query(new Filter<Document>(x => x.ID).IsEqualTo(document.DocumentLink.ID)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    var doc = table.Rows.FirstOrDefault().ToObject<Document>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    doc.Data = GetData(file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    new Client<Document>().Save(doc, "Reloaded Marked up Document"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void LoadExistingStaging() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             CoreTable stagingseouttable = new Client<StagingSetout>().Query( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -199,42 +206,55 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 _existingFileNames.Add(row.Get<StagingSetout, string>(x => x.Number)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private bool CheckStagingSetoutExists(FileInfo file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private bool CheckStagingSetoutExists(string file) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             foreach (var existing in _existingFileNames) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (file.Name.Substring(0, file.Name.Length - 4).Equals(existing)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (file.Equals(existing)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        protected override void Reload(Filters<StagingSetout> criteria, Columns<StagingSetout> columns, ref SortOrder<StagingSetout>? sort, Action<CoreTable?, Exception?> action) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void ReloadFile(StagingSetout stagingSetout) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            criteria.Add(new Filter<StagingSetout>(x => x.Archived).IsEqualTo(DateTime.MinValue)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            base.Reload(criteria, columns, ref sort, action); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (string.IsNullOrWhiteSpace(stagingSetout.SavePath)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        public void DeleteFile(IEntityDocument document) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var file = GetFiles().FirstOrDefault(x => x.Name == document.DocumentLink.FileName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (file.Exists) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CoreTable table = new Client<StagingSetoutDocument>().Query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Filter<StagingSetoutDocument>(x => x.EntityLink.ID).IsEqualTo(stagingSetout.ID), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Columns<StagingSetoutDocument>(x => x.DocumentLink.ID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var doc = new Client<Document>().Query( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new Filter<Document>(x => x.ID).IsEqualTo( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    table.Rows.FirstOrDefault().Get<StagingSetoutDocument, Guid>(x => x.DocumentLink.ID))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .Rows.FirstOrDefault() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .ToObject<Document>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FileInfo file = new FileInfo(stagingSetout.SavePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    file.Attributes = FileAttributes.Normal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    file.Delete(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                catch (Exception ex) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    MessageBox.Show("If your file is currently open in another program, please close it now and press OK to try again", "Error deleting file", MessageBoxButton.OK); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    file.Attributes = FileAttributes.Normal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    file.Delete(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                doc.Data = GetData(stagingSetout.SavePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stagingSetout.SavePath = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                stagingSetout.LockedBy.ID = Guid.Empty; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                file.Attributes = FileAttributes.Normal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                file.Delete(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MultiSave save = new MultiSave(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                save.Add(typeof(Document), doc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                save.Add(typeof(StagingSetout), stagingSetout); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                save.Save(null, "Reloaded / Unlocked staging setout"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                MessageBox.Show("Could not find file!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            catch (Exception ex) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MessageBox.Show(ex.Message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        protected override void Reload(Filters<StagingSetout> criteria, Columns<StagingSetout> columns, ref SortOrder<StagingSetout>? sort, Action<CoreTable?, Exception?> action) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            criteria.Add(new Filter<StagingSetout>(x => x.Archived).IsEqualTo(DateTime.MinValue)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            base.Reload(criteria, columns, ref sort, action); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |