From 25c5e1aca22d8ff5c3eed46c41048a45a228db74 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Tue, 24 Apr 2018 15:06:14 +0200 Subject: [PATCH] Client: Completed Feature "Utilities" --- Client.Config/ConfigController.cs | 12 ++--- Client.Config/SubModels/Software.cs | 12 ++--- Client/Browser_Tools/BrowserJSObject.cs | 38 ++++++++++----- Step.Utils/languages/IT.xml | 3 ++ Step.Utils/languages/en.xml | 3 ++ Step.Utils/languages/zh.xml | 3 ++ Step/wwwroot/src/components/utilities.ts | 47 +++++-------------- Step/wwwroot/src/components/utilities.vue | 18 ++----- .../base-components/cards/card-utilities.vue | 8 +++- 9 files changed, 67 insertions(+), 77 deletions(-) diff --git a/Client.Config/ConfigController.cs b/Client.Config/ConfigController.cs index 36212661..c915fcb4 100644 --- a/Client.Config/ConfigController.cs +++ b/Client.Config/ConfigController.cs @@ -66,12 +66,12 @@ namespace Client.Config .Elements("Software") .Select(x =>new SubModels.Software() { - Path = ValidateSFTPath(x.Element("Path").Value), - Arguments = x.Element("Arguments").Value, - LongName = ValidateSFTLName(x.Element("LongName").Value), - ShortName = ValidateSFTSName(x.Element("ShortName").Value), - IconBase64 = ExtractBase64Icon(x.Element("Path").Value), - Id = SoftwareId++.ToString() + path = ValidateSFTPath(x.Element("Path").Value), + arguments = x.Element("Arguments").Value, + longName = ValidateSFTLName(x.Element("LongName").Value), + shortName = ValidateSFTSName(x.Element("ShortName").Value), + iconBase64 = ExtractBase64Icon(x.Element("Path").Value), + id = SoftwareId++.ToString() } ).ToArray(); diff --git a/Client.Config/SubModels/Software.cs b/Client.Config/SubModels/Software.cs index 2f7b3beb..4b74a86a 100644 --- a/Client.Config/SubModels/Software.cs +++ b/Client.Config/SubModels/Software.cs @@ -11,17 +11,17 @@ namespace Client.Config.SubModels public class Software { [DataMember] - public string Id { get; set; } + public string id { get; set; } [DataMember] - public string Path { get; set; } + public string path { get; set; } [DataMember] - public string LongName { get; set; } + public string longName { get; set; } [DataMember] - public string ShortName { get; set; } + public string shortName { get; set; } [DataMember] - public string Arguments { get; set; } + public string arguments { get; set; } [DataMember] - public string IconBase64 { get; set; } + public string iconBase64 { get; set; } } diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs index eee7c5de..7fe0f30b 100644 --- a/Client/Browser_Tools/BrowserJSObject.cs +++ b/Client/Browser_Tools/BrowserJSObject.cs @@ -14,6 +14,7 @@ using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using static Client.Utils.Constants; @@ -205,14 +206,9 @@ namespace CMS_Client.Browser_Tools { if (e.Arguments.Count() == 0) return; - String id = e.Arguments[0].StringValue; - Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.Id == id); - - if (sft != null) - { - Process.Start(sft.Path, sft.Arguments); - } + Thread t = new Thread(new ParameterizedThreadStart(OpenNew)); + t.Start(e.Arguments[0].StringValue); } @@ -222,20 +218,36 @@ namespace CMS_Client.Browser_Tools { if (e.Arguments.Count() == 0) return; - String id = e.Arguments[0].StringValue; - Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.Id == id); + Thread t = new Thread(new ParameterizedThreadStart(OpenStartNew)); + t.Start(e.Arguments[0].StringValue); + } + + + //Function used in Thread + private void OpenStartNew(object id) + { + Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.id == (string)id); if (sft != null) { - Process[] p = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(sft.Path)).OrderByDescending(X => X.StartTime).ToArray(); + Process[] p = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(sft.path)).OrderByDescending(X => X.StartTime).ToArray(); if (p.Count() > 0 && p[0].MainWindowHandle != IntPtr.Zero) NcWindow.ForceExtFocus(p[0].MainWindowHandle); else - Process.Start(sft.Path, sft.Arguments); - } - } + Process.Start(sft.path, sft.arguments); + } + } + + + //Function used in Thread + private void OpenNew(object id) + { + Software sft = Config.ExtSoftwaresConfig.FirstOrDefault(X => X.id == (string)id); + if (sft != null) + Process.Start(sft.path, sft.arguments); + } #endregion } diff --git a/Step.Utils/languages/IT.xml b/Step.Utils/languages/IT.xml index f0e82db5..3cc8de44 100644 --- a/Step.Utils/languages/IT.xml +++ b/Step.Utils/languages/IT.xml @@ -83,6 +83,9 @@ Conferma Annulla + + Utility & Software esterni + Manager della produzione diff --git a/Step.Utils/languages/en.xml b/Step.Utils/languages/en.xml index 832fd354..824f0405 100644 --- a/Step.Utils/languages/en.xml +++ b/Step.Utils/languages/en.xml @@ -82,6 +82,9 @@ Are you sure? Confirm Cancel + + + Utilities & External Softwares diff --git a/Step.Utils/languages/zh.xml b/Step.Utils/languages/zh.xml index ef627e09..97905bfc 100644 --- a/Step.Utils/languages/zh.xml +++ b/Step.Utils/languages/zh.xml @@ -82,6 +82,9 @@ 你確定? 確認 取消 + + + 公用事业和外部软件 diff --git a/Step/wwwroot/src/components/utilities.ts b/Step/wwwroot/src/components/utilities.ts index bd2018d1..09d2a287 100644 --- a/Step/wwwroot/src/components/utilities.ts +++ b/Step/wwwroot/src/components/utilities.ts @@ -8,42 +8,19 @@ declare let cmsClient: any; software: Object, i: Number }}) export default class Utilities extends Vue{ + + + public getUtilities(): Array { + if (typeof cmsClient != "undefined") + return JSON.parse(cmsClient.getConfiguredProcesses()); + else + return new Array(); + } - // public arrayJsonSoftware: Array = cmsClient.getConfiguredProcess(); - - /** Cancellare proprietà sotto se quella commentata è ok, attendere conferma Paolo */ - - public arrayJsonSoftware: Array = [{ - id: 1234567, - path: "/test", - longName: "CMS Copy", - shortName: "CC", - iconBase64: "" - },{ - id: 3133213, - path: "/test2", - longName: "Presetting Tool", - shortName: "ES", - iconBase64: "" - },{ - id: 46456464, - path: "/test2", - longName: "Presetting Tool", - shortName: "ES", - iconBase64: "" - },{ - id: 867866, - path: "/test2", - longName: "Presetting Tool", - shortName: "ES", - iconBase64: "" - },{ - id: 827726, - path: "/test2", - longName: "Presetting Tool", - shortName: "ES", - iconBase64: "" - }]; + public startUtility(id) { + if (typeof cmsClient != "undefined") + cmsClient.openOrStartProcess(id); + } } \ No newline at end of file diff --git a/Step/wwwroot/src/components/utilities.vue b/Step/wwwroot/src/components/utilities.vue index 9e8494d8..cbbdbbdf 100644 --- a/Step/wwwroot/src/components/utilities.vue +++ b/Step/wwwroot/src/components/utilities.vue @@ -5,26 +5,14 @@ {{'utilities_header_label' | localize("Utilities")}}
-
-
- +
+
+
- -
- \ No newline at end of file diff --git a/Step/wwwroot/src/modules/base-components/cards/card-utilities.vue b/Step/wwwroot/src/modules/base-components/cards/card-utilities.vue index 17eb44f1..247b5852 100644 --- a/Step/wwwroot/src/modules/base-components/cards/card-utilities.vue +++ b/Step/wwwroot/src/modules/base-components/cards/card-utilities.vue @@ -5,7 +5,10 @@ {{title}}
- +
@@ -14,7 +17,8 @@ export default { props:{ title: {default:""}, - letters: {default:""} + letters: {default:""}, + image: {default:""} }, methods:{ clickEvent(){