|
|
@@ -1,79 +0,0 @@
|
|
|
-using Comal.Classes;
|
|
|
-using InABox.Clients;
|
|
|
-using InABox.Core;
|
|
|
-using InABox.DynamicGrid;
|
|
|
-using Microsoft.Win32;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.IO;
|
|
|
-using System.Threading;
|
|
|
-
|
|
|
-namespace PRSDesktop
|
|
|
-{
|
|
|
- public class StagingMaterialListGrid : DynamicDataGrid<StagingMaterialList>
|
|
|
- {
|
|
|
- protected override void DoReconfigure(DynamicGridOptions options)
|
|
|
- {
|
|
|
- base.DoReconfigure(options);
|
|
|
- options.ImportData = false;
|
|
|
- options.ExportData = false;
|
|
|
- }
|
|
|
-
|
|
|
- protected override void DoAdd(bool openEditorOnDirectEdit = false)
|
|
|
- {
|
|
|
- var dlg = new OpenFileDialog();
|
|
|
- dlg.Multiselect = true;
|
|
|
- dlg.Title = "Add Staging Files"; ;
|
|
|
- if (dlg.ShowDialog() == true)
|
|
|
- {
|
|
|
- List<Document> documents = new List<Document>();
|
|
|
- foreach (var file in dlg.FileNames)
|
|
|
- documents.Add(ReadFile(file));
|
|
|
-
|
|
|
- new Client<Document>().Save(documents, "Created from Staging Screen");
|
|
|
-
|
|
|
- foreach (var document in documents)
|
|
|
- {
|
|
|
- var materiallist = new StagingMaterialList();
|
|
|
- materiallist.Name = Path.GetFileNameWithoutExtension(document.FileName);
|
|
|
-
|
|
|
- new Client<StagingMaterialList>().Save(materiallist, "Created from Staging Screen");
|
|
|
-
|
|
|
- var materiallistdoc = new StagingMaterialListDocument();
|
|
|
- materiallistdoc.EntityLink.ID = materiallist.ID;
|
|
|
- materiallistdoc.DocumentLink.ID = document.ID;
|
|
|
-
|
|
|
- new Client<StagingMaterialListDocument>().Save(materiallistdoc, "Created from Staging Screen");
|
|
|
-
|
|
|
- Refresh(false, true);
|
|
|
- }
|
|
|
- }
|
|
|
- base.DoAdd(openEditorOnDirectEdit);
|
|
|
- }
|
|
|
-
|
|
|
- private Document ReadFile(string file)
|
|
|
- {
|
|
|
- Document doc = new Document();
|
|
|
- doc.FileName = Path.GetFileName(file);
|
|
|
- doc.Data = GetData(file);
|
|
|
- return doc;
|
|
|
- }
|
|
|
-
|
|
|
- private byte[] GetData(string file)
|
|
|
- {
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
- protected override void Reload(
|
|
|
- Filters<StagingMaterialList> criteria, Columns<StagingMaterialList> columns, ref SortOrder<StagingMaterialList>? sort,
|
|
|
- CancellationToken token, Action<CoreTable?, Exception?> action)
|
|
|
- {
|
|
|
- criteria.Add(Filter<StagingMaterialList>.Where(x => x.Archived).IsEqualTo(DateTime.MinValue));
|
|
|
- base.Reload(criteria, columns, ref sort, token, action);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|