diff --git a/Insomnia/MAPO-IOC.json b/Insomnia/MAPO-IOC.json new file mode 100644 index 00000000..0db921f7 --- /dev/null +++ b/Insomnia/MAPO-IOC.json @@ -0,0 +1 @@ +{"_type":"export","__export_format":4,"__export_date":"2024-10-23T15:46:37.409Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_d6789dcf78d94816bbd8572ed8e50c32","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680674272654,"created":1680674272654,"url":"https://localhost:7212/api/Recipe/GetRecipe?idxPODL=1656","name":"New Request","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680616613017,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_e3f940b0e7364ede9659ddc904ed76da","parentId":null,"modified":1680674272619,"created":1680674272619,"name":"MP-IOC","description":"","scope":"collection","_type":"workspace"},{"_id":"req_0990f1f8b8054c6aa775c08233beb68a","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680674272646,"created":1680674272646,"url":"{{ _.BASE_URL }}/api/Recipe/GetRecipe?idxPODL=1656","name":"GET RECIPE (calc)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680615241541.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_86ef875060b240979a923807d5726572","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680674272651,"created":1680674272651,"url":"{{ BASE_URL }}/api/RecipeArchive/GetFile?idxMacc=SIMUL_02&fileName=10002.xml","name":"GET FILE (from archive)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1679846511868.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_80ed4f0bb8ac463b90112c98d457c478","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680679124960,"created":1680679120652,"url":"{{ BASE_URL }}/api/RecipeArchive/GetFile?idxMacc=SIMUL_02&fileName=999.xml","name":"GET FILE - not exists","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1679462147031.9062,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_ca021599ba8443c1a79a2eb69aa92128","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680674272620,"created":1680674272620,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1680615228640,"_type":"environment"},{"_id":"jar_8fed13ca3e9a477dad1b0a6699c43b70","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680674272634,"created":1680674272634,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"spc_aaf61ce728e747a89c242f3c012bb23c","parentId":"wrk_e3f940b0e7364ede9659ddc904ed76da","modified":1680674272662,"created":1680674272637,"fileName":"MP-IOC","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_b5e3d19ecc18458b96877ecc73b04729","parentId":"env_ca021599ba8443c1a79a2eb69aa92128","modified":1680679494694,"created":1680674272621,"name":"DEV","data":{"BASE_URL":"https://localhost:7050"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#ff0000","isPrivate":false,"metaSortKey":1680615301619,"_type":"environment"},{"_id":"env_89e83800dd9d435ebe6745b4f80b2082","parentId":"env_ca021599ba8443c1a79a2eb69aa92128","modified":1680674621408,"created":1680674272628,"name":"IIS01","data":{"BASE_URL":"https://iis01.egalware.com/MP/IOC"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#6600ff","isPrivate":false,"metaSortKey":1680615328099,"_type":"environment"}]} \ No newline at end of file diff --git a/Insomnia/MAPO-PROG.json b/Insomnia/MAPO-PROG.json new file mode 100644 index 00000000..9258b930 --- /dev/null +++ b/Insomnia/MAPO-PROG.json @@ -0,0 +1 @@ +{"_type":"export","__export_format":4,"__export_date":"2024-10-23T15:45:49.150Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_bb23a3e0a78f44999350ddcefebaaf82","parentId":"wrk_0d1a3f6f42fe486dacbeeea3026c648b","modified":1729691634502,"created":1729691518776,"url":"{{ _.BASE_URL }}/api/Health","name":"Health","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680616613017,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_0d1a3f6f42fe486dacbeeea3026c648b","parentId":null,"modified":1729691518738,"created":1729691518738,"name":"MAPO-PROG","description":"","scope":"collection","_type":"workspace"},{"_id":"req_2b3ff677e75040ed9dfe30463fb5d408","parentId":"fld_cf0e8b6c31334d67bc421487d31a5540","modified":1729691689274,"created":1729691666872,"url":"{{ _.BASE_URL }}/api/FileChange","name":"FileChange Health","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1729691677997,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"fld_cf0e8b6c31334d67bc421487d31a5540","parentId":"wrk_0d1a3f6f42fe486dacbeeea3026c648b","modified":1729691675552,"created":1729691673364,"name":"FileChange","description":"","environment":{},"environmentPropertyOrder":null,"metaSortKey":-1680616270148.125,"_type":"request_group"},{"_id":"req_8fa584b2405b4c3588e1da50c6c02cbc","parentId":"fld_cf0e8b6c31334d67bc421487d31a5540","modified":1729691870054,"created":1729691818717,"url":"{{ _.BASE_URL }}/api/FileChange/approve/ALL?numDayPrev=7","name":"FileChange AutoSave","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1726323968489,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_b28dbcb90b9f4a30ae621f46ca80abf1","parentId":"fld_cf0e8b6c31334d67bc421487d31a5540","modified":1729698051601,"created":1729698043734,"url":"{{ _.BASE_URL }}/api/FileChange/check/ALL?numDayPrev=0","name":"FileChange CheckAll","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1724640113735,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_f533a867e5e74bc7a712974eb5185fe2","parentId":"wrk_0d1a3f6f42fe486dacbeeea3026c648b","modified":1729691518740,"created":1729691518740,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1680615228640,"_type":"environment"},{"_id":"jar_52975036fdb946749a04bf8b105649dc","parentId":"wrk_0d1a3f6f42fe486dacbeeea3026c648b","modified":1729691518752,"created":1729691518752,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"spc_034d8153209c43289ef94bb511a381e4","parentId":"wrk_0d1a3f6f42fe486dacbeeea3026c648b","modified":1729691518782,"created":1729691518757,"fileName":"MAPO-PROG","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_6acd2ea246a54f2fa42dfa7191704e4f","parentId":"env_f533a867e5e74bc7a712974eb5185fe2","modified":1729691571662,"created":1729691518742,"name":"DEV","data":{"BASE_URL":"https://localhost:5001"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#ff0000","isPrivate":false,"metaSortKey":1680615301619,"_type":"environment"},{"_id":"env_add3f929a9774e949eaacdfef9669698","parentId":"env_f533a867e5e74bc7a712974eb5185fe2","modified":1729691576277,"created":1729691518746,"name":"IIS01","data":{"BASE_URL":"https://iis01.egalware.com/MP/PROG"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#6600ff","isPrivate":false,"metaSortKey":1680615328099,"_type":"environment"},{"_id":"env_78f831742ec84968878b6bb3e2dbbee3","parentId":"env_f533a867e5e74bc7a712974eb5185fe2","modified":1729691592437,"created":1729691579006,"name":"PROD","data":{"BASE_URL":"https://iis01.egalware.com/MP/PROG"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#6600ff","isPrivate":false,"metaSortKey":1692979703520,"_type":"environment"}]} \ No newline at end of file diff --git a/Insomnia/MAPO-SPEC.json b/Insomnia/MAPO-SPEC.json index b14c98f9..65a34e4a 100644 --- a/Insomnia/MAPO-SPEC.json +++ b/Insomnia/MAPO-SPEC.json @@ -1 +1 @@ -{"_type":"export","__export_format":4,"__export_date":"2023-04-04T15:23:33.215Z","__export_source":"insomnia.desktop.app:v2023.1.0","resources":[{"_id":"req_cd57cb8728854cd5a7d026b9aba60047","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680616613886,"created":1680616613017,"url":"https://localhost:7212/api/Recipe/GetRecipe?idxPODL=1656","name":"New Request","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680616613017,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","parentId":null,"modified":1680615228636,"created":1680615228636,"name":"MAPO-SPEC","description":"","scope":"collection","_type":"workspace"},{"_id":"req_4d233d6fb970485ea929bdffdcfae05a","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680621773464,"created":1680615246346,"url":"{{ _.BASE_URL }}/api/Recipe/GetRecipe?idxPODL=1656","name":"GET RECIPE (calc)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680615241541.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_278d5f0a6555457e88ad2e58cfdaae23","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680621754168,"created":1680615436433,"url":"{{ BASE_URL }}/api/RecipeArchive/GetFile?idxMacc=SIMUL_02&fileName=10002.xml","name":"GET FILE (from archive)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1679846511868.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615377532,"created":1680615228640,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1680615228640,"_type":"environment"},{"_id":"jar_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615228642,"created":1680615228642,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"spc_b61936e963e34a759001c6a22ad8da60","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615228637,"created":1680615228637,"fileName":"MAPO-SPEC","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_2757d8ba1b17435987847d0499e9369e","parentId":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","modified":1680616993850,"created":1680615301619,"name":"DEV","data":{"BASE_URL":"https://localhost:7212"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#ff0000","isPrivate":false,"metaSortKey":1680615301619,"_type":"environment"},{"_id":"env_f5b6aef3c2b444aab04c9056404d63f9","parentId":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","modified":1680616996428,"created":1680615328099,"name":"IIS01","data":{"BASE_URL":"https://iis01.egalware.com/MP/SPEC"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#6600ff","isPrivate":false,"metaSortKey":1680615328099,"_type":"environment"}]} \ No newline at end of file +{"_type":"export","__export_format":4,"__export_date":"2024-10-23T15:46:09.187Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_cd57cb8728854cd5a7d026b9aba60047","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680616613886,"created":1680616613017,"url":"https://localhost:7212/api/Recipe/GetRecipe?idxPODL=1656","name":"New Request","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680616613017,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","parentId":null,"modified":1680615228636,"created":1680615228636,"name":"MAPO-SPEC","description":"","scope":"collection","_type":"workspace"},{"_id":"req_4d233d6fb970485ea929bdffdcfae05a","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680621773464,"created":1680615246346,"url":"{{ _.BASE_URL }}/api/Recipe/GetRecipe?idxPODL=1656","name":"GET RECIPE (calc)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1680615241541.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_278d5f0a6555457e88ad2e58cfdaae23","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680621754168,"created":1680615436433,"url":"{{ BASE_URL }}/api/RecipeArchive/GetFile?idxMacc=SIMUL_02&fileName=10002.xml","name":"GET FILE (from archive)","description":"","method":"GET","body":{},"parameters":[],"headers":[],"authentication":{},"metaSortKey":-1679846511868.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615377532,"created":1680615228640,"name":"Base Environment","data":{},"dataPropertyOrder":{},"color":null,"isPrivate":false,"metaSortKey":1680615228640,"_type":"environment"},{"_id":"jar_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615228642,"created":1680615228642,"name":"Default Jar","cookies":[],"_type":"cookie_jar"},{"_id":"spc_b61936e963e34a759001c6a22ad8da60","parentId":"wrk_86debe1a96ca41cdbfb53ed71a9d6d84","modified":1680615228637,"created":1680615228637,"fileName":"MAPO-SPEC","contents":"","contentType":"yaml","_type":"api_spec"},{"_id":"env_2757d8ba1b17435987847d0499e9369e","parentId":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","modified":1680616993850,"created":1680615301619,"name":"DEV","data":{"BASE_URL":"https://localhost:7212"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#ff0000","isPrivate":false,"metaSortKey":1680615301619,"_type":"environment"},{"_id":"env_f5b6aef3c2b444aab04c9056404d63f9","parentId":"env_ea1cd34b6839260f9a1edf3546f3c605bb6f3a2c","modified":1680616996428,"created":1680615328099,"name":"IIS01","data":{"BASE_URL":"https://iis01.egalware.com/MP/SPEC"},"dataPropertyOrder":{"&":["BASE_URL"]},"color":"#6600ff","isPrivate":false,"metaSortKey":1680615328099,"_type":"environment"}]} \ No newline at end of file diff --git a/MP.FileData/Controllers/FileController.cs b/MP.FileData/Controllers/FileController.cs index a1e46967..40a17543 100644 --- a/MP.FileData/Controllers/FileController.cs +++ b/MP.FileData/Controllers/FileController.cs @@ -115,8 +115,9 @@ namespace MP.FileData.Controllers /// Forza il controllo dei Tags /// Regole di ricerca applicate /// Utente connesso x approvazione + /// indica se vada approvata la modifica o lasciato "in sospeso" /// - public int CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, bool forceTag, SearchRules currRule, string UserName) + public int CheckFileArchived(string idxMacchina, string path, int numDayPre, string searchPattern, bool forceTag, SearchRules currRule, string UserName, bool DoApprove) { Log.Info($"CheckFileArchived S00 | macchina: {idxMacchina} | path: {path} | pattern: {searchPattern} | # ExcludedFileExt: {currRule.ExcludedFileExt.Count()}"); int checkDone = 0; @@ -213,7 +214,7 @@ namespace MP.FileData.Controllers if (fileNew != null && fileNew.Count > 0) { checkDone += fileNew.Count; - FileInsert(idxMacchina, path, fileNew, UserName, 0, currRule); + FileInsert(idxMacchina, path, fileNew, UserName, 0, currRule, DoApprove); Log.Trace($"CheckFileArchived S03 | insert {fileNew.Count} files"); } // aggiorno i file modificati @@ -282,24 +283,26 @@ namespace MP.FileData.Controllers .DbSetProgFile .Where(x => x.FileId == currItem.FileId) .FirstOrDefault(); - localDbCtx - .DbSetProgFile - .Remove(file2del); // se ce ne fosse un altro precedente --> lo (ri)attiva var file2open = localDbCtx - .DbSetProgFile - .Where(x => x.Name == currItem.Name && x.IdxMacchina == currItem.IdxMacchina) - .OrderByDescending(y => y.Rev) - .FirstOrDefault(); + .DbSetProgFile + .Where(x => !x.Active && x.IdxMacchina == currItem.IdxMacchina && x.Path == currItem.Path) + .OrderByDescending(y => y.Rev) + .FirstOrDefault(); if (file2open != null) { file2open.Active = true; } + // elimino record! + localDbCtx + .DbSetProgFile + .Remove(file2del); + // salvo! - localDbCtx.SaveChanges(); - done = true; + int numDone = localDbCtx.SaveChanges(); + done = numDone != 0; } return done; } @@ -383,9 +386,9 @@ namespace MP.FileData.Controllers } - public List FileGetByPath(string path, bool onlyActive) + public List FileGetByPath(string path, bool onlyActive) { - List dbResult = new List(); + List dbResult = new List(); using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration)) { dbResult = localDbCtx @@ -398,9 +401,9 @@ namespace MP.FileData.Controllers return dbResult; } - public List FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, bool OnlyNoTag, string FileName, string UserName, string Tag, string SearchVal, int NumStart, int NumRecords) + public List FileGetFilt(string IdxMacchina, bool OnlyActive, bool OnlyMod, bool OnlyNoTag, string FileName, string UserName, string Tag, string SearchVal, int NumStart, int NumRecords) { - List dbResult = new List(); + List dbResult = new List(); using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration)) { dbResult = localDbCtx @@ -432,8 +435,9 @@ namespace MP.FileData.Controllers /// Utente che ha approvato la modifica, "" = NON confermata/eliminabile /// rev da usare x creazione /// Configuraizone ricerca + /// indica se vada approvata la modifica o lasciato "in sospeso" /// - public bool FileInsert(string idxMacchina, string basePath, List newFiles, string UserName, int rev, SearchRules currRule) + public bool FileInsert(string idxMacchina, string basePath, List newFiles, string UserName, int rev, SearchRules currRule, bool DoApprove) { // fare: lettura conf x macchina Log.Info($"FileInsert S01 per macchina {idxMacchina}: {newFiles.Count} files da valutare"); @@ -448,7 +452,7 @@ namespace MP.FileData.Controllers List newRec = newFiles.Select(o => new FileModel() { Active = true, - DiskStatus = FileState.Ok, + DiskStatus = DoApprove ? FileState.Ok : FileState.Changed, IdxMacchina = idxMacchina, LastCheck = adesso, LastMod = o.LastWriteTime, @@ -536,6 +540,38 @@ namespace MP.FileData.Controllers return answ; } + /// + /// Imposta utente approvazione + data modifica File + /// + /// + /// + /// + public bool FileSetUserApp(FileModel currFile, string UserName) + { + bool done = false; + List listUpdate = new List(); + using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration)) + { + FileModel currRec = localDbCtx + .DbSetProgFile + .Where(x => x.FileId == currFile.FileId) + .FirstOrDefault(); + if (currRec != null) + { + DateTime adesso = DateTime.Now; + currRec.UserAppr = UserName; + currRec.LastMod = adesso; + currRec.LastCheck = adesso; + //currFile.DiskStatus = FileState.Ok; + localDbCtx.Entry(currRec).State = EntityState.Modified; + // salvo DB + localDbCtx.SaveChanges(); + } + } + return done; + } + + /// /// Approvazione modifica File /// @@ -545,8 +581,6 @@ namespace MP.FileData.Controllers public bool FileModApprove(FileModel currFile, string UserName) { bool done = false; - // recupero file regole json da macchina.. - List listUpdate = new List(); using (MoonPro_ProgContext localDbCtx = new MoonPro_ProgContext(_configuration)) { @@ -575,7 +609,7 @@ namespace MP.FileData.Controllers if (currRule.Name != "ND") { // inserisco come REVISIONE - FileInsert(currFile.IdxMacchina, currMacchina.BasePath, listUpdate, UserName, currFile.Rev + 1, currRule); + FileInsert(currFile.IdxMacchina, currMacchina.BasePath, listUpdate, UserName, currFile.Rev + 1, currRule, true); // archivio vecchio file currFile.Active = false; diff --git a/MP.Prog/Components/ArchiveStatus.razor.cs b/MP.Prog/Components/ArchiveStatus.razor.cs index 6630245e..d464a198 100644 --- a/MP.Prog/Components/ArchiveStatus.razor.cs +++ b/MP.Prog/Components/ArchiveStatus.razor.cs @@ -162,7 +162,7 @@ namespace MP.Prog.Components sw.Restart(); // recupero elenco macchine percLoading += 100 / numMacchine; - numChecks = await FDService.UpdateMachineArchive(idxMacchina, numDays, true, false, MServ.UserName); + numChecks = await FDService.UpdateMachineArchive(idxMacchina, numDays, true, false, MServ.UserName, false); await Task.Delay(1); setupMessages.Add($"{idxMacchina}: {numChecks} files"); await InvokeAsync(StateHasChanged); diff --git a/MP.Prog/Components/FileEditor.razor.cs b/MP.Prog/Components/FileEditor.razor.cs index 40dd4f56..de286318 100644 --- a/MP.Prog/Components/FileEditor.razor.cs +++ b/MP.Prog/Components/FileEditor.razor.cs @@ -181,7 +181,7 @@ namespace MP.Prog.Components if (_currItem != null) { - await FDService.FileApprove(_currItem, MServ.UserName); + await FDService.FileModApprove(_currItem, MServ.UserName); await DataUpdated.InvokeAsync(1); } else @@ -225,7 +225,7 @@ namespace MP.Prog.Components await DataReset.InvokeAsync(0); await FDService.FileExport(_currItem); await DataReset.InvokeAsync(0); - await FDService.UpdateMachineArchive(_currItem.IdxMacchina, 1, false, false, MServ.UserName); + await FDService.UpdateMachineArchive(_currItem.IdxMacchina, 1, false, false, MServ.UserName, true); await DataUpdated.InvokeAsync(1); } else diff --git a/MP.Prog/Controllers/FileChangeController.cs b/MP.Prog/Controllers/FileChangeController.cs index 9ece29c0..7e7494da 100644 --- a/MP.Prog/Controllers/FileChangeController.cs +++ b/MP.Prog/Controllers/FileChangeController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using MP.FileData.Controllers; using MP.Prog.Data; @@ -10,6 +11,7 @@ using System.Threading.Tasks; namespace MP.Prog.Controllers { + [AllowAnonymous] [Route("api/[controller]")] [ApiController] public class FileChangeController : ControllerBase @@ -31,25 +33,13 @@ namespace MP.Prog.Controllers #region Public Methods /// - /// Verifica Health servizi FileChange - /// GET api/FileChange - /// - /// - [HttpGet] - public ActionResult Get() - { - return "OK"; - } - - /// - /// Esegue controllo + approvazione modifiche x directory - /// GET api/FileChange/anagkeyval/[id]?[CodApp] + /// Esegue controllo + approvazione modifiche x directory GET api/FileChange/approve/[id]?[numDayPrev] /// /// Directory / IdxMacchina | 0/ALL = tutte /// Verifica file modificati da numDayPrev gg /// Elenco dei file approvati [HttpGet("approve/{id}")] - public async Task> approve(string id, int numDayPrev) + public async Task> Approve(string id, int numDayPrev) { List result = new List(); // verifico se una o tutte le macchine @@ -69,13 +59,78 @@ namespace MP.Prog.Controllers foreach (var currDir in listDir) { // eseguo singolo controllo, utente = "" (è auto-approvazione) - await FADService.UpdateMachineArchive(currDir, numDayPrev, false, false, ""); + await FADService.UpdateMachineArchive(currDir, numDayPrev, false, false, "", true); List listAppr = await ForceApproveMod(currDir, numDayPrev); result.AddRange(listAppr); } return result; } + /// + /// Esegue controllo + approvazione modifiche x directory GET api/FileChange/Approve/[id]?[numDayPrev] + /// + /// Directory / IdxMacchina | 0/ALL = tutte + /// Verifica file modificati da numDayPrev gg + /// Elenco dei file approvati + [HttpGet("check/{id}")] + public async Task> Check(string id, int numDayPrev) + { + List result = new List(); + // verifico se una o tutte le macchine + List listDir = new List(); + if (id == "ALL" || id == "0") + { + var machList = await FADService.ArchMaccGetAll(); + listDir = machList + .Where(x => !string.IsNullOrEmpty(x.BasePath)) + .Select(x => x.IdxMacchina).ToList(); + } + else + { + listDir.Add(id); + } + // ciclo su tutte le macchine e faccio verifica modificati... + foreach (var currDir in listDir) + { + // eseguo singolo controllo, utente = "" , SENZA auto-approvazione + int numCheks = await FADService.UpdateMachineArchive(currDir, numDayPrev, false, false, "", false); + result.Add($"{currDir} | {numCheks} files"); + } + return result; + } + + /// + /// Verifica Health servizi FileChange GET api/FileChange + /// + /// + [HttpGet] + public ActionResult Get() + { + return "OK"; + } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected FileArchDataService FADService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + /// + /// Classe per logging + /// + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + + #region Private Methods + /// /// Effettua approvazione file modificati, restituendo elenco /// @@ -97,8 +152,8 @@ namespace MP.Prog.Controllers // ciclo ogni file modificato foreach (var cFile in listChanged) { - // approvo il file modificato con utente anonimo (auto-approve) - bool fatto = await FADService.FileApprove(cFile, ""); + // approvo il file modificato con utente anonimo (auto-Approve) + bool fatto = await FADService.FileModApprove(cFile, ""); if (fatto) { answ.Add(cFile.Path); @@ -107,24 +162,6 @@ namespace MP.Prog.Controllers return answ; } - #endregion Public Methods - - #region Protected Properties - - /// - /// Dataservice x accesso DB - /// - protected FileArchDataService FADService { get; set; } - - #endregion Protected Properties - - #region Private Fields - - /// - /// Classe per logging - /// - private static Logger Log = LogManager.GetCurrentClassLogger(); - - #endregion Private Fields + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Prog/Controllers/HealthController.cs b/MP.Prog/Controllers/HealthController.cs index eb7e4144..edb99b62 100644 --- a/MP.Prog/Controllers/HealthController.cs +++ b/MP.Prog/Controllers/HealthController.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using MP.FileData.Controllers; using MP.Prog.Data; @@ -7,6 +8,7 @@ using System.Threading.Tasks; namespace MP.Prog.Controllers { + [AllowAnonymous] [Route("api/[controller]")] [ApiController] public class HealthController : ControllerBase diff --git a/MP.Prog/Data/FileArchDataService.cs b/MP.Prog/Data/FileArchDataService.cs index 5fb05c99..ab68d383 100644 --- a/MP.Prog/Data/FileArchDataService.cs +++ b/MP.Prog/Data/FileArchDataService.cs @@ -271,17 +271,18 @@ namespace MP.Prog.Data /// Numero giorni x ricerca all'indietro da data corrente / 0 = nessun limite /// Indica se forzare il tag /// Utente attivo + /// indica se vada approvata la modifica o lasciato "in sospeso" /// - public async Task UpdateAllArchive(int numDayPre, bool forceTag, string UserName) + public async Task UpdateAllArchive(int numDayPre, bool forceTag, string UserName, bool DoApprove) { int checkDone = 0; var listaMacchine = await ArchMaccGetAll(); foreach (var item in listaMacchine.Where(x => !string.IsNullOrEmpty(x.BasePath)).ToList()) { - checkDone += await UpdateMachineArchive(item.IdxMacchina, numDayPre, forceTag, false, UserName); + checkDone += await UpdateMachineArchive(item.IdxMacchina, numDayPre, forceTag, false, UserName, DoApprove); } - return await Task.FromResult(checkDone); + return checkDone; } /// @@ -294,8 +295,9 @@ namespace MP.Prog.Data /// Forza la riverifica dei tags (x update da setup) /// Scrittura log verboso macchina /// Utente attivo + /// indica se vada approvata la modifica o lasciato "in sospeso" /// - public async Task UpdateMachineArchive(string idxMacchina, int numDayPre, bool forceTag, bool fullLog, string UserName) + public async Task UpdateMachineArchive(string idxMacchina, int numDayPre, bool forceTag, bool fullLog, string UserName, bool DoApprove) { int checkDone = 0; Stopwatch stopWatch = new Stopwatch(); @@ -355,7 +357,7 @@ namespace MP.Prog.Data Log.Trace($"Conf rule generato:{Environment.NewLine}{rawRule}"); } } - checkDone = dbController.CheckFileArchived(macchina.IdxMacchina, macchina.BasePath, numDayPre, "*.*", forceTag, currRule, UserName); + checkDone = dbController.CheckFileArchived(macchina.IdxMacchina, macchina.BasePath, numDayPre, "*.*", forceTag, currRule, UserName, DoApprove); } } } @@ -383,7 +385,7 @@ namespace MP.Prog.Data /// /// /// - internal async Task FileApprove(FileModel currItem, string UserName) + internal async Task FileModApprove(FileModel currItem, string UserName) { bool answ = dbController.FileModApprove(currItem, UserName); // svuoto cache! @@ -391,6 +393,20 @@ namespace MP.Prog.Data return answ; } + /// + /// Forza registrazione della sola approvazione utente + data + /// + /// + /// + /// + internal async Task FileSetUserApp(FileModel currItem, string UserName) + { + bool answ = dbController.FileSetUserApp(currItem, UserName); + // svuoto cache! + await ResetArchiveCache(); + return answ; + } + /// /// Eliminazione file (x rifiuto modifica) /// diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj index 18a4c859..8a1a91a0 100644 --- a/MP.Prog/MP.Prog.csproj +++ b/MP.Prog/MP.Prog.csproj @@ -3,7 +3,7 @@ net6.0 MP.Prog - 6.16.2410.2311 + 6.16.2410.2317 True diff --git a/MP.Prog/Pages/Archive.razor b/MP.Prog/Pages/Archive.razor index 873233f3..51bf960a 100644 --- a/MP.Prog/Pages/Archive.razor +++ b/MP.Prog/Pages/Archive.razor @@ -81,7 +81,7 @@
@@ -128,7 +128,6 @@ Macchina Tags Modificato - @*Controllo*@ @@ -162,21 +161,30 @@
@CalcSize(record.Size)
-
+
@if (!string.IsNullOrEmpty(record.UserAppr)) { - } + else + { + + + }
@record.Macchina.Nome
@record.Macchina.Descrizione
- + @foreach (var item in record.Tags) { + } } @@ -197,6 +212,6 @@ }
\ No newline at end of file diff --git a/MP.Prog/Pages/Archive.razor.cs b/MP.Prog/Pages/Archive.razor.cs index af50582a..7d5039fd 100644 --- a/MP.Prog/Pages/Archive.razor.cs +++ b/MP.Prog/Pages/Archive.razor.cs @@ -106,15 +106,6 @@ namespace MP.Prog.Pages #region Protected Methods - protected async Task ReloadAsync() - { - isLoading = true; - currRecord = null; - ListRecords = null; - await ReloadData(); - isLoading = false; - } - /// /// Restituisce size calcolata /// @@ -137,6 +128,41 @@ namespace MP.Prog.Pages currRecord = await FDService.FileGetByKey(selRecord.FileId); } + /// + /// forza approvazione utente corrente + /// + /// + protected async Task FileSetUserApp(FileModel CurrRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler approvare il salvataggio automatico della nuova revisione?")) + return; + + await FDService.FileSetUserApp(CurrRec, MServ.UserName); + isLoading = true; + await ReloadData(); + isLoading = false; + } + + /// + /// Elimina record (non approvato) corrente e riattiva precedente + /// + /// + protected async Task DeleteRec(FileModel CurrRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record e riattivare la revisione antecedente? Il file potrebbe risultare modificato")) + return; + + // elimino + await FDService.FileDelete(CurrRec); + //// verifico eventuali modifiche + //var numCheck = await FDService.UpdateMachineArchive(CurrRec.IdxMacchina, 30, false, false, ""); + + isLoading = true; + await ReloadData(); + isLoading = false; + } + + protected async Task FilterPath(string searchVal) { SelFileName = searchVal; @@ -146,6 +172,14 @@ namespace MP.Prog.Pages isLoading = false; } + protected async Task FilterTag(string searchVal) + { + SelTag = searchVal; + currPage = 1; + await ReloadData(); + isLoading = false; + } + protected async Task FilterUserName(string userName) { SelUserName = userName; @@ -155,27 +189,48 @@ namespace MP.Prog.Pages isLoading = false; } - protected async Task FilterTag(string searchVal) - { - SelTag = searchVal; - currPage = 1; - await ReloadData(); - isLoading = false; - } - + /// + /// Esegue comparazione tra dati DB e filesystem (modificati entro numDays) + /// + /// + /// protected async Task ForceCheck(int numDays) { currRecord = null; ListRecords = null; // importante altrimenti NON mostra update UI await Task.Delay(1); - //MServ.File_Filter = SelectData.Init(5, 10); - var numCheck = await FDService.UpdateAllArchive(numDays, false, MServ.UserName); + var numCheck = await FDService.UpdateAllArchive(numDays, false, MServ.UserName, false); await ReloadAllData(); await Task.Delay(1); await RefreshDisplayLoading(); } + /// + /// effettua approvazione di ttute le modifiche visualizzate + /// + /// + protected async Task MassAppr() + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler procedere approvando una nuova revisione di ogni file modificato visualizzato?")) + return; + + //verifico che sia cliccato solo modificati... + if(OnlyMod) + { + foreach (var item in ListRecords) + { + await FDService.FileModApprove(item, MServ.UserName); + } + } + // rileggo! + ResetData(); + await ResetFilter(); + await Task.Delay(1); + await ReloadData(); + isLoading = false; + } + protected override async Task OnInitializedAsync() { SearchTag = defTag; @@ -188,20 +243,6 @@ namespace MP.Prog.Pages isLoading = false; } - protected async Task PagerReloadNum(int newNum) - { - numRecord = newNum; - await ReloadData(); - isLoading = false; - } - - protected async Task PagerReloadPage(int newNum) - { - currPage = newNum; - await ReloadData(); - isLoading = false; - } - protected async Task RefreshDisplayLoading() { await Task.Delay(1); @@ -218,6 +259,15 @@ namespace MP.Prog.Pages await ReloadData(); } + protected async Task ReloadAsync() + { + isLoading = true; + currRecord = null; + ListRecords = null; + await ReloadData(); + isLoading = false; + } + protected async Task ReloadData() { isLoading = true; @@ -230,19 +280,6 @@ namespace MP.Prog.Pages await Task.Delay(1); } - /// - /// effettua approvazione di ttute le modifiche visualizzate - /// - /// - protected async Task MassAppr() - { - ResetData(); - await ResetFilter(); - await Task.Delay(1); - await ReloadData(); - isLoading = false; - } - protected void ResetData() { FDService.rollBackEdit(currRecord); @@ -278,6 +315,30 @@ namespace MP.Prog.Pages currRecord = selRecord; } + /// + /// Imposta pagina corrente + /// + /// + /// + protected async Task SetNumPage(int newNum) + { + currPage = newNum; + await ReloadData(); + isLoading = false; + } + + /// + /// Imposta num record x pagina + /// + /// + /// + protected async Task SetRecPage(int newNum) + { + numRecord = newNum; + await ReloadData(); + isLoading = false; + } + protected string TextReduce(string textOriginal, int maxChar) { string answ = textOriginal; @@ -462,30 +523,6 @@ namespace MP.Prog.Pages } } } - private string SelUserName - { - get - { - string answ = ""; - if (MServ.File_Filter != null) - { - answ = MServ.File_Filter.UserName; - } - return answ; - } - set - { - if (!MServ.File_Filter.UserName.Equals(value)) - { - MServ.File_Filter.UserName = value; - var pUpd = Task.Run(async () => - { - await ReloadAsync(); - }); - pUpd.Wait(); - } - } - } private string SelIdxMacc { @@ -537,6 +574,31 @@ namespace MP.Prog.Pages } } + private string SelUserName + { + get + { + string answ = ""; + if (MServ.File_Filter != null) + { + answ = MServ.File_Filter.UserName; + } + return answ; + } + set + { + if (!MServ.File_Filter.UserName.Equals(value)) + { + MServ.File_Filter.UserName = value; + var pUpd = Task.Run(async () => + { + await ReloadAsync(); + }); + pUpd.Wait(); + } + } + } + #endregion Private Properties #region Private Methods diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html index c017c782..8fc47a9f 100644 --- a/MP.Prog/Resources/ChangeLog.html +++ b/MP.Prog/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 6.16.2410.2311

+

Versione: 6.16.2410.2317


Note di rilascio:
    diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt index d39e7196..87e7119a 100644 --- a/MP.Prog/Resources/VersNum.txt +++ b/MP.Prog/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2410.2311 +6.16.2410.2317 diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml index d2730839..7422f1c2 100644 --- a/MP.Prog/Resources/manifest.xml +++ b/MP.Prog/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2410.2311 + 6.16.2410.2317 https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html false