From fe7a0738a1e8b5426c025824ec3b034790b0489e Mon Sep 17 00:00:00 2001 From: scoxen1 Date: Tue, 16 Jul 2024 15:43:51 -0400 Subject: [PATCH 01/23] #113 - Fix UTF-8 - BOM encoding issue when downloading one of "my profiles". --- api/CESMII.ProfileDesigner.OpcUa/OpcUaImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/CESMII.ProfileDesigner.OpcUa/OpcUaImporter.cs b/api/CESMII.ProfileDesigner.OpcUa/OpcUaImporter.cs index b5e4387f..538519f5 100644 --- a/api/CESMII.ProfileDesigner.OpcUa/OpcUaImporter.cs +++ b/api/CESMII.ProfileDesigner.OpcUa/OpcUaImporter.cs @@ -646,7 +646,7 @@ public async System.Threading.Tasks.Task Date: Sat, 27 Jul 2024 00:29:01 -0700 Subject: [PATCH 02/23] Update backend-publish-stage-azure.yml (Adding branch PLY/Develop) --- .github/workflows/backend-publish-stage-azure.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/backend-publish-stage-azure.yml b/.github/workflows/backend-publish-stage-azure.yml index 1adca9bc..ad07e6a3 100644 --- a/.github/workflows/backend-publish-stage-azure.yml +++ b/.github/workflows/backend-publish-stage-azure.yml @@ -25,6 +25,7 @@ on: branches: - develop - CO5/Develop + - PLY/Develop env: # set this to your application's name From 10897996ccfbda9d5d61687519fab96b13ceb9c8 Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Sat, 27 Jul 2024 00:29:43 -0700 Subject: [PATCH 03/23] Update frontend-publish-stage-azure.yml (Add branch PLY/Develop) --- .github/workflows/frontend-publish-stage-azure.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/frontend-publish-stage-azure.yml b/.github/workflows/frontend-publish-stage-azure.yml index 616671cb..39aa7a8f 100644 --- a/.github/workflows/frontend-publish-stage-azure.yml +++ b/.github/workflows/frontend-publish-stage-azure.yml @@ -25,6 +25,7 @@ on: branches: - develop - CO5/Develop + - PLY/Develop env: # set this to your application's name From 8541559edbb3ab3963c9349c8b5ecae5a51e0c30 Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Sat, 27 Jul 2024 00:30:07 -0700 Subject: [PATCH 04/23] Update sonar-cloud-scan-stage.yml (Add branch PLY/Develop) --- .github/workflows/sonar-cloud-scan-stage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonar-cloud-scan-stage.yml b/.github/workflows/sonar-cloud-scan-stage.yml index e74c3e4d..568b7383 100644 --- a/.github/workflows/sonar-cloud-scan-stage.yml +++ b/.github/workflows/sonar-cloud-scan-stage.yml @@ -11,6 +11,7 @@ on: branches: - develop - CO5/Develop + - PLY/Develop env: # set this to the organization name, project key in Sonar From a5ce775100b4c6b91ba5ce3ff1546108791dd20c Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Sat, 27 Jul 2024 00:34:16 -0700 Subject: [PATCH 05/23] Update tests.yml (add branch PLY/Develop) --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9c29cbce..bf286551 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,11 +10,13 @@ on: branches: - develop - CO5/Develop + - PLY/Develop - main pull_request: branches: - develop - CO5/Develop + - PLY/Develop - main env: From cc7285fb876e4a30ed71ad04393615db0a75a0dc Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Sat, 27 Jul 2024 00:55:46 -0700 Subject: [PATCH 06/23] Delete .github/workflows/tests-in-browser.yml (placeholder YML file - not needed in production) --- .github/workflows/tests-in-browser.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .github/workflows/tests-in-browser.yml diff --git a/.github/workflows/tests-in-browser.yml b/.github/workflows/tests-in-browser.yml deleted file mode 100644 index 55745fc4..00000000 --- a/.github/workflows/tests-in-browser.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Add to main branch to allow to be seen in other branches. -# CESMII Profile Designer - Setup and test Profile Designer Web Page using Selenium Tests -# -# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples -name: Test|In Browser|Profile Designer -on: - #manually trigger deploy - workflow_dispatch: - # Trigger the workflow on push - #push: - # branches: - # - develop - # - main - #pull_request: - # branches: - # - develop - # - main From 98881738b9c121f084b35a2bd9abacbfce0975ec Mon Sep 17 00:00:00 2001 From: Paul Lin Yao Date: Sat, 27 Jul 2024 00:42:55 -0700 Subject: [PATCH 07/23] Link to submodule CESMII-Common --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common b/common index fc95d1e4..ed05d565 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit fc95d1e44ea15f8a867ae7f61861d6ac6c54be62 +Subproject commit ed05d565820e78a0b2079ea56633c33b6f395b01 From e20f71f52f28768d3de48de90efa105f669eb0d4 Mon Sep 17 00:00:00 2001 From: Paul Lin Yao Date: Mon, 29 Jul 2024 13:17:21 -0700 Subject: [PATCH 08/23] Cloud Test -- add in missing SearchAsync function in mock tests needed for ICloudLibWrapper --- .../CloudLibMock/CloudLibMock.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs b/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs index d2bd2f54..13b4f76d 100644 --- a/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs +++ b/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs @@ -91,6 +91,32 @@ int IEqualityComparer.GetHashCode(SearchInputs obj) public OnNodeSet OnNodeSetFound { get; set; } public OnNodeSet OnNodeSetNotFound { get; set; } + public async Task> SearchAsync(int? limit, string cursor, bool pageBackwards, List keywords, List exclude, bool noTotalCount, object? order) + { + var inputs = new SearchInputs + { + Keywords = keywords?.ToArray(), + Cursor = cursor, + PageBackwards = pageBackwards, + Limit = limit, + }; + if (_wrapper != null) + { + var result = await _wrapper.SearchAsync(limit, cursor, pageBackwards, keywords, exclude, noTotalCount, order); + + if (!_searchData.ContainsKey(inputs)) + { + _searchData.Add(inputs, result); + } + return result; + } + if (_searchData.TryGetValue(inputs, out var data)) + { + return data; + } + throw new Exception($"Request not in mock data: {inputs}"); + } + public async Task> SearchAsync(int? limit, string cursor, bool pageBackwards, List keywords, List exclude, bool noTotalCount) { var inputs = new SearchInputs From 6ad7bf5124006a1cf34d502b21325dd4dfe6c6ed Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 13:45:57 -0700 Subject: [PATCH 09/23] Update sonar-cloud-scan.yml -- Java SDK action. Upgrade actions/setup-java from v3.4.0 to v4.2.1 (actions/setup-java@v4.2.1) --- .github/workflows/sonar-cloud-scan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar-cloud-scan.yml b/.github/workflows/sonar-cloud-scan.yml index 7afa1910..bd70ba97 100644 --- a/.github/workflows/sonar-cloud-scan.yml +++ b/.github/workflows/sonar-cloud-scan.yml @@ -44,7 +44,7 @@ jobs: steps: #Set up Java which is needed for SonarScan post processing step - name: Setup Java JDK - uses: actions/setup-java@v3.4.0 + uses: actions/setup-java@v4.2.1 with: distribution: 'microsoft' # See 'Supported distributions' for available options java-version: '11' @@ -85,4 +85,4 @@ jobs: - name: Build (${{env.SOLUTION_FILE}}) run: dotnet build ${{env.SOLUTION_DIRECTORY}}/${{env.SOLUTION_FILE}} --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore - name: SonarScan - End (${{env.SONAR_PROJECT_KEY}}) - run: ${{env.SONAR_TOOL_PATH}}\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_ACCESS_TOKEN }}" \ No newline at end of file + run: ${{env.SONAR_TOOL_PATH}}\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_ACCESS_TOKEN }}" From 5713a3e901591c9b531448626376ab458bc02d6b Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 13:56:55 -0700 Subject: [PATCH 10/23] Update sonar-cloud-scan.yml -- Fix java class file version error by updating java-version from 11 to 17 --- .github/workflows/sonar-cloud-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonar-cloud-scan.yml b/.github/workflows/sonar-cloud-scan.yml index bd70ba97..3cc5cf81 100644 --- a/.github/workflows/sonar-cloud-scan.yml +++ b/.github/workflows/sonar-cloud-scan.yml @@ -47,7 +47,7 @@ jobs: uses: actions/setup-java@v4.2.1 with: distribution: 'microsoft' # See 'Supported distributions' for available options - java-version: '11' + java-version: '17' - uses: actions/checkout@v2 with: From 959119af6bdd879a462052cf23f6189e00c9aaca Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 14:18:42 -0700 Subject: [PATCH 11/23] Update sonar-cloud-scan.yml -- update out of date actions (to actions/checkout@v4 and actions/cache@v4) --- .github/workflows/sonar-cloud-scan.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sonar-cloud-scan.yml b/.github/workflows/sonar-cloud-scan.yml index 3cc5cf81..9a6c0dcc 100644 --- a/.github/workflows/sonar-cloud-scan.yml +++ b/.github/workflows/sonar-cloud-scan.yml @@ -49,7 +49,7 @@ jobs: distribution: 'microsoft' # See 'Supported distributions' for available options java-version: '17' - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: # # Shallow clones should be disabled for a better relevancy of analysis # fetch-depth: 0 @@ -57,7 +57,7 @@ jobs: # Speed-up analysis by caching the scanner workspace - name: SonarScan - Cache SonarCloud workspace - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~\.sonar\cache key: ${{ runner.os }}-sonar-cache @@ -66,7 +66,7 @@ jobs: # Speed-up analysis by caching the scanner installation - name: SonarScan - Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{env.SONAR_TOOL_PATH}} key: ${{ runner.os }}-sonar-scanner From 2b23605d94d8f6e9563a7678f1bfb708b1e7445c Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 14:45:19 -0700 Subject: [PATCH 12/23] Update sonar-cloud-scan-stage.yml -- update to match changes already put in place for production --- .github/workflows/sonar-cloud-scan-stage.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sonar-cloud-scan-stage.yml b/.github/workflows/sonar-cloud-scan-stage.yml index 568b7383..a63577bf 100644 --- a/.github/workflows/sonar-cloud-scan-stage.yml +++ b/.github/workflows/sonar-cloud-scan-stage.yml @@ -46,12 +46,12 @@ jobs: steps: #Set up Java which is needed for SonarScan post processing step - name: Setup Java JDK - uses: actions/setup-java@v3.4.0 + uses: actions/setup-java@v4.2.1 with: distribution: 'microsoft' # See 'Supported distributions' for available options - java-version: '11' + java-version: '17' - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 @@ -59,7 +59,7 @@ jobs: # Speed-up analysis by caching the scanner workspace - name: SonarScan - Cache SonarCloud workspace - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~\.sonar\cache key: ${{ runner.os }}-sonar-cache @@ -68,7 +68,7 @@ jobs: # Speed-up analysis by caching the scanner installation - name: SonarScan - Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{env.SONAR_TOOL_PATH}} key: ${{ runner.os }}-sonar-scanner From 3af3cce936a59bcb53a062b334c5376a8bb9d8c3 Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 14:54:36 -0700 Subject: [PATCH 13/23] Update backend-publish-stage-azure.yml -- update to actions/checkout@v4 and actions/setup-dotnet@v4 --- .github/workflows/backend-publish-stage-azure.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backend-publish-stage-azure.yml b/.github/workflows/backend-publish-stage-azure.yml index ad07e6a3..12356fd1 100644 --- a/.github/workflows/backend-publish-stage-azure.yml +++ b/.github/workflows/backend-publish-stage-azure.yml @@ -48,11 +48,11 @@ jobs: name: Build and Deploy .NET6 Web API runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Set up dotnet Core ${{ env.NETCORE_VERSION }} - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.NETCORE_VERSION }} - name: Restore dependencies (${{env.SOLUTION_FILE}}) From 16c7edde40d8a7ba70aa75b87f02c864972182b0 Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 14:58:52 -0700 Subject: [PATCH 14/23] Update frontend-publish-stage-azure.yml -- updating to actions/checkout@v4 and actions/setup-node@v4 --- .github/workflows/frontend-publish-stage-azure.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/frontend-publish-stage-azure.yml b/.github/workflows/frontend-publish-stage-azure.yml index 39aa7a8f..20c6c74a 100644 --- a/.github/workflows/frontend-publish-stage-azure.yml +++ b/.github/workflows/frontend-publish-stage-azure.yml @@ -41,9 +41,9 @@ jobs: name: 'Job: Build and Deploy React frontend' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: 'Build React Code - npm install, build' From 1dd1ce571a036124fa213724fa44bac32eeaffcb Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 15:02:00 -0700 Subject: [PATCH 15/23] Update tests.yml -- update to actions/checkout@v4 and actions/setup-dotnet@v4 --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bf286551..945f615b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,11 +36,11 @@ jobs: name: Build and Test .NET6 Web API runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Set up dotnet Core ${{ env.NETCORE_VERSION }} - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.NETCORE_VERSION }} From ca80275a158b7a851a3d14e4f224f264446087f7 Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 15:46:57 -0700 Subject: [PATCH 16/23] Update frontend-publish-azure.yml -- Update to actions/checkout@v4 and actions/setup-node@v4 --- .github/workflows/frontend-publish-azure.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/frontend-publish-azure.yml b/.github/workflows/frontend-publish-azure.yml index 6bb45591..db26860f 100644 --- a/.github/workflows/frontend-publish-azure.yml +++ b/.github/workflows/frontend-publish-azure.yml @@ -38,9 +38,9 @@ jobs: name: 'Job: Build and Deploy React frontend' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: 'Build React Code - npm install, build' From 9270306ac8f53c0916c582f1c0106faf3d1a0454 Mon Sep 17 00:00:00 2001 From: Paul Yao Date: Mon, 29 Jul 2024 15:48:13 -0700 Subject: [PATCH 17/23] Update backend-publish-azure.yml -- update to actions/checkout@v4 and actions/setup-dotnet@v4 --- .github/workflows/backend-publish-azure.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/backend-publish-azure.yml b/.github/workflows/backend-publish-azure.yml index 821a363b..92e407fa 100644 --- a/.github/workflows/backend-publish-azure.yml +++ b/.github/workflows/backend-publish-azure.yml @@ -42,14 +42,14 @@ env: jobs: build: - name: Build and Deploy .NET5 Web API + name: Build and Deploy .NET6 Web API runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Set up dotnet Core ${{ env.NETCORE_VERSION }} - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.NETCORE_VERSION }} - name: Restore dependencies (${{env.SOLUTION_FILE}}) From 9094b7894573176a4384cb258591e5e9e54272c3 Mon Sep 17 00:00:00 2001 From: Paul Lin Yao Date: Mon, 29 Jul 2024 17:17:53 -0700 Subject: [PATCH 18/23] Sssu - just added de-bouncing to CESMII-Common. Link now to main module. --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common b/common index ed05d565..ea352502 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit ed05d565820e78a0b2079ea56633c33b6f395b01 +Subproject commit ea352502d3a7f3660529a067aa77af6545a54b5d From f0373af3eb13bdc478500bd70288d2970f3b1612 Mon Sep 17 00:00:00 2001 From: Paul Lin Yao Date: Mon, 29 Jul 2024 17:45:13 -0700 Subject: [PATCH 19/23] Sssu - Removing dictionary. Link to Submodule CESMII-Common --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common b/common index ea352502..2a6241f9 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit ea352502d3a7f3660529a067aa77af6545a54b5d +Subproject commit 2a6241f9cb646bbc7e8aa9a5c195a122eb79a429 From 372abca43ce6201732a16e794e9577e99db2c55d Mon Sep 17 00:00:00 2001 From: Paul Lin Yao Date: Mon, 29 Jul 2024 20:17:04 -0700 Subject: [PATCH 20/23] Sssu - Link to CESMII-Common to return BadRequest for extra user clicks --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common b/common index 2a6241f9..c815ff84 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 2a6241f9cb646bbc7e8aa9a5c195a122eb79a429 +Subproject commit c815ff84d82b6e233225927095c2d9a60801fcc0 From 9e4f252d704a2d81bb40c5a734cfa259f4832a6f Mon Sep 17 00:00:00 2001 From: Paul Lin Yao Date: Mon, 29 Jul 2024 21:53:27 -0700 Subject: [PATCH 21/23] Sssu - Adding in dictionary - linking to CESMII-Common --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common b/common index c815ff84..0eb7c7e4 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit c815ff84d82b6e233225927095c2d9a60801fcc0 +Subproject commit 0eb7c7e4a91b1d1b08d412d300385a0cd034fe42 From 5b4e032e5e0c476737fb9703f9784d619cfc92f6 Mon Sep 17 00:00:00 2001 From: Sean Coxen Date: Tue, 20 Aug 2024 10:38:07 -0400 Subject: [PATCH 22/23] Make equivalent to Main - resolve merge conflicts --- .../CloudLibMock/CloudLibMock.cs | 450 +++++++++--------- 1 file changed, 225 insertions(+), 225 deletions(-) diff --git a/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs b/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs index 13b4f76d..d7af7dce 100644 --- a/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs +++ b/api/Tests/CESMII.ProfileDesigner.Api.Tests/CloudLibMock/CloudLibMock.cs @@ -1,225 +1,225 @@ -using CESMII.OpcUa.NodeSetImporter; -using CESMII.Common.CloudLibClient; -using Newtonsoft.Json; -using Opc.Ua.Cloud.Library.Client; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace CESMII.ProfileDesigner.Api.Tests -{ - public class CloudLibMock : ICloudLibWrapper, IDisposable - { - private readonly ICloudLibWrapper _wrapper; - static bool recording = false; - const string strSearchDataFile = "CloudLibMock/Searchdata.json"; - public CloudLibMock() - { - } - - public CloudLibMock(CloudLibWrapper wrapper) - { - if (!recording && File.Exists(strSearchDataFile)) - { - if (_searchData?.Any() != true) - { - var searchDataJson = File.ReadAllText(strSearchDataFile); - var sd = JsonConvert.DeserializeObject>>>(searchDataJson); - var comparer = new SearchInputs.Comparer(); - _searchData = sd.ToDictionary(kv => kv.Key, kv => kv.Value, comparer); - _lastSavedCount = _searchData.Count; - } - } - else - { - _wrapper = wrapper; - recording = true; - } - } - public Task> GetManyAsync(List identifiers) - { - return null; - } - - record SearchInputs - { - public string[] Keywords { get; set; } - public string Cursor { get; set; } - public bool PageBackwards { get; set; } - public int? Limit { get; set; } - - internal class Comparer : IEqualityComparer - { - bool IEqualityComparer.Equals(SearchInputs x, SearchInputs y) - { - return x == y || - (x.Cursor == y.Cursor - && x.Limit == y.Limit - && (x.Keywords == y.Keywords - || ( x.Keywords != null - && y.Keywords != null - && x.Keywords.SequenceEqual(y.Keywords) - ) - ) - ); - } - - int IEqualityComparer.GetHashCode(SearchInputs obj) - { - if (obj == null) return 0; - unchecked - { - return obj.Cursor?.GetHashCode() ?? 0 + obj.Limit.GetHashCode() + obj.Keywords?.Aggregate(0, (s, k) => - { - unchecked - { - return s + k.GetHashCode(); - } - }) ?? 0; - } - } - } - } - static Dictionary> _searchData = new Dictionary>(new SearchInputs.Comparer()); - static int _lastSavedCount = 0; - private bool disposedValue; - - public OnResolveNodeSets OnResolveNodeSets { get; set; } - public OnNodeSet OnDownloadNodeSet { get; set; } - public OnNodeSet OnNodeSetFound { get; set; } - public OnNodeSet OnNodeSetNotFound { get; set; } - - public async Task> SearchAsync(int? limit, string cursor, bool pageBackwards, List keywords, List exclude, bool noTotalCount, object? order) - { - var inputs = new SearchInputs - { - Keywords = keywords?.ToArray(), - Cursor = cursor, - PageBackwards = pageBackwards, - Limit = limit, - }; - if (_wrapper != null) - { - var result = await _wrapper.SearchAsync(limit, cursor, pageBackwards, keywords, exclude, noTotalCount, order); - - if (!_searchData.ContainsKey(inputs)) - { - _searchData.Add(inputs, result); - } - return result; - } - if (_searchData.TryGetValue(inputs, out var data)) - { - return data; - } - throw new Exception($"Request not in mock data: {inputs}"); - } - - public async Task> SearchAsync(int? limit, string cursor, bool pageBackwards, List keywords, List exclude, bool noTotalCount) - { - var inputs = new SearchInputs - { - Keywords = keywords?.ToArray(), - Cursor = cursor, - PageBackwards = pageBackwards, - Limit = limit, - }; - if (_wrapper != null) - { - var result = await _wrapper.SearchAsync(limit, cursor, pageBackwards, keywords, exclude, noTotalCount); - - if (!_searchData.ContainsKey(inputs)) - { - _searchData.Add(inputs, result); - } - return result; - } - if (_searchData.TryGetValue(inputs, out var data)) - { - return data; - } - throw new Exception($"Request not in mock data: {inputs}"); - } - - - public Task DownloadAsync(string id) - { - throw new System.NotImplementedException(); - } - - public Task> ResolveNodeSetsAsync(List missingModels) - { - return Task.FromResult(new List().AsEnumerable()); - } - - - public Task GetAsync(string modelUri, DateTime? publicationDate, bool exactMatch) - { - return Task.FromResult(null); - } - - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - // dispose managed state (managed objects) - } - - // free unmanaged resources (unmanaged objects) and override finalizer - // set large fields to null - if (recording && _searchData.Any() && _searchData.Count != _lastSavedCount) - { - try - { - var toSave = _searchData.ToList(); - File.WriteAllText(strSearchDataFile, JsonConvert.SerializeObject(toSave)); - _lastSavedCount = toSave.Count; - } - catch (Exception) - { - // ignore - } - } - disposedValue = true; - } - } - - ~CloudLibMock() - { - // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - Dispose(disposing: false); - } - - public void Dispose() - { - // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method - Dispose(disposing: true); - GC.SuppressFinalize(this); - } - - public Task UploadAsync(UANameSpace uaNamespace) - { - throw new NotImplementedException(); - } - - public Task> GetNodeSetsPendingApprovalAsync(int? limit, string cursor, bool pageBackwards, bool noTotalCount = false, UAProperty prop = null) - { - throw new NotImplementedException(); - } - public Task UpdateApprovalStatusAsync(string nodeSetId, string newStatus, string statusInfo, UAProperty additionalProperty = null) - { - throw new NotImplementedException(); - } - - public Task GetAsync(string identifier) - { - throw new NotImplementedException(); - } - - } -} +using CESMII.OpcUa.NodeSetImporter; +using CESMII.Common.CloudLibClient; +using Newtonsoft.Json; +using Opc.Ua.Cloud.Library.Client; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +namespace CESMII.ProfileDesigner.Api.Tests +{ + public class CloudLibMock : ICloudLibWrapper, IDisposable + { + private readonly ICloudLibWrapper _wrapper; + static bool recording = false; + const string strSearchDataFile = "CloudLibMock/Searchdata.json"; + public CloudLibMock() + { + } + + public CloudLibMock(CloudLibWrapper wrapper) + { + if (!recording && File.Exists(strSearchDataFile)) + { + if (_searchData?.Any() != true) + { + var searchDataJson = File.ReadAllText(strSearchDataFile); + var sd = JsonConvert.DeserializeObject>>>(searchDataJson); + var comparer = new SearchInputs.Comparer(); + _searchData = sd.ToDictionary(kv => kv.Key, kv => kv.Value, comparer); + _lastSavedCount = _searchData.Count; + } + } + else + { + _wrapper = wrapper; + recording = true; + } + } + public Task> GetManyAsync(List identifiers) + { + return null; + } + + record SearchInputs + { + public string[] Keywords { get; set; } + public string Cursor { get; set; } + public bool PageBackwards { get; set; } + public int? Limit { get; set; } + + internal class Comparer : IEqualityComparer + { + bool IEqualityComparer.Equals(SearchInputs x, SearchInputs y) + { + return x == y || + (x.Cursor == y.Cursor + && x.Limit == y.Limit + && (x.Keywords == y.Keywords + || ( x.Keywords != null + && y.Keywords != null + && x.Keywords.SequenceEqual(y.Keywords) + ) + ) + ); + } + + int IEqualityComparer.GetHashCode(SearchInputs obj) + { + if (obj == null) return 0; + unchecked + { + return obj.Cursor?.GetHashCode() ?? 0 + obj.Limit.GetHashCode() + obj.Keywords?.Aggregate(0, (s, k) => + { + unchecked + { + return s + k.GetHashCode(); + } + }) ?? 0; + } + } + } + } + static Dictionary> _searchData = new Dictionary>(new SearchInputs.Comparer()); + static int _lastSavedCount = 0; + private bool disposedValue; + + public OnResolveNodeSets OnResolveNodeSets { get; set; } + public OnNodeSet OnDownloadNodeSet { get; set; } + public OnNodeSet OnNodeSetFound { get; set; } + public OnNodeSet OnNodeSetNotFound { get; set; } + + public async Task> SearchAsync(int? limit, string cursor, bool pageBackwards, List keywords, List exclude, bool noTotalCount, object? order) + { + var inputs = new SearchInputs + { + Keywords = keywords?.ToArray(), + Cursor = cursor, + PageBackwards = pageBackwards, + Limit = limit, + }; + if (_wrapper != null) + { + var result = await _wrapper.SearchAsync(limit, cursor, pageBackwards, keywords, exclude, noTotalCount, order); + + if (!_searchData.ContainsKey(inputs)) + { + _searchData.Add(inputs, result); + } + return result; + } + if (_searchData.TryGetValue(inputs, out var data)) + { + return data; + } + throw new Exception($"Request not in mock data: {inputs}"); + } + + public async Task> SearchAsync(int? limit, string cursor, bool pageBackwards, List keywords, List exclude, bool noTotalCount) + { + var inputs = new SearchInputs + { + Keywords = keywords?.ToArray(), + Cursor = cursor, + PageBackwards = pageBackwards, + Limit = limit, + }; + if (_wrapper != null) + { + var result = await _wrapper.SearchAsync(limit, cursor, pageBackwards, keywords, exclude, noTotalCount); + + if (!_searchData.ContainsKey(inputs)) + { + _searchData.Add(inputs, result); + } + return result; + } + if (_searchData.TryGetValue(inputs, out var data)) + { + return data; + } + throw new Exception($"Request not in mock data: {inputs}"); + } + + + public Task DownloadAsync(string id) + { + throw new System.NotImplementedException(); + } + + public Task> ResolveNodeSetsAsync(List missingModels) + { + return Task.FromResult(new List().AsEnumerable()); + } + + + public Task GetAsync(string modelUri, DateTime? publicationDate, bool exactMatch) + { + return Task.FromResult(null); + } + + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // dispose managed state (managed objects) + } + + // free unmanaged resources (unmanaged objects) and override finalizer + // set large fields to null + if (recording && _searchData.Any() && _searchData.Count != _lastSavedCount) + { + try + { + var toSave = _searchData.ToList(); + File.WriteAllText(strSearchDataFile, JsonConvert.SerializeObject(toSave)); + _lastSavedCount = toSave.Count; + } + catch (Exception) + { + // ignore + } + } + disposedValue = true; + } + } + + ~CloudLibMock() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: false); + } + + public void Dispose() + { + // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + + public Task UploadAsync(UANameSpace uaNamespace) + { + throw new NotImplementedException(); + } + + public Task> GetNodeSetsPendingApprovalAsync(int? limit, string cursor, bool pageBackwards, bool noTotalCount = false, UAProperty prop = null) + { + throw new NotImplementedException(); + } + public Task UpdateApprovalStatusAsync(string nodeSetId, string newStatus, string statusInfo, UAProperty additionalProperty = null) + { + throw new NotImplementedException(); + } + + public Task GetAsync(string identifier) + { + throw new NotImplementedException(); + } + + } +} From 269c267b891578ab8de33ea92e8cb5d9e1bb92e9 Mon Sep 17 00:00:00 2001 From: Sean Coxen Date: Tue, 3 Sep 2024 13:14:04 -0400 Subject: [PATCH 23/23] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07cd194a..754e9580 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@

Prerequisites

  • - Install node.js (version > 10.16) - https://nodejs.org/en/ +Install node.js (version > 18.17) - https://nodejs.org/en/
  • - Install npm (version > 5.6) - https://www.npmjs.com/ (note I just upgraded to 7.17 => npm install -g npm) +Install npm (version > 8.5.4) - https://www.npmjs.com/ (npm install -g npm)
  • React - https://reactjs.org/ - First time React users, install React using create-react-app from a node.js command prompt, a tool that installs all of the dependencies to build and run a full React.js application.