Skip to content

Commit

Permalink
v1.0.39
Browse files Browse the repository at this point in the history
Version 1.0.39
-----------------------------------------------------------------
Strukturelle Änderung:
+ Lautstärke des Lesers Konfigurierbar

Fehlerbehebung:
+ ClassicProtokoll wurde nicht in die DB gespeichert
+ Fehlender/nicht erkannter Chip konnte keinen Bericht erzeugen
  • Loading branch information
c3rebro committed Mar 4, 2024
1 parent 21a3879 commit 542a8f3
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 53 deletions.
4 changes: 2 additions & 2 deletions CardCheckAssistant/CardCheckAssistant.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<AppxBundle>Never</AppxBundle>
<AppInstallerUri>https://github.com/c3rebro/CardCheckAssistant/releases/latest/download/</AppInstallerUri>
<FileVersion>$(AssemblyVersion)</FileVersion>
<AssemblyVersion>1.0.38</AssemblyVersion>
<AssemblyVersion>1.0.39</AssemblyVersion>
<StartupObject></StartupObject>
<DefaultLanguage>de-DE</DefaultLanguage>
<SignAssembly>False</SignAssembly>
Expand Down Expand Up @@ -70,7 +70,7 @@
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="System.Windows.Extensions" Version="7.0.0" />
Expand Down
11 changes: 11 additions & 0 deletions CardCheckAssistant/DataAccessLayer/DefaultSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public DefaultSettings(bool init)
_defaultTheme = "Light";
_defaultRFIDGearExePath = "";
_defaultProjectOutputPath = "";
_readerVolume = 0;
_cardCheckTextTemplates = new ObservableCollection<CardCheckTextTemplate>(new());

_selectedDBName = "db";
Expand Down Expand Up @@ -243,6 +244,16 @@ public string? DefaultProjectOutputPath
set => _defaultProjectOutputPath = value;
}
private string? _defaultProjectOutputPath;

/// <summary>
///
/// </summary>
public int? ReaderVolume
{
get => _readerVolume;
set => _readerVolume = value;
}
private int? _readerVolume;
#endregion properties

