diff options
| author | Roy <Roy.mail.net@gmail.com> | 2023-09-03 17:35:54 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2023-09-03 17:35:54 +0300 |
| commit | 78ba28666b686329661f4a8fded423af94bbfb84 (patch) | |
| tree | dea73edeffb65d5005bee12e09726c33e44992f8 /Software/Visual_Studio/PPC/Modules | |
| parent | c66acc359b311ecc940f3c4e74bd9e21dc0bfd51 (diff) | |
| download | Tango-78ba28666b686329661f4a8fded423af94bbfb84.tar.gz Tango-78ba28666b686329661f4a8fded423af94bbfb84.zip | |
Job Resume Manager.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
4 files changed, 16 insertions, 160 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resume/JobResumeDB.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resume/JobResumeDB.cs deleted file mode 100644 index 28184eee1..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resume/JobResumeDB.cs +++ /dev/null @@ -1,83 +0,0 @@ -using LiteDB; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Jobs.Resume -{ - public class JobResumeDB : IDisposable - { - private LiteDatabase _db; - private ILiteCollection<JobResumeModel> _collection; - - private static Lazy<JobResumeDB> _default = new Lazy<JobResumeDB>(() => new JobResumeDB()); - - public static JobResumeDB Default - { - get - { - return _default.Value; - } - } - - private JobResumeDB() - { - Init(); - } - - private void Init() - { - String dbFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "Job Resume v2"); - Directory.CreateDirectory(dbFolder); - _db = new LiteDatabase($"Filename={Path.Combine(dbFolder, "job_resume.db")};connection=shared"); - _collection = _db.GetCollection<JobResumeModel>("JobResume"); - } - - public void Update(JobResumeModel model) - { - _collection.Update(model); - } - - public void Add(JobResumeModel model) - { - _collection.Insert(model); - } - - public List<JobResumeModel> GetAll() - { - return _collection.FindAll().ToList(); - } - - public JobResumeModel Get(String jobGuild) - { - return _collection.FindOne(x => x.JobGuid == jobGuild); - } - - public void Delete(JobResumeModel model) - { - _collection.Delete(model.JobGuid); - } - - public void Delete(String jobGuid) - { - _collection.Delete(jobGuid); - } - - ~JobResumeDB() - { - Dispose(); - } - - public void Dispose() - { - try - { - _db?.Dispose(); - } - catch { } - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resume/JobResumeModel.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resume/JobResumeModel.cs deleted file mode 100644 index 4ded7e313..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Resume/JobResumeModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -using LiteDB; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.PPC.Jobs.Resume -{ - public class JobResumeModel - { - [BsonId] - public String JobGuid { get; set; } - - public int RemainingUnits { get; set; } - - public double GlobalStartPosition { get; set; } - - public double FirstUnitStartPosition { get; set; } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj index 5ec7c3f39..96083d842 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/Tango.PPC.JobsV2.csproj @@ -352,8 +352,6 @@ <DependentUpon>ColorCorrectionReport.xaml</DependentUpon> </Compile> <Compile Include="Reports\ColorCorrectionRepotVM.cs" /> - <Compile Include="Resume\JobResumeDB.cs" /> - <Compile Include="Resume\JobResumeModel.cs" /> <Compile Include="UndoRedoCommands\AddBrushStopCommand.cs" /> <Compile Include="UndoRedoCommands\AddNewSegmentCommand.cs" /> <Compile Include="UndoRedoCommands\ChangeLengthCommand.cs" /> @@ -757,7 +755,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs index 9d8ae1555..123151fcf 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.JobsV2/ViewModels/JobViewVM.cs @@ -46,8 +46,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Tango.PPC.Jobs.ColorCorrectionTool; using Tango.PPC.Common.Printing; -using Tango.PPC.Jobs.Resume; using Tango.Core.ExtensionMethods; +using Tango.PPC.Common.Resume; namespace Tango.PPC.Jobs.ViewModels { @@ -509,7 +509,7 @@ namespace Tango.PPC.Jobs.ViewModels try { - ResumeModel = JobResumeDB.Default.Get(Job.Guid); + ResumeModel = JobResumeManager.GetJobResumeModel(Job.Guid); if (ResumeModel != null) { @@ -1326,6 +1326,9 @@ namespace Tango.PPC.Jobs.ViewModels MachineProvider.MachineOperator.PrintingEnded += MachineOperator_PrintingEnded; MachineProvider.MachineOperator.PrintingStarted += MachineOperator_PrintingStarted; + + JobResumeManager.JobResumeUpdated += JobResumeManager_JobResumeUpdated; + JobResumeManager.JobResumeDropped += JobResumeManager_JobResumeDropped; } /// <summary> @@ -1793,11 +1796,6 @@ namespace Tango.PPC.Jobs.ViewModels } RaisePropertyChanged(nameof(CanEdit)); - - if (BuildProvider.IsEureka) - { - UpdateJobResume(e); - } } @@ -1805,54 +1803,19 @@ namespace Tango.PPC.Jobs.ViewModels #region Resume - private void UpdateJobResume(PrintingEventArgs e) + private void JobResumeManager_JobResumeUpdated(object sender, Common.Resume.JobResumeUpdatedEventArgs e) { - try + if (Job.Guid == e.JobGuid) { - if (!e.JobHandler.Status.IsCompleted) - { - if (e.JobHandler.JobStatus.Progress <= e.JobHandler.ProcessParameters.DryerBufferLengthMeters) return; - - var model = JobResumeDB.Default.Get(e.Job.Guid); - bool insert = false; - if (model == null) - { - model = new JobResumeModel(); - insert = true; - } - - model.JobGuid = e.Job.Guid; - model.FirstUnitStartPosition = e.JobHandler.Status.CurrentUnitProgress; - model.RemainingUnits = e.JobHandler.Status.RemainingUnits; - model.GlobalStartPosition = e.JobHandler.JobStatus.Progress; - - if (insert) - { - JobResumeDB.Default.Add(model); - } - else - { - JobResumeDB.Default.Update(model); - } - - if (Job.Guid == e.Job.Guid) - { - ResumeModel = model; - } - } - else - { - JobResumeDB.Default.Delete(e.Job.Guid); - - if (Job.Guid == e.Job.Guid) - { - ResumeModel = null; - } - } + ResumeModel = e.ResumeModel; } - catch (Exception ex) + } + + private void JobResumeManager_JobResumeDropped(object sender, Common.Resume.JobResumeDroppedEventArgs e) + { + if (Job.Guid == e.JobGuid) { - LogManager.Log(ex, "Error inserting/updating job resume info on db."); + ResumeModel = null; } } @@ -1862,8 +1825,7 @@ namespace Tango.PPC.Jobs.ViewModels { if (await NotificationProvider.ShowQuestion("Drop resume information and enable job editing?")) { - JobResumeDB.Default.Delete(Job.Guid); - ResumeModel = null; + JobResumeManager.DropResume(Job.Guid); } } } |
