Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 797ffd2

Browse files
authored
Merge pull request #15 from bytedreamer/develop
0.1.102 Release
2 parents de7bacf + c9ccd29 commit 797ffd2

20 files changed

Lines changed: 1832 additions & 3192 deletions

File tree

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ variables:
2323
- name: minor
2424
value: 1
2525
- name: patch
26-
value: 101
26+
value: 102
2727
- name: AssemblyVersion
2828
value: $(major).$(minor).$(patch)
2929

setup/Windows/SetupProject/Aporta.wxs

Lines changed: 1194 additions & 2902 deletions
Large diffs are not rendered by default.

setup/Windows/SetupProject/Product.wxs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
33
<Product Id="*" Name="Aporta" Language="1033" Version="!(bind.FileVersion.AportaService)" Manufacturer="Z-bit" UpgradeCode="3155e450-efaf-4294-a12b-097295667284">
44
<Package InstallerVersion="200"
55
Platform="x64"
@@ -10,6 +10,8 @@
1010
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
1111
<MediaTemplate EmbedCab="yes" />
1212

13+
<PropertyRef Id="WIX_ACCOUNT_USERS" />
14+
1315
<Property Id="DOTNETCORE6">0</Property>
1416

1517
<Binary Id="WixCA.dll" SourceFile="$(var.CustomActions.TargetDir)$(var.CustomActions.TargetName).CA.dll" />
@@ -26,7 +28,7 @@
2628
<Custom Action="Check.NetCore" Before="LaunchConditions">NOT Installed</Custom>
2729
</InstallExecuteSequence>
2830

29-
<Feature Id="ProductFeature" Title="Aporta" Level="1">
31+
<Feature Id="ProductFeature" Title="Aporta" Level="1">
3032
<ComponentGroupRef Id="Aporta_Exe" />
3133
<ComponentGroupRef Id="Aporta_Project" />
3234
</Feature>
@@ -79,7 +81,7 @@
7981

8082
<Component Id="Aporta_SetFolderPermissions" Directory="DATAFOLDER" Guid="989FE60B-79C3-4FC9-8CC2-5D3101850576">
8183
<CreateFolder>
82-
<Permission GenericAll="yes" User="Users"/>
84+
<Permission GenericAll="yes" User="[WIX_ACCOUNT_USERS]"/>
8385
</CreateFolder>
8486
</Component>
8587
</ComponentGroup>

setup/Windows/SetupProject/SetupProject.wixproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
4343
</ProjectReference>
4444
</ItemGroup>
45+
<ItemGroup>
46+
<WixExtension Include="WixUtilExtension">
47+
<HintPath>$(WixExtDir)\WixUtilExtension.dll</HintPath>
48+
<Name>WixUtilExtension</Name>
49+
</WixExtension>
50+
</ItemGroup>
4551
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
4652
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
4753
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Data;
2+
using System.Threading.Tasks;
3+
using Dapper;
4+
5+
namespace Aporta.Core.DataAccess.Migrations
6+
{
7+
public class _0009_AddEventTable : IMigration
8+
{
9+
public int Version => 9;
10+
11+
public string Name => "Add Event table";
12+
13+
public async Task PerformUpdate(IDbConnection connection, IDbTransaction transaction)
14+
{
15+
await connection.ExecuteAsync(
16+
@"create table event
17+
(
18+
id integer not null
19+
constraint event_pk
20+
primary key autoincrement,
21+
endpoint_id integer not null
22+
constraint endpoint_id_fk
23+
references endpoint,
24+
timestamp datetime not null,
25+
event_type integer not null,
26+
data text not null
27+
);
28+
29+
create unique index event_id_uindex
30+
on event (id);
31+
32+
create unique index credential_number_uindex
33+
on credential (number);
34+
35+
",
36+
transaction: transaction);
37+
}
38+
}
39+
}

src/Aporta.Core/DataAccess/Repositories/CredentialRepository.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public async Task<AssignedCredential> AssignedCredential(string cardNumber)
6262

6363
if (personAssignment == null)
6464
{
65-
return credential;
65+
return null;
6666
}
6767

6868
var personRepository = new PersonRepository(DataAccess);
@@ -72,7 +72,7 @@ public async Task<AssignedCredential> AssignedCredential(string cardNumber)
7272
return credential;
7373
}
7474

75-
public async Task AssignPerson(int personId, int credentialId)
75+
public async Task AssignPerson(int personId, int credentialId, bool assignmentEnabled)
7676
{
7777
using var connection = DataAccess.CreateDbConnection();
7878
connection.Open();
@@ -82,7 +82,7 @@ await connection.ExecuteAsync(SqlAssignmentInsert,
8282
{
8383
personId,
8484
credentialId,
85-
enabled = true
85+
enabled = assignmentEnabled
8686
});
8787
}
8888
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Aporta.Shared.Models;
2+
3+
namespace Aporta.Core.DataAccess.Repositories;
4+
5+
public class EventRepository : BaseRepository<Event>
6+
{
7+
public EventRepository(IDataAccess dataAccess)
8+
{
9+
DataAccess = dataAccess;
10+
}
11+
12+
protected override IDataAccess DataAccess { get; }
13+
14+
protected override string SqlSelect => @"select event.id,
15+
event.endpoint_id as endpointId,
16+
event.timestamp,
17+
event.event_type as type,
18+
event.data
19+
from event";
20+
21+
protected override string SqlInsert => @"insert into event
22+
(endpoint_id, timestamp, event_type, data) values
23+
(@endpointId, @timestamp, @type, @data)";
24+
25+
protected override string SqlDelete => @"delete from event where id = @id";
26+
27+
protected override object InsertParameters(Event @event)
28+
{
29+
return new
30+
{
31+
endpointId = @event.EndpointId,
32+
timestamp = @event.Timestamp,
33+
type = @event.Type,
34+
data = @event.Data
35+
};
36+
}
37+
38+
protected override void InsertId(Event @event, int id)
39+
{
40+
@event.Id = id;
41+
}
42+
}

src/Aporta.Core/DataAccess/SqLiteDataAccess.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public class SqLiteDataAccess : IDataAccess
2525
new _0005_AddDoorTable(),
2626
new _0006_AddGlobalSettingTable(),
2727
new _0007_AddCredentialTable(),
28-
new _0008_AddPersonTable()
28+
new _0008_AddPersonTable(),
29+
new _0009_AddEventTable()
2930
};
3031

3132
/// <summary>

src/Aporta.Core/Services/AccessService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ private async Task<bool> IsAccessGranted(BitArray cardData, Door matchingDoor)
109109
if (assignedCredential == null)
110110
{
111111
_logger.LogInformation("Door {Name} badge requires enrollment", matchingDoor.Name);
112+
await _credentialRepository.Insert(new Credential { Number = builder.ToString() });
112113
return false;
113114
}
114115

src/Aporta.Shared/Models/Event.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
3+
namespace Aporta.Shared.Models;
4+
5+
public class Event
6+
{
7+
public int Id { get; set; }
8+
9+
public int EndpointId { get; set; }
10+
11+
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
12+
13+
public EventType Type { get; set; }
14+
15+
public string Data { get; set; } = "";
16+
}
17+
18+
public enum EventType
19+
{
20+
AccessGranted,
21+
AccessDenied
22+
}

0 commit comments

Comments
 (0)