Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop -> Main #105

Closed
wants to merge 104 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
1757421
Fix missing code for Unsaved changes that wan't getting called for ty…
PaulLinYao Jun 8, 2023
1f8bac1
CloudLib resolver: fallback to rest more carefully
MarkusHorstmann Jun 13, 2023
a7e3557
Pick up new common
MarkusHorstmann Jun 14, 2023
fae2af7
Pick up staging
MarkusHorstmann Jun 14, 2023
c6d65c4
Composition: properly delete nested generated objects (FolderType pat…
MarkusHorstmann Jun 14, 2023
4a97a50
Enable Unsaved changes warning for Profile Explorer and Side Menu (MR…
PaulLinYao Jun 15, 2023
61f926f
Merge branch 'develop' of https://github.com/cesmii/ProfileDesigner i…
PaulLinYao Jun 15, 2023
ea8bd43
Merge pull request #98 from cesmii/stage
scoxen1 Jun 15, 2023
fbd7162
Merge pull request #100 from cesmii/stage
scoxen1 Jun 15, 2023
ddb0878
Frontend: show/edit OPC NodeID for attributes
MarkusHorstmann Jun 20, 2023
5255a2e
test - add support for more profile integration tests
scoxen1 Jun 28, 2023
0b1deb7
Import/Export: Symbolic Name, EnumValues/EnumStrings, bug fixes
MarkusHorstmann Jun 29, 2023
78e717f
Test: diff updates
MarkusHorstmann Jun 29, 2023
d91e0e3
readme for cloudlib resolver
MarkusHorstmann Jun 29, 2023
739e98a
Test: one more diff update
MarkusHorstmann Jun 29, 2023
a76d486
Merge pull request #101 from cesmii/feature/enumvalues
MarkusHorstmann Jun 29, 2023
67fb178
FrontEnd: prevent unintended redirect
MarkusHorstmann Jun 29, 2023
278f6ea
CloudLibResolver: add option to include nodesets pending approval
MarkusHorstmann Jun 29, 2023
3a18def
Readme update
MarkusHorstmann Jun 29, 2023
a3d9653
add tests for attributes (in progress). unlreated small cosmetic fix.
scoxen1 Jul 5, 2023
bbe19c8
Merge branch 'develop' of https://github.com/cesmii/ProfileDesigner i…
scoxen1 Jul 5, 2023
7ec75fb
refactor - moving controller test code files into different folder fo…
scoxen1 Jul 5, 2023
63f5eda
add attribute tests (in progress)
scoxen1 Jul 5, 2023
bc41658
updating tests to run type def attribute tests. re-factoring code to …
scoxen1 Jul 7, 2023
f9d4b95
fixes to unit tests related to adding attributes
scoxen1 Jul 10, 2023
f5036a8
tweak to DeleteIntermediateItem - removing usage of string constant t…
scoxen1 Jul 10, 2023
9fb9740
cosmetics, usability, cleanup on front end
scoxen1 Jul 11, 2023
1dcc9ac
Import: upgrade cloudlib profiles is newer version is required
MarkusHorstmann Jul 12, 2023
cd97a00
Merge develop
MarkusHorstmann Jul 12, 2023
f27b223
Fix - front end handle api error loops endlessly on error - due to re…
scoxen1 Jul 14, 2023
5f3e9b5
try out abbreviated smoke test
scoxen1 Jul 14, 2023
ea657fd
Update tests-shared.yml
scoxen1 Jul 14, 2023
974e709
Update smoke-tests.yml
scoxen1 Jul 14, 2023
a6df1f5
Update tests-shared.yml
scoxen1 Jul 14, 2023
033e11f
trying out trait at class level and multiple traits per test.
scoxen1 Jul 14, 2023
a580959
Merge branch 'feature/smoke-tests' of https://github.com/cesmii/Profi…
scoxen1 Jul 14, 2023
347e983
adding trait attribute to other contoller tests
scoxen1 Jul 14, 2023
4abfd84
Update tests-shared.yml
scoxen1 Jul 14, 2023
460600d
Update smoke-tests.yml
scoxen1 Jul 14, 2023
ce038ce
Update tests-shared.yml
scoxen1 Jul 14, 2023
fb9818e
Update tests-shared.yml
scoxen1 Jul 14, 2023
5472d95
Update tests-shared.yml
scoxen1 Jul 14, 2023
b88599e
Update tests.yml
scoxen1 Jul 14, 2023
fe4a80b
Update tests-shared.yml
scoxen1 Jul 14, 2023
3cef4b4
Update tests-shared.yml
scoxen1 Jul 14, 2023
43ad481
adding smoke test attr.
scoxen1 Jul 14, 2023
7e21f16
Update tests.yml
scoxen1 Jul 14, 2023
29af06d
Merge branch 'feature/smoke-tests' of https://github.com/cesmii/Profi…
scoxen1 Jul 14, 2023
47f1e81
Delete original profile XML on updates (enables clean cloudlib update)
MarkusHorstmann Jul 14, 2023
6e25aa0
Profile: track creation and update
MarkusHorstmann Jul 14, 2023
8b4080d
ImportLogDAL: avoid null ref on delete of non-exiting ID
MarkusHorstmann Jul 14, 2023
1994e9d
Import: handle profiles without cached XML. Export: Generate encodings
MarkusHorstmann Jul 14, 2023
6f16e82
Test: cloud lib mock update
MarkusHorstmann Jul 15, 2023
f374218
Test: updated diffs
MarkusHorstmann Jul 15, 2023
82346c2
Pick up NodeSet Model 1.0.16
MarkusHorstmann Jul 15, 2023
8890484
Front End: prevent undesired navigation also on edit (workaround)
MarkusHorstmann Jul 15, 2023
05fac62
FE cloudlib grid: Remove dead code
MarkusHorstmann Jul 15, 2023
1e8eac9
Merge pull request #103 from cesmii/feature/smoke-tests
scoxen1 Jul 17, 2023
bbc5d0c
Readme: add section on running PD, MP, Cloudlib on dev machine
MarkusHorstmann Jul 17, 2023
a3a97d6
Pick up common/develop
MarkusHorstmann Jul 17, 2023
bd61a05
Merge develop
MarkusHorstmann Jul 17, 2023
84be158
Test fixes
MarkusHorstmann Jul 18, 2023
144fcbb
Test fix
MarkusHorstmann Jul 18, 2023
56c66ae
Test: one more diff
MarkusHorstmann Jul 18, 2023
0293540
Fixes for update script
MarkusHorstmann Jul 18, 2023
f6da7fb
Merge pull request #102 from cesmii/feature/pendingresolver
MarkusHorstmann Jul 18, 2023
a7a0003
Profile: don't map IsActive
MarkusHorstmann Jul 18, 2023
8e0fe97
Test: update column count
MarkusHorstmann Jul 18, 2023
90a8ca2
Import Export smoketests
MarkusHorstmann Jul 19, 2023
662c5fb
Test: rename import/export tests
MarkusHorstmann Jul 19, 2023
1e1d50d
Merge pull request #104 from cesmii/feature/importsmoke
MarkusHorstmann Jul 19, 2023
4fe904b
Outgoing email using 'CESMII DevOps Team' in signature of email
PaulLinYao Aug 10, 2023
d126fe7
Update CorsSettings in appsettings.Staging.json
PaulLinYao Aug 11, 2023
2bdec05
importing logs - check for null before foreach
scoxen1 Aug 16, 2023
81d1ca9
Merge branch 'develop' of https://github.com/cesmii/ProfileDesigner i…
scoxen1 Aug 16, 2023
9edc653
Comment out add cols portion - cols already present in prod db
scoxen1 Aug 24, 2023
b6b3aba
fix - if import fails on first try, correct to allow a subsequent try
scoxen1 Sep 29, 2023
99b0056
Merge pull request #107 from cesmii/feature/import-azure-function
scoxen1 Oct 2, 2023
b1f56aa
Merge pull request #109 from cesmii/main
scoxen1 Nov 13, 2023
8c6a6a7
Link to common submodule
PaulLinYao Mar 4, 2024
143764c
Create tests-github-filter.yml
PaulLinYao Nov 24, 2023
4a8a4d5
Delete .github/workflows/tests-github-filter.yml
PaulLinYao Nov 24, 2023
38f4002
Create tests-in-browser.yml
PaulLinYao Nov 24, 2023
6e6ee26
Start to fixing problem with multiple database records preventing use…
PaulLinYao Mar 4, 2024
6adb0c2
Adding missing function for ClouLibMock (was missing 'SearchAsync')
PaulLinYao Mar 4, 2024
1113e7b
Bug fix - correcting wrong handling of login when multiple database r…
PaulLinYao Mar 4, 2024
bcc1311
Github Issue - changing actions/checkout@v3 to actions/checkout@v2
PaulLinYao Mar 4, 2024
ff9de18
Fixing single sign to deal with multiple user records in public.user
PaulLinYao Apr 9, 2024
4de55c4
Update nuget packages with known vulnerabilities
PaulLinYao Apr 9, 2024
ad8de79
Self Service Sign Up -- Removing code that deletes duplicate records …
PaulLinYao Apr 10, 2024
1e3fd6d
Make equivalent to Main - updating versions of script plugins
scoxen1 Aug 20, 2024
71220d6
Make equivalent to Main - updating versions of script plugins
scoxen1 Aug 20, 2024
f7cc729
Make equivalent to Main - updating versions of script plugins
scoxen1 Aug 20, 2024
db9aea8
Make equivalent to Main - resolve merge conflicts
scoxen1 Aug 20, 2024
38ce4e6
Merge pull request #126 from cesmii/main
scoxen1 Sep 3, 2024
29882c7
Update README.md
scoxen1 Sep 3, 2024
f2c8f03
Update README.md
scoxen1 Sep 3, 2024
cc556cb
Update tests.yml
scoxen1 Sep 3, 2024
427685c
Update AuthController.cs
scoxen1 Sep 3, 2024
e5ea560
updating submodule common to point to main branch
scoxen1 Sep 4, 2024
ed99abd
Merge branch 'develop' into CO5/Develop
scoxen1 Sep 4, 2024
bce369d
update develop branch to point to common/develop branch for submodule…
scoxen1 Sep 4, 2024
0957799
point to develop branch on common submodule
scoxen1 Sep 4, 2024
9fa1b06
Merge pull request #127 from cesmii/CO5/Develop
scoxen1 Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/backend-publish-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,3 @@ jobs:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_PROFILEDESIGNER_BACK_PUBLISHSETTINGS }}
package: ${{ env.PROJECT_DIRECTORY }}${{ env.PUBLISH_FOLDER }}

