From e890fa136bf652a87cf317454f1f89e04b1c2411 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Fri, 6 Dec 2019 11:39:13 +0100 Subject: [PATCH] Added Scm version of the contacts window --- Step.Config/Config/maintenancesConfig.xml | 59 +++++++++++++------ .../Config/maintenancesConfigValidator.xsd | 21 ++++++- Step.Config/ServerConfig.cs | 14 +++-- Step.Config/ServerConfigController.cs | 55 ++++++++++++++--- .../WebApi/ConfigurationController.cs | 40 +++++++++++-- Step/wwwroot/assets/styles/base/modals.less | 4 +- Step/wwwroot/assets/styles/style.css | 6 +- Step/wwwroot/src/app.business-logic.ts | 2 +- .../machine/components/contact-info-dialog.ts | 31 ++++++++-- .../components/contact-info-dialog.vue | 28 +++++---- Step/wwwroot/src/services/machineService.ts | 18 +++--- 11 files changed, 209 insertions(+), 69 deletions(-) diff --git a/Step.Config/Config/maintenancesConfig.xml b/Step.Config/Config/maintenancesConfig.xml index 638b649e..8ec82203 100644 --- a/Step.Config/Config/maintenancesConfig.xml +++ b/Step.Config/Config/maintenancesConfig.xml @@ -1,24 +1,45 @@  - - CMS spa - cms.assistance@cms.it - +39 0345 64 350 - https://www.scmgroup.com/en/cms/customer-care - - - true - SPARE PARTS - cms.spares@cms.it - +39 0345 64 832 - - - true - Retrofit - cms.retrofit@cms.it - +39 0345 64 350 - - + + + CMS spa + cms.assistance@cms.it + +39 0345 64 350 + https://www.scmgroup.com/en/cms/customer-care + + + true + SPARE PARTS + cms.spares@cms.it + +39 0345 64 832 + + + true + Retrofit + cms.retrofit@cms.it + +39 0345 64 350 + + + + + CMS spa + cms.assistance@cms.it + +39 0345 64 350 + https://www.scmgroup.com/en/cms/customer-care + + + true + SPARE PARTS + cms.spares@cms.it + +39 0345 64 832 + + + true + Retrofit + cms.retrofit@cms.it + +39 0345 64 350 + + 1 diff --git a/Step.Config/Config/maintenancesConfigValidator.xsd b/Step.Config/Config/maintenancesConfigValidator.xsd index 87fc9072..f3b815be 100644 --- a/Step.Config/Config/maintenancesConfigValidator.xsd +++ b/Step.Config/Config/maintenancesConfigValidator.xsd @@ -3,9 +3,24 @@ - - - + + + + + + + + + + + + + + + + + + diff --git a/Step.Config/ServerConfig.cs b/Step.Config/ServerConfig.cs index c79d8c62..bf97d3c1 100644 --- a/Step.Config/ServerConfig.cs +++ b/Step.Config/ServerConfig.cs @@ -14,11 +14,15 @@ namespace Step.Config public static SoftwareProdConfigModel SoftwareProdConfig; public static MachineModel MachineConfig; public static List MaintenancesConfig; - public static ContactModel ContactConfig; - public static ContactModel AuxContact1; - public static ContactModel AuxContact2; - public static string CmsWebsiteUrl; - public static string CmsCompanyName; + public static ContactModel CmsContactConfig; + public static ContactModel ScmContactConfig; + public static ContactModel DealerContactConfig; + public static ContactModel CmsAuxContact1; + public static ContactModel ScmAuxContact1; + public static ContactModel DealerAuxContact1; + public static ContactModel CmsAuxContact2; + public static ContactModel ScmAuxContact2; + public static ContactModel DealerAuxContact2; public static string ContactInfoError; public static List FunctionsAccessConfig; diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index 46f024a1..db48fc65 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Reflection; +using System.Security.Cryptography; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; @@ -262,6 +263,8 @@ namespace Step.Config public static void ReadServerConfig() { + CalculateHash(SERVER_CONFIG_PATH); + // Get server file handler XDocument xmlConfigFile = GetXmlHandlerWithValidator(SERVER_CONFIG_SCHEMA_PATH, SERVER_CONFIG_PATH); @@ -379,15 +382,30 @@ namespace Step.Config //Read Standard CMS Configuration XDocument xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH, true); - ReadAssistanceConfigFromXml(xmlConfigFile); + ReadAssistanceConfigFromXml( + xmlConfigFile.Root.Descendants("cmsContacts").FirstOrDefault(), + out CmsContactConfig, + out CmsAuxContact1, + out CmsAuxContact2 + ); + + xmlConfigFile = GetXmlHandlerWithValidator(MAINTENANCES_CONFIG_SCHEMA_PATH, MAINTENANCES_CONFIG_PATH, true); + ReadAssistanceConfigFromXml( + xmlConfigFile.Root.Descendants("scmContacts").FirstOrDefault(), + out ScmContactConfig, + out ScmAuxContact1, + out ScmAuxContact2 + ); - //Setup STD var - CmsWebsiteUrl = ContactConfig.WebSite; - CmsCompanyName = ContactConfig.Company; } public static bool ReadAssistanceCustomConfig() { + + DealerContactConfig = null; + DealerAuxContact1 = null; + DealerAuxContact2 = null; + //Read Dealer Configuration if (File.Exists(CUSTOMER_CONTACTS)) { @@ -420,14 +438,21 @@ namespace Step.Config ReadAssistanceConfig(); return false; } - ReadAssistanceConfigFromXml(XDocument.Parse(xmlContactFile.OuterXml)); + + ReadAssistanceConfigFromXml( + XDocument.Parse(xmlContactFile.OuterXml).Root, + out DealerContactConfig, + out DealerAuxContact1, + out DealerAuxContact2 + ); + } return true; } - public static void ReadAssistanceConfigFromXml(XDocument xmlConfigFile) + public static void ReadAssistanceConfigFromXml(XElement xmlRoot, out ContactModel MainContact, out ContactModel AuxContact1, out ContactModel AuxContact2) { - ContactConfig = xmlConfigFile + MainContact = xmlRoot .Descendants("MainOffice") .Select(x => new ContactModel() @@ -439,7 +464,7 @@ namespace Step.Config }) .FirstOrDefault(); - AuxContact1 = xmlConfigFile + AuxContact1 = xmlRoot .Descendants("AuxOffice1") .Select(x => new ContactModel() @@ -451,7 +476,7 @@ namespace Step.Config }) .FirstOrDefault(); - AuxContact2 = xmlConfigFile + AuxContact2 = xmlRoot .Descendants("AuxOffice2") .Select(x => new ContactModel() @@ -699,6 +724,18 @@ namespace Step.Config } } + public static string CalculateHash(string filename) + { + using (var sha = SHA1.Create()) + { + using (var stream = File.OpenRead(filename)) + { + var hash = sha.ComputeHash(stream); + return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); + } + } + } + #endregion Read config from file from configuration } } \ No newline at end of file diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs index 92ae3b8c..ccc060f1 100644 --- a/Step/Controllers/WebApi/ConfigurationController.cs +++ b/Step/Controllers/WebApi/ConfigurationController.cs @@ -1,5 +1,6 @@ using CMS_CORE_Library.Models; using Step.Database.Controllers; +using Step.Model.ConfigModels; using Step.Model.DTOModels; using Step.Model.DTOModels.AlarmModels; using Step.NC; @@ -139,23 +140,54 @@ namespace Step.Controllers.WebApi } } - [Route("contact"), HttpGet] - public IHttpActionResult GetContact() + [Route("cmscontact"), HttpGet] + public IHttpActionResult GetCmsContact() { if (!Config.ServerConfigController.ReadAssistanceCustomConfig()) ContactInfoError = Model.Constants.API_ERROR_KEYS.CUSTOMER_FILE_INVALID; else ContactInfoError = ""; + ContactModel ContactConfig = CmsContactConfig; + ContactModel AuxContact1 = CmsAuxContact1; + ContactModel AuxContact2 = CmsAuxContact2; + ContactModel ItalyContactConfig = CmsContactConfig; + + if (DealerContactConfig != null && DealerAuxContact1 != null && DealerAuxContact2 != null) + { + ContactConfig = DealerContactConfig; + AuxContact1 = DealerAuxContact1; + AuxContact2 = DealerAuxContact2; + } + return Ok(new { ContactConfig, AuxContact1, AuxContact2, - CmsWebsiteUrl, - CmsCompanyName, + ItalyContactConfig, ContactInfoError }); } + + [Route("scmcontact"), HttpGet] + public IHttpActionResult GetScmContact() + { + ContactInfoError = ""; + + ContactModel ContactConfig = ScmContactConfig; + ContactModel AuxContact1 = ScmAuxContact1; + ContactModel AuxContact2 = ScmAuxContact2; + ContactModel ItalyContactConfig = ScmContactConfig; + + return Ok(new + { + ContactConfig, + AuxContact1, + AuxContact2, + ItalyContactConfig, + ContactInfoError + }); + } } } \ No newline at end of file diff --git a/Step/wwwroot/assets/styles/base/modals.less b/Step/wwwroot/assets/styles/base/modals.less index c2aa9cbb..8a6bab5a 100644 --- a/Step/wwwroot/assets/styles/base/modals.less +++ b/Step/wwwroot/assets/styles/base/modals.less @@ -46,7 +46,7 @@ @modal-machine-width: 600px; @modal-machine-top: @modal-machine-height / 2; @modal-machine-left: @modal-machine-width / 2; -@modal-contact-height: 750px; +@modal-contact-height: 850px; @modal-contact-width: 600px; @modal-machine-top: @modal-contact-height / 2; @modal-machine-left: @modal-contact-width / 2; @@ -712,7 +712,7 @@ flex-direction: column; justify-content:center; margin-top: 20px; - height: 360px; + height: 450px; } .hoverqr{ position: absolute; diff --git a/Step/wwwroot/assets/styles/style.css b/Step/wwwroot/assets/styles/style.css index ad0a4eb0..c817b588 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -516,8 +516,8 @@ } .modal.contact-info { width: 600px; - height: 750px; - top: calc(50% - 750px / 2); + height: 850px; + top: calc(50% - 850px / 2); left: calc(50% - 600px / 2); } .modal.contact-info .body { @@ -628,7 +628,7 @@ flex-direction: column; justify-content: center; margin-top: 20px; - height: 360px; + height: 450px; } .modal.contact-info .hoverqr { position: absolute; diff --git a/Step/wwwroot/src/app.business-logic.ts b/Step/wwwroot/src/app.business-logic.ts index 87b02d03..dba3d262 100644 --- a/Step/wwwroot/src/app.business-logic.ts +++ b/Step/wwwroot/src/app.business-logic.ts @@ -90,7 +90,7 @@ async function loadMachineConfig() { if (!USE_RUNTIME_CONFIGURATION) vendor = DEBUG_CONFIGURATION; - + // set vendor type switch (vendor) { case "siemens": machineInfoActions.updateMachineInfo(store, { isSiemens: true, isFanuc: false, isOsai: false, defaultLanguage: mcresult.defaultLanguage, isSCMVisualStyle: isSCM, mgiOption : false, cmsConnectReady: mcresult.cmsConnectReady }); break; diff --git a/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.ts b/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.ts index 3ef9c43f..d61c2e4b 100644 --- a/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.ts +++ b/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.ts @@ -13,6 +13,7 @@ export default class ContactInfoDialog extends Vue { contactInfo: ContactModel = {visible: false,name: null,company: null,email: null,phoneNumber: null,webSite: null}; auxContact1: ContactModel = {visible: false,name: null,company: null,email: null,phoneNumber: null,webSite: null}; auxContact2: ContactModel = {visible: false,name: null,company: null,email: null,phoneNumber: null,webSite: null}; + italyContactConfig: ContactModel = {visible: false,name: null,company: null,email: null,phoneNumber: null,webSite: null}; cmsCompanyName: string = "" cmsWebsiteUrl: string = "" vendorWebsiteUrl: string = "" @@ -55,7 +56,21 @@ export default class ContactInfoDialog extends Vue { //Get Info from API try { - var contactResult = await awaiter(new machineService().getContactConfiguration()); + + //If is not CMS-Client i don't know who are you looking for + if (typeof cmsClient == "undefined") { + this.onloading = false; + this.onError = true; + this.error = "Function not allowed for this Browser"; + return + } + + //Difference from CMS / SCM + if(!this.isSCMVisualStyle) + var contactResult = await awaiter(new machineService().getCmsContactConfiguration()); + else + var contactResult = await awaiter(new machineService().getScmContactConfiguration()); + if(contactResult.contactInfoError && contactResult.contactInfoError!=''){ this.onloading = false; this.onError = true; @@ -72,14 +87,18 @@ export default class ContactInfoDialog extends Vue { this.contactInfo = contactResult.contactConfig; this.auxContact1 = contactResult.auxContact1; this.auxContact2 = contactResult.auxContact2; - this.cmsCompanyName = contactResult.cmsCompanyName; + this.italyContactConfig = contactResult.italyContactConfig; //Setup Weburl - this.cmsWebsiteUrl = contactResult.cmsWebsiteUrl; + this.cmsWebsiteUrl = contactResult.italyContactConfig.webSite; this.vendorWebsiteUrl = contactResult.contactConfig.webSite; - if(this.cmsWebsiteUrl == this.vendorWebsiteUrl) + + if(this.cmsWebsiteUrl && this.cmsWebsiteUrl == this.vendorWebsiteUrl) this.cmsWebsiteUrl = null; + if(this.italyContactConfig && this.italyContactConfig.company == this.contactInfo.company) + this.italyContactConfig = null; + //Setup QRCode try { if(this.cmsWebsiteUrl) @@ -100,6 +119,10 @@ export default class ContactInfoDialog extends Vue { this.onloading = false; } + get isSCMVisualStyle() { + return this.$store.state.machineInfo.isSCMVisualStyle; + } + beforeDestroy() { messageService.deleteChannel("esc_pressed"); } diff --git a/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.vue b/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.vue index 17cba387..4b7b524d 100644 --- a/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.vue +++ b/Step/wwwroot/src/app_modules/machine/components/contact-info-dialog.vue @@ -24,17 +24,23 @@ -
-

