|
@@ -7,6 +7,7 @@ using Syncfusion.Pdf.Parsing;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Drawing.Imaging;
|
|
|
+using InABox.Database;
|
|
|
|
|
|
namespace Comal.Stores
|
|
|
{
|
|
@@ -23,28 +24,39 @@ namespace Comal.Stores
|
|
|
return;
|
|
|
|
|
|
var docID = table.Rows.FirstOrDefault().Get<SetoutGroup, Guid>(x => x.OptimizationDocument.ID);
|
|
|
- if (docID == Guid.Empty)
|
|
|
- return;
|
|
|
|
|
|
- List<Guid> ids = new List<Guid>();
|
|
|
- var docsTable = Provider.Query<SetoutDocument>(
|
|
|
- new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(entity.ID),
|
|
|
- new Columns<SetoutDocument>(x => x.DocumentLink.ID)
|
|
|
- );
|
|
|
- foreach (var row in docsTable.Rows)
|
|
|
- ids.Add(row.Get<SetoutDocument, Guid>(x => x.DocumentLink.ID));
|
|
|
+ UpdateOptimisationDocument(FindSubStore<SetoutDocument>, entity, docID);
|
|
|
|
|
|
- if (!ids.Contains(docID))
|
|
|
- {
|
|
|
- var setoutdoc = new SetoutDocument();
|
|
|
- setoutdoc.EntityLink.ID = entity.ID;
|
|
|
- setoutdoc.DocumentLink.ID = docID;
|
|
|
+ }
|
|
|
+ base.AfterSave(entity);
|
|
|
+ }
|
|
|
|
|
|
- FindSubStore<SetoutDocument>().Save(setoutdoc, "Added optimsation document from Group");
|
|
|
- }
|
|
|
+ /// <summary>
|
|
|
+ /// Update the optimisation document ID for a setout. The setout must have a non-empty <see cref="Entity.ID"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="docStore"></param>
|
|
|
+ /// <param name="setout">Setout with non-empty <see cref="Entity.ID"/></param>
|
|
|
+ /// <param name="optimisationDocumentID"></param>
|
|
|
+ public static void UpdateOptimisationDocument(Func<IStore<SetoutDocument>> docStore, Setout setout, Guid optimisationDocumentID)
|
|
|
+ {
|
|
|
+ if (optimisationDocumentID == Guid.Empty) return;
|
|
|
|
|
|
+ var ids = new List<Guid>();
|
|
|
+ var docsTable = DbFactory.Provider.Query<SetoutDocument>(
|
|
|
+ new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(setout.ID),
|
|
|
+ new Columns<SetoutDocument>(x => x.DocumentLink.ID)
|
|
|
+ );
|
|
|
+ foreach (var row in docsTable.Rows)
|
|
|
+ ids.Add(row.Get<SetoutDocument, Guid>(x => x.DocumentLink.ID));
|
|
|
+
|
|
|
+ if (!ids.Contains(optimisationDocumentID))
|
|
|
+ {
|
|
|
+ var setoutdoc = new SetoutDocument();
|
|
|
+ setoutdoc.EntityLink.ID = setout.ID;
|
|
|
+ setoutdoc.DocumentLink.ID = optimisationDocumentID;
|
|
|
+
|
|
|
+ docStore().Save(setoutdoc, "Added optimsation document from Group");
|
|
|
}
|
|
|
- base.AfterSave(entity);
|
|
|
}
|
|
|
|
|
|
protected override void BeforeDelete(Setout entity)
|