aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-01-21 18:25:11 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-01-21 18:25:11 +0200
commitedb3800ebc5baee6728dbcc5154a6d7a28a9c5eb (patch)
treeb71197c152ef6e9c50d37aeaebbbb4746e71ee57 /Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs
parentd32fcef7f22da344abe9efa40526540437448b08 (diff)
downloadTango-edb3800ebc5baee6728dbcc5154a6d7a28a9c5eb.tar.gz
Tango-edb3800ebc5baee6728dbcc5154a6d7a28a9c5eb.zip
Implemented JOB_RUN: Name, Length, Source, JobFile
Implemented a complete fix using JobRunsGenerator/Fixer.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs67
1 files changed, 56 insertions, 11 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs
index 8131a11ba..40c784815 100644
--- a/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs
+++ b/Software/Visual_Studio/Utilities/Tango.JobRunsGenerator/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -24,29 +25,73 @@ namespace Tango.JobRunsGenerator
using (ObservablesContext db = ObservablesContext.CreateDefault(dataSource))
{
- var count = db.JobRuns.Where(x => x.MachineGuid == null).Count();
+ var count = db.JobRuns.Where(x => x.JobGuid != null).Count();
int index = 0;
int saveIndex = 0;
- var runs = db.JobRuns.Where(x => x.MachineGuid == null).OrderBy(x => x.JobGuid).ToList();
+ var runsGroup = db.JobRuns.Where(x => x.JobGuid != null).GroupBy(x => x.JobGuid).ToList();
- foreach (var run in runs)
+ foreach (var runGroup in runsGroup)
{
- var job = db.Jobs.SingleOrDefault(x => x.Guid == run.JobGuid);
- Console.WriteLine($"Fixing job {job.Name}... ({index++}/{count})");
- run.MachineGuid = job.MachineGuid;
+ var runs = runGroup;
- saveIndex++;
+ var firstRun = runs.First();
- if (saveIndex > 100)
+ var job = new JobBuilder(db).Set(x => x.Guid == firstRun.JobGuid).WithSegments().WithBrushStops().WithRML().Build();
+
+ if (job == null)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine($"Job '{firstRun.JobGuid}' was not found on the database!");
+ Console.ForegroundColor = ConsoleColor.Gray;
+ continue;
+ }
+
+ var machine = new MachineBuilder(db).Set(job.MachineGuid).WithConfiguration().Build();
+
+ foreach (var segment in job.Segments)
+ {
+ foreach (var stop in segment.BrushStops)
+ {
+ stop.SetLiquidVolumes(machine.Configuration, job.Rml, job.Rml.GetActiveProcessGroup().ProcessParametersTables.First());
+ }
+ }
+
+ foreach (var run in runs)
{
- saveIndex = 0;
- db.SaveChanges();
+ Console.WriteLine($"Fixing job {job.Name}... ({index++}/{count})");
+ run.MachineGuid = job.MachineGuid;
+
+ run.JobSource = job.Source;
+
+ if (run.JobLength == 0)
+ {
+ run.JobLength = job.LengthIncludingNumberOfUnits;
+ }
+
+ if (run.JobName == null)
+ {
+ run.JobName = job.Name;
+ }
+
+ if (run.JobString == null)
+ {
+ run.JobString = job.ToJobFileWhenLoaded().ToString();
+ }
+
+ saveIndex++;
+
+ if (saveIndex > 100)
+ {
+ saveIndex = 0;
+ Console.WriteLine("Saving changes...");
+ db.SaveChanges();
+ }
}
}
- Console.WriteLine("Saving changed...");
+ Console.WriteLine("Saving changes...");
db.SaveChanges();
Console.WriteLine("Done!");