1 change: 0 additions & 1 deletion .github/workflows/backend-publish-stage-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ jobs:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_PROFILEDESIGNER_BACK_STAGE_PUBLISHSETTINGS }}
package: ${{ env.PROJECT_DIRECTORY }}${{ env.PUBLISH_FOLDER }}

25 changes: 25 additions & 0 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will build and test a .NET 6 web API.
# The tests will be a subset of tests which run quickly while still getting good code coverage.
name: Smoke Test|API|Profile Designer
on:
#manually trigger deploy
workflow_dispatch:
# Trigger the workflow on push
push:
branches:
- feature/smoke-tests
- develop
- main
pull_request:
branches:
- develop
- main


jobs:
#call a common workflow which checks out, builds, publishes, zips, deploys to AWS Elastic beanstalk
call-workflow-publish-common-aws:
uses: ./.github/workflows/tests-shared.yml
with:
TEST_FILTER: 'SmokeTest="true"'
BUILD_TARGET: 'Staging'
17 changes: 17 additions & 0 deletions .github/workflows/tests-in-browser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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
87 changes: 87 additions & 0 deletions .github/workflows/tests-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# This workflow will build and test a .NET 6 web API.
# The tests will be a subset of tests which run quickly while still getting good code coverage.
name: Shared | Tests | Common Test Workflow
on:
workflow_call:
inputs:
#ie Staging, Release
BUILD_TARGET:
required: true
type: string
#optional test filter (ie. filter on smoke test trait)
TEST_FILTER:
required: true
type: string
#'--filter SmokeTest="true"'

