diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-12-18 13:27:02 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-12-18 13:27:02 +0200 |
| commit | 41129873d38034c5679eeaf46f48e4f67fd38ba2 (patch) | |
| tree | 94109a9602e91bcf7f114e3491bc8018e60bef4c /Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs | |
| parent | 70e3f2699a500666d1ca4e4d5db2dbaafb339e80 (diff) | |
| parent | a61a911d1ebde107ba7bf210af7e753e692d93e2 (diff) | |
| download | Tango-41129873d38034c5679eeaf46f48e4f67fd38ba2.tar.gz Tango-41129873d38034c5679eeaf46f48e4f67fd38ba2.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index f1c722d96..29daedb4c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -11,6 +11,8 @@ using System.Net.Http.Headers; using System.Text; using System.Threading; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; using Tango.Core; using Tango.Core.DB; using Tango.Core.ExtensionMethods; @@ -29,6 +31,7 @@ using Tango.Settings; using Tango.SharedUI.Helpers; using Tango.SQLExaminer; using Tango.Transport.Web; +using System.Data.Entity; namespace Tango.PPC.Common.MachineSetup { @@ -44,6 +47,8 @@ namespace Tango.PPC.Common.MachineSetup private IOperationSystemManager _windows_manager; private PPCWebClient _client; private List<LogItemBase> _logs; + private bool _isUpdating; + private DateTime _setupStartDate; #region Events @@ -93,7 +98,10 @@ namespace Tango.PPC.Common.MachineSetup private void LogManager_NewLog(object sender, LogItemBase e) { - _logs.Add(e); + if (_isUpdating) + { + _logs.Add(e); + } } #endregion @@ -136,6 +144,8 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log(xx, "Error notifying setup completed."); } } + + _isUpdating = false; } private async void OnCompleted(MachineSetupResult result, TaskCompletionSource<MachineSetupResult> completionSource, MachineSetupResponse response) @@ -156,7 +166,28 @@ namespace Tango.PPC.Common.MachineSetup { LogManager.Log(xx, "Error notifying setup completed."); } + + try + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + TangoUpdate update = new TangoUpdate(); + update.ApplicationVersion = response.Version; + update.FirmwareVersion = response.FirmwareVersion; + update.MachineGuid = (await db.Machines.FirstAsync()).Guid; + update.UpdateStatus = BL.Enumerations.TangoUpdateStatuses.SetupCompleted; + update.StartDate = _setupStartDate; + update.EndDate = DateTime.UtcNow; + await db.SaveChangesAsync(); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error saving tango setup information to database."); + } } + + _isUpdating = false; } private String GetLogsStringAndClear() @@ -183,9 +214,12 @@ namespace Tango.PPC.Common.MachineSetup TaskCompletionSource<MachineSetupResult> result = new TaskCompletionSource<MachineSetupResult>(); MachineSetupResponse setup_response = null; + _setupStartDate = DateTime.UtcNow; try { + _isUpdating = true; + LogManager.Log($"Starting machine setup for serial number {serialNumber}..."); var machineServiceAddress = SettingsManager.Default.GetOrCreate<PPCSettings>().GetMachineServiceAddress(); |