#region Extensions
Expand Down
10 changes: 8 additions & 2 deletions CardCheckAssistant/Models/GenericChipModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ public class GenericChipModel
{
public GenericChipModel()
{

Childs = new List<GenericChipModel>();
}

public GenericChipModel(string uid, ChipType cardType)
{
Childs = new List<GenericChipModel>();
UID = uid;
TCard = new CType() { PrimaryType = cardType, SecondaryType = MifareChipSubType.Unspecified };
}

public GenericChipModel(string uid, ChipType cardType, string sak, string rats)
{
Childs = new List<GenericChipModel>();
UID = uid;
TCard = new CType() { PrimaryType = cardType, SecondaryType = MifareChipSubType.Unspecified };
SAK = sak;
Expand All @@ -29,6 +31,7 @@ public GenericChipModel(string uid, ChipType cardType, string sak, string rats)

public GenericChipModel(string uid, MifareChipSubType cardType, string sak, string rats)
{
Childs = new List<GenericChipModel>();
UID = uid;
TCard = new CType() { PrimaryType = ChipType.MIFARE, SecondaryType = cardType };
SAK = sak;
Expand All @@ -37,6 +40,7 @@ public GenericChipModel(string uid, MifareChipSubType cardType, string sak, stri

public GenericChipModel(string uid, ChipType cardType, string sak, string rats, string versionL4)
{
Childs = new List<GenericChipModel>();
UID = uid;
TCard = new CType() { PrimaryType = cardType, SecondaryType = MifareChipSubType.Unspecified };
SAK = sak;
Expand All @@ -46,6 +50,7 @@ public GenericChipModel(string uid, ChipType cardType, string sak, string rats,

public GenericChipModel(string uid, MifareChipSubType cardType, string sak, string rats, string versionL4)
{
Childs = new List<GenericChipModel>();
UID = uid;
TCard = new CType() { PrimaryType = ChipType.MIFARE, SecondaryType = cardType };
SAK = sak;
Expand All @@ -55,14 +60,15 @@ public GenericChipModel(string uid, MifareChipSubType cardType, string sak, stri

public GenericChipModel(GenericChipModel chip)
{
Childs = new List<GenericChipModel>();
UID = chip.UID;
TCard = new CType() { PrimaryType = chip.TCard.PrimaryType, SecondaryType = chip.TCard.SecondaryType };
SAK = chip.SAK;
RATS = chip.RATS;
VersionL4 = chip.VersionL4;
}

public bool? HasChilds => Childs?.Count > 0;
public bool? HasChilds => Childs?.Any() ?? false;

public List<GenericChipModel> Childs
{
Expand Down
16 changes: 13 additions & 3 deletions CardCheckAssistant/Services/ModalView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Threading.Tasks;
using Windows.UI.Core;

Expand All @@ -12,6 +14,7 @@ namespace CardCheckAssistant.Services
/// </summary>
public static class ModalView
{
private static readonly EventLog eventLog = new("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
public static ObservableCollection<ContentDialog> Dialogs { get; set; }

public static async Task MessageDialogAsync(this FrameworkElement element, string title, string message)
Expand Down Expand Up @@ -43,11 +46,18 @@ public static async Task MessageDialogAsync(this FrameworkElement element, strin
RequestedTheme = element.ActualTheme
};

Dialogs.Add(dialog);
try
{
Dialogs.Add(dialog);

await dialog.ShowAsync();
await dialog.ShowAsync();

Dialogs.Remove(dialog);
Dialogs.Remove(dialog);
}
catch (Exception e)
{
eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}

public static async Task<bool?> ConfirmationDialogAsync(this FrameworkElement element, string title, string message)
Expand Down
4 changes: 3 additions & 1 deletion CardCheckAssistant/Services/ReaderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public async Task<int> ReadChipPublic()
{
try
{
using SettingsReaderWriter settings = new SettingsReaderWriter();

if (readerDevice != null)
{
if (!readerDevice.IsConnected)
Expand Down Expand Up @@ -186,7 +188,7 @@ public async Task<int> ReadChipPublic()
}
if(hfTag == null && lfTag == null && legicTag == null)
{
await readerDevice.BeepAsync(40, 2500, 50, 0);
await readerDevice.BeepAsync((byte)(settings.DefaultSettings.ReaderVolume ?? 0), 2500, 50, 0);

GenericChip = null;

Expand Down
25 changes: 22 additions & 3 deletions CardCheckAssistant/ViewModels/HomePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Windows.ApplicationModel.Store;
using Microsoft.UI.Windowing;
using CardCheckAssistant.Contracts.ViewModels;
using Windows.Foundation.Diagnostics;

namespace CardCheckAssistant.ViewModels;

Expand All @@ -26,6 +27,7 @@ public partial class HomePageViewModel : ObservableRecipient, INavigationAware
private readonly EventLog eventLog = new("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
private readonly Microsoft.UI.Xaml.DispatcherTimer scanDBTimer;
private SQLDBService dbService;
private readonly bool isCreateEventLogSourceErr;

private ObservableCollection<CardCheckProcess> cardCheckProcessesFromCache;

Expand All @@ -34,12 +36,20 @@ public partial class HomePageViewModel : ObservableRecipient, INavigationAware
/// </summary>
public HomePageViewModel()
{
if (!EventLog.SourceExists(Assembly.GetEntryAssembly().GetName().Name))
try
{
if (!EventLog.SourceExists(Assembly.GetEntryAssembly()?.GetName()?.Name))
{
EventLog.CreateEventSource(new EventSourceCreationData(Assembly.GetEntryAssembly().GetName().Name, "Application"));
isCreateEventLogSourceErr = false;
}
}
catch
{
EventLog.CreateEventSource(new EventSourceCreationData(Assembly.GetEntryAssembly().GetName().Name, "Application"));
isCreateEventLogSourceErr = true;
}

eventLog.Source = Assembly.GetEntryAssembly().GetName().Name;
eventLog.Source = Assembly.GetEntryAssembly()?.GetName()?.Name;

DataGridItemCollection = new ObservableCollection<CardCheckProcess>();
SetSortAscending = false;
Expand Down Expand Up @@ -453,6 +463,15 @@ private async Task PostPageLoadedCommand_Executed()
{
try
{
if(isCreateEventLogSourceErr)
{
await App.MainRoot.MessageDialogAsync(
"Fehler.",
"Es konnte keine Lagdatei erzeugt werden.\n" +
"Bitte das Programm einmal mit Adminrechten starten...");
}


await CheckForUpdates();

using var settings = new SettingsReaderWriter();
Expand Down
53 changes: 52 additions & 1 deletion CardCheckAssistant/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
using Microsoft.Extensions.Hosting;
using CardCheckAssistant.Views;
using System.Diagnostics;
using CardCheckAssistant.Contracts.ViewModels;

namespace CardCheckAssistant.ViewModels;

public partial class SettingsPageViewModel : ObservableRecipient
public partial class SettingsPageViewModel : ObservableRecipient, INavigationAware
{
private readonly IThemeSelectorService _themeSelectorService;
private readonly EventLog eventLog = new("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
Expand Down Expand Up @@ -77,6 +78,7 @@ public SettingsPageViewModel(IThemeSelectorService themeSelectorService)
CardCheckUseSQLLite = settings.DefaultSettings.CardCheckUseMSSQL == true ? true : false;
CreateSubdirectoryIsEnabled = settings.DefaultSettings.CreateSubdirectoryIsEnabled == true ? true : false;
RemoveTemporaryReportsIsEnabled = settings.DefaultSettings.RemoveTemporaryReportsIsEnabled == true ? true : false;
ReaderVolume = settings.DefaultSettings.ReaderVolume ?? 0;

SelectedDBUserPwd = enc.Decrypt(settings?.DefaultSettings?.SelectedDBUserPwd ?? "NoPWD");

Expand Down Expand Up @@ -346,6 +348,24 @@ public bool RFiDGearIsAutoRunEnabled
/// </summary>
[ObservableProperty]
private CardCheckTextTemplate _selectedTextTemplate;

/// <summary>
///
/// </summary>
public int ReaderVolume
{
get => _readerVolume;
set
{
SetProperty(ref _readerVolume, value);
using var settings = new SettingsReaderWriter();

settings.DefaultSettings.ReaderVolume = value;
settings.SaveSettings();
}
}
private int _readerVolume;

#endregion

#region Commands
Expand All @@ -362,6 +382,8 @@ public bool RFiDGearIsAutoRunEnabled
public ICommand SelectProjectFolderCommand => new AsyncRelayCommand(SelectProjectFolder_Executed);

public ICommand SelectRFIDGearCustomProjectCommand => new AsyncRelayCommand(SelectRFIDGearCustomProjectCommand_Executed);

public ICommand ReaderConnectionTestCommand => new AsyncRelayCommand(ReaderConnectionTestCommand_Executed);
#endregion

private async Task CreateNewTextTemplate_Executed()
Expand Down Expand Up @@ -505,6 +527,35 @@ private async Task SelectProjectFolder_Executed()
}
}

private async Task ReaderConnectionTestCommand_Executed()
{

}

/// <summary>
/// INavigation Aware Event. Close Connection If Open
/// </summary>
/// <param name="parameter"></param>
public async void OnNavigatedTo(object parameter)
{
// Run code when the app navigates to this page
using var reader = ReaderService.Instance;

await reader.Disconnect();

}

/// <summary>
/// INavigation Aware Event. Close Connection If Open
/// </summary>
public async void OnNavigatedFrom()
{
// Run code when the app navigates away from this page
using var reader = ReaderService.Instance;

await reader.Disconnect();
}

private async Task NavigateBackCommand_Executed()
{
try
Expand Down
6 changes: 6 additions & 0 deletions CardCheckAssistant/ViewModels/Step1PageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ private async Task NavigateBackCommand_Executed()
public async void OnNavigatedTo(object parameter)
{
// Run code when the app navigates to this page
scanChipTimer.Stop();
scanChipTimer.Tick -= ScanChipEvent;

using var reader = ReaderService.Instance;

await reader.Disconnect();
Expand All @@ -430,6 +433,9 @@ public async void OnNavigatedTo(object parameter)
public async void OnNavigatedFrom()
{
// Run code when the app navigates away from this page
scanChipTimer.Stop();
scanChipTimer.Tick -= ScanChipEvent;

using var reader = ReaderService.Instance;

await reader.Disconnect();
Expand Down
Loading

0 comments on commit 542a8f3

Please sign in to comment.