env:
# set this to the path to your solution file, defaults to the repository root (this is the folder in the git repo)
SOLUTION_DIRECTORY: './'
# set this to the path to your web app project, defaults to the repository root (this is the folder in the git repo)
PROJECT_DIRECTORY: './api/CESMII.ProfileDesigner.Api'
# Solution file to use
SOLUTION_FILE: 'CESMII.ProfileDesigner.sln'
# Project file to use
PROJECT_NAME: 'CESMII.ProfileDesigner.Api'
# set this to the .NET core version to use
NETCORE_VERSION: "6.0.x"

jobs:
build:
name: Build and Test .NET6 Web API
runs-on: ubuntu-latest
steps:
#dynamically set up env variables based on inputs
- name: Dynamically set test filter based on input filter
run: |
if [ ${{inputs.TEST_FILTER}} != "" ]; then
echo "Test uses filter..."
echo "TEST_LABEL=Filter=${{inputs.TEST_FILTER}}" >> $GITHUB_ENV
echo "TEST_FILTER=--filter ${{inputs.TEST_FILTER}}" >> $GITHUB_ENV
else
echo "Test does not use filter..."
echo "TEST_LABEL=" >> $GITHUB_ENV
echo "TEST_FILTER=" >> $GITHUB_ENV
fi

