diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index e16b0fd2..182125a0 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Config/Config/serverConfig.xml b/Step.Config/Config/serverConfig.xml index ec1bcc1e..5222c93e 100644 --- a/Step.Config/Config/serverConfig.xml +++ b/Step.Config/Config/serverConfig.xml @@ -1,11 +1,13 @@ - DEMO + OSAI true - localhost + 192.168.139.1 8080 Ares 37 OF + C:\PartPrg\ + //PARTPRG:/ 9000 diff --git a/Step.Config/Config/serverConfigValidator.xsd b/Step.Config/Config/serverConfigValidator.xsd index a704ecd9..a7b73acc 100644 --- a/Step.Config/Config/serverConfigValidator.xsd +++ b/Step.Config/Config/serverConfigValidator.xsd @@ -11,6 +11,8 @@ + + diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index 10624ea8..aee27570 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -172,10 +172,12 @@ namespace Step.Config .Select(x => new NcConfigModel() { NcVendor = x.Element("ncVendor").Value, - showNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value), + ShowNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value), NcIpAddress = x.Element("ncIpAddress").Value, NcPort = Convert.ToUInt16(x.Element("ncPort").Value), - NcName = x.Element("machineModel").Value + NcName = x.Element("machineModel").Value, + SharedPath = x.Element("sharedPath").Value, + SharedName = x.Element("sharedName").Value, }).FirstOrDefault(); // Read server config with LINQ and save into static config diff --git a/Step.Model/ConfigModels/NcConfigModel.cs b/Step.Model/ConfigModels/NcConfigModel.cs index 0919844e..cbbc5fe1 100644 --- a/Step.Model/ConfigModels/NcConfigModel.cs +++ b/Step.Model/ConfigModels/NcConfigModel.cs @@ -9,10 +9,12 @@ namespace Step.Model.ConfigModels public class NcConfigModel { public string NcVendor { get; set; } - public bool showNcHMI { get; set; } + public bool ShowNcHMI { get; set; } public string NcIpAddress { get; set; } public ushort NcPort { get; set; } public string NcUniqueId { get; set; } public string NcName { get; set; } + public string SharedPath { get; set; } + public string SharedName { get; set; } } } diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 86aeb115..6a10fff7 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -6,8 +6,9 @@ namespace Step.Model { public static class Constants { + public static readonly string[] VALID_FILE_EXTENSIONS = { "", ".txt", ".cnc", ".ini", ".mpf", ".spf" }; public const double EPSILON = 0.001; - + public enum ROLE_IDS { CMS_SERVICE_ONLY = 1, diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs index 1a5e4b77..0a78cd85 100644 --- a/Step/Controllers/WebApi/ConfigurationController.cs +++ b/Step/Controllers/WebApi/ConfigurationController.cs @@ -36,7 +36,7 @@ namespace Step.Controllers.WebApi DTOClientConfigurationModel clientConfiguration = new DTOClientConfigurationModel() { NcVendor = NcConfig.NcVendor, - ShowHMI = NcConfig.showNcHMI, + ShowHMI = NcConfig.ShowNcHMI, DefaultLanguage = ServerStartupConfig.Language, NcIp = NcConfig.NcIpAddress, NcPort = NcConfig.NcPort diff --git a/Step/Controllers/WebApi/NcFileController.cs b/Step/Controllers/WebApi/NcFileController.cs index b38b7461..ed2cfb7e 100644 --- a/Step/Controllers/WebApi/NcFileController.cs +++ b/Step/Controllers/WebApi/NcFileController.cs @@ -11,6 +11,9 @@ using System.Text; using System.Threading.Tasks; using System.Web.Http; using static CMS_CORE_Library.DataStructures; +using System.Linq; +using static Step.Config.ServerConfig; +using System.ComponentModel.DataAnnotations; namespace Step.Controllers.WebApi { @@ -24,7 +27,7 @@ namespace Step.Controllers.WebApi { ncHandler.Connect(); - CmsError cmsError = ncHandler.GetFileList(filePath, out List fileList); + CmsError cmsError = ncHandler.GetFileList(filePath, out List fileList); if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); @@ -33,7 +36,7 @@ namespace Step.Controllers.WebApi } [Route("file/info"), HttpGet] - public IHttpActionResult GetFileInfo([FromUri]string filePath) + public IHttpActionResult GetFileInfo([FromUri]string filePath) { using (NcHandler ncHandler = new NcHandler()) { @@ -113,5 +116,45 @@ namespace Step.Controllers.WebApi return Ok(); } + + [Route("shared_files"), HttpGet] + public IHttpActionResult GetSharedFolderFileList(string sharedPath) + { + List filelist = new List(); + + string sharedFullPath = NcConfig.SharedPath + sharedPath; + + if (!Directory.Exists(sharedFullPath)) + { + return NotFound(); + } + + foreach (string item in Directory.GetDirectories(sharedFullPath)) + { + filelist.Add(new + { + Name = Path.GetFileName(item), + AbsolutePath = NcConfig.SharedPath + sharedPath, + Path = sharedPath, + IsDirectory = true + }); + } + + string sharedNcPath = NcConfig.SharedName + sharedPath.Replace('\\', '/'); + + foreach (string item in Directory.GetFiles(sharedFullPath)) + { + if (VALID_FILE_EXTENSIONS.Contains(Path.GetExtension(item).ToLower())) + filelist.Add(new + { + Name = Path.GetFileName(item), + AbsolutePath = sharedNcPath + "/" + Path.GetFileName(item), + Path = sharedPath + "\\" + Path.GetFileName(item), + IsDirectory = false + }); + } + + return Ok(filelist); + } } } \ No newline at end of file diff --git a/Step/Controllers/WebApi/NcToolManagerController.cs b/Step/Controllers/WebApi/NcToolManagerController.cs index 3d4d5b35..26e27243 100644 --- a/Step/Controllers/WebApi/NcToolManagerController.cs +++ b/Step/Controllers/WebApi/NcToolManagerController.cs @@ -144,23 +144,24 @@ namespace Step.Controllers.WebApi return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); } - // If option is active - if (!ToolManagerConfig.FamilyOpt) - { - // Copy only family - DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel(); - SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily); - // Update only family data - DbNcFamilyModel dbFam = toolsManager.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily); - if (dbFam == null) - return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); - } - using (NcHandler ncHandler = new NcHandler()) { + CmsError cmsError; + // If option is active + if (!ToolManagerConfig.FamilyOpt) + { + // Copy only family + DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel(); + SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily); + // Update only family data + cmsError = ncHandler.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily, out DTONcFamilyModel newFam); + if (cmsError.IsError()) + return BadRequest(cmsError.localizationKey); + } + ncHandler.Connect(); // Update - CmsError cmsError = ncHandler.UpdateTool(toolId, dtoToolWithFamily, out DTONcToolModel newTool); + cmsError = ncHandler.UpdateTool(toolId, dtoToolWithFamily, out DTONcToolModel newTool); if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); diff --git a/Step/wwwroot/src/modules/base-components/modal-load-program.ts b/Step/wwwroot/src/modules/base-components/modal-load-program.ts index e5a27fce..57a618c4 100644 --- a/Step/wwwroot/src/modules/base-components/modal-load-program.ts +++ b/Step/wwwroot/src/modules/base-components/modal-load-program.ts @@ -75,7 +75,7 @@ export default class ModalLoadProgram extends Vue { this.currentPath = absolutePath; this.lastClickPath = absolutePath; this.checkChangeNavigationType(local); - var files = await this.getFilesForPath(absolutePath, local); + var files = await this.getFilesForPath(absolutePath, path, local); // controlla se impostare il currentDrive if (fromdepth == 0) this.currentDrive = absolutePath; @@ -97,7 +97,7 @@ export default class ModalLoadProgram extends Vue { this.fillArray(this.secondColumnData, files); this.currentFilterSecond = ""; } - this.calcBreadCrumb(path); + this.calcBreadCrumb(absolutePath); } fillArray(destinationArray: Array, sourceArray: Array) { @@ -118,10 +118,11 @@ export default class ModalLoadProgram extends Vue { } } - async getFilesForPath(path: string, local: boolean): Promise> { + async getFilesForPath(absolutePath: string, path: string, local: boolean): Promise> { this.isLocalNavigation = local; var result = null; - if (local) result = JSON.parse(cmsClient.getFileList(path)); + console.log(path); + if (local) result = JSON.parse(cmsClient.getFileList(absolutePath)); else result = await awaiter(fileService.getFiles(path)); return this.toUpperCaseModel(result).sort(this.compareDirectoriesFirst); } @@ -131,6 +132,7 @@ export default class ModalLoadProgram extends Vue { } toUpperCaseModel(data: Array): Array { + console.log(data) return data.map(i => { return { Name: i.name || i.Name, diff --git a/Step/wwwroot/src/modules/base-components/modal-load-program.vue b/Step/wwwroot/src/modules/base-components/modal-load-program.vue index 88928912..1e9b8c5b 100644 --- a/Step/wwwroot/src/modules/base-components/modal-load-program.vue +++ b/Step/wwwroot/src/modules/base-components/modal-load-program.vue @@ -46,7 +46,7 @@ :selected="isInPath(val.AbsolutePath) || val.AbsolutePath == lastClickPath" :withArrow="val.IsDirectory == true" :iconType="val.IsDirectory? 'FOLDER':'FILE'" - @click="val.IsDirectory ? navigateTo(val.AbsolutePath,val.AbsolutePath, isLocalNavigation, 2,1): fileInfo(val.AbsolutePath,1)"> + @click="val.IsDirectory ? navigateTo(val.Path, val.AbsolutePath, isLocalNavigation, 2,1): fileInfo(val.AbsolutePath,1)">
@@ -68,7 +68,7 @@ :selected="isInPath(val.AbsolutePath) || val.AbsolutePath == lastClickPath" :withArrow="val.IsDirectory == true" :iconType="val.IsDirectory? 'FOLDER':'FILE'" - @click="val.IsDirectory? navigateTo(val.AbsolutePath,val.AbsolutePath, isLocalNavigation, 2,2):fileInfo(val.AbsolutePath,2) "> + @click="val.IsDirectory? navigateTo(val.Path, val.AbsolutePath, isLocalNavigation, 2,2):fileInfo(val.AbsolutePath,2) "> diff --git a/Step/wwwroot/src/services/hub.ts b/Step/wwwroot/src/services/hub.ts index 4556fa87..c100ee37 100644 --- a/Step/wwwroot/src/services/hub.ts +++ b/Step/wwwroot/src/services/hub.ts @@ -110,15 +110,14 @@ export class Hub { private static activeProgramData(data) { // Controllo se devo ricaricare l'immagine var cp = (store.state as AppModel).process.currentProgram; - - if ((!cp || (cp && cp.path != data.path)) && data.path !="") { + if(data.path != "" && (!cp || cp.path != data.path)){ fileService.getFileInfo(data.path).then(r => { var image = r.previewBase64; processModelActions.setCurrentProgramImage(store, image); processModelActions.setCurrentProgramName(store, r.name); }); } - else + else if(data.path =="") { processModelActions.setCurrentProgramImage(store, null); processModelActions.setCurrentProgramName(store, null);