{{fieldMandatory(auxContact1.name,"AUX Office 1").toUpperCase()}}

- - -
-
-

{{fieldMandatory(auxContact2.name,"AUX Office 2").toUpperCase()}}

- - -
+
+

{{'contactinfo_lbl_cms_assistance_name' | localize('Informazioni assistenza CMS:').toUpperCase()}}

+ + +
+
+

{{fieldMandatory(auxContact1.name,"AUX Office 1").toUpperCase()}}

+ + +
+
+

{{fieldMandatory(auxContact2.name,"AUX Office 2").toUpperCase()}}

+ + +
+
@@ -53,7 +59,7 @@
-
{{fieldMandatory(cmsCompanyName,"CMS Office")}}
+
{{fieldMandatory(italyContactConfig.company,"CMS Office")}}
diff --git a/Step/wwwroot/src/services/machineService.ts b/Step/wwwroot/src/services/machineService.ts index 9da48481..7e10e06a 100644 --- a/Step/wwwroot/src/services/machineService.ts +++ b/Step/wwwroot/src/services/machineService.ts @@ -10,8 +10,11 @@ export class machineService extends baseRestService { return await this.Get("/api/configuration/areas"); } - async getContactConfiguration(): Promise { - return await this.Get("/api/configuration/contact") + async getCmsContactConfiguration(): Promise { + return await this.Get("/api/configuration/cmscontact") + } + async getScmContactConfiguration(): Promise { + return await this.Get("/api/configuration/scmcontact") } async getMachineConfiguration(): Promise { @@ -56,11 +59,11 @@ export interface ClientConfigurationModel { } export interface ContactConfigurationModel { - contactConfig: ContactModel, - contact1: ContactModel, - contact2: ContactModel, - contact3: ContactModel, - webSiteUrl: string + ContactConfig: ContactModel, + AuxContact1: ContactModel, + AuxContact2: ContactModel, + ItalyContactConfig: ContactModel, + ContactInfoError: string } export interface ContactModel{ @@ -70,7 +73,6 @@ export interface ContactModel{ email: string, phoneNumber: string, webSite: string - } export interface NCInfoModel {