update before switch2

This commit is contained in:
Kim 2023-02-22 14:46:36 +01:00
parent dff51b0d53
commit e76e99d86f
120 changed files with 18925 additions and 25803 deletions

6
.gitignore vendored
View File

@ -1,2 +1,6 @@
/typescript/Frontend/node_modules /typescript/Frontend/node_modules
/typescript/Frontend/node_modules/* /typescript/Frontend/node_modules/*
*/Debug/*
*/Release/*
*/db.sqlite
*/*.fossil

View File

@ -1477,88 +1477,92 @@
<DasType>varchar|0s</DasType> <DasType>varchar|0s</DasType>
<Position>8</Position> <Position>8</Position>
</column> </column>
<index id="527" parent="485" name="User_Email"> <column id="527" parent="485" name="S3Key">
<DasType>varchar|0s</DasType>
<Position>9</Position>
</column>
<index id="528" parent="485" name="User_Email">
<ColNames>Email</ColNames> <ColNames>Email</ColNames>
</index> </index>
<index id="528" parent="485" name="User_ParentId"> <index id="529" parent="485" name="User_ParentId">
<ColNames>ParentId</ColNames> <ColNames>ParentId</ColNames>
</index> </index>
<key id="529" parent="485"> <key id="530" parent="485">
<ColNames>Id</ColNames> <ColNames>Id</ColNames>
<Primary>1</Primary> <Primary>1</Primary>
</key> </key>
<column id="530" parent="486" name="UserId"> <column id="531" parent="486" name="UserId">
<DasType>integer|0s</DasType> <DasType>integer|0s</DasType>
<Position>1</Position> <Position>1</Position>
</column> </column>
<column id="531" parent="486" name="FolderId"> <column id="532" parent="486" name="FolderId">
<DasType>integer|0s</DasType> <DasType>integer|0s</DasType>
<Position>2</Position> <Position>2</Position>
</column> </column>
<column id="532" parent="486" name="Id"> <column id="533" parent="486" name="Id">
<AutoIncrement>1</AutoIncrement> <AutoIncrement>1</AutoIncrement>
<DasType>integer|0s</DasType> <DasType>integer|0s</DasType>
<NotNull>1</NotNull> <NotNull>1</NotNull>
<Position>3</Position> <Position>3</Position>
</column> </column>
<index id="533" parent="486" name="User2Folder_UserId"> <index id="534" parent="486" name="User2Folder_UserId">
<ColNames>UserId</ColNames> <ColNames>UserId</ColNames>
</index> </index>
<index id="534" parent="486" name="User2Folder_FolderId"> <index id="535" parent="486" name="User2Folder_FolderId">
<ColNames>FolderId</ColNames> <ColNames>FolderId</ColNames>
</index> </index>
<key id="535" parent="486"> <key id="536" parent="486">
<ColNames>Id</ColNames> <ColNames>Id</ColNames>
<Primary>1</Primary> <Primary>1</Primary>
</key> </key>
<column id="536" parent="487" name="UserId"> <column id="537" parent="487" name="UserId">
<DasType>integer|0s</DasType> <DasType>integer|0s</DasType>
<Position>1</Position> <Position>1</Position>
</column> </column>
<column id="537" parent="487" name="InstallationId"> <column id="538" parent="487" name="InstallationId">
<DasType>integer|0s</DasType> <DasType>integer|0s</DasType>
<Position>2</Position> <Position>2</Position>
</column> </column>
<column id="538" parent="487" name="Id"> <column id="539" parent="487" name="Id">
<AutoIncrement>1</AutoIncrement> <AutoIncrement>1</AutoIncrement>
<DasType>integer|0s</DasType> <DasType>integer|0s</DasType>
<NotNull>1</NotNull> <NotNull>1</NotNull>
<Position>3</Position> <Position>3</Position>
</column> </column>
<index id="539" parent="487" name="User2Installation_UserId"> <index id="540" parent="487" name="User2Installation_UserId">
<ColNames>UserId</ColNames> <ColNames>UserId</ColNames>
</index> </index>
<index id="540" parent="487" name="User2Installation_InstallationId"> <index id="541" parent="487" name="User2Installation_InstallationId">
<ColNames>InstallationId</ColNames> <ColNames>InstallationId</ColNames>
</index> </index>
<key id="541" parent="487"> <key id="542" parent="487">
<ColNames>Id</ColNames> <ColNames>Id</ColNames>
<Primary>1</Primary> <Primary>1</Primary>
</key> </key>
<column id="542" parent="488" name="type"> <column id="543" parent="488" name="type">
<DasType>TEXT|0s</DasType> <DasType>TEXT|0s</DasType>
<Position>1</Position> <Position>1</Position>
</column> </column>
<column id="543" parent="488" name="name"> <column id="544" parent="488" name="name">
<DasType>TEXT|0s</DasType> <DasType>TEXT|0s</DasType>
<Position>2</Position> <Position>2</Position>
</column> </column>
<column id="544" parent="488" name="tbl_name"> <column id="545" parent="488" name="tbl_name">
<DasType>TEXT|0s</DasType> <DasType>TEXT|0s</DasType>
<Position>3</Position> <Position>3</Position>
</column> </column>
<column id="545" parent="488" name="rootpage"> <column id="546" parent="488" name="rootpage">
<DasType>INT|0s</DasType> <DasType>INT|0s</DasType>
<Position>4</Position> <Position>4</Position>
</column> </column>
<column id="546" parent="488" name="sql"> <column id="547" parent="488" name="sql">
<DasType>TEXT|0s</DasType> <DasType>TEXT|0s</DasType>
<Position>5</Position> <Position>5</Position>
</column> </column>
<column id="547" parent="489" name="name"> <column id="548" parent="489" name="name">
<Position>1</Position> <Position>1</Position>
</column> </column>
<column id="548" parent="489" name="seq"> <column id="549" parent="489" name="seq">
<Position>2</Position> <Position>2</Position>
</column> </column>
</database-model> </database-model>

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
16769606177554988 16769731911267901

View File

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Flurl.Http" Version="3.2.4" />
<PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.3" /> <PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.3" />
<PackageReference Include="Microsoft.AspNet.Identity.Owin" Version="2.2.3" /> <PackageReference Include="Microsoft.AspNet.Identity.Owin" Version="2.2.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" /> <PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" />
@ -26,6 +27,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AWSSDK.Core">
<HintPath>..\..\..\..\..\..\.nuget\packages\awssdk.core\3.7.8.10\lib\netcoreapp3.1\AWSSDK.Core.dll</HintPath>
</Reference>
<Reference Include="SQLite-net"> <Reference Include="SQLite-net">
<HintPath>..\..\..\..\..\.nuget\packages\sqlite-net-pcl\1.8.116\lib\netstandard2.0\SQLite-net.dll</HintPath> <HintPath>..\..\..\..\..\.nuget\packages\sqlite-net-pcl\1.8.116\lib\netstandard2.0\SQLite-net.dll</HintPath>
</Reference> </Reference>

View File

@ -23,8 +23,8 @@ public class Controller
usernamepass.TryGetProperty("password", out var pwd); usernamepass.TryGetProperty("password", out var pwd);
var username = usr.ToString(); var username = usr.ToString();
var password = pwd.ToString(); var password = pwd.ToString();
if (username is null || password is null) if (username is null || username == "" || password == "" || password is null)
return new HttpResponseMessage(HttpStatusCode.BadRequest); return new HttpResponseMessage(HttpStatusCode.BadRequest);
using var db = Db.Connect(); using var db = Db.Connect();
@ -58,6 +58,19 @@ public class Controller
return db.DeleteSession(currentUser.Id); return db.DeleteSession(currentUser.Id);
} }
[ProducesResponseType(200)]
[ProducesResponseType(401)]
[HttpPost($"{nameof(UpdateS3Creds)}")]
public Object UpdateS3Creds()
{
var ctxAccessor = new HttpContextAccessor();
var ctx = ctxAccessor.HttpContext;
using var db = Db.Connect();
var currentUser = (User)ctx!.Items["User"]!;
return db.CreateAndSaveUserS3ApiKey(currentUser);
}
[ProducesResponseType(200)] [ProducesResponseType(200)]
[ProducesResponseType(401)] [ProducesResponseType(401)]

View File

@ -89,9 +89,10 @@ public partial class Db : IDisposable
public IEnumerable<Installation> GetAllAccessibleInstallations(User user) public IEnumerable<Installation> GetAllAccessibleInstallations(User user)
{ {
var direct = GetDirectlyAccessibleInstallations(user); var direct = GetDirectlyAccessibleInstallations(user).ToList();
var fromFolders = GetAllAccessibleFolders(user) var fromFolders = GetAllAccessibleFolders(user)
.SelectMany(GetChildInstallations); .SelectMany(GetChildInstallations)
.Except(direct);
return direct.Concat(fromFolders); return direct.Concat(fromFolders);
} }

View File

@ -1,7 +1,13 @@
using System.Net;
using System.Net.Mail; using System.Net.Mail;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.Json;
using Backend.Model; using Backend.Model;
using Backend.Utils; using Backend.Utils;
using Flurl.Http;
using InnovEnergy.Lib.Utils;
using Microsoft.AspNetCore.DataProtection;
using SQLite; using SQLite;
#pragma warning disable CS0472 #pragma warning disable CS0472
#pragma warning disable CS8602 #pragma warning disable CS8602
@ -52,6 +58,48 @@ public partial class Db
return Create(user); return Create(user);
} }
public Object CreateAndSaveUserS3ApiKey(User user)
{
//EXOSCALE API URL
const String url = "https://api-ch-dk-2.exoscale.com/v2/access-key";
const String secret = "S2K1okphiCSNK4mzqr4swguFzngWAMb1OoSlZsJa9F0";
const String apiKey = "EXOb98ec9008e3ec16e19d7b593";
var payload = new
{ name = user.Email,
operations = new List<String> {"getObject", "listBucket"},
content = new List<Object>{}};
var installationIdList = User2Installation
.Where(i => i.UserId == user.Id)
.SelectMany(i => Installations.Where(f => i.InstallationId == f.Id))
.ToList();
foreach (var installation in installationIdList)
{
payload.content.Add(new {domain = "sos", resource_type = "bucket", resource_name = installation.Name}); //TODO CHANGE NAME TO S3BUCKET
}
using var hmacSha1 = new HMACSHA1(Encoding.UTF8.GetBytes(secret));
var signature = Encoding.UTF8
.GetBytes(payload.ToString())
.Apply(hmacSha1.ComputeHash)
.Apply(Convert.ToBase64String);
var keyJson = url
.WithHeader("Authorization", $"POST {apiKey};{signature}")
.PostJsonAsync(payload)
.ReceiveJson()
.Result;
return SetUserS3ApiKey(user, keyJson.GetValue("key"));
}
public Result SetUserS3ApiKey(User user,String key)
{
user.S3Key = key;
return Update(user);
}
public Result UpdateUser(User user) public Result UpdateUser(User user)
{ {
var oldUser = GetUserById(user.Id); var oldUser = GetUserById(user.Id);
@ -96,5 +144,6 @@ public partial class Db
} }
} }

View File

@ -9,7 +9,24 @@ public abstract class TreeNode
public Int64 Id { get; set; } public Int64 Id { get; set; }
public String Name { get; set; } = ""; public String Name { get; set; } = "";
public String Information { get; set; } = ""; // unstructured random info public String Information { get; set; } = ""; // unstructured random info
protected Boolean Equals(TreeNode other)
{
return Id == other.Id && ParentId == other.ParentId;
}
public override Boolean Equals(Object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == this.GetType() && Equals((TreeNode)obj);
}
public override Int32 GetHashCode()
{
return HashCode.Combine(Id, ParentId);
}
[Indexed] // parent/child relation [Indexed] // parent/child relation
public Int64 ParentId { get; set; } public Int64 ParentId { get; set; }

View File

@ -7,6 +7,7 @@ public class User : TreeNode
[Indexed] [Indexed]
public String Email { get; set; } = ""; public String Email { get; set; } = "";
public Boolean HasWriteAccess { get; set; } public Boolean HasWriteAccess { get; set; }
public String S3Key { get; set; }
public String Salt { get; set; } public String Salt { get; set; }
public String Password { get; set; } public String Password { get; set; }

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
".NETCoreApp,Version=v6.0": { ".NETCoreApp,Version=v6.0": {
"Backend/1.0.0": { "Backend/1.0.0": {
"dependencies": { "dependencies": {
"Flurl.Http": "3.2.4",
"Microsoft.AspNet.Identity.Core": "2.2.3", "Microsoft.AspNet.Identity.Core": "2.2.3",
"Microsoft.AspNet.Identity.Owin": "2.2.3", "Microsoft.AspNet.Identity.Owin": "2.2.3",
"Microsoft.AspNet.WebApi.Core": "5.2.9", "Microsoft.AspNet.WebApi.Core": "5.2.9",
@ -24,7 +25,8 @@
"Swashbuckle.AspNetCore.Filters.Abstractions": "7.0.6", "Swashbuckle.AspNetCore.Filters.Abstractions": "7.0.6",
"WebServer": "1.0.0", "WebServer": "1.0.0",
"sqlite-net-pcl": "1.8.116", "sqlite-net-pcl": "1.8.116",
"sqlite-net-sqlcipher": "1.9.141-beta" "sqlite-net-sqlcipher": "1.9.141-beta",
"AWSSDK.Core": "3.3.0.0"
}, },
"runtime": { "runtime": {
"Backend.dll": {} "Backend.dll": {}
@ -108,24 +110,24 @@
} }
} }
}, },
"Flurl/3.0.1": { "Flurl/3.0.6": {
"runtime": { "runtime": {
"lib/netstandard2.0/Flurl.dll": { "lib/netstandard2.0/Flurl.dll": {
"assemblyVersion": "3.0.1.0", "assemblyVersion": "3.0.6.0",
"fileVersion": "3.0.1.0" "fileVersion": "3.0.6.0"
} }
} }
}, },
"Flurl.Http/3.0.1": { "Flurl.Http/3.2.4": {
"dependencies": { "dependencies": {
"Flurl": "3.0.1", "Flurl": "3.0.6",
"Newtonsoft.Json": "12.0.2", "Newtonsoft.Json": "12.0.2",
"System.Text.Encoding.CodePages": "4.5.1" "System.Text.Encoding.CodePages": "4.5.1"
}, },
"runtime": { "runtime": {
"lib/netstandard2.0/Flurl.Http.dll": { "lib/netstandard2.0/Flurl.Http.dll": {
"assemblyVersion": "3.0.1.0", "assemblyVersion": "3.2.4.0",
"fileVersion": "3.0.1.0" "fileVersion": "3.2.4.0"
} }
} }
}, },
@ -1823,14 +1825,22 @@
}, },
"WebServer/1.0.0": { "WebServer/1.0.0": {
"dependencies": { "dependencies": {
"Flurl": "3.0.1", "Flurl": "3.0.6",
"Flurl.Http": "3.0.1", "Flurl.Http": "3.2.4",
"System.Reactive.Linq": "5.0.0", "System.Reactive.Linq": "5.0.0",
"Utils": "1.0.0" "Utils": "1.0.0"
}, },
"runtime": { "runtime": {
"WebServer.dll": {} "WebServer.dll": {}
} }
},
"AWSSDK.Core/3.3.0.0": {
"runtime": {
"AWSSDK.Core.dll": {
"assemblyVersion": "3.3.0.0",
"fileVersion": "3.7.8.10"
}
}
} }
} }
}, },
@ -1882,19 +1892,19 @@
"path": "decimalmath.decimalex/1.0.2", "path": "decimalmath.decimalex/1.0.2",
"hashPath": "decimalmath.decimalex.1.0.2.nupkg.sha512" "hashPath": "decimalmath.decimalex.1.0.2.nupkg.sha512"
}, },
"Flurl/3.0.1": { "Flurl/3.0.6": {
"type": "package", "type": "package",
"serviceable": true, "serviceable": true,
"sha512": "sha512-i7CuPSikVroBaWG8sPvO707Ex9C6BP5+r4JufKNU1FGMmiFgLJvNo1ttUg6ZiXIzUNknvIb1VUTIO9iEDucibg==", "sha512": "sha512-XMIlB/tJ4nTYF2+79xDsnnlgbXHpKyizKX2fffrECekI6pEsa9MSLzf5tPVMdLy4k4AcJPLs356Sa2Le5VRDCw==",
"path": "flurl/3.0.1", "path": "flurl/3.0.6",
"hashPath": "flurl.3.0.1.nupkg.sha512" "hashPath": "flurl.3.0.6.nupkg.sha512"
}, },
"Flurl.Http/3.0.1": { "Flurl.Http/3.2.4": {
"type": "package", "type": "package",
"serviceable": true, "serviceable": true,
"sha512": "sha512-wt4RrmYOPWu8v0sjuuSfhYBFzjfrCz4nJP48Kw2HFGssq0U6pMBPFHcL3zbsBFALJipAjgRET5mf+0Xz4ZnZpQ==", "sha512": "sha512-Me9Vm4Lm21vt/pbR0G2Dww/ZOjJgh6mB2FiH28aiUYStJD10ZecDp8jxg2zKxcy6lnkvLm99pjG4yC/k7a/d8w==",
"path": "flurl.http/3.0.1", "path": "flurl.http/3.2.4",
"hashPath": "flurl.http.3.0.1.nupkg.sha512" "hashPath": "flurl.http.3.2.4.nupkg.sha512"
}, },
"Microsoft.AspNet.Cors/5.0.0": { "Microsoft.AspNet.Cors/5.0.0": {
"type": "package", "type": "package",
@ -3123,6 +3133,11 @@
"type": "project", "type": "project",
"serviceable": false, "serviceable": false,
"sha512": "" "sha512": ""
},
"AWSSDK.Core/3.3.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
} }
} }
} }

Binary file not shown.

Binary file not shown.

View File

@ -42,6 +42,10 @@
"net6.0": { "net6.0": {
"targetAlias": "net6.0", "targetAlias": "net6.0",
"dependencies": { "dependencies": {
"Flurl.Http": {
"target": "Package",
"version": "[3.2.4, )"
},
"Microsoft.AspNet.Identity.Core": { "Microsoft.AspNet.Identity.Core": {
"target": "Package", "target": "Package",
"version": "[2.2.3, )" "version": "[2.2.3, )"

View File

@ -1 +1 @@
0ab5225c4cc41cf94cee403f98b2900d6f369d86 7da5f9a9c2b3b0c732309c09777d2f7e8e62e6a6

View File

@ -208,3 +208,6 @@
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/net6.0/System.Security.Cryptography.Pkcs.dll /home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/net6.0/System.Security.Cryptography.Pkcs.dll
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll /home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/DecimalEx.dll /home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/DecimalEx.dll
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/AWSSDK.Core.dll
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/AWSSDK.Core.pdb
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/AWSSDK.Core.xml

View File

@ -110,34 +110,34 @@
} }
} }
}, },
"Flurl/3.0.1": { "Flurl/3.0.6": {
"type": "package", "type": "package",
"compile": { "compile": {
"lib/netstandard2.0/Flurl.dll": { "lib/netstandard2.0/Flurl.dll": {
"related": ".pdb;.xml" "related": ".xml"
} }
}, },
"runtime": { "runtime": {
"lib/netstandard2.0/Flurl.dll": { "lib/netstandard2.0/Flurl.dll": {
"related": ".pdb;.xml" "related": ".xml"
} }
} }
}, },
"Flurl.Http/3.0.1": { "Flurl.Http/3.2.4": {
"type": "package", "type": "package",
"dependencies": { "dependencies": {
"Flurl": "3.0.1", "Flurl": "3.0.6",
"Newtonsoft.Json": "12.0.2", "Newtonsoft.Json": "12.0.2",
"System.Text.Encoding.CodePages": "4.5.1" "System.Text.Encoding.CodePages": "4.5.1"
}, },
"compile": { "compile": {
"lib/netstandard2.0/Flurl.Http.dll": { "lib/netstandard2.0/Flurl.Http.dll": {
"related": ".pdb" "related": ".xml"
} }
}, },
"runtime": { "runtime": {
"lib/netstandard2.0/Flurl.Http.dll": { "lib/netstandard2.0/Flurl.Http.dll": {
"related": ".pdb" "related": ".xml"
} }
} }
}, },
@ -3313,40 +3313,40 @@
"lib/netstandard2.0/DecimalEx.xml" "lib/netstandard2.0/DecimalEx.xml"
] ]
}, },
"Flurl/3.0.1": { "Flurl/3.0.6": {
"sha512": "i7CuPSikVroBaWG8sPvO707Ex9C6BP5+r4JufKNU1FGMmiFgLJvNo1ttUg6ZiXIzUNknvIb1VUTIO9iEDucibg==", "sha512": "XMIlB/tJ4nTYF2+79xDsnnlgbXHpKyizKX2fffrECekI6pEsa9MSLzf5tPVMdLy4k4AcJPLs356Sa2Le5VRDCw==",
"type": "package", "type": "package",
"path": "flurl/3.0.1", "path": "flurl/3.0.6",
"files": [ "files": [
".nupkg.metadata", ".nupkg.metadata",
".signature.p7s", ".signature.p7s",
"flurl.3.0.1.nupkg.sha512", "flurl.3.0.6.nupkg.sha512",
"flurl.nuspec", "flurl.nuspec",
"icon.png", "icon.png",
"lib/net461/Flurl.dll", "lib/net461/Flurl.dll",
"lib/net461/Flurl.pdb",
"lib/net461/Flurl.xml", "lib/net461/Flurl.xml",
"lib/net472/Flurl.dll",
"lib/net472/Flurl.xml",
"lib/netstandard2.0/Flurl.dll", "lib/netstandard2.0/Flurl.dll",
"lib/netstandard2.0/Flurl.pdb",
"lib/netstandard2.0/Flurl.xml" "lib/netstandard2.0/Flurl.xml"
] ]
}, },
"Flurl.Http/3.0.1": { "Flurl.Http/3.2.4": {
"sha512": "wt4RrmYOPWu8v0sjuuSfhYBFzjfrCz4nJP48Kw2HFGssq0U6pMBPFHcL3zbsBFALJipAjgRET5mf+0Xz4ZnZpQ==", "sha512": "Me9Vm4Lm21vt/pbR0G2Dww/ZOjJgh6mB2FiH28aiUYStJD10ZecDp8jxg2zKxcy6lnkvLm99pjG4yC/k7a/d8w==",
"type": "package", "type": "package",
"path": "flurl.http/3.0.1", "path": "flurl.http/3.2.4",
"files": [ "files": [
".nupkg.metadata", ".nupkg.metadata",
".signature.p7s", ".signature.p7s",
"flurl.http.3.0.1.nupkg.sha512", "flurl.http.3.2.4.nupkg.sha512",
"flurl.http.nuspec", "flurl.http.nuspec",
"icon.png", "icon.png",
"lib/net461/Flurl.Http.dll", "lib/net461/Flurl.Http.dll",
"lib/net461/Flurl.Http.pdb", "lib/net461/Flurl.Http.xml",
"lib/net461/Flurl.xml", "lib/net472/Flurl.Http.dll",
"lib/net472/Flurl.Http.xml",
"lib/netstandard2.0/Flurl.Http.dll", "lib/netstandard2.0/Flurl.Http.dll",
"lib/netstandard2.0/Flurl.Http.pdb", "lib/netstandard2.0/Flurl.Http.xml"
"lib/netstandard2.0/Flurl.xml"
] ]
}, },
"Microsoft.AspNet.Cors/5.0.0": { "Microsoft.AspNet.Cors/5.0.0": {
@ -8876,6 +8876,7 @@
}, },
"projectFileDependencyGroups": { "projectFileDependencyGroups": {
"net6.0": [ "net6.0": [
"Flurl.Http >= 3.2.4",
"Microsoft.AspNet.Identity.Core >= 2.2.3", "Microsoft.AspNet.Identity.Core >= 2.2.3",
"Microsoft.AspNet.Identity.Owin >= 2.2.3", "Microsoft.AspNet.Identity.Owin >= 2.2.3",
"Microsoft.AspNet.WebApi.Core >= 5.2.9", "Microsoft.AspNet.WebApi.Core >= 5.2.9",
@ -8936,6 +8937,10 @@
"net6.0": { "net6.0": {
"targetAlias": "net6.0", "targetAlias": "net6.0",
"dependencies": { "dependencies": {
"Flurl.Http": {
"target": "Package",
"version": "[3.2.4, )"
},
"Microsoft.AspNet.Identity.Core": { "Microsoft.AspNet.Identity.Core": {
"target": "Package", "target": "Package",
"version": "[2.2.3, )" "version": "[2.2.3, )"

View File

@ -1,6 +1,6 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "MdRskQtEzVoDz9Sm7iAX4BseowH8RQwBYdJ5zAQHKrlwu1lEHilXUBfKGcTAJ2MpQBrppgcAwKnwTyQJuU6q3Q==", "dgSpecHash": "1RbPp0FEU5KEAhKC3sKKqtzItTMT7Hl8P876cSQLAmvYjhxsYlAjV776Uk2Gh6OMCI2eEoIB6g3d6Cj4SAdSJg==",
"success": true, "success": true,
"projectFilePath": "/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj", "projectFilePath": "/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [
@ -10,8 +10,8 @@
"/home/kim/.nuget/packages/azure.security.keyvault.secrets/4.1.0/azure.security.keyvault.secrets.4.1.0.nupkg.sha512", "/home/kim/.nuget/packages/azure.security.keyvault.secrets/4.1.0/azure.security.keyvault.secrets.4.1.0.nupkg.sha512",
"/home/kim/.nuget/packages/cliwrap/3.3.1/cliwrap.3.3.1.nupkg.sha512", "/home/kim/.nuget/packages/cliwrap/3.3.1/cliwrap.3.3.1.nupkg.sha512",
"/home/kim/.nuget/packages/decimalmath.decimalex/1.0.2/decimalmath.decimalex.1.0.2.nupkg.sha512", "/home/kim/.nuget/packages/decimalmath.decimalex/1.0.2/decimalmath.decimalex.1.0.2.nupkg.sha512",
"/home/kim/.nuget/packages/flurl/3.0.1/flurl.3.0.1.nupkg.sha512", "/home/kim/.nuget/packages/flurl/3.0.6/flurl.3.0.6.nupkg.sha512",
"/home/kim/.nuget/packages/flurl.http/3.0.1/flurl.http.3.0.1.nupkg.sha512", "/home/kim/.nuget/packages/flurl.http/3.2.4/flurl.http.3.2.4.nupkg.sha512",
"/home/kim/.nuget/packages/microsoft.aspnet.cors/5.0.0/microsoft.aspnet.cors.5.0.0.nupkg.sha512", "/home/kim/.nuget/packages/microsoft.aspnet.cors/5.0.0/microsoft.aspnet.cors.5.0.0.nupkg.sha512",
"/home/kim/.nuget/packages/microsoft.aspnet.identity.core/2.2.3/microsoft.aspnet.identity.core.2.2.3.nupkg.sha512", "/home/kim/.nuget/packages/microsoft.aspnet.identity.core/2.2.3/microsoft.aspnet.identity.core.2.2.3.nupkg.sha512",
"/home/kim/.nuget/packages/microsoft.aspnet.identity.owin/2.2.3/microsoft.aspnet.identity.owin.2.2.3.nupkg.sha512", "/home/kim/.nuget/packages/microsoft.aspnet.identity.owin/2.2.3/microsoft.aspnet.identity.owin.2.2.3.nupkg.sha512",

View File

@ -1 +1 @@
"restore":{"projectUniqueName":"/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj","projectName":"Backend","projectPath":"/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj","outputPath":"/home/kim/code/innovenergy/new/csharp/app/Backend/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net6.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net6.0":{"targetAlias":"net6.0","projectReferences":{"/home/kim/code/innovenergy/new/csharp/lib/WebServer/WebServer.csproj":{"projectPath":"/home/kim/code/innovenergy/new/csharp/lib/WebServer/WebServer.csproj"}}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net6.0":{"targetAlias":"net6.0","dependencies":{"Microsoft.AspNet.Identity.Core":{"target":"Package","version":"[2.2.3, )"},"Microsoft.AspNet.Identity.Owin":{"target":"Package","version":"[2.2.3, )"},"Microsoft.AspNet.WebApi.Core":{"target":"Package","version":"[5.2.9, )"},"Microsoft.AspNetCore.Identity":{"target":"Package","version":"[2.2.0, )"},"Microsoft.Extensions.DependencyInjection":{"target":"Package","version":"[7.0.0, )"},"Microsoft.Identity.Web":{"target":"Package","version":"[1.26.0, )"},"Microsoft.Owin.Cors":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Host.SystemWeb":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Security":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Security.Cookies":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Security.OAuth":{"target":"Package","version":"[4.2.2, )"},"Swashbuckle.AspNetCore":{"target":"Package","version":"[6.2.3, )"},"Swashbuckle.AspNetCore.Filters":{"target":"Package","version":"[7.0.6, )"},"Swashbuckle.AspNetCore.Filters.Abstractions":{"target":"Package","version":"[7.0.6, )"},"sqlite-net-pcl":{"target":"Package","version":"[1.8.116, )"},"sqlite-net-sqlcipher":{"target":"Package","version":"[1.9.141-beta, )"}},"imports":["net461","net462","net47","net471","net472","net48"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.AspNetCore.App":{"privateAssets":"none"},"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/usr/lib/dotnet/sdk/6.0.113/RuntimeIdentifierGraph.json"}} "restore":{"projectUniqueName":"/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj","projectName":"Backend","projectPath":"/home/kim/code/innovenergy/new/csharp/app/Backend/Backend.csproj","outputPath":"/home/kim/code/innovenergy/new/csharp/app/Backend/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net6.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net6.0":{"targetAlias":"net6.0","projectReferences":{"/home/kim/code/innovenergy/new/csharp/lib/WebServer/WebServer.csproj":{"projectPath":"/home/kim/code/innovenergy/new/csharp/lib/WebServer/WebServer.csproj"}}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net6.0":{"targetAlias":"net6.0","dependencies":{"Flurl.Http":{"target":"Package","version":"[3.2.4, )"},"Microsoft.AspNet.Identity.Core":{"target":"Package","version":"[2.2.3, )"},"Microsoft.AspNet.Identity.Owin":{"target":"Package","version":"[2.2.3, )"},"Microsoft.AspNet.WebApi.Core":{"target":"Package","version":"[5.2.9, )"},"Microsoft.AspNetCore.Identity":{"target":"Package","version":"[2.2.0, )"},"Microsoft.Extensions.DependencyInjection":{"target":"Package","version":"[7.0.0, )"},"Microsoft.Identity.Web":{"target":"Package","version":"[1.26.0, )"},"Microsoft.Owin.Cors":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Host.SystemWeb":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Security":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Security.Cookies":{"target":"Package","version":"[4.2.2, )"},"Microsoft.Owin.Security.OAuth":{"target":"Package","version":"[4.2.2, )"},"Swashbuckle.AspNetCore":{"target":"Package","version":"[6.2.3, )"},"Swashbuckle.AspNetCore.Filters":{"target":"Package","version":"[7.0.6, )"},"Swashbuckle.AspNetCore.Filters.Abstractions":{"target":"Package","version":"[7.0.6, )"},"sqlite-net-pcl":{"target":"Package","version":"[1.8.116, )"},"sqlite-net-sqlcipher":{"target":"Package","version":"[1.9.141-beta, )"}},"imports":["net461","net462","net47","net471","net472","net48"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.AspNetCore.App":{"privateAssets":"none"},"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/usr/lib/dotnet/sdk/6.0.113/RuntimeIdentifierGraph.json"}}

View File

@ -1 +1 @@
16769606178754984 16769731911787900

View File

@ -3,3 +3,10 @@
2.0 2.0
2.0 2.0
2.0 2.0
2.0
2.0
2.0
2.0
2.0
2.0
2.0

View File

@ -1 +1 @@
16769606177514988 16769731911227901

View File

@ -1 +1 @@
16769606177474988 16769731911227901

View File

@ -1 +1 @@
16769606177474988 16769731911227901

View File

@ -1 +1 @@
16769606177434988 16769731911227901

View File

@ -1 +1 @@
16769606177474988 16769731911187901

View File

@ -1 +1 @@
16769606177434988 16769731911227901

View File

@ -1 +1 @@
16769606177514988 16769731911227901

View File

@ -1 +1 @@
16769606177554988 16769731911227901

View File

@ -1 +1 @@
16769606177474988 16769731911267901

View File

@ -1 +1 @@
16769606177594988 16769731911227901

View File

@ -1 +1 @@
16769606177674987 16769731911227901

View File

@ -69,9 +69,9 @@ public record S3Config
// CanonicalizedAmzHeaders + // CanonicalizedAmzHeaders +
// CanonicalizedResource; // CanonicalizedResource;
var payload = $"{method}\n{md5Hash}\n{contentType}\n{date}\n/{bucket.Trim('/')}/{s3Path.Trim('/')}"; var payload = $"{method}\n{md5Hash}\n{contentType}\n{date}\n/{bucket.Trim('/')}/{s3Path.Trim('/')}";
using var hmacSha1 = new HMACSHA1(UTF8.GetBytes(s3Secret)); using var hmacSha1 = new HMACSHA1(UTF8.GetBytes(s3Secret));
var signature = UTF8 var signature = UTF8
.GetBytes(payload) .GetBytes(payload)
.Apply(hmacSha1.ComputeHash) .Apply(hmacSha1.ComputeHash)

View File

@ -1 +1 @@
16769606177554988 16769731911187901

View File

@ -1 +1 @@
16769606177514988 16769731911187901

View File

@ -1 +1 @@
16769606177594988 16769731911187901

View File

@ -1 +1 @@
16769606177514988 16769731911187901

View File

@ -1 +1 @@
16769606177474988 16769731911187901

View File

@ -1 +1 @@
16769606177594988 16769731911107901

View File

@ -1 +1 @@
16769606177554988 16769731911067902

View File

@ -1 +1 @@
16769606177554988 16769731911107901

View File

@ -1 +1 @@
16769606177594988 16769731911067902

View File

@ -1 +1 @@
16769606177594988 16769731911067902

View File

@ -1 +1 @@
16769606177634987 16769731911107901

View File

@ -1 +1 @@
16758719413202651 16769731911107901

View File

@ -1 +1 @@
16769606177554988 16769731911187901

View File

@ -1 +1 @@
16769606178234985 16769731911507901

View File

@ -1 +1 @@
16769606177474988 16769731911107901

View File

@ -3,8 +3,7 @@ using InnovEnergy.Lib.StatusApi.Phases;
namespace InnovEnergy.Lib.StatusApi.Connections; namespace InnovEnergy.Lib.StatusApi.Connections;
public class DcConnection : Phase public record DcConnection(Decimal Voltage, Decimal Current) : Phase(Voltage, Current)
{ {
public static DcConnection Null { get; } = new DcConnection();
public Decimal Power => Current * Voltage; public Decimal Power => Current * Voltage;
} }

View File

@ -2,9 +2,11 @@ using InnovEnergy.Lib.StatusApi.Phases;
namespace InnovEnergy.Lib.StatusApi.Connections; namespace InnovEnergy.Lib.StatusApi.Connections;
public class SinglePhaseAcConnection : AcPhase public record SinglePhaseAcConnection
{ (
public Decimal Frequency { get; init; } Decimal Voltage,
Decimal Current,
public new static SinglePhaseAcConnection Null = new SinglePhaseAcConnection(); Decimal Phi,
} Decimal Frequency
)
: AcPhase(Voltage, Current, Phi);

View File

@ -2,18 +2,9 @@ using InnovEnergy.Lib.StatusApi.Phases;
namespace InnovEnergy.Lib.StatusApi.Connections; namespace InnovEnergy.Lib.StatusApi.Connections;
public class ThreePhaseAcConnection public record ThreePhaseAcConnection(AcPhase L1, AcPhase L2, AcPhase L3, Decimal Frequency)
{ {
public static ThreePhaseAcConnection Null { get; } = new ThreePhaseAcConnection();
public AcPhase L1 { get; init; } = AcPhase.Null;
public AcPhase L2 { get; init; } = AcPhase.Null;
public AcPhase L3 { get; init; } = AcPhase.Null;
public Decimal Frequency { get; init; }
public Decimal ApparentPower => L1.ApparentPower + L2.ApparentPower + L3.ApparentPower; public Decimal ApparentPower => L1.ApparentPower + L2.ApparentPower + L3.ApparentPower;
public Decimal ReactivePower => L1.ReactivePower + L2.ReactivePower + L3.ReactivePower; public Decimal ReactivePower => L1.ReactivePower + L2.ReactivePower + L3.ReactivePower;
public Decimal ActivePower => L1.ActivePower + L2.ActivePower + L3.ActivePower; public Decimal ActivePower => L1.ActivePower + L2.ActivePower + L3.ActivePower;
} }

View File

@ -1,8 +1,12 @@
using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class Battery : DcDevice public abstract record Battery
{ (
public Decimal Soc { get; init; } DcConnection Dc,
public Decimal Temperature { get; init; } Decimal Soc,
} Decimal Temperature
)
: DcDevice(Dc);

View File

@ -2,8 +2,9 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class DcDcConverter : Device public abstract record DcDcConverter
{ (
public DcConnection Left { get; init; } = DcConnection.Null; DcConnection Left,
public DcConnection Right { get; init; } = DcConnection.Null; DcConnection Right
} )
: Device;

View File

@ -2,7 +2,4 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class DcDevice : Device public abstract record DcDevice(DcConnection Dc) : Device;
{
public DcConnection Dc { get; init; } = DcConnection.Null;
}

View File

@ -1,16 +1,16 @@
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class Device public abstract record Device
{ {
public String DeviceType public String DeviceType
{ {
get get
{ {
var t = GetType(); var t = GetType();
while (!t!.IsAbstract) while (!t!.IsAbstract)
t = t.BaseType; t = t.BaseType;
return t.Name; return t.Name;
} }
} }

View File

@ -1,7 +1,5 @@
using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract record GridMeter(ThreePhaseAcConnection Ac) : ThreePhaseAcDevice(Ac);
public abstract class GridMeter : ThreePhaseAcDevice
{
}

View File

@ -2,7 +2,9 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class Mppt : DcDevice, IPvCoupledDevice public abstract record Mppt
{ (
public IReadOnlyList<DcConnection> Strings { get; init; } = ArraySegment<DcConnection>.Empty; DcConnection Dc,
} IReadOnlyList<DcConnection> Strings
)
: DcDevice(Dc), IPvCoupledDevice;

View File

@ -3,7 +3,4 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class SinglePhaseAcDevice : Device public abstract record SinglePhaseAcDevice(SinglePhaseAcConnection Ac) : Device;
{
public SinglePhaseAcConnection Ac { get; init; } = SinglePhaseAcConnection.Null;
}

View File

@ -2,10 +2,6 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class SinglePhaseInverter public abstract record SinglePhaseInverter(SinglePhaseAcConnection Ac, DcConnection Dc);
{
public SinglePhaseAcConnection Ac { get; init; } = SinglePhaseAcConnection.Null;
public DcConnection Dc { get; init; } = DcConnection.Null;
}

View File

@ -2,7 +2,9 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class SinglePhasePvInverter : SinglePhaseAcDevice, IPvCoupledDevice public abstract record SinglePhasePvInverter
{ (
public IReadOnlyList<DcConnection> Strings { get; init; } = ArraySegment<DcConnection>.Empty; SinglePhaseAcConnection Ac,
} IReadOnlyList<DcConnection> Strings
)
: SinglePhaseAcDevice(Ac), IPvCoupledDevice;

View File

@ -2,7 +2,4 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class ThreePhaseAcDevice: Device public abstract record ThreePhaseAcDevice(ThreePhaseAcConnection Ac) : Device;
{
public ThreePhaseAcConnection Ac { get; init; } = ThreePhaseAcConnection.Null;
}

View File

@ -4,8 +4,9 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class ThreePhaseInverter : Device public abstract record ThreePhaseInverter
{ (
public ThreePhaseAcConnection Ac { get; init; } = ThreePhaseAcConnection.Null; ThreePhaseAcConnection Ac,
public DcConnection Dc { get; init; } = DcConnection.Null; DcConnection Dc
} )
: Device;

View File

@ -2,7 +2,9 @@ using InnovEnergy.Lib.StatusApi.Connections;
namespace InnovEnergy.Lib.StatusApi.Devices; namespace InnovEnergy.Lib.StatusApi.Devices;
public abstract class ThreePhasePvInverter : ThreePhaseAcDevice , IPvCoupledDevice public abstract record ThreePhasePvInverter
{ (
public IReadOnlyList<DcConnection> Strings { get; init; } = ArraySegment<DcConnection>.Empty; ThreePhaseAcConnection Ac,
} IReadOnlyList<DcConnection> Strings
)
: ThreePhaseAcDevice(Ac), IPvCoupledDevice;

View File

@ -1,17 +1,77 @@
using DecimalMath;
using static DecimalMath.DecimalEx; using static DecimalMath.DecimalEx;
namespace InnovEnergy.Lib.StatusApi.Phases; namespace InnovEnergy.Lib.StatusApi.Phases;
public class AcPhase : Phase public record AcPhase
(
Decimal Voltage,
Decimal Current,
Decimal Phi ,
Decimal ApparentPower,
Decimal ActivePower,
Decimal ReactivePower,
Decimal PowerFactor
)
: Phase(Voltage, Current)
{ {
public Decimal Phi { get; init; }
public static AcPhase FromActiveReactive
(
Decimal activePower,
Decimal reactivePower,
Decimal voltage,
Decimal current
)
{
var apparentPower = Sqrt(activePower * activePower + reactivePower * reactivePower);
var phi = ATan2(reactivePower, activePower);
return new AcPhase
(
Voltage: voltage,
Current: current,
Phi: phi,
ApparentPower: apparentPower,
ActivePower: activePower,
ReactivePower: reactivePower,
PowerFactor: Cos(phi)
);
}
public Decimal ApparentPower => Voltage * Current;
public Decimal ReactivePower => ApparentPower * Sin(Phi);
public Decimal ActivePower => ApparentPower * PowerFactor;
public Decimal PowerFactor => Cos(Phi);
internal AcPhase() {} public static AcPhase FromVoltageCurrentPhi(Decimal voltage, Decimal current, Decimal phi)
public static AcPhase Null = new AcPhase(); {
var powerFactor = Cos(phi);
var apparentPower = voltage * current;
var activePower = apparentPower * powerFactor;
var reactivePower = apparentPower * Sin(phi);
return new AcPhase
(
voltage,
current,
phi,
apparentPower,
activePower,
reactivePower,
powerFactor
);
}
//public Decimal ApparentPower => Voltage * Current;
//public Decimal ActivePower => ApparentPower * PowerFactor;
//public Decimal ReactivePower => ApparentPower * Sin(Phi);
//public Decimal PowerFactor => Cos(Phi);
// public Decimal ReactivePower {get; init;}
// public Decimal ApparentPower {get; }
// public Decimal ActivePower {get; }
// public Decimal PowerFactor {get; init;}
} }

View File

@ -5,8 +5,8 @@ namespace InnovEnergy.Lib.StatusApi.Phases;
/// For AC the values have to be in RMS (not amplitude or P2P) /// For AC the values have to be in RMS (not amplitude or P2P)
/// Power can be inferred, P = UI /// Power can be inferred, P = UI
public abstract class Phase public abstract record Phase
{ (
public Decimal Voltage { get; init; } // U, non-negative Decimal Voltage,
public Decimal Current { get; init; } // I, sign depends on device type, see sign convention above Decimal Current
} );

View File

@ -1 +1 @@
16769606177554988 16769731911187901

Some files were not shown because too many files have changed in this diff Show More