From efde98a69746f41c1055858142b1935955d82fb0 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 24 Feb 2020 16:51:04 +0200 Subject: Implemented job runs reset on factory restore. --- .../Controllers/PPCController.cs | 22 ++++++++++++++++++++++ .../Tango.MachineService.csproj | 15 +++++++++++++-- .../Web/Tango.MachineService/Web.config | 4 ++++ .../Web/Tango.MachineService/packages.config | 3 +++ 4 files changed, 42 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/Web/Tango.MachineService') diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index b132a4c48..71e540dbf 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -24,6 +24,7 @@ using Tango.Web.ActiveDirectory; using Tango.Core.Cryptography; using Tango.MachineService.Filters; using Tango.BL.DTO; +using Z.EntityFramework.Plus; namespace Tango.MachineService.Controllers { @@ -170,6 +171,27 @@ namespace Tango.MachineService.Controllers Token = response.NotifyCompletedToken, TangoUpdateGuid = tangoUpdate.Guid, }); + + Task.Factory.StartNew(() => + { + using (ObservablesContext b = ObservablesContextHelper.CreateContext()) + { + //Reset Job Runs. + try + { + b.JobRuns.Where(x => x.MachineGuid == machine.Guid && x.IsSynchronized).Update(x => new JobRun() { IsSynchronized = false }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error resetting synchronized job runs for machine '{machine.SerialNumber}'."); + } + + //Reset Events. + //b.MachinesEvents.Where(x => x.MachineGuid == machine.Guid).Update(x => new MachinesEvent() { IsSynchronized = false }); + //Reset Jobs. + //b.Jobs.Where(x => x.MachineGuid == machine.Guid).Update(x => new Job() { IsSynchronized = false }); + } + }); } return response; diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj index a05fee42f..ee5f3440e 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj +++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj @@ -274,6 +274,15 @@ True ..\..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll + + ..\..\packages\Z.EntityFramework.Extensions.4.0.50\lib\net45\Z.EntityFramework.Extensions.dll + + + ..\..\packages\Z.EntityFramework.Plus.EF6.1.12.13\lib\net45\Z.EntityFramework.Plus.EF6.dll + + + ..\..\packages\Z.Expressions.Eval.3.1.5\lib\net45\Z.Expressions.Eval.dll + @@ -370,7 +379,9 @@ - + + Designer + @@ -461,7 +472,7 @@ False - + diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 85b89ec38..1da22f45b 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -185,6 +185,10 @@ + + + + diff --git a/Software/Visual_Studio/Web/Tango.MachineService/packages.config b/Software/Visual_Studio/Web/Tango.MachineService/packages.config index 54144fcea..599e31535 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/packages.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/packages.config @@ -44,4 +44,7 @@ + + + \ No newline at end of file -- cgit v1.3.1