|
@@ -93,7 +93,7 @@ namespace PRSDesktop
|
|
|
else
|
|
|
{
|
|
|
if (manufacturingControl.Data.Rows.Count == 0)
|
|
|
- if (MessageBox.Show("No Packets created for this setout", "Proceed?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
|
+ if (MessageBox.Show("No Packets created for this setout. Continue?", "Proceed?", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
|
return;
|
|
|
|
|
|
setout.Number = _item.Number;
|
|
@@ -128,7 +128,9 @@ namespace PRSDesktop
|
|
|
private void CreatePackets(Setout setout)
|
|
|
{
|
|
|
List<ManufacturingPacket> packets = new List<ManufacturingPacket>();
|
|
|
- List<StagingManufacturingPacket> stagings = new List<StagingManufacturingPacket>();
|
|
|
+ List<StagingManufacturingPacket> stagingPackets = new List<StagingManufacturingPacket>();
|
|
|
+
|
|
|
+ //create new manufacturing packets from the staging packets
|
|
|
foreach (var row in manufacturingControl.Data.Rows)
|
|
|
{
|
|
|
var staging = row.ToObject<StagingManufacturingPacket>();
|
|
@@ -148,38 +150,91 @@ namespace PRSDesktop
|
|
|
packet.Location = staging.Location;
|
|
|
|
|
|
packets.Add(packet);
|
|
|
- stagings.Add(staging);
|
|
|
+ stagingPackets.Add(staging);
|
|
|
}
|
|
|
|
|
|
+ //save the newly created packets to provide an ID
|
|
|
new Client<ManufacturingPacket>().Save(packets, "Created from Design Management Panel");
|
|
|
|
|
|
+ //now work on their stages with the provided packet.ID
|
|
|
List<ManufacturingPacketStage> stages = new List<ManufacturingPacketStage>();
|
|
|
|
|
|
- foreach (var staging in stagings)
|
|
|
+ Dictionary<StagingManufacturingPacketComponent, ManufacturingPacketComponent> stagingToActualComponents = new Dictionary<StagingManufacturingPacketComponent, ManufacturingPacketComponent>();
|
|
|
+
|
|
|
+ //Handled in this loop:
|
|
|
+ // - staging packets (update packet.ID)
|
|
|
+ // - creation of template stages
|
|
|
+ // - creation of components from staging components
|
|
|
+ foreach (var stagingPacket in stagingPackets)
|
|
|
{
|
|
|
- var packet = packets.FirstOrDefault(x => x.Serial == staging.Serial);
|
|
|
- staging.ManufacturingPacket.ID = packet.ID;
|
|
|
-
|
|
|
- CoreTable table = new Client<ManufacturingTemplateStage>().Query(
|
|
|
- new Filter<ManufacturingTemplateStage>(x => x.Template.ID).IsEqualTo(packet.ManufacturingTemplateLink.ID),
|
|
|
- new Columns<ManufacturingTemplateStage>
|
|
|
- (
|
|
|
- x => x.Time,
|
|
|
- x => x.Sequence,
|
|
|
- x => x.SequenceType,
|
|
|
- x => x.Section.ID,
|
|
|
- x => x.Section.Name
|
|
|
- ));
|
|
|
- foreach (var row in table.Rows)
|
|
|
- {
|
|
|
- var packetStage = row.ToObject<ManufacturingTemplateStage>().CreateManufacturingPacketStage();
|
|
|
- packetStage.ManufacturingPacketLink.ID = packet.ID;
|
|
|
- stages.Add(packetStage);
|
|
|
- }
|
|
|
+ var packet = packets.FirstOrDefault(x => x.Serial == stagingPacket.Serial);
|
|
|
+ stagingPacket.ManufacturingPacket.ID = packet.ID;
|
|
|
+
|
|
|
+ stages.AddRange(CreateStagesForTemplate(packet.ManufacturingTemplateLink.ID, packet.ID));
|
|
|
+
|
|
|
+ CreateComponents(stagingPacket.ID, packet.ID, stagingToActualComponents);
|
|
|
+ }
|
|
|
+
|
|
|
+ //save everything
|
|
|
+ MultiSave save = new MultiSave();
|
|
|
+ save.Add(typeof(ManufacturingPacketStage), stages.ToArray());
|
|
|
+ save.Add(typeof(StagingManufacturingPacket), stagingPackets.ToArray());
|
|
|
+ save.Add(typeof(ManufacturingPacketComponent), stagingToActualComponents.Values.ToArray());
|
|
|
+ save.Save(null, "Updated from setout staging screen");
|
|
|
+
|
|
|
+ foreach (var pair in stagingToActualComponents)
|
|
|
+ {
|
|
|
+ var stagingComponent = pair.Key;
|
|
|
+ stagingComponent.ComponentID = pair.Value.ID;
|
|
|
}
|
|
|
|
|
|
- new Client<ManufacturingPacketStage>().Save(stages, "Created from Design Management Panel");
|
|
|
- new Client<StagingManufacturingPacket>().Save(stagings, "Added manufacturing packet id on packet creation");
|
|
|
+ new Client<StagingManufacturingPacketComponent>().Save(stagingToActualComponents.Keys.ToArray(), "Updated from setout staging screen");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CreateComponents(Guid stagingPacketID, Guid packetID, Dictionary<StagingManufacturingPacketComponent, ManufacturingPacketComponent> stagingToActualComponents)
|
|
|
+ {
|
|
|
+ var components = new List<ManufacturingPacketComponent>();
|
|
|
+ CoreTable table = new Client<StagingManufacturingPacketComponent>().Query(
|
|
|
+ new Filter<StagingManufacturingPacketComponent>(x => x.StagingPacket.ID).IsEqualTo(stagingPacketID)
|
|
|
+ .And(x => x.ComponentID).IsEqualTo(Guid.Empty),
|
|
|
+ new Columns<StagingManufacturingPacketComponent>(
|
|
|
+ x => x.Product.ID,
|
|
|
+ x => x.Quantity,
|
|
|
+ x => x.Length,
|
|
|
+ x => x.Height,
|
|
|
+ x => x.Width
|
|
|
+ ));
|
|
|
+ foreach (var row in table.Rows)
|
|
|
+ {
|
|
|
+ var stagingComponent = row.ToObject<StagingManufacturingPacketComponent>();
|
|
|
+ var component = stagingComponent.CreateComponent(packetID);
|
|
|
+ components.Add(component);
|
|
|
+
|
|
|
+ stagingToActualComponents.Add(stagingComponent, component);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ManufacturingPacketStage> CreateStagesForTemplate(Guid templateID, Guid packetID)
|
|
|
+ {
|
|
|
+ var stages = new List<ManufacturingPacketStage>();
|
|
|
+ CoreTable table = new Client<ManufacturingTemplateStage>().Query(
|
|
|
+ new Filter<ManufacturingTemplateStage>(x => x.Template.ID).IsEqualTo(templateID),
|
|
|
+ new Columns<ManufacturingTemplateStage>
|
|
|
+ (
|
|
|
+ x => x.Time,
|
|
|
+ x => x.Sequence,
|
|
|
+ x => x.SequenceType,
|
|
|
+ x => x.Section.ID,
|
|
|
+ x => x.Section.Name
|
|
|
+ ));
|
|
|
+ foreach (var row in table.Rows)
|
|
|
+ {
|
|
|
+ var templateStage = row.ToObject<ManufacturingTemplateStage>();
|
|
|
+ var packetStage = templateStage.CreateManufacturingPacketStage();
|
|
|
+ packetStage.ManufacturingPacketLink.ID = packetID;
|
|
|
+ stages.Add(packetStage);
|
|
|
+ }
|
|
|
+ return stages;
|
|
|
}
|
|
|
|
|
|
private void DeleteAndRefresh(IEntityDocument stagingsetoutdocument)
|
|
@@ -335,13 +390,6 @@ namespace PRSDesktop
|
|
|
|
|
|
private void DocumentPreviewer_OnMarkupSelected(IEntityDocument document)
|
|
|
{
|
|
|
- //if (string.IsNullOrWhiteSpace(_settings.MarkupPathway))
|
|
|
- //{
|
|
|
- // MessageBox.Show("Please configure default Markup Program Pathway first");
|
|
|
- // return;
|
|
|
- //}
|
|
|
-
|
|
|
- //System.Diagnostics.Process.Start(_settings.SetoutsFolder + @"\" + document.DocumentLink.FileName);
|
|
|
using (Process p = new Process())
|
|
|
{
|
|
|
p.StartInfo = new ProcessStartInfo()
|
|
@@ -352,8 +400,6 @@ namespace PRSDesktop
|
|
|
|
|
|
p.Start();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public void Shutdown()
|