54 | ");
55 |
56 | public static async Task Send(IEmailSender emailSender, string email, string subject, string action, string url)
57 | {
58 | string body = string.Format(
59 | CultureInfo.InvariantCulture,
60 | EmailTemplate,
61 | action,
62 | url);
63 |
64 | await emailSender.SendEmailAsync(
65 | email,
66 | subject,
67 | body).ConfigureAwait(false);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/ApprovalModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System.Collections.Generic;
31 | using System.Linq;
32 | using System.Threading.Tasks;
33 | using HotChocolate;
34 | using HotChocolate.Authorization;
35 | using HotChocolate.Data;
36 | using HotChocolate.Language;
37 | using HotChocolate.Resolvers;
38 | using HotChocolate.Types;
39 | using Opc.Ua.Cloud.Library.DbContextModels;
40 | using Opc.Ua.Cloud.Library.Models;
41 |
42 | namespace Opc.Ua.Cloud.Library
43 | {
44 | [Authorize]
45 | public partial class MutationModel
46 | {
47 | public class ApprovalInput
48 | {
49 | public string Identifier { get; set; }
50 | public ApprovalStatus Status { get; set; }
51 | public string ApprovalInformation { get; set; }
52 | ///
53 | /// Set/overwrite these properties upon approval. Null or empty string value deletes the property.
54 | ///
55 | public List AdditionalProperties { get; set; }
56 | }
57 |
58 | [Authorize(Policy = "ApprovalPolicy")]
59 | public async Task ApproveNodeSetAsync([Service()] IDatabase db, ApprovalInput input)
60 | {
61 | NamespaceMetaDataModel nodeSet = await db.ApproveNamespaceAsync(input.Identifier, input.Status, input.ApprovalInformation, input.AdditionalProperties).ConfigureAwait(false);
62 | return nodeSet;
63 | }
64 |
65 | }
66 | [Authorize]
67 | public partial class QueryModel
68 | {
69 | [UsePaging, UseFiltering, UseSorting]
70 | public IQueryable GetNodeSetsPendingApproval([Service()] IDatabase dp, IResolverContext context)
71 | {
72 | IQueryable query = dp.GetNodeSetsPendingApproval();
73 |
74 | // Make sure the result is ordered even if the graphl query didn't specify an order so that pagination works correctly
75 | IValueNode orderByArgument = context.ArgumentLiteral("order");
76 | if (orderByArgument == NullValueNode.Default || orderByArgument == null)
77 | {
78 | query = query.OrderBy(nsm => nsm.ModelUri).ThenBy(nsm => nsm.PublicationDate);
79 | }
80 |
81 | return query;
82 | }
83 |
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/DBContextModels/DatatypeModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library.DbContextModels
31 | {
32 | using System.ComponentModel.DataAnnotations.Schema;
33 |
34 | [Table("datatype")]
35 | public partial class DatatypeModel
36 | {
37 | [Column("datatype_id")]
38 | public int Id { get; set; }
39 |
40 | [Column("nodeset_id")]
41 | public long NodesetId { get; set; }
42 |
43 | [Column("datatype_browsename")]
44 | public string BrowseName { get; set; }
45 |
46 | [Column("datatype_value")]
47 | public string Value { get; set; }
48 |
49 | [Column("datatype_namespace")]
50 | public string NameSpace { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/DBContextModels/MetadataModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System.ComponentModel.DataAnnotations.Schema;
31 |
32 | namespace Opc.Ua.Cloud.Library.DbContextModels
33 | {
34 | [Table("metadata")]
35 | public partial class MetadataModel
36 | {
37 | [Column("metadata_id")]
38 | public int Id { get; set; }
39 |
40 | [Column("nodeset_id")]
41 | public long NodesetId { get; set; }
42 |
43 | [Column("metadata_name")]
44 | public string Name { get; set; }
45 |
46 | [Column("metadata_value")]
47 | public string Value { get; set; }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/DBContextModels/ObjecttypeModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library.DbContextModels
31 | {
32 | using System.ComponentModel.DataAnnotations.Schema;
33 |
34 | [Table("objecttype")]
35 | public partial class ObjecttypeModel
36 | {
37 | [Column("objecttype_id")]
38 | public int Id { get; set; }
39 |
40 | [Column("nodeset_id")]
41 | public long NodesetId { get; set; }
42 |
43 | [Column("objecttype_browsename")]
44 | public string BrowseName { get; set; }
45 |
46 | [Column("objecttype_value")]
47 | public string Value { get; set; }
48 |
49 | [Column("objecttype_namespace")]
50 | public string NameSpace { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/DBContextModels/ReferencetypeModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library.DbContextModels
31 | {
32 | using System.ComponentModel.DataAnnotations.Schema;
33 |
34 | [Table("referencetype")]
35 | public partial class ReferencetypeModel
36 | {
37 | [Column("referencetype_id")]
38 | public int Id { get; set; }
39 |
40 | [Column("nodeset_id")]
41 | public long NodesetId { get; set; }
42 |
43 | [Column("referencetype_browsename")]
44 | public string BrowseName { get; set; }
45 |
46 | [Column("referencetype_value")]
47 | public string Value { get; set; }
48 |
49 | [Column("referencetype_namespace")]
50 | public string NameSpace { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/DBContextModels/VariabletypeModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library.DbContextModels
31 | {
32 | using System.ComponentModel.DataAnnotations.Schema;
33 |
34 | [Table("variabletype")]
35 | public partial class VariabletypeModel
36 | {
37 | [Column("variabletype_id")]
38 | public int Id { get; set; }
39 |
40 | [Column("nodeset_id")]
41 | public long NodesetId { get; set; }
42 |
43 | [Column("variabletype_browsename")]
44 | public string BrowseName { get; set; }
45 |
46 | [Column("variabletype_value")]
47 | public string Value { get; set; }
48 |
49 | [Column("variabletype_namespace")]
50 | public string NameSpace { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/NameSpaceCategoryComparer.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library
31 | {
32 | using System;
33 | using System.Collections.Generic;
34 | using System.Globalization;
35 | using Opc.Ua.Cloud.Library.Models;
36 |
37 | internal class NameSpaceCategoryComparer : IComparer
38 | {
39 | public string OrderBy { get; }
40 |
41 | public NameSpaceCategoryComparer(string orderBy)
42 | {
43 | OrderBy = orderBy.ToLower(CultureInfo.InvariantCulture);
44 | }
45 |
46 | public int Compare(Category x, Category y)
47 | {
48 | switch (OrderBy)
49 | {
50 | case "name": return string.Compare(x.Name, y.Name, StringComparison.Ordinal);
51 | case "description": return string.Compare(x.Description, y.Description, StringComparison.Ordinal);
52 | default: return 0; // return unordered
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/NameSpaceComparer.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library
31 | {
32 | using System;
33 | using System.Collections.Generic;
34 | using System.Globalization;
35 | using Opc.Ua.Cloud.Library.Models;
36 |
37 | internal class NameSpaceComparer : IComparer
38 | {
39 | public string OrderBy { get; }
40 |
41 | public NameSpaceComparer(string orderBy)
42 | {
43 | OrderBy = orderBy.ToLower(CultureInfo.InvariantCulture);
44 | }
45 |
46 | public int Compare(UANameSpace x, UANameSpace y)
47 | {
48 | switch (OrderBy)
49 | {
50 | case "name": return string.Compare(x.Title, y.Title, StringComparison.Ordinal);
51 | case "copyrighttext": return string.Compare(x.CopyrightText, y.CopyrightText, StringComparison.Ordinal);
52 | case "description": return string.Compare(x.Description, y.Description, StringComparison.Ordinal);
53 | default: return 0; // return unordered
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/GraphQL/OrganisationComparer.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library
31 | {
32 | using System;
33 | using System.Collections.Generic;
34 | using System.Globalization;
35 | using Opc.Ua.Cloud.Library.Models;
36 |
37 | internal class OrganisationComparer : IComparer
38 | {
39 | public string OrderBy { get; }
40 |
41 | public OrganisationComparer(string orderBy)
42 | {
43 | OrderBy = orderBy.ToLower(CultureInfo.InvariantCulture);
44 | }
45 |
46 | public int Compare(Organisation x, Organisation y)
47 | {
48 | switch (OrderBy)
49 | {
50 | case "name": return string.Compare(x.Name, y.Name, StringComparison.Ordinal);
51 | case "description": return string.Compare(x.Description, y.Description, StringComparison.Ordinal);
52 | case "contactemail": return string.Compare(x.ContactEmail, y.ContactEmail, StringComparison.Ordinal);
53 | default: return 0; // return unordered
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Interfaces/ICaptchaValidation.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Security.Claims;
3 | using System.Threading.Tasks;
4 |
5 | namespace Opc.Ua.Cloud.Library.Interfaces
6 | {
7 | public interface ICaptchaValidation
8 | {
9 | Task ValidateCaptcha(string responseToken);
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Interfaces/IFileStorage.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System.Threading;
31 | using System.Threading.Tasks;
32 |
33 | namespace Opc.Ua.Cloud.Library.Interfaces
34 | {
35 | public interface IFileStorage
36 | {
37 | ///
38 | /// Find a file based on a unique name
39 | ///
40 | Task FindFileAsync(string name, CancellationToken cancellationToken = default);
41 |
42 | ///
43 | /// Upload a nodeset from a local directory to storage
44 | ///
45 | Task UploadFileAsync(string name, string content, CancellationToken cancellationToken = default);
46 |
47 | ///
48 | /// Download a nodeset from storage to a local file
49 | ///
50 | Task DownloadFileAsync(string name, CancellationToken cancellationToken = default);
51 | ///
52 | /// Delete a nodeset from storage
53 | ///
54 | ///
55 | ///
56 | ///
57 | Task DeleteFileAsync(string name, CancellationToken cancellationToken = default);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Interfaces/IUserService.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System.Collections.Generic;
31 | using System.Security.Claims;
32 | using System.Threading.Tasks;
33 |
34 | namespace Opc.Ua.Cloud.Library.Interfaces
35 | {
36 | public interface IUserService
37 | {
38 | Task> ValidateCredentialsAsync(string username, string password);
39 | Task> ValidateApiKeyAsync(string apiKey);
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20220827002530_ReferencingNodes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4 |
5 | #nullable disable
6 |
7 | namespace Opc.Ua.Cloud.Library
8 | {
9 | public partial class ReferencingNodes : Migration
10 | {
11 | protected override void Up(MigrationBuilder migrationBuilder)
12 | {
13 | migrationBuilder.CreateTable(
14 | name: "Nodes_OtherReferencingNodes",
15 | columns: table => new {
16 | OwnerNodeId = table.Column(type: "text", nullable: false),
17 | OwnerModelUri = table.Column(type: "text", nullable: false),
18 | OwnerPublicationDate = table.Column(type: "timestamp with time zone", nullable: false),
19 | Id = table.Column(type: "integer", nullable: false)
20 | .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
21 | ReferencingNodeId = table.Column(type: "text", nullable: true),
22 | ReferencingModelUri = table.Column(type: "text", nullable: true),
23 | ReferencingPublicationDate = table.Column(type: "timestamp with time zone", nullable: true),
24 | Reference = table.Column(type: "text", nullable: true)
25 | },
26 | constraints: table => {
27 | table.PrimaryKey("PK_Nodes_OtherReferencingNodes", x => new { x.OwnerNodeId, x.OwnerModelUri, x.OwnerPublicationDate, x.Id });
28 | table.ForeignKey(
29 | name: "FK_Nodes_OtherReferencingNodes_Nodes_OwnerNodeId_OwnerModelUri~",
30 | columns: x => new { x.OwnerNodeId, x.OwnerModelUri, x.OwnerPublicationDate },
31 | principalTable: "Nodes",
32 | principalColumns: ["NodeId", "NodeSetModelUri", "NodeSetPublicationDate"],
33 | onDelete: ReferentialAction.Cascade);
34 | table.ForeignKey(
35 | name: "FK_Nodes_OtherReferencingNodes_Nodes_ReferencingNodeId_Referen~",
36 | columns: x => new { x.ReferencingNodeId, x.ReferencingModelUri, x.ReferencingPublicationDate },
37 | principalTable: "Nodes",
38 | principalColumns: ["NodeId", "NodeSetModelUri", "NodeSetPublicationDate"]);
39 | });
40 |
41 | migrationBuilder.CreateIndex(
42 | name: "IX_Nodes_OtherReferencingNodes_ReferencingNodeId_ReferencingMo~",
43 | table: "Nodes_OtherReferencingNodes",
44 | columns: ["ReferencingNodeId", "ReferencingModelUri", "ReferencingPublicationDate"]);
45 | }
46 |
47 | protected override void Down(MigrationBuilder migrationBuilder)
48 | {
49 | migrationBuilder.DropTable(
50 | name: "Nodes_OtherReferencingNodes");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20221130233758_subtypes.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace Opc.Ua.Cloud.Library
4 | {
5 | public partial class Subtypes : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 |
10 | }
11 |
12 | protected override void Down(MigrationBuilder migrationBuilder)
13 | {
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20230217020508_ModellingRule.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Opc.Ua.Cloud.Library
6 | {
7 | public partial class ModellingRule : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.RenameColumn(
12 | name: "ModelingRule",
13 | table: "Variables",
14 | newName: "ModellingRule");
15 |
16 | migrationBuilder.RenameColumn(
17 | name: "EngUnitModelingRule",
18 | table: "Variables",
19 | newName: "EngUnitModellingRule");
20 |
21 | migrationBuilder.RenameColumn(
22 | name: "EURangeModelingRule",
23 | table: "Variables",
24 | newName: "EURangeModellingRule");
25 |
26 | migrationBuilder.RenameColumn(
27 | name: "ModelingRule",
28 | table: "Objects",
29 | newName: "ModellingRule");
30 |
31 | migrationBuilder.RenameColumn(
32 | name: "ModelingRule",
33 | table: "Methods",
34 | newName: "ModellingRule");
35 | }
36 |
37 | protected override void Down(MigrationBuilder migrationBuilder)
38 | {
39 | migrationBuilder.RenameColumn(
40 | name: "ModellingRule",
41 | table: "Variables",
42 | newName: "ModelingRule");
43 |
44 | migrationBuilder.RenameColumn(
45 | name: "EngUnitModellingRule",
46 | table: "Variables",
47 | newName: "EngUnitModelingRule");
48 |
49 | migrationBuilder.RenameColumn(
50 | name: "EURangeModellingRule",
51 | table: "Variables",
52 | newName: "EURangeModelingRule");
53 |
54 | migrationBuilder.RenameColumn(
55 | name: "ModellingRule",
56 | table: "Objects",
57 | newName: "ModelingRule");
58 |
59 | migrationBuilder.RenameColumn(
60 | name: "ModellingRule",
61 | table: "Methods",
62 | newName: "ModelingRule");
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20230309012709_instrumentrange.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace Opc.Ua.Cloud.Library
4 | {
5 | public partial class InstrumentRange : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 | migrationBuilder.AddColumn(
10 | name: "InstrumentRangeAccessLevel",
11 | table: "Variables",
12 | type: "bigint",
13 | nullable: true);
14 |
15 | migrationBuilder.AddColumn(
16 | name: "InstrumentRangeModellingRule",
17 | table: "Variables",
18 | type: "text",
19 | nullable: true);
20 |
21 | migrationBuilder.AddColumn(
22 | name: "InstrumentRangeNodeId",
23 | table: "Variables",
24 | type: "text",
25 | nullable: true);
26 | }
27 |
28 | protected override void Down(MigrationBuilder migrationBuilder)
29 | {
30 | migrationBuilder.DropColumn(
31 | name: "InstrumentRangeAccessLevel",
32 | table: "Variables");
33 |
34 | migrationBuilder.DropColumn(
35 | name: "InstrumentRangeModellingRule",
36 | table: "Variables");
37 |
38 | migrationBuilder.DropColumn(
39 | name: "InstrumentRangeNodeId",
40 | table: "Variables");
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20230608191754_creationtime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 |
4 | namespace Opc.Ua.Cloud.Library
5 | {
6 | public partial class CreationTime : Migration
7 | {
8 | protected override void Up(MigrationBuilder migrationBuilder)
9 | {
10 | migrationBuilder.AddColumn(
11 | name: "CreationTime",
12 | table: "NamespaceMeta",
13 | type: "timestamp with time zone",
14 | nullable: false,
15 | defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
16 | }
17 |
18 | protected override void Down(MigrationBuilder migrationBuilder)
19 | {
20 | migrationBuilder.DropColumn(
21 | name: "CreationTime",
22 | table: "NamespaceMeta");
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20230706182650_symbolicname.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace Opc.Ua.Cloud.Library
4 | {
5 | public partial class SymbolicName : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 | migrationBuilder.AddColumn(
10 | name: "SymbolicName",
11 | table: "UaEnumField",
12 | type: "text",
13 | nullable: true);
14 |
15 | migrationBuilder.AddColumn(
16 | name: "SymbolicName",
17 | table: "StructureField",
18 | type: "text",
19 | nullable: true);
20 | }
21 |
22 | protected override void Down(MigrationBuilder migrationBuilder)
23 | {
24 | migrationBuilder.DropColumn(
25 | name: "SymbolicName",
26 | table: "UaEnumField");
27 |
28 | migrationBuilder.DropColumn(
29 | name: "SymbolicName",
30 | table: "StructureField");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20230918174126_AllowSubTypes.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | #nullable disable
4 |
5 | namespace Opc.Ua.Cloud.Library
6 | {
7 | public partial class AllowSubTypes : Migration
8 | {
9 | protected override void Up(MigrationBuilder migrationBuilder)
10 | {
11 | migrationBuilder.AddColumn(
12 | name: "AllowSubTypes",
13 | table: "StructureField",
14 | type: "boolean",
15 | nullable: false,
16 | defaultValue: false);
17 | }
18 |
19 | protected override void Down(MigrationBuilder migrationBuilder)
20 | {
21 | migrationBuilder.DropColumn(
22 | name: "AllowSubTypes",
23 | table: "StructureField");
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20231115021818_eventnotifier.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace Opc.Ua.Cloud.Library
4 | {
5 | public partial class EventNotifier : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 | migrationBuilder.AddColumn(
10 | name: "EventNotifier",
11 | table: "Objects",
12 | type: "smallint",
13 | nullable: true);
14 |
15 | migrationBuilder.AddColumn(
16 | name: "NodeIdIdentifier",
17 | table: "Nodes",
18 | type: "text",
19 | nullable: true);
20 | }
21 |
22 | protected override void Down(MigrationBuilder migrationBuilder)
23 | {
24 | migrationBuilder.DropColumn(
25 | name: "EventNotifier",
26 | table: "Objects");
27 |
28 | migrationBuilder.DropColumn(
29 | name: "NodeIdIdentifier",
30 | table: "Nodes");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20231116212539_methods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.EntityFrameworkCore.Migrations;
3 |
4 | namespace Opc.Ua.Cloud.Library
5 | {
6 | public partial class BasetypeModel : Migration
7 | {
8 | protected override void Up(MigrationBuilder migrationBuilder)
9 | {
10 | migrationBuilder.AddColumn(
11 | name: "NodeSetMethodsModelUri",
12 | table: "Methods",
13 | type: "text",
14 | nullable: true);
15 |
16 | migrationBuilder.AddColumn(
17 | name: "NodeSetMethodsPublicationDate",
18 | table: "Methods",
19 | type: "timestamp with time zone",
20 | nullable: true);
21 |
22 | migrationBuilder.CreateIndex(
23 | name: "IX_Methods_NodeSetMethodsModelUri_NodeSetMethodsPublicationDate",
24 | table: "Methods",
25 | columns: ["NodeSetMethodsModelUri", "NodeSetMethodsPublicationDate"]);
26 |
27 | migrationBuilder.AddForeignKey(
28 | name: "FK_Methods_NodeSets_NodeSetMethodsModelUri_NodeSetMethodsPubli~",
29 | table: "Methods",
30 | columns: ["NodeSetMethodsModelUri", "NodeSetMethodsPublicationDate"],
31 | principalTable: "NodeSets",
32 | principalColumns: ["ModelUri", "PublicationDate"],
33 | onDelete: ReferentialAction.Cascade);
34 | }
35 |
36 | protected override void Down(MigrationBuilder migrationBuilder)
37 | {
38 | migrationBuilder.DropForeignKey(
39 | name: "FK_Methods_NodeSets_NodeSetMethodsModelUri_NodeSetMethodsPubli~",
40 | table: "Methods");
41 |
42 | migrationBuilder.DropIndex(
43 | name: "IX_Methods_NodeSetMethodsModelUri_NodeSetMethodsPublicationDate",
44 | table: "Methods");
45 |
46 | migrationBuilder.DropColumn(
47 | name: "NodeSetMethodsModelUri",
48 | table: "Methods");
49 |
50 | migrationBuilder.DropColumn(
51 | name: "NodeSetMethodsPublicationDate",
52 | table: "Methods");
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Migrations/20231117000340_removereferenceid.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace Opc.Ua.Cloud.Library
4 | {
5 | public partial class RemoveReferenceId : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 | migrationBuilder.DropColumn(
10 | name: "Reference",
11 | table: "Nodes_OtherReferencingNodes");
12 |
13 | migrationBuilder.DropColumn(
14 | name: "Reference",
15 | table: "Nodes_OtherReferencedNodes");
16 | }
17 |
18 | protected override void Down(MigrationBuilder migrationBuilder)
19 | {
20 | migrationBuilder.AddColumn(
21 | name: "Reference",
22 | table: "Nodes_OtherReferencingNodes",
23 | type: "text",
24 | nullable: true);
25 |
26 | migrationBuilder.AddColumn(
27 | name: "Reference",
28 | table: "Nodes_OtherReferencedNodes",
29 | type: "text",
30 | nullable: true);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Models/ErrorViewModel.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | namespace Opc.Ua.Cloud.Library.Models
31 | {
32 | public class ErrorViewModel
33 | {
34 | public string RequestId { get; set; }
35 |
36 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Models/UANodesetResult.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System;
31 | using System.Collections.Generic;
32 | using Newtonsoft.Json;
33 |
34 | namespace Opc.Ua.Cloud.Library.Models
35 | {
36 | public class UANodesetResult : UANameSpace
37 | {
38 | [JsonProperty(PropertyName = "nodesetId")]
39 | public uint LegacyId { get => Nodeset?.Identifier ?? 0; }
40 |
41 | [JsonProperty(PropertyName = "nodesetTitle")]
42 | public string LegacyTitle { get => Title; }
43 |
44 | [JsonProperty(PropertyName = "orgName")]
45 | public string LegacyOrgName { get => Contributor?.Name; }
46 |
47 | // TODO enum vs. string & compat
48 | [JsonProperty(PropertyName = "version")]
49 | public string LegacyVersion { get => Nodeset?.Version; }
50 |
51 | [JsonProperty(PropertyName = "publicationDate")]
52 | public System.DateTime? LegacyPublicationDate { get => Nodeset?.PublicationDate; }
53 |
54 | [JsonProperty(PropertyName = "nodesetNamespaceUri")]
55 | public string LegacyNamespaceUri
56 | {
57 | get => Nodeset?.NamespaceUri?.OriginalString;
58 | }
59 |
60 | [JsonProperty(PropertyName = "requiredNodesets")]
61 | public List LegacyRequiredNodesets { get => Nodeset?.RequiredModels; }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/NodeSetIndex/CloudLibDbOpcUaContext.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2022 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System;
31 | using CESMII.OpcUa.NodeSetModel;
32 | using CESMII.OpcUa.NodeSetModel.EF;
33 | using CESMII.OpcUa.NodeSetModel.Factory.Opc;
34 | using Microsoft.Extensions.Logging;
35 | using Opc.Ua.Export;
36 |
37 | namespace Opc.Ua.Cloud.Library
38 | {
39 | internal class CloudLibDbOpcUaContext : DbOpcUaContext
40 | {
41 | public CloudLibDbOpcUaContext(AppDbContext dbContext, ILogger logger, Func nodeSetFactory) : base(dbContext, logger, nodeSetFactory)
42 | {
43 | }
44 |
45 | public override NodeSetModel GetOrAddNodesetModel(ModelTableEntry model, bool createNew = true)
46 | {
47 | var nodeSetModel = base.GetOrAddNodesetModel(model) as CloudLibNodeSetModel;
48 | if (!createNew && nodeSetModel != null && nodeSetModel.ValidationStatus != ValidationStatus.Indexed)
49 | {
50 | throw new NodeSetResolverException($"Required NodeSet {nodeSetModel} not indexed yet.");
51 | }
52 | return nodeSetModel;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/NodeSetIndex/reindex.sql:
--------------------------------------------------------------------------------
1 | -- Deletes the nodeset index. Index will be re-created on next upload (even a failed upload)
2 | DELETE FROM "ReferenceTypes";
3 | DELETE FROM "RequiredModelInfo";
4 | DELETE FROM "Nodes_OtherReferencedNodes";
5 | DELETE FROM "Nodes_OtherReferencingNodes";
6 | --DELETE FROM "ChildAndReference";
7 | DELETE FROM "Methods";
8 | DELETE FROM "DataVariables";
9 | DELETE FROM "Properties";
10 | DELETE FROM "DataTypes";
11 | DELETE FROM "Objects";
12 | DELETE FROM "Interfaces";
13 | DELETE FROM "ObjectTypes";
14 | DELETE FROM "Variables";
15 | DELETE FROM "VariableTypes";
16 | DELETE FROM "BaseTypes";
17 |
18 | DELETE FROM "Nodes";
19 | DELETE FROM "Nodes_Description";
20 | DELETE FROM "Nodes_DisplayName";
21 | DELETE FROM "StructureField";
22 | DELETE FROM "StructureField_Description";
23 | DELETE FROM "UaEnumField";
24 | DELETE FROM "UaEnumField_Description";
25 | DELETE FROM "UaEnumField_DisplayName";
26 |
27 | DELETE FROM "NodeSets";
28 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/PostmarkEmailSender.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System;
31 | using System.Threading.Tasks;
32 | using Microsoft.AspNetCore.Identity.UI.Services;
33 | using PostmarkDotNet;
34 |
35 | namespace Opc.Ua.Cloud.Library
36 | {
37 | public class PostmarkEmailSender : IEmailSender
38 | {
39 | public Task SendEmailAsync(string email, string subject, string htmlMessage)
40 | {
41 | string apiKey = Environment.GetEnvironmentVariable("EmailSenderAPIKey");
42 | if (!string.IsNullOrEmpty(apiKey))
43 | {
44 | PostmarkClient client = new(apiKey);
45 |
46 | string emailFrom = Environment.GetEnvironmentVariable("RegistrationEmailFrom");
47 | if (string.IsNullOrEmpty(emailFrom)) emailFrom = "office@opcfoundation.org";
48 |
49 | // Send an email asynchronously:
50 | PostmarkMessage msg = new() {
51 | To = email,
52 | From = emailFrom,
53 | TrackOpens = true,
54 | Subject = subject,
55 | TextBody = htmlMessage,
56 | HtmlBody = htmlMessage,
57 | MessageStream = "outbound",
58 | Tag = "UA Cloud Library"
59 | };
60 |
61 | return client.SendMessageAsync(msg);
62 | }
63 | else
64 | {
65 | Console.WriteLine($"Mail sending is disabled due to missing API-Key for Postmark (email: ${email}, subject: ${subject})");
66 | return Task.CompletedTask;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Program.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using Microsoft.AspNetCore.Hosting;
31 | using Microsoft.Extensions.Hosting;
32 |
33 | namespace Opc.Ua.Cloud.Library
34 | {
35 | public class Program
36 | {
37 | public static void Main(string[] args)
38 | {
39 | CreateHostBuilder(args).Build().Run();
40 | }
41 |
42 | public static IHostBuilder CreateHostBuilder(string[] args) =>
43 | Host.CreateDefaultBuilder(args)
44 | .ConfigureWebHostDefaults(webBuilder => {
45 | webBuilder.UseStartup();
46 | });
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:65446",
7 | "sslPort": 44388
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "launchUrl": "swagger",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "UA_CloudLibrary": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "launchUrl": "swagger",
23 | "environmentVariables": {
24 | "ASPNETCORE_ENVIRONMENT": "Development"
25 | },
26 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
27 | },
28 | "Docker": {
29 | "commandName": "Docker",
30 | "launchBrowser": true,
31 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
32 | "environmentVariables": {
33 | "PostgreSQLEndpoint": "localhost",
34 | "ASPNETCORE_ENVIRONMENT": "Development",
35 | "HostingPlatform": "Azure",
36 | "PostgreSQLUsername": "",
37 | "PostgreSQLPassword": "",
38 | "BlobStorageConnectionString": "",
39 | "EmailSenderAPIKey": "",
40 | "DataProtectionBlobName": ""
41 | },
42 | "publishAllPorts": true,
43 | "useSSL": true
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/UACloudLibraryServer/SendGridEmailSender.cs:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Copyright (c) 2005-2021 The OPC Foundation, Inc. All rights reserved.
3 | *
4 | * OPC Foundation MIT License 1.00
5 | *
6 | * Permission is hereby granted, free of charge, to any person
7 | * obtaining a copy of this software and associated documentation
8 | * files (the "Software"), to deal in the Software without
9 | * restriction, including without limitation the rights to use,
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the
12 | * Software is furnished to do so, subject to the following
13 | * conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be
16 | * included in all copies or substantial portions of the Software.
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | * OTHER DEALINGS IN THE SOFTWARE.
25 | *
26 | * The complete license agreement can be found here:
27 | * http://opcfoundation.org/License/MIT/1.00/
28 | * ======================================================================*/
29 |
30 | using System;
31 | using System.Threading.Tasks;
32 | using Microsoft.AspNetCore.Identity.UI.Services;
33 | using SendGrid;
34 | using SendGrid.Helpers.Mail;
35 |
36 | namespace Opc.Ua.Cloud.Library
37 | {
38 | public class SendGridEmailSender : IEmailSender
39 | {
40 | public Task SendEmailAsync(string email, string subject, string htmlMessage)
41 | {
42 | string apiKey = Environment.GetEnvironmentVariable("EmailSenderAPIKey");
43 | if (!string.IsNullOrEmpty(apiKey))
44 | {
45 | SendGridClient client = new SendGridClient(apiKey);
46 | string emailFrom = Environment.GetEnvironmentVariable("RegistrationEmailFrom");
47 | if (string.IsNullOrEmpty(emailFrom)) emailFrom = "office@opcfoundation.org";
48 |
49 | string emailReplyTo = Environment.GetEnvironmentVariable("RegistrationEmailReplyTo");
50 | if (string.IsNullOrEmpty(emailReplyTo)) emailReplyTo = "no-reply@opcfoundation.org";
51 |
52 | SendGridMessage msg = new SendGridMessage() {
53 | From = new EmailAddress(emailFrom),
54 | ReplyTo = new EmailAddress(emailReplyTo),
55 | Subject = subject,
56 | HtmlContent = htmlMessage
57 | };
58 |
59 | msg.AddTo(new EmailAddress(email));
60 |
61 | // Disable click tracking.
62 | // See https://sendgrid.com/docs/User_Guide/Settings/tracking.html
63 | msg.SetClickTracking(false, false);
64 |
65 | return client.SendEmailAsync(msg);
66 | }
67 | else
68 | {
69 | Console.WriteLine($"Mail sending is disabled due to missing API-Key for sendgrid (email: ${email}, subject: ${subject})");
70 | return Task.CompletedTask;
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Views/Explorer/Index.cshtml:
--------------------------------------------------------------------------------
1 | @using Opc.Ua.Cloud.Library.Components.Pages
2 | @using Azure.Core
3 | @using Microsoft.AspNetCore.Http
4 | @{
5 | ViewData["Title"] = "Explorer";
6 | }
7 |
8 | @(await Html.RenderComponentAsync(RenderMode.ServerPrerendered).ConfigureAwait(false))
9 |
10 | @section Scripts{
11 |
12 |
21 | }
22 |
--------------------------------------------------------------------------------
/UACloudLibraryServer/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 |
2 | @using Opc.Ua.Cloud.Library.Models
3 |
4 | @model ErrorViewModel
5 | @{
6 | ViewData["Title"] = "Error";
7 | }
8 |
9 |