From 690eb0e4e8af452ae2d6f7b20155a6510d3a4a49 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Sat, 4 May 2019 20:07:54 +0200 Subject: [PATCH] FIx Marcolin Problems --- Client/View/MainForm.cs | 9 ++++-- Step.NC/NcFileHandler.cs | 30 ++++++++++++++----- Step/Controllers/WebApi/NcFileController.cs | 20 +++++++++++++ Step/Listeners/ListenersHandler.cs | 3 ++ .../production/components/production.ts | 1 - 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Client/View/MainForm.cs b/Client/View/MainForm.cs index 168247ad..9262ae93 100644 --- a/Client/View/MainForm.cs +++ b/Client/View/MainForm.cs @@ -121,9 +121,11 @@ namespace Active_Client.View if (WindowState == FormWindowState.Minimized) { NcWindow.ShowTaskBar(); - + NcWindow.MinimizeNcWindow(); + NcWindow.HideNcWindow(); NcWindow.MinimizeProdWindow(); + NcWindow.HideProdWindow(); } else { @@ -168,14 +170,15 @@ namespace Active_Client.View NcWindow.CloseProdWindow(false); //Close Chromium Runtime + Close(); try { CfxRuntime.Shutdown(); - Close(); + } catch (Exception) { - + Environment.Exit(0); } } diff --git a/Step.NC/NcFileHandler.cs b/Step.NC/NcFileHandler.cs index 8d55fdfa..8a192c7f 100644 --- a/Step.NC/NcFileHandler.cs +++ b/Step.NC/NcFileHandler.cs @@ -26,15 +26,29 @@ namespace Step.NC public CmsError GetFileInfo(string path, out InfoFile fileInfo) { - fileInfo = new InfoFile(); - // CmsError cmsError = NO_ERROR; + fileInfo = new InfoFile(); + // CmsError cmsError = NO_ERROR; + + // if (FileExistWithNc(path)) + // cmsError = LocalPartProgramFileInfo(path, out fileInfo); + // else + // cmsError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); + + + CmsError cmsError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); + + if (cmsError.IsError()) + return cmsError; + + string [] names = fileInfo.Name.Split('/'); + if(names.Length > 0) + { + string name = names.Last(); + if (!String.IsNullOrWhiteSpace(name)) + fileInfo.PreviewBase64 = SupportFunctions.GetImageBase64String(PART_PRG_IMAGES, name); + } - // if (FileExistWithNc(path)) - // cmsError = LocalPartProgramFileInfo(path, out fileInfo); - // else - // cmsError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); - - return numericalControl.FILES_RGetFileInfo(path, ref fileInfo); + return NO_ERROR; } public bool FileExistWithNc(string path) diff --git a/Step/Controllers/WebApi/NcFileController.cs b/Step/Controllers/WebApi/NcFileController.cs index 468eb57b..deb04517 100644 --- a/Step/Controllers/WebApi/NcFileController.cs +++ b/Step/Controllers/WebApi/NcFileController.cs @@ -95,6 +95,10 @@ namespace Step.Controllers.WebApi [Route("upload"), HttpPost] public async Task UpdloadProgramWithImage() { + + bool imageUploaded = false; + string mainPPName = ""; + if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); @@ -120,6 +124,8 @@ namespace Step.Controllers.WebApi if (item.ParameterName == "main") { File.WriteAllBytes(TEMP_PP_FOLDER + item.FileName, item.Data); + mainPPName = item.FileName; + // Upload main program CmsError cmsError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out ActiveProgramDataModel programData); if (cmsError.IsError()) @@ -137,9 +143,23 @@ namespace Step.Controllers.WebApi { // Upload image File.WriteAllBytes(PART_PRG_IMAGES + item.FileName, item.Data); + imageUploaded = true; } } } + + if (!imageUploaded) + { + mainPPName = Path.GetFileNameWithoutExtension(mainPPName); + string [] imgFiles = Directory.GetFiles(PART_PRG_IMAGES); + foreach(string f in imgFiles) + { + if(Path.GetFileNameWithoutExtension(f) == mainPPName) + File.Delete(f); + } + + } + } return Ok(); diff --git a/Step/Listeners/ListenersHandler.cs b/Step/Listeners/ListenersHandler.cs index 7c7eec9e..aef3d2f4 100644 --- a/Step/Listeners/ListenersHandler.cs +++ b/Step/Listeners/ListenersHandler.cs @@ -3,6 +3,7 @@ using Step.Listeners.SignalR; using Step.Model.DTOModels; using Step.Model.DTOModels.AlarmModels; using System.Collections.Generic; +using System.Threading; using TeamDev.SDK.MVVM; using static Step.Model.Constants; @@ -108,6 +109,8 @@ namespace Step.Listeners // Broadcast infos.Add(MessageServices.Current.Subscribe(BROADCAST_DATA, (a, b) => { + //Added sleep for the sync-error that happen sometimes during opening + Thread.Sleep(500); SignalRListener.BroadcastData(); })); } diff --git a/Step/wwwroot/src/app_modules/production/components/production.ts b/Step/wwwroot/src/app_modules/production/components/production.ts index c4e44b9d..a0bc2b56 100644 --- a/Step/wwwroot/src/app_modules/production/components/production.ts +++ b/Step/wwwroot/src/app_modules/production/components/production.ts @@ -123,7 +123,6 @@ export default class Production extends Vue { } getHeadstoolName(id) { var r = this.getHeadsProperty(id); - console.log(r); if(r.toolData) return r.toolData.toolName }