- uses: actions/checkout@v2
with:
submodules: true
- name: Set up dotnet Core ${{ env.NETCORE_VERSION }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Start PostgreSQL on Ubuntu for use by integration tests
run: |
sudo systemctl start postgresql.service
pg_isready
- name: Create additional user
run: |
sudo -u postgres psql --command="CREATE USER profiledesigner SUPERUSER PASSWORD 'cesmii'" --command="\du"
- name: List existing databases
run: |
sudo -u postgres psql -l
- name: Create database
run: |
sudo -u postgres psql --command="CREATE DATABASE profile_designer_local_test WITH OWNER = profiledesigner TABLESPACE = pg_default CONNECTION LIMIT = -1;"
- name: Create schema
run: |
ls -l ./sql
head -5 ./sql/CESMII.ProfileDesigner.DB.sql
sudo -u postgres psql -d profile_designer_local_test < ./sql/CESMII.ProfileDesigner.DB.sql
#sudo -u postgres psql -d profile_designer_local_test --file ./sql/CESMII.ProfileDesigner.DB.sql
- name: List existing databases
run: |
sudo -u postgres psql -l

- name: Restore dependencies (${{env.SOLUTION_FILE}})
run: dotnet restore ${{env.SOLUTION_FILE}}
working-directory: ${{env.SOLUTION_DIRECTORY}}
- name: Build (${{env.SOLUTION_FILE}})
run: dotnet build ${{env.SOLUTION_FILE}} --configuration ${{inputs.BUILD_TARGET}} --no-restore
working-directory: ${{env.SOLUTION_DIRECTORY}}

- name: Test (${{env.SOLUTION_FILE}}) ${{env.TEST_LABEL}}
run: dotnet test ${{env.SOLUTION_FILE}} ${{env.TEST_FILTER}} --configuration ${{ inputs.BUILD_TARGET }} --no-build --verbosity normal -l:"console;verbosity=normal"
working-directory: ${{env.SOLUTION_DIRECTORY}}
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,59 @@ Install npm (version > 8.5.4) - https://www.npmjs.com/ (npm install -g npm)
</p>
</li>
</ol>
<p>
## Directories
- \api - This contains a .NET web API back end for profile designer. Within this solution, the OPC translations will occur, database connections will occur, etc.
- \frontend - This contains the REACT front end for profile designer.
- \SampleNodeSets - This contains nodesets that we use to import into system. Any OPC UA compliant nodeset is permitted. These are stored just for convenience while developing within the system.
- \sql - This contains the SQL script used to generate the DB structure and insert required lookup data as well as some sample users.

## How to Build
- Clone the repo from GIT.

If you have an older clone that is missing the common submodule:
```ps
cd c:\sources\cesmii\profiledesigner
git submodule add https://github.com/cesmii/cesmii-common
```

- **Build/Run the front end:**
```powershell
cd \frontend
npm install
npm run start
```
- Verify the site is running in a browser: http://localhost:3000

> **Note**
>
> The ENV files in the root React folder point to the base URL for the web API.
> Login: The login process was intentionally simple. Use cesmii/cesmii to login.


- **Build/Run the back end API (.NET 6 Solution):**
- Standard .NET build and run.

- **PostgreSql DB**
See above for initial install instructions.
- Run pgAdmin
- Create local DB (see AppSettings.json for database name.)
- Open the Query Tool (Tools menu)
- Open the CESMII-Profile-Designer\sql\CESMII.ProfileDesigner.DB.sql file
- Create the cesmii role/login and the database (comment out everything except the create role and create database sections and run the script)
- Open a query tool on the newly created database and run the rest of the script
- Change the password on the cesmii login to match the one in the appsettings.development.json file.

## Run Profile Designer, Market Place and Cloud Library locally

### Profile Designer: Front End port 3002, API port 5004

1. Add a frontend/.env.development file with the following entries/content:
```
REACT_APP_BASE_API_URL=https://localhost:5004/api
PORT=3002
```

2. Change

</p>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="CESMII.OpcUa.NodeSetImporter" Version="1.0.13" />
<PackageReference Include="CESMII.OpcUa.NodeSetImporter" Version="1.0.16" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public static class UANodeSetCloudLibraryResolverExtensions
public static IServiceCollection AddCloudLibraryResolver(this IServiceCollection services)
{
services
.AddScoped<IUANodeSetResolverWithProgress, UANodeSetCloudLibraryResolver>(sp => new UANodeSetCloudLibraryResolver(sp.GetRequiredService<IOptions<UACloudLibClient.Options>>().Value))
.AddScoped<IUANodeSetResolverWithPending, UANodeSetCloudLibraryResolver>(sp => new UANodeSetCloudLibraryResolver(sp.GetRequiredService<IOptions<UACloudLibClient.Options>>().Value))
;
return services;
}
public static IServiceCollection AddCloudLibraryResolver(this IServiceCollection services, IConfiguration configurationSection)
{
services
.Configure<UACloudLibClient.Options>(configurationSection)
.AddScoped<IUANodeSetResolverWithProgress, UANodeSetCloudLibraryResolver>(sp => new UANodeSetCloudLibraryResolver(sp.GetRequiredService<IOptions<UACloudLibClient.Options>>().Value))
.AddScoped<IUANodeSetResolverWithPending, UANodeSetCloudLibraryResolver>(sp => new UANodeSetCloudLibraryResolver(sp.GetRequiredService<IOptions<UACloudLibClient.Options>>().Value))
;
return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CESMII.OpcUa.NodeSetImporter" Version="1.0.13" />
<PackageReference Include="CESMII.OpcUa.NodeSetImporter" Version="1.0.16" />
<ProjectReference Include="..\..\common\Opc.Ua.Cloud.Library.Client\Opc.Ua.Cloud.Library.Client.csproj" />
</ItemGroup>

Expand Down
26 changes: 24 additions & 2 deletions api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

namespace CESMII.OpcUa.NodeSetImporter
{
public class UANodeSetCloudLibraryResolver : IUANodeSetResolverWithProgress
public class UANodeSetCloudLibraryResolver : IUANodeSetResolverWithPending
{
public OnResolveNodeSets OnResolveNodeSets { get; set; }
public OnNodeSet OnDownloadNodeSet { get; set; }
public OnNodeSet OnNodeSetFound { get; set; }
public OnNodeSet OnNodeSetNotFound { get; set; }

public Func<Nodeset, bool> FilterPendingNodeSet { get; set; }

public UANodeSetCloudLibraryResolver(string strUserName, string strPassword)
{
_client = new UACloudLibClient(strUserName, strPassword);
Expand Down Expand Up @@ -62,9 +64,29 @@
{
nodesetWithURIAndDate.Add((nodeSet.NamespaceUri.OriginalString, nodeSet.PublicationDate, nodeSet.Identifier.ToString(CultureInfo.InvariantCulture), nodeSet.NodesetXml));
}
try
{
if (FilterPendingNodeSet != null)
{
var pendingNodeSets = await _client.GetNodeSetsPendingApprovalAsync(namespaceUri: missingModel.ModelUri).ConfigureAwait(false);
var filteredPending = pendingNodeSets.Nodes.Where(FilterPendingNodeSet).ToList();
foreach(var pending in filteredPending)
{
var pendingNodeSetDownload = await _client.GetNodeSetDependencies(identifier: pending.Identifier.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
foreach (var nodeSet in pendingNodeSetDownload)
{
nodesetWithURIAndDate.Add((nodeSet.NamespaceUri.OriginalString, nodeSet.PublicationDate, nodeSet.Identifier.ToString(CultureInfo.InvariantCulture), nodeSet.NodesetXml));
}
}
}
}
catch (Exception ex)

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / Build and Deploy .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / call-workflow-publish-common-aws / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / call-workflow-publish-common-aws / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / call-workflow-publish-common-aws / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / call-workflow-publish-common-aws / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / Build and Test .NET6 Web API

The variable 'ex' is declared but never used

Check warning on line 83 in api/CESMII.OpcUa.CloudLibraryResolver/CloudLibraryResolver.cs

View workflow job for this annotation

GitHub Actions / Build and Test .NET6 Web API

The variable 'ex' is declared but never used
{

}
}
}
catch (Exception) // TODO more specific exception to detect if cloudlib doesn't support GetNodeSetDependencies
catch (GraphQlNotSupportedException)
{
// Fall back to retrieving and downloading all matching namespaces
var namespacesAndIds = await _client.GetNamespaceIdsAsync().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Some contributions thanks to CESMII – the Smart Manufacturing Institute, 2022
*/

using Opc.Ua.Cloud.Library.Client;
using System;

namespace CESMII.OpcUa.NodeSetImporter
Expand All @@ -15,8 +16,13 @@ public interface IUANodeSetResolverWithProgress : IUANodeSetResolver
public OnNodeSet OnDownloadNodeSet { get; set; }
public OnNodeSet OnNodeSetFound { get; set; }
public OnNodeSet OnNodeSetNotFound { get; set; }

}
public delegate void OnResolveNodeSets();
public delegate void OnNodeSet(string namespaceUri, DateTime? publicationDate);

public interface IUANodeSetResolverWithPending : IUANodeSetResolverWithProgress
{
public Func<Nodeset, bool> FilterPendingNodeSet { get; set; }
}
}
80 changes: 80 additions & 0 deletions api/CESMII.OpcUa.CloudLibraryResolver/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Usage

## Basic

Pass resolver to UANodeSetCacheManager constructor:
```c#
var cacheManager = new UANodeSetCacheManager(myNodeSetCache, _cloudLibResolver);
```
## With progress
```c#
try
{
_cloudLibResolver.OnDownloadNodeSet += callback;
var cacheManager = new UANodeSetCacheManager(myNodeSetCache, _cloudLibResolver);
resultSet = cacheManager.ImportNodeSets(nodeSetXmlStringList, false, userToken);
}
finally
{
_cloudLibResolver.OnDownloadNodeSet -= callback;
}
```

## With nodesets pending approval

```c#
try
{
_cloudLibResolver.OnDownloadNodeSet += callback;
_cloudLibResolver.FilterPendingNodeSet = (n => true); // All pending nodesets
var cacheManager = new UANodeSetCacheManager(myNodeSetCache, _cloudLibResolver);
resultSet = cacheManager.ImportNodeSets(nodeSetXmlStringList, false, userToken);
}
finally
{
_cloudLibResolver.OnDownloadNodeSet -= callback;
}
```

### Filter by user id
```c#
_cloudLibResolver.FilterPendingNodeSet = (n =>
{
return n.Metadata.UserId == userId;
}
);
```

### Filter by user id for the CESMII cloud library when used via CESMII Profile Designer
```c#
_cloudLibResolver.FilterPendingNodeSet = (n =>
{
return n.Metadata.UserId == userId
|| (n.Metadata?.AdditionalProperties?
.Any(p => p.Name == ICloudLibDal<CloudLibProfileModel>.strCESMIIUserInfo
&& p.Value.StartsWith($"{userId,}")) ?? false);
}
);
```


## Dependency Injection
Add service in startup.cs / program.cs:
```c#
services.AddCloudLibraryResolver();
```

Provide configuration:
```json
"CloudLibrary": {
"UserName": "something",
"Password": "secure",
"EndPoint": "https://localhost:5007"
}
```

Request as IUANodeSetResolverWithPending:
```c#
services.GetService<IUANodeSetResolverWithPending>();
```

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.11.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.11.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.35.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading