|
@@ -1,4 +1,7 @@
|
|
|
-using System;
|
|
|
+using com.sun.security.ntlm;
|
|
|
+using Comal.Classes;
|
|
|
+using InABox.Core;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
@@ -12,17 +15,190 @@ using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
+using InABox.Client;
|
|
|
+using InABox.Clients;
|
|
|
+using Syncfusion.UI.Xaml.Kanban;
|
|
|
|
|
|
namespace PRSDesktop
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Interaction logic for StagingPanel.xaml
|
|
|
/// </summary>
|
|
|
- public partial class StagingPanel : UserControl
|
|
|
+ public partial class StagingPanel : UserControl, IPanel<StagingSetout>
|
|
|
{
|
|
|
+ StagingSetout _item = new StagingSetout();
|
|
|
public StagingPanel()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
+ SectionName = nameof(StagingPanel);
|
|
|
+ stagingSetoutGrid.Refresh(true, true);
|
|
|
+ stagingSetoutGrid.OnSelectItem += StagingSetoutGrid_OnSelectItem;
|
|
|
+
|
|
|
+ documentPreviewer.SetupButtons(/*approveVisible: false*/);
|
|
|
+ documentPreviewer.OnMarkupComplete += DocumentPreviewer_OnMarkupComplete;
|
|
|
+ documentPreviewer.OnRejected += DocumentPreviewer_OnRejected;
|
|
|
+ documentPreviewer.OnApproved += DocumentPreviewer_OnApproved;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DocumentPreviewer_OnMarkupComplete(IEntityDocument document)
|
|
|
+ {
|
|
|
+ stagingSetoutGrid.ReloadFile(document);
|
|
|
+ stagingSetoutGrid.Refresh(false, true);
|
|
|
+ }
|
|
|
+ private void DocumentPreviewer_OnApproved(IEntityDocument stagingsetoutdocument)
|
|
|
+ {
|
|
|
+ var table = new Client<Setout>().Query(new Filter<Setout>(x => x.Number).IsEqualTo(_item.Number),
|
|
|
+ new Columns<Setout>(x => x.ID));
|
|
|
+
|
|
|
+ //setout already exists - create new setoutdoc and supercede old ones
|
|
|
+ if (table.Rows.Any())
|
|
|
+ {
|
|
|
+ if (MessageBox.Show("Supercede existing documents?", "Proceed?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ var setout = table.Rows.FirstOrDefault().ToObject<Setout>();
|
|
|
+
|
|
|
+ _item.Setout.ID = setout.ID;
|
|
|
+
|
|
|
+ var setoutdoc = new SetoutDocument();
|
|
|
+ setoutdoc.EntityLink.ID = setout.ID;
|
|
|
+ setoutdoc.DocumentLink.ID = stagingsetoutdocument.DocumentLink.ID;
|
|
|
+
|
|
|
+ List<SetoutDocument> setoutdocs = new List<SetoutDocument>
|
|
|
+ {
|
|
|
+ setoutdoc
|
|
|
+ };
|
|
|
+
|
|
|
+ CoreTable oldDocsTable = new Client<SetoutDocument>().Query(new Filter<SetoutDocument>(x => x.EntityLink.ID).IsEqualTo(setout.ID));
|
|
|
+ foreach (var row in oldDocsTable.Rows)
|
|
|
+ {
|
|
|
+ var oldDoc = row.ToObject<SetoutDocument>();
|
|
|
+ if (oldDoc.Superceded == DateTime.MinValue)
|
|
|
+ {
|
|
|
+ oldDoc.Superceded = DateTime.Now;
|
|
|
+ setoutdocs.Add(oldDoc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ new Client<SetoutDocument>().Save(setoutdocs, "Updated from Staging Screen");
|
|
|
+
|
|
|
+ MessageBox.Show("Document for setout " + _item.Number + " superceded.", "Success");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //no setout for this pdf - create new
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var setout = new Setout();
|
|
|
+ setout.Number = _item.Number;
|
|
|
+
|
|
|
+ new Client<Setout>().Save(setout, "Added from staging screen");
|
|
|
+ _item.Setout.ID = setout.ID;
|
|
|
+
|
|
|
+ MessageBox.Show("Setout created for document " + _item.Number, "Success");
|
|
|
+ }
|
|
|
+
|
|
|
+ new Client<StagingSetout>().Save(_item, "Updated from staging screen");
|
|
|
+ _item = new StagingSetout();
|
|
|
+
|
|
|
+ stagingSetoutGrid.DeleteFile(stagingsetoutdocument);
|
|
|
+ documentPreviewer.Document = new StagingSetoutDocument();
|
|
|
+ stagingSetoutGrid.Refresh(false, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DocumentPreviewer_OnRejected(IEntityDocument stagingsetoutdocument)
|
|
|
+ {
|
|
|
+ //dont create setout - setout.id remains blank
|
|
|
+ //create kanban and populate task.id - this prevents it from appearing on the stagingsetout grid, and allows a new staging setout to be created when the file is saved to the folder again
|
|
|
+ //attach the document to the task for reference
|
|
|
+
|
|
|
+ Kanban task = new Kanban();
|
|
|
+ task.Title = "Setout Review Task (setout rejected)";
|
|
|
+ task.Description = "Please review the attached document for setout " + _item.Number;
|
|
|
+ task.ManagerLink.ID = App.EmployeeID;
|
|
|
+
|
|
|
+ var page = new KanbanGrid();
|
|
|
+ page.MyID = App.EmployeeID;
|
|
|
+
|
|
|
+ page.OnAfterSave += (editor, items) =>
|
|
|
+ {
|
|
|
+ Kanban savedTask = (Kanban)items[0];
|
|
|
+ KanbanDocument doc = new KanbanDocument();
|
|
|
+ doc.EntityLink.ID = savedTask.ID;
|
|
|
+ doc.DocumentLink.ID = stagingsetoutdocument.DocumentLink.ID;
|
|
|
+ new Client<KanbanDocument>().Save(doc, "Created from staging screen");
|
|
|
+
|
|
|
+ _item.Task.ID = savedTask.ID;
|
|
|
+ new Client<StagingSetout>().Save(_item, "Updated from staging screen");
|
|
|
+
|
|
|
+
|
|
|
+ MessageBox.Show("Success - Task Created for Document " + _item.Number + " (Task no. " + savedTask.Number + " assigned to " + savedTask.EmployeeLink.Name + ")");
|
|
|
+ _item = new StagingSetout();
|
|
|
+
|
|
|
+ stagingSetoutGrid.DeleteFile(stagingsetoutdocument);
|
|
|
+ documentPreviewer.Document = new StagingSetoutDocument();
|
|
|
+ stagingSetoutGrid.Refresh(false, true);
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!page.EditItems(new[] { task }))
|
|
|
+ MessageBox.Show("Task creation cancelled - setout not rejected");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void StagingSetoutGrid_OnSelectItem(object sender, InABox.DynamicGrid.DynamicGridSelectionEventArgs e)
|
|
|
+ {
|
|
|
+ _item = stagingSetoutGrid.SelectedRows.FirstOrDefault().ToObject<StagingSetout>();
|
|
|
+
|
|
|
+ var doc = new Client<StagingSetoutDocument>().Query(
|
|
|
+ new Filter<StagingSetoutDocument>(x => x.EntityLink.ID)
|
|
|
+ .IsEqualTo(_item.ID),
|
|
|
+ new Columns<StagingSetoutDocument>(x => x.ID, x => x.DocumentLink.ID, x => x.DocumentLink.FileName))
|
|
|
+ .Rows.FirstOrDefault().ToObject<StagingSetoutDocument>();
|
|
|
+
|
|
|
+ documentPreviewer.Document = doc;
|
|
|
+ manufacturingControl.StagingSetout = _item;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsReady { get; set; }
|
|
|
+
|
|
|
+ public string SectionName { get; }
|
|
|
+
|
|
|
+
|
|
|
+ public event DataModelUpdateEvent? OnUpdateDataModel;
|
|
|
+
|
|
|
+ public void CreateToolbarButtons(IPanelHost host)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public DataModel DataModel(Selection selection)
|
|
|
+ {
|
|
|
+ return new AutoDataModel<StagingSetout>(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Heartbeat(TimeSpan time)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Refresh()
|
|
|
+ {
|
|
|
+ stagingSetoutGrid.ScanFiles();
|
|
|
+ stagingSetoutGrid.Refresh(false, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public Dictionary<string, object[]> Selected()
|
|
|
+ {
|
|
|
+ return new();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Setup()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Shutdown()
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|