diff --git a/.gitignore b/.gitignore
index b6ce1cc..a416e0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,4 @@
*.xml
*.zip
*.htm
+RFiDGear/RFiDGear.SDKStyle.csproj
diff --git a/RFiDGear.sln b/RFiDGear.sln
index 0366dd6..8d10ff7 100644
--- a/RFiDGear.sln
+++ b/RFiDGear.sln
@@ -10,18 +10,18 @@ EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "RFiDGearBundleSetup", "RFiDGearBundleSetup\RFiDGearBundleSetup.wixproj", "{5A7DF993-C696-4958-B7C9-9396122DFF21}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ByteArray", "..\ByteArray\ByteArray.csproj", "{BDD5DF8C-6FC1-4882-8151-924820FDBC05}"
- ProjectSection(ProjectDependencies) = postProject
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70} = {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elatec.NET", "..\Elatec.NET\Elatec.NET.csproj", "{53FBD2F3-638E-4892-9F09-9A372C8F76D2}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Log4CSharp", "..\Log4CSharp\Log4CSharp.csproj", "{786D71E7-4D92-43E4-A9EB-4E07FFE36F70}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginSystem", "..\PluginSystem\PluginSystem.csproj", "{E99B606A-25B8-4113-9E75-5016CCFDB410}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMDialogs", "..\MVVMDialogs\MVVMDialogs.csproj", "{EF56252E-257F-41D1-974B-C9015071CE7E}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elatec.NET", "..\Elatec.NET\Elatec.NET.csproj", "{360F9AF9-6717-45B6-9707-5974575FE96A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projektmappenelemente", "Projektmappenelemente", "{A50839AB-9B8F-49C6-AB4A-7BD1BC9FA9DB}"
+ ProjectSection(SolutionItems) = preProject
+ debugParam.txt = debugParam.txt
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -72,30 +72,6 @@ Global
{BDD5DF8C-6FC1-4882-8151-924820FDBC05}.Release|x64.Build.0 = Release|x64
{BDD5DF8C-6FC1-4882-8151-924820FDBC05}.Release|x86.ActiveCfg = Release|Any CPU
{BDD5DF8C-6FC1-4882-8151-924820FDBC05}.Release|x86.Build.0 = Release|Any CPU
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Debug|x64.ActiveCfg = Debug|x64
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Debug|x64.Build.0 = Debug|x64
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Debug|x86.ActiveCfg = Debug|x86
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Debug|x86.Build.0 = Debug|x86
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Release|Any CPU.Build.0 = Release|Any CPU
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Release|x64.ActiveCfg = Release|x64
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Release|x64.Build.0 = Release|x64
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Release|x86.ActiveCfg = Release|x86
- {53FBD2F3-638E-4892-9F09-9A372C8F76D2}.Release|x86.Build.0 = Release|x86
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Debug|x64.ActiveCfg = Debug|x64
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Debug|x64.Build.0 = Debug|x64
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Debug|x86.ActiveCfg = Debug|x86
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Debug|x86.Build.0 = Debug|x86
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Release|Any CPU.Build.0 = Release|Any CPU
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Release|x64.ActiveCfg = Release|x64
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Release|x64.Build.0 = Release|x64
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Release|x86.ActiveCfg = Release|x86
- {786D71E7-4D92-43E4-A9EB-4E07FFE36F70}.Release|x86.Build.0 = Release|x86
{E99B606A-25B8-4113-9E75-5016CCFDB410}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E99B606A-25B8-4113-9E75-5016CCFDB410}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E99B606A-25B8-4113-9E75-5016CCFDB410}.Debug|x64.ActiveCfg = Debug|x64
@@ -120,6 +96,18 @@ Global
{EF56252E-257F-41D1-974B-C9015071CE7E}.Release|x64.Build.0 = Release|x64
{EF56252E-257F-41D1-974B-C9015071CE7E}.Release|x86.ActiveCfg = Release|Any CPU
{EF56252E-257F-41D1-974B-C9015071CE7E}.Release|x86.Build.0 = Release|Any CPU
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Debug|x64.ActiveCfg = Debug|x64
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Debug|x64.Build.0 = Debug|x64
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Debug|x86.ActiveCfg = Debug|x86
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Debug|x86.Build.0 = Debug|x86
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Release|x64.ActiveCfg = Release|x64
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Release|x64.Build.0 = Release|x64
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Release|x86.ActiveCfg = Release|x86
+ {360F9AF9-6717-45B6-9707-5974575FE96A}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs b/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs
index 87b8538..308e25b 100644
--- a/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs
+++ b/RFiDGear/3rdParty/RedCell/RedCell.Diagnostics.Update/Updater.cs
@@ -1,23 +1,26 @@
using RFiDGear;
using RFiDGear.DataAccessLayer;
-using Log4CSharp;
+using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics;
using System.IO;
+using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
+using System.Threading.Tasks;
using Ionic.Zip;
using RedCell.Net;
+using System.Windows.Threading;
namespace RedCell.Diagnostics.Update
{
public class Updater : IDisposable
{
#region Constants
- private static readonly string FacilityName = "RFiDGear";
+ private readonly EventLog eventLog = new EventLog("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
private static readonly string appDataPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
@@ -33,13 +36,12 @@ public class Updater : IDisposable
/// The default configuration file
///
public static readonly string DefaultConfigFile = "update.xml";
-
public static readonly string WorkPath = "work";
#endregion
#region Fields
//private readonly SettingsReaderWriter settings;
- private Timer _timer;
+ private DispatcherTimer _timer;
private volatile bool _updating;
private readonly Manifest _localConfig;
private Manifest _remoteConfig;
@@ -49,17 +51,12 @@ public class Updater : IDisposable
private readonly string me;
public bool AllowUpdate { get; set; }
+ public bool UpdateAvailable { get; set; }
public bool IsUserNotified { get; set; }
public string UpdateInfoText { get; private set; }
#endregion
- #region events
-
- public event EventHandler NewVersionAvailable;
-
- #endregion
-
#region Initialization
///
/// Initializes a new instance of the class.
@@ -79,11 +76,11 @@ public Updater(FileInfo configFile)
{
me = thisprocess.MainModule.FileName;
- Log.Write("Loaded.");
- Log.Write("Initializing using file '{0}'.", configFile.FullName);
+ eventLog.WriteEntry(string.Format("Loaded"), EventLogEntryType.Information);
+ eventLog.WriteEntry(string.Format("Initializing using file '{0}'.", configFile), EventLogEntryType.Information);
if (!configFile.Exists)
{
- Log.Write("Config file '{0}' does not exist, stopping.", configFile.Name);
+ eventLog.WriteEntry(string.Format("Config file '{0}' does not exist, stopping.", configFile), EventLogEntryType.Warning);
return;
}
@@ -99,8 +96,7 @@ public Updater(FileInfo configFile)
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
-
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
#endregion
@@ -109,63 +105,80 @@ public Updater(FileInfo configFile)
///
/// Starts the monitoring.
///
- public void StartMonitoring()
+ public async Task StartMonitoring()
{
- if (_localConfig != null)
+ await Task.Run(() =>
{
- Log.Write("Starting monitoring every {0}s.", _localConfig.CheckInterval);
- Check(null);
+ if (_localConfig != null)
+ {
+ eventLog.WriteEntry(string.Format("Starting monitoring every {0}s.", _localConfig.CheckInterval), EventLogEntryType.Information);
+ Check(null, null);
- _timer = new Timer(Check, null, 5000, _localConfig.CheckInterval * 1000);
- }
+ _timer = new DispatcherTimer
+ {
+ Interval = new TimeSpan(0, 0, 0, _localConfig.CheckInterval, 0)
+ };
+
+ _timer.Tick += Check;
+
+ _timer.Start();
+ _timer.IsEnabled = true;
+ }
+ }).ConfigureAwait(false);
+ return;
}
///
/// Stops the monitoring.
///
- public void StopMonitoring()
+ public async Task StopMonitoring()
{
- Log.Write("Stopping monitoring.");
- if (_timer == null)
+ await Task.Run(() =>
{
- Log.Write("Monitoring was already stopped.");
- return;
- }
- _timer.Dispose();
+ eventLog.WriteEntry(string.Format("Stopping monitoring."), EventLogEntryType.Information);
+ if (_timer == null)
+ {
+ eventLog.WriteEntry(string.Format("Monitoring was already stopped."), EventLogEntryType.Information);
+ return;
+ }
+ _timer.Stop();
+ }).ConfigureAwait(false);
+
+ return;
}
///
/// Checks the specified state.
///
/// The state.
- private void Check(object state)
+ public async void Check(object state, EventArgs args)
{
try
{
if (AllowUpdate && !_updating)
{
- _timer.Change(5000, DefaultCheckInterval * 1000);
+ _timer.Interval = new TimeSpan(0, 0, 0, _localConfig.CheckInterval, 0);
_updating = true;
- Update();
+ await Update();
_updating = false;
IsUserNotified = false;
- Log.Write("Check ending.");
+ eventLog.WriteEntry(string.Format("Check ending."), EventLogEntryType.Information);
return;
}
- Log.Write("Check starting.");
+ eventLog.WriteEntry(string.Format("Check starting."), EventLogEntryType.Information);
if (_updating)
{
- Log.Write("Updater is already updating.");
- Log.Write("Check ending.");
+ eventLog.WriteEntry(string.Format("Updater is already updating."), EventLogEntryType.Warning);
+ eventLog.WriteEntry(string.Format("Check ending."), EventLogEntryType.Information);
return;
}
var remoteUri = new Uri(_localConfig.RemoteConfigUri);
- Log.Write("Fetching '{0}'.", remoteUri.AbsoluteUri);
+ eventLog.WriteEntry(string.Format("Fetching '{0}'.", _localConfig.RemoteConfigUri), EventLogEntryType.Information);
var http = new Fetch { Retries = 5, RetrySleep = 30000, Timeout = 30000 };
try
{
@@ -173,15 +186,17 @@ private void Check(object state)
if (!http.Success)
{
+
try
{
- Log.Write("Fetch error: {0}", http.Response != null ? http.Response.StatusDescription : "");
+ eventLog.WriteEntry(string.Format("Fetch error: {0}", http.Response != null ? http.Response.StatusDescription : ""), EventLogEntryType.Error);
}
catch
{
- Log.Write("Fetch error: Unknown http Err");
+ eventLog.WriteEntry(string.Format("Fetch error: Unknown http Err"), EventLogEntryType.Information);
}
+
_remoteConfig = null;
return;
}
@@ -189,9 +204,8 @@ private void Check(object state)
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
_remoteConfig = null;
-
+ UpdateAvailable = false;
return;
}
@@ -200,126 +214,130 @@ private void Check(object state)
if (_remoteConfig == null)
{
+ UpdateAvailable = false;
return;
}
if (_localConfig.SecurityToken != _remoteConfig.SecurityToken)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}", DateTime.Now, "Security token mismatch."), FacilityName);
+ UpdateAvailable = false;
return;
}
- LogWriter.CreateLogEntry(string.Format("{0}: {1}", DateTime.Now, "Remote config is valid."), FacilityName);
- LogWriter.CreateLogEntry(string.Format("{0}: {1}, {2}", DateTime.Now, "Local version is ", _localConfig.Version), FacilityName);
- LogWriter.CreateLogEntry(string.Format("{0}: {1}, {2}", DateTime.Now, "Remote version is ", _remoteConfig.Version), FacilityName);
+ eventLog.WriteEntry(string.Format("Remote config is valid."), EventLogEntryType.Information);
+ eventLog.WriteEntry(string.Format("Local version is ", _localConfig.Version), EventLogEntryType.Information);
+ eventLog.WriteEntry(string.Format("Remote version is ", _remoteConfig.Version), EventLogEntryType.Information);
if (_remoteConfig.Version == _localConfig.Version)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}", DateTime.Now, "Versions are the same. Check ending."), FacilityName);
+ eventLog.WriteEntry(string.Format("Versions are the same. Check ending."), EventLogEntryType.Information);
+ UpdateAvailable = false;
return;
}
if (_remoteConfig.Version < _localConfig.Version)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}", DateTime.Now, "Remote version is older. That's weird. Check ending."), FacilityName);
+ eventLog.WriteEntry(string.Format("Remote version is older. That's weird o_O. Check ending."), EventLogEntryType.Warning);
+ UpdateAvailable = false;
return;
}
- LogWriter.CreateLogEntry(string.Format("{0}: {1}", DateTime.Now, "Remote version is newer. Updating."), FacilityName);
- _timer.Change(0, 1000);
+ eventLog.WriteEntry(string.Format("Remote version is newer. Updating."), EventLogEntryType.Information);
+ UpdateAvailable = true;
+ /*
+ if (_timer != null)
+ {
+ _timer.Change(0, 1000);
+ }
+ */
if (!AllowUpdate && !IsUserNotified)
{
IsUserNotified = true;
UpdateInfoText = _remoteConfig.VersionInfoText;
- NewVersionAvailable(this, null);
return;
}
if (IsUserNotified && !AllowUpdate)
{
- StopMonitoring();
+ await StopMonitoring();
return;
}
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
///
/// Updates this instance.
///
- public void Update()
+ public async Task Update()
{
+ UpdateAvailable = true;
- Log.Write("Updating '{0}' files.", _remoteConfig.Payloads.Length);
-
- // Clean up failed attempts.
- if (Directory.Exists(Path.Combine(appDataPath, WorkPath)))
+ await Task.Run(() =>
{
- Log.Write("WARNING: Work directory already exists.");
- try { Directory.Delete(Path.Combine(appDataPath, WorkPath), true); }
- catch (IOException e)
+ // Clean up failed attempts.
+ if (Directory.Exists(Path.Combine(appDataPath, WorkPath)))
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
-
- return;
+ //"WARNING: Work directory already exists."
+ try { Directory.Delete(Path.Combine(appDataPath, WorkPath), true); }
+ catch
+ {
+ return;
+ }
}
- }
- else
- {
- try
- {
- Directory.CreateDirectory(Path.Combine(appDataPath, WorkPath));
- }
- catch (Exception e)
+ else
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
-
- return;
+ try
+ {
+ Directory.CreateDirectory(Path.Combine(appDataPath, WorkPath));
+ }
+ catch
+ {
+ return;
+ }
}
- }
- // Download files in manifest.
- foreach (var update in _remoteConfig.Payloads)
- {
- Log.Write("Fetching '{0}'.", update);
- var url = _remoteConfig.BaseUri + update; //TODO: make this localizable ? e.g. + (settings.DefaultSpecification.DefaultLanguage == "german" ? "de-de/" : "en-us/")
- var file = Fetch.Get(url);
- if (file == null)
+ // Download files in manifest.
+ foreach (var update in _remoteConfig.Payloads)
{
- Log.Write("Fetch failed.");
- return;
- }
- var info = new FileInfo(Path.Combine(Path.Combine(appDataPath, WorkPath), update));
- Directory.CreateDirectory(info.DirectoryName);
- File.WriteAllBytes(Path.Combine(Path.Combine(appDataPath, WorkPath), update), file);
+ eventLog.WriteEntry(string.Format("Fetching '{0}'.", update), EventLogEntryType.Information);
+ var url = _remoteConfig.BaseUri + update; //TODO: make this localizable ? e.g. + (settings.DefaultSpecification.DefaultLanguage == "german" ? "de-de/" : "en-us/")
+ var file = Fetch.Get(url);
+ if (file == null)
+ {
+ eventLog.WriteEntry(string.Format("Fetch failed."), EventLogEntryType.Error);
+ return;
+ }
+ var info = new FileInfo(Path.Combine(Path.Combine(appDataPath, WorkPath), update));
+ Directory.CreateDirectory(info.DirectoryName);
+ File.WriteAllBytes(Path.Combine(Path.Combine(appDataPath, WorkPath), update), file);
- // Unzip
- if (Regex.IsMatch(update, @"\.zip"))
- {
- try
+ // Unzip
+ if (Regex.IsMatch(update, @"\.zip"))
{
- var zipfile = Path.Combine(Path.Combine(appDataPath, WorkPath), update);
- using (var zip = ZipFile.Read(zipfile))
+ try
{
- zip.ExtractAll(Path.Combine(appDataPath, WorkPath), ExtractExistingFileAction.Throw);
- }
+ var zipfile = Path.Combine(Path.Combine(appDataPath, WorkPath), update);
+ using (var zip = ZipFile.Read(zipfile))
+ {
+ zip.ExtractAll(Path.Combine(appDataPath, WorkPath), ExtractExistingFileAction.Throw);
+ }
- File.Delete(zipfile);
+ File.Delete(zipfile);
- AllowUpdate = true;
- }
- catch (Exception e)
- {
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
-
- return;
+ AllowUpdate = true;
+ }
+ catch
+ {
+ return;
+ }
}
}
- }
+ }).ConfigureAwait(false);
if (IsUserNotified && AllowUpdate)
{
@@ -342,10 +360,8 @@ public void Update()
Environment.Exit(0);
}
- catch (Exception e)
+ catch
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
-
return;
}
}
diff --git a/RFiDGear/App.xaml b/RFiDGear/App.xaml
index e83caf7..2dc9e06 100644
--- a/RFiDGear/App.xaml
+++ b/RFiDGear/App.xaml
@@ -4,12 +4,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:dialogsview="clr-namespace:MvvmDialogs.View;assembly=MVVMDialogs"
- xmlns:dialogsvm="clr-namespace:MvvmDialogs.ViewModels;assembly=MVVMDialogs"
+ xmlns:dialogsview="clr-namespace:MVVMDialogs.View;assembly=MVVMDialogs"
+ xmlns:dialogsvm="clr-namespace:MVVMDialogs.ViewModels;assembly=MVVMDialogs"
xmlns:local="clr-namespace:RFiDGear"
xmlns:mainview="clr-namespace:RFiDGear.View"
xmlns:mainvm="clr-namespace:MefMvvm.SharedContracts.ViewModel;assembly=PluginSystem"
- xmlns:pre="clr-namespace:MvvmDialogs.Presenters;assembly=MVVMDialogs"
+ xmlns:pre="clr-namespace:MVVMDialogs.Presenters;assembly=MVVMDialogs"
xmlns:vm="clr-namespace:RFiDGear.ViewModel"
d1p1:Ignorable="d"
StartupUri="View/MainWindow.xaml">
diff --git a/RFiDGear/DataAccessLayer/Local/Constants.cs b/RFiDGear/DataAccessLayer/Local/Constants.cs
index ddc4305..8045688 100644
--- a/RFiDGear/DataAccessLayer/Local/Constants.cs
+++ b/RFiDGear/DataAccessLayer/Local/Constants.cs
@@ -195,8 +195,26 @@ public enum AccessCondition_MifareClassicSectorTrailer
}
///
- /// Currently Available Cardtechnologies
+ /// Type of Chip from NXP AN10833
///
+ ///
+ ///
+ /// Mifare Classic = 0x10xx - 0x1Fxx
+ /// NXP SAM = 0x20xx - 0x2Fxx
+ /// Mifare Plus = 0x30xx - 0x3Fxx
+ /// Mifare Desfire = 0x40xx - 0x7Fxx
+ /// Desfire Light = 0x80xx - 0x8Fxx
+ /// Mifare Ultralight = 0x90xx - 0x9Fxx
+ /// Mifare Mini = 0xA0xx - 0xAFxx
+ /// NXP NTAG = 0xB0xx - 0xBFxx
+ /// NXP ICODE = 0xC0xx - 0xCFxx
+ ///
+ /// 0bxxxx 0000 = nxp type
+ /// 0b0000 xxxx = nxp subtype
+ /// 0bxxxx 1xxx = smartmx variant
+ ///
+ ///
+ [Flags]
public enum CARD_TYPE
{
NOTAG = 0,
@@ -241,60 +259,233 @@ public enum CARD_TYPE
TOPAZ = 0x89, // "Topaz"
CTS = 0x8A, // "CTS256 / CTS512"
BLELC = 0x8B, // "Bluetooth Low Energy LEGIC Connect"
- // Custom
- Unspecified = 0xB0,
- NTAG = 0xB1,
- MifareMini = 0xB2,
- Mifare1K = 0xB3,
- Mifare2K = 0xB4,
- Mifare4K = 0xB5,
- SAM_AV1 = 0xB6,
- SAM_AV2 = 0xB7,
- MifarePlus_SL0_1K = 0xB9,
- MifarePlus_SL0_2K = 0xBA,
- MifarePlus_SL0_4K = 0xBB,
- MifarePlus_SL1_1K = 0xBC,
- MifarePlus_SL1_2K = 0xBD,
- MifarePlus_SL1_4K = 0xBE,
- MifarePlus_SL2_1K = 0xBF,
- MifarePlus_SL2_2K = 0xC0,
- MifarePlus_SL2_4K = 0xC1,
- MifarePlus_SL3_1K = 0xC2,
- MifarePlus_SL3_2K = 0xC3,
- MifarePlus_SL3_4K = 0xC4,
- DESFire = 0xC5,
- DESFireEV1 = 0xC6,
- DESFireEV2 = 0xC7,
- DESFireEV3 = 0xC8,
- SmartMX_DESFire_Generic = 0xC9,
- SmartMX_DESFire_2K = 0xCA,
- SmartMX_DESFire_4K = 0xCB,
- SmartMX_DESFire_8K = 0xCC,
- SmartMX_DESFire_16K = 0xCD,
- SmartMX_DESFire_32K = 0xCE,
- DESFire_256 = 0xD0,
- DESFire_2K = 0xD1,
- DESFire_4K = 0xD2,
- DESFireEV1_256 = 0xD3,
- DESFireEV1_2K = 0xD4,
- DESFireEV1_4K = 0xD5,
- DESFireEV1_8K = 0xD6,
- DESFireEV2_2K = 0xD7,
- DESFireEV2_4K = 0xD8,
- DESFireEV2_8K = 0xD9,
- DESFireEV2_16K = 0xDA,
- DESFireEV2_32K = 0xDB,
- DESFireEV3_2K = 0xDC,
- DESFireEV3_4K = 0xDD,
- DESFireEV3_8K = 0xDE,
- DESFireEV3_16K = 0xDF,
- DESFireEV3_32K = 0xE0,
- DESFireLight = 0xE1,
- SmartMX_Mifare_1K = 0xF9,
- SmartMX_Mifare_4K = 0xFA,
- MifareUltralight = 0xFB,
- MifareUltralightC = 0xFC,
- GENERIC_T_CL_A = 0xFF
+
+ /* CUSTOM
+ *
+ * Mifare Classic = 0x10 - 0x1F
+ * NXP SAM = 0x20 - 0x2F
+ * Mifare Plus = 0x30 - 0x3F
+ * Mifare Desfire = 0x40 - 0x7F
+ * Mifare Desfire Light = 0x80 - 0x8F
+ * Mifare Ultralight = 0x90 - 0x9F
+ * Mifare Mini = 0xA0 - 0xAF
+ * NXP NTAG = 0xB0 - 0xBF
+ * NXP ICODE = 0xC0 - 0xCF
+ *
+ * 0bxxxx 0000 = mifare type
+ * 0x0000 xxxx = mifare subtype
+ */
+
+ /*
+ * 0b0001 xxxx = mifare classic
+ * 0b0001 1xxx = smartmx classic
+ *
+ * 0b0001 0000 = mifare classic - 1k
+ * 0b0001 0001 = mifare classic - 2k
+ * 0b0001 0010 = mifare classic - 4k
+ *
+ * 0b0001 1000 = smartmx classic - 1k
+ * 0b0001 1001 = smartmx classic - 2k
+ * 0b0001 1010 = smartmx classic - 4k
+ */
+ Unspecified = 0x0100,
+
+ MifareClassic = 0x1000,
+ Mifare1K = 0x1100,
+ Mifare2K = 0x1200,
+ Mifare4K = 0x1300,
+
+ SmartMX_Mifare_1K = 0x1900,
+ SmartMX_Mifare_2K = 0x1A00,
+ SmartMX_Mifare_4K = 0x1B00,
+
+ /* 0b0010 0000 = MifareSAM
+ *
+ * 0b0010 0001 = SAM_AV1
+ * 0b0010 0010 = SAM_AV2
+ */
+
+ MifareSAM = 0x2000,
+ SAM_AV1 = 0x2100,
+ SAM_AV2 = 0x2200,
+
+ /* 0b0011 xxxx = Mifare Plus
+ *
+ * 0b0011 00xx = Mifare Plus SL0
+ * 0b0011 0000 = Mifare Plus SL0 - 1k
+ * 0b0011 0001 = Mifare Plus SL0 - 2k
+ * 0b0011 0010 = Mifare Plus SL0 - 4k
+ *
+ * 0b0011 01xx = Mifare Plus SL1
+ * 0b0011 0100 = Mifare Plus SL1 - 1k
+ * 0b0011 0101 = Mifare Plus SL1 - 2k
+ * 0b0011 0110 = Mifare Plus SL1 - 4k
+ *
+ * 0b0011 10xx = Mifare Plus SL2
+ * 0b0011 1000 = Mifare Plus SL2 - 1k
+ * 0b0011 1001 = Mifare Plus SL2 - 2k
+ * 0b0011 1010 = Mifare Plus SL2 - 4k
+ *
+ * 0b0011 11xx = Mifare Plus SL3
+ * 0b0011 1100 = Mifare Plus SL3 - 1k
+ * 0b0011 1101 = Mifare Plus SL3 - 2k
+ * 0b0011 1110 = Mifare Plus SL3 - 4k
+ */
+
+ MifarePlus = 0x3000,
+ MifarePlus_SL0_1K = 0x3100,
+ MifarePlus_SL0_2K = 0x3200,
+ MifarePlus_SL0_4K = 0x3300,
+
+ MifarePlus_SL1_1K = 0x3400,
+ MifarePlus_SL1_2K = 0x3500,
+ MifarePlus_SL1_4K = 0x3600,
+
+ MifarePlus_SL2_1K = 0x3800,
+ MifarePlus_SL2_2K = 0x3900,
+ MifarePlus_SL2_4K = 0x3A00,
+
+ MifarePlus_SL3_1K = 0x3C00,
+ MifarePlus_SL3_2K = 0x3D00,
+ MifarePlus_SL3_4K = 0x3E00,
+
+ /* 0b01xx xxxx = Mifare Desfire
+ * 0b01xx 1xxx = SmartMX Desfire
+ * 0b0100 x000 = EV0
+ * 0b0101 x000 = EV1
+ * 0b0110 x000 = EV2
+ * 0b0111 x000 = EV3
+ *
+ * 0b0100 0001 = Mifare Desfire EV0 - 256
+ * 0b0100 0010 = Mifare Desfire EV0 - 1k
+ * 0b0100 0011 = Mifare Desfire EV0 - 2k
+ * 0b0100 0100 = Mifare Desfire EV0 - 4k
+ *
+ * 0b0100 1xxx = SmartMX Desfire EV0
+ * 0b0100 1001 = SmartMX Desfire EV0 - 256
+ * 0b0100 1010 = SmartMX Desfire EV0 - 1k
+ * 0b0100 1011 = SmartMX Desfire EV0 - 2k
+ * 0b0100 1100 = SmartMX Desfire EV0 - 4k
+ *
+ * 0b0101 0xxx = Mifare Desfire EV1
+ * 0b0101 0000 = Mifare Desfire EV1 - 256
+ * 0b0101 0001 = Mifare Desfire EV1 - 2k
+ * 0b0101 0010 = Mifare Desfire EV1 - 4k
+ * 0b0101 0011 = Mifare Desfire EV1 - 8k
+ *
+ * 0b0101 1xxx = SmartMX Desfire EV1
+ * 0b0101 1000 = SmartMX Desfire EV1 - 256
+ * 0b0101 1001 = SmartMX Desfire EV1 - 2k
+ * 0b0101 1010 = SmartMX Desfire EV1 - 4k
+ * 0b0101 1011 = SmartMX Desfire EV1 - 8k
+ *
+ * 0b0110 0xxx = Mifare Desfire EV2
+ * 0b0110 0000 = Mifare Desfire EV2 - 2k
+ * 0b0110 0001 = Mifare Desfire EV2 - 4k
+ * 0b0110 0010 = Mifare Desfire EV2 - 8k
+ * 0b0110 0011 = Mifare Desfire EV2 - 16k
+ * 0b0110 0100 = Mifare Desfire EV2 - 32k
+ *
+ * 0b0110 1xxx = SmartMX Desfire EV2
+ * 0b0110 1000 = SmartMX Desfire EV2 - 2k
+ * 0b0110 1001 = SmartMX Desfire EV2 - 4k
+ * 0b0110 1010 = SmartMX Desfire EV2 - 8k
+ * 0b0110 1011 = SmartMX Desfire EV2 - 16k
+ * 0b0110 1100 = SmartMX Desfire EV2 - 32k
+ *
+ * 0b0111 0xxx = Mifare Desfire EV3
+ * 0b0111 0000 = Mifare Desfire EV3 - 2k
+ * 0b0111 0001 = Mifare Desfire EV3 - 4k
+ * 0b0111 0010 = Mifare Desfire EV3 - 8k
+ * 0b0111 0011 = Mifare Desfire EV3 - 16k
+ * 0b0111 0100 = Mifare Desfire EV3 - 32k
+ *
+ * 0b0111 1xxx = SmartMX Desfire EV3
+ * 0b0111 1000 = SmartMX Desfire EV3 - 1k
+ * 0b0111 1001 = SmartMX Desfire EV3 - 2k
+ * 0b0111 1010 = SmartMX Desfire EV3 - 4k
+ * 0b0111 1011 = SmartMX Desfire EV3 - 16k
+ * 0b0111 1100 = SmartMX Desfire EV3 - 32k
+ *
+ */
+
+ DESFire = 0x4000,
+ DESFireEV0 = 0x4000,
+ DESFireEV0_256 = 0x4100,
+ DESFireEV0_1K = 0x4200,
+ DESFireEV0_2K = 0x4300,
+ DESFireEV0_4K = 0x4400,
+ // 0x44 - 0x47 = RFU
+
+ SmartMX_DESFire = 0x4800,
+ SmartMX_DESFire_Generic = 0x4800,
+ SmartMX_DESFireEV0_256 = 0x4900,
+ SmartMX_DESFireEV0_1K = 0x4A00,
+ SmartMX_DESFireEV0_2K = 0x4B00,
+ SmartMX_DESFireEV0_4K = 0x4C00,
+ // 0x4C - 0x4F = RFU
+
+ DESFireEV1 = 0x5000,
+ DESFireEV1_256 = 0x5100,
+ DESFireEV1_2K = 0x5200,
+ DESFireEV1_4K = 0x5300,
+ DESFireEV1_8K = 0x5400,
+ // 0x55 - 0x57 = RFU
+
+ SmartMX_DESFireEV1_256 = 0x5900,
+ SmartMX_DESFireEV1_2K = 0x5A00,
+ SmartMX_DESFireEV1_4K = 0x5B00,
+ SmartMX_DESFireEV1_8K = 0x5C00,
+ // 0x5C - 0x5F = RFU
+
+ DESFireEV2 = 0x6000,
+ DESFireEV2_2K = 0x6100,
+ DESFireEV2_4K = 0x6200,
+ DESFireEV2_8K = 0x6300,
+ DESFireEV2_16K = 0x6400,
+ DESFireEV2_32K = 0x6500,
+ // 0x5C - 0x5F = RFU
+
+ SmartMX_DESFireEV2_2K = 0x6900,
+ SmartMX_DESFireEV2_4K = 0x6A00,
+ SmartMX_DESFireEV2_8K = 0x6B00,
+ SmartMX_DESFireEV2_16K = 0x6C00,
+ SmartMX_DESFireEV2_32K = 0x6D00,
+ // 0x5C - 0x5F = RFU
+
+ DESFireEV3 = 0x7000,
+ DESFireEV3_2K = 0x7100,
+ DESFireEV3_4K = 0x7200,
+ DESFireEV3_8K = 0x7300,
+ DESFireEV3_16K = 0x7400,
+ DESFireEV3_32K = 0x7500,
+ // 0x5C - 0x5F = RFU
+
+ SmartMX_DESFireEV3_2K = 0x7900,
+ SmartMX_DESFireEV3_4K = 0x7A00,
+ SmartMX_DESFireEV3_8K = 0x7B00,
+ SmartMX_DESFireEV3_16K = 0x7C00,
+ SmartMX_DESFireEV3_32K = 0x7D00,
+ // 0x5C - 0x5F = RFU
+
+ DESFireLight = 0x8000,
+
+ MifareUltralight = 0x9000,
+ MifareUltralightC = 0x9100,
+ MifareUltralightC_EV1 = 0x9200,
+
+ NTAG_210 = 0xA000,
+ NTAG_211 = 0xA100,
+ NTAG_212 = 0xA200,
+ NTAG_213 = 0xA300,
+ NTAG_214 = 0xA400,
+ NTAG_215 = 0xA500,
+ NTAG_216 = 0xA600,
+ // 0xA7 - 0xA9 = RFU
+ NTAG_424 = 0xAA00,
+ NTAG_426 = 0xAB00,
+
+ MifareMini = 0xB000
};
///
diff --git a/RFiDGear/DataAccessLayer/Local/CustomConverter.cs b/RFiDGear/DataAccessLayer/Local/CustomConverter.cs
index 1284739..48dc484 100644
--- a/RFiDGear/DataAccessLayer/Local/CustomConverter.cs
+++ b/RFiDGear/DataAccessLayer/Local/CustomConverter.cs
@@ -1,7 +1,5 @@
using RFiDGear.DataAccessLayer;
-using Elatec.NET;
-
using System;
using System.Globalization;
using System.Collections.Generic;
diff --git a/RFiDGear/DataAccessLayer/Local/ResourceLoader.cs b/RFiDGear/DataAccessLayer/Local/ResourceLoader.cs
index 3d0f5ba..c653f17 100644
--- a/RFiDGear/DataAccessLayer/Local/ResourceLoader.cs
+++ b/RFiDGear/DataAccessLayer/Local/ResourceLoader.cs
@@ -1,7 +1,7 @@
using RFiDGear.DataAccessLayer;
using RFiDGear.Model;
-using Log4CSharp;
+using Microsoft.Extensions.Logging;
using System;
using System.Collections.ObjectModel;
@@ -10,6 +10,8 @@
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup;
+using System.Diagnostics;
+using System.Reflection;
namespace RFiDGear.DataAccessLayer
{
@@ -70,7 +72,7 @@ public EnumerateExtension(Type type)
var settings = new SettingsReaderWriter();
resManager = new ResourceManager("RFiDGear.Resources.Manifest", System.Reflection.Assembly.GetExecutingAssembly());
- settings.ReadSettings();
+ settings.ReadSettings().GetAwaiter().GetResult();
cultureInfo = (new DefaultSpecification().DefaultLanguage == "german") ? new CultureInfo("de") : new CultureInfo("en");
}
@@ -97,7 +99,7 @@ public override object ProvideValue(IServiceProvider serviceProvider)
///
public sealed class ResourceLoader : IValueConverter, IDisposable
{
- private static readonly string FacilityName = "RFiDGear";
+ private readonly EventLog eventLog = new EventLog("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
private readonly ResourceManager resManager;
///
@@ -150,7 +152,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
throw new ArgumentOutOfRangeException(
string.Format("parameter:{0}\nvalue:{1}",
@@ -206,7 +208,7 @@ public static string GetResource(string resName)
{
using (var settings = new SettingsReaderWriter())
{
- settings.ReadSettings();
+ settings.ReadSettings().GetAwaiter().GetResult();
var ressource = new ResourceManager("RFiDGear.Resources.Manifest", System.Reflection.Assembly.GetExecutingAssembly())
.GetString(resName, (settings.DefaultSpecification.DefaultLanguage == "german") ? new CultureInfo("de") : new CultureInfo("en"));
@@ -217,7 +219,8 @@ public static string GetResource(string resName)
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ EventLog eventLog2 = new EventLog("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
+ eventLog2.WriteEntry(e.Message, EventLogEntryType.Error);
return string.Empty;
}
}
diff --git a/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs b/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs
index 699eeb3..cd48310 100644
--- a/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs
+++ b/RFiDGear/DataAccessLayer/Remote/FromFile/DatabaseReaderWriter.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
@@ -11,7 +12,7 @@
using System.Xml;
using System.Xml.Serialization;
using Ionic.Zip;
-using Log4CSharp;
+
using RFiDGear.Model;
using RFiDGear.ViewModel;
@@ -23,9 +24,8 @@ namespace RFiDGear.DataAccessLayer
public class DatabaseReaderWriter
{
#region fields
- private static readonly string FacilityName = "RFiDGear";
-
private readonly Version Version = Assembly.GetExecutingAssembly().GetName().Version;
+ private readonly EventLog eventLog = new EventLog("Application", ".", "RFiDGear");
private const string chipDatabaseFileName = "chipdatabase.xml";
private const string taskDatabaseFileNameCompressed = "chipdatabase.rfPrj";
@@ -81,7 +81,7 @@ public DatabaseReaderWriter()
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}; {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return;
}
}
@@ -90,7 +90,7 @@ public DatabaseReaderWriter()
///
///
///
- public bool ReadDatabase(string _fileName = "")
+ public async Task ReadDatabase(string _fileName = "")
{
var verInfo = 0;
FileInfo file;
@@ -104,86 +104,89 @@ public bool ReadDatabase(string _fileName = "")
file = new FileInfo(_fileName);
}
- try
+ await Task.Run(() =>
{
- var doc = new XmlDocument();
-
- if (file.Extension.ToLower(CultureInfo.CurrentCulture) == ".xml")
+ try
{
- doc.Load(@_fileName);
- TextReader reader = new StreamReader(_fileName);
-
- var node = doc.SelectSingleNode("//ManifestVersion");
- verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
+ var doc = new XmlDocument();
- try
- {
- AsyncRelayCommandLoadDB.ExecuteAsync(reader);
- }
- catch (Exception e)
+ if (file.Extension.ToLower(CultureInfo.CurrentCulture) == ".xml")
{
- LogWriter.CreateLogEntry(e, FacilityName);
- }
+ doc.Load(@_fileName);
+ TextReader reader = new StreamReader(_fileName);
- }
+ var node = doc.SelectSingleNode("//ManifestVersion");
+ verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
- if (file.Extension.ToLower(CultureInfo.CurrentCulture) == ".rfprj")
- {
- using (var zip1 = ZipFile.Read(string.IsNullOrWhiteSpace(_fileName) ?
- @Path.Combine(appDataPath, taskDatabaseFileNameCompressed) :
- _fileName))
+ try
+ {
+ AsyncRelayCommandLoadDB.Execute(reader);
+ }
+ catch (Exception e)
+ {
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
+ }
+
+ }
+
+ if (file.Extension.ToLower(CultureInfo.CurrentCulture) == ".rfprj")
{
- if (Directory.GetFiles(appDataPath, "*.tmp").Length > 0)
+ using (var zip1 = ZipFile.Read(string.IsNullOrWhiteSpace(_fileName) ?
+ @Path.Combine(appDataPath, taskDatabaseFileNameCompressed) :
+ _fileName))
{
- foreach (var tempFile in Directory.GetFiles(appDataPath, "*.tmp"))
+ if (Directory.GetFiles(appDataPath, "*.tmp").Length > 0)
{
- File.Delete(tempFile);
+ foreach (var tempFile in Directory.GetFiles(appDataPath, "*.tmp"))
+ {
+ File.Delete(tempFile);
+ }
}
+ zip1.ExtractAll(appDataPath, ExtractExistingFileAction.OverwriteSilently);
}
- zip1.ExtractAll(appDataPath, ExtractExistingFileAction.OverwriteSilently);
- }
- TextReader reader = null;
+ TextReader reader = null;
- if (File.Exists(@Path.Combine(appDataPath, file.Name)))
- {
- doc.Load(@Path.Combine(appDataPath, file.Name));
- var node = doc.SelectSingleNode("//ManifestVersion");
- verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
- reader = new StreamReader(@Path.Combine(appDataPath, file.Name));
- } // old Variant. Needed to open old databases
- else if(File.Exists(@Path.Combine(appDataPath, taskDatabaseFileName)))
- {
- doc.Load(@Path.Combine(appDataPath, taskDatabaseFileName));
- var node = doc.SelectSingleNode("//ManifestVersion");
- verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
- reader = new StreamReader(@Path.Combine(appDataPath, taskDatabaseFileName));
- }
+ if (File.Exists(@Path.Combine(appDataPath, file.Name)))
+ {
+ doc.Load(@Path.Combine(appDataPath, file.Name));
+ var node = doc.SelectSingleNode("//ManifestVersion");
+ verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
+ reader = new StreamReader(@Path.Combine(appDataPath, file.Name));
+ } // old Variant. Needed to open old databases
+ else if(File.Exists(@Path.Combine(appDataPath, taskDatabaseFileName)))
+ {
+ doc.Load(@Path.Combine(appDataPath, taskDatabaseFileName));
+ var node = doc.SelectSingleNode("//ManifestVersion");
+ verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
+ reader = new StreamReader(@Path.Combine(appDataPath, taskDatabaseFileName));
+ }
- try
- {
- XmlSerializer serializer = new XmlSerializer(typeof(ChipTaskHandlerModel));
- SetupModel = (serializer.Deserialize(reader) as ChipTaskHandlerModel);
- reader.Close();
+ try
+ {
+ XmlSerializer serializer = new XmlSerializer(typeof(ChipTaskHandlerModel));
+ SetupModel = (serializer.Deserialize(reader) as ChipTaskHandlerModel);
+ reader.Close();
+ }
+ catch (Exception e)
+ {
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
+ }
}
- catch (Exception e)
+
+ if (verInfo > Convert.ToInt32(string.Format("{0}{1}{2}", Version.Major, Version.Minor, Version.Build)))
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(string.Format("{0}; {1}", DateTime.Now, string.Format("database that was tried to open is newer ({0}) than this version of rfidgear ({1})"
+ , verInfo, Convert.ToInt32(string.Format("{0}{1}{2}", Version.Major, Version.Minor, Version.Build)))), EventLogEntryType.Warning);
+ return ;
}
}
-
- if (verInfo > Convert.ToInt32(string.Format("{0}{1}{2}", Version.Major, Version.Minor, Version.Build)))
+ catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}; {1}", DateTime.Now, string.Format("database that was tried to open is newer ({0}) than this version of rfidgear ({1})"
- , verInfo, Convert.ToInt32(string.Format("{0}{1}{2}", Version.Major, Version.Minor, Version.Build)))), FacilityName);
- return true;
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
+ return ;
}
- }
- catch (Exception e)
- {
- LogWriter.CreateLogEntry(e, FacilityName);
- return true;
- }
+ }).ConfigureAwait(false);
return false;
}
@@ -210,7 +213,7 @@ public void WriteDatabase(ObservableCollection obj
}
catch (XmlException e)
{
- LogWriter.CreateLogEntry(string.Format("{0}; {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
Environment.Exit(0);
}
}
@@ -248,7 +251,7 @@ public void WriteDatabase(ChipTaskHandlerModel objModel, string _path = "")
}
catch (XmlException e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
@@ -256,31 +259,5 @@ public void DeleteDatabase()
{
File.Delete(Path.Combine(appDataPath, chipDatabaseFileName));
}
-
- private object LoadXML(TextReader reader)
- {
- try
- {
- var serializer = new XmlSerializer(typeof(ChipTaskHandlerModel));
- return (serializer.Deserialize(reader) as ChipTaskHandlerModel);
- }
- catch (Exception e)
- {
- LogWriter.CreateLogEntry(e, FacilityName);
-
- try
- {
- var serializer = new XmlSerializer(typeof(ObservableCollection));
- return serializer.Deserialize(reader) as ObservableCollection;
- }
-
- catch (Exception innerE)
- {
- LogWriter.CreateLogEntry(innerE, FacilityName);
- }
- }
-
- return null;
- }
}
}
\ No newline at end of file
diff --git a/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs b/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs
index 4d235a5..8260ba3 100644
--- a/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs
+++ b/RFiDGear/DataAccessLayer/Remote/FromFile/ReportReaderWriter.cs
@@ -1,13 +1,12 @@
-using GemBox.Pdf;
-
-using Log4CSharp;
-
-using System;
+using System;
using System.Collections.ObjectModel;
-using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
+using System.Linq;
using System.Reflection;
+using System.Threading.Tasks;
using System.Xml;
+using GemBox.Pdf;
namespace RFiDGear.DataAccessLayer
{
@@ -17,10 +16,8 @@ namespace RFiDGear.DataAccessLayer
public class ReportReaderWriter : IDisposable
{
#region fields
- private static readonly string FacilityName = "RFiDGear";
-
private readonly Version Version = Assembly.GetExecutingAssembly().GetName().Version;
-
+ private readonly EventLog eventLog = new EventLog("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
private const string reportTemplateTempFileName = "temptemplate.pdf";
private readonly string appDataPath;
public string ReportOutputPath { get; set; }
@@ -51,7 +48,7 @@ public ReportReaderWriter()
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}; {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return;
}
}
@@ -78,7 +75,7 @@ public ObservableCollection GetReportFields()
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
@@ -87,82 +84,96 @@ public ObservableCollection GetReportFields()
}
catch (XmlException e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return null;
}
}
- public void SetReportField(string _field, string _value)
+ public async Task SetReportField(string _field, string _value)
{
if (!String.IsNullOrWhiteSpace(ReportOutputPath))
{
try
{
- using (var pdfDoc = PdfDocument.Load(ReportTemplateFile)) // (new PdfReader(ReportTemplateFile), new PdfWriter(ReportOutputPath)))
+ await Task.Run(() =>
{
- try
+ using (var pdfDoc = PdfDocument.Load(ReportTemplateFile))
{
- ReportTemplateFile = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName);
+ try
+ {
+ ReportTemplateFile = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName);
- var form = pdfDoc.Form;
- pdfDoc.Info.Title = "RFiDGear Report";
- pdfDoc.Info.Author = "RFiDGear";
+ var form = pdfDoc.Form;
+ pdfDoc.Info.Title = "RFiDGear Report";
+ pdfDoc.Info.Author = "RFiDGear";
- pdfDoc.Form.Fields[_field].Hidden = false;
- pdfDoc.Form.Fields[_field].ReadOnly = false;
- pdfDoc.Form.Fields[_field].Value = _value;
+ if (pdfDoc.Form.Fields.Any(x => x.Name == _field))
+ {
+ pdfDoc.Form.Fields[_field].Hidden = false;
+ pdfDoc.Form.Fields[_field].ReadOnly = false;
+ pdfDoc.Form.Fields[_field].Value = _value;
+ }
- pdfDoc.Save(ReportOutputPath);
- pdfDoc.Close();
+ pdfDoc.Save(ReportOutputPath);
+ pdfDoc.Close();
- File.Copy(ReportOutputPath, System.IO.Path.Combine(appDataPath, reportTemplateTempFileName), true);
- }
- catch (Exception e)
- {
- LogWriter.CreateLogEntry(e, FacilityName);
+ File.Copy(ReportOutputPath, System.IO.Path.Combine(appDataPath, reportTemplateTempFileName), true);
+ }
+ catch (Exception e)
+ {
+ eventLog.WriteEntry(string.Format(e.Message + "; SetReportField: " + _field), EventLogEntryType.Error);
+ }
}
- }
+ }).ConfigureAwait(true);
+
+ return;
}
catch (XmlException e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
-
+ return;
}
- public void ConcatReportField(string _field, string _value)
+ public async Task ConcatReportField(string _field, string _value)
{
if (!String.IsNullOrWhiteSpace(ReportOutputPath))
{
try
{
- ReportTemplateFile = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName);
-
- using (var pdfDoc = PdfDocument.Load(ReportTemplateFile))
+ await Task.Run(() =>
{
- try
+ ReportTemplateFile = System.IO.Path.Combine(appDataPath, reportTemplateTempFileName);
+
+ using (var pdfDoc = PdfDocument.Load(ReportTemplateFile))
{
- var form = pdfDoc.Form;
+ try
+ {
+ var form = pdfDoc.Form;
- pdfDoc.Form.Fields[_field].Hidden = false;
- pdfDoc.Form.Fields[_field].ReadOnly = false;
- pdfDoc.Form.Fields[_field].Value = string.Format("{0}{1}", pdfDoc.Form.Fields[_field]?.Value, _value);
+ pdfDoc.Form.Fields[_field].Hidden = false;
+ pdfDoc.Form.Fields[_field].ReadOnly = false;
+ pdfDoc.Form.Fields[_field].Value = string.Format("{0}{1}", pdfDoc.Form.Fields[_field]?.Value, _value);
- pdfDoc.Save(ReportOutputPath);
- pdfDoc.Close();
+ pdfDoc.Save(ReportOutputPath);
+ pdfDoc.Close();
- File.Copy(ReportOutputPath, System.IO.Path.Combine(appDataPath, reportTemplateTempFileName), true);
- }
- catch (Exception e)
- {
- LogWriter.CreateLogEntry(e, FacilityName);
+ File.Copy(ReportOutputPath, System.IO.Path.Combine(appDataPath, reportTemplateTempFileName), true);
+ }
+ catch (Exception e)
+ {
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
+ }
}
- }
+
+ return;
+ }).ConfigureAwait(false);
+
}
catch (XmlException e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
@@ -187,7 +198,7 @@ protected virtual void Dispose(bool disposing)
catch (XmlException e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
diff --git a/RFiDGear/DataAccessLayer/Remote/FromFile/SettingsReaderWriter.cs b/RFiDGear/DataAccessLayer/Remote/FromFile/SettingsReaderWriter.cs
index 397a387..3e14dc0 100644
--- a/RFiDGear/DataAccessLayer/Remote/FromFile/SettingsReaderWriter.cs
+++ b/RFiDGear/DataAccessLayer/Remote/FromFile/SettingsReaderWriter.cs
@@ -1,15 +1,13 @@
-using RFiDGear.DataAccessLayer;
-using RFiDGear.Model;
-
-using Log4CSharp;
-
-using System;
+using System;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
+using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
+using RFiDGear.Model;
namespace RFiDGear
{
@@ -19,8 +17,7 @@ namespace RFiDGear
public class SettingsReaderWriter : IDisposable
{
#region fields
- private static readonly string FacilityName = "RFiDGear";
-
+ private readonly EventLog eventLog = new EventLog("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
private readonly string _settingsFileFileName = "settings.xml";
private readonly string _updateConfigFileFileName = "update.xml";
private readonly string _updateURL = @"https://github.com/c3rebro/RFiDGear/releases/latest/download/update.xml";
@@ -30,7 +27,7 @@ public class SettingsReaderWriter : IDisposable
private readonly string _infoText = "Version Info\n\ngoes here! \n==>";
private readonly string _baseUri = @"https://github.com/c3rebro/RFiDGear/releases/latest/download/";
- private readonly XmlWriter xmlWriter;
+
private readonly Version Version = Assembly.GetExecutingAssembly().GetName().Version;
private readonly string appDataPath;
@@ -41,7 +38,7 @@ public DefaultSpecification DefaultSpecification
{
get
{
- ReadSettings();
+ ReadSettings().GetAwaiter().GetResult();
return defaultSpecification ?? new DefaultSpecification();
}
@@ -50,7 +47,7 @@ public DefaultSpecification DefaultSpecification
defaultSpecification = value;
if (defaultSpecification != null)
{
- SaveSettings();
+ SaveSettings().GetAwaiter().GetResult();
}
}
}
@@ -71,50 +68,10 @@ public SettingsReaderWriter()
{
Directory.CreateDirectory(appDataPath);
}
-
- var xmlSettings = new XmlWriterSettings();
- xmlSettings.Encoding = new UTF8Encoding(false);
-
- xmlWriter = XmlWriter.Create(Path.Combine(appDataPath, _updateConfigFileFileName), xmlSettings);
- xmlWriter.WriteStartDocument();
- xmlWriter.WriteStartElement("Manifest");
- xmlWriter.WriteAttributeString("version", string.Format("{0}.{1}.{2}", Version.Major, Version.Minor, Version.Build));
-
- xmlWriter.WriteEndElement();
- xmlWriter.Close();
-
- var doc = new XmlDocument();
- doc.Load(Path.Combine(appDataPath, _updateConfigFileFileName));
-
- if (doc.SelectSingleNode("//CheckInterval") == null)
- {
- var CheckIntervalElem = doc.CreateElement("CheckInterval");
- var RemoteConfigUriElem = doc.CreateElement("RemoteConfigUri");
- var SecurityTokenElem = doc.CreateElement("SecurityToken");
- var BaseUriElem = doc.CreateElement("BaseUri");
- var PayLoadElem = doc.CreateElement("Payload");
- var InfoTextElem = doc.CreateElement("VersionInfoText");
-
- doc.DocumentElement.AppendChild(CheckIntervalElem);
- doc.DocumentElement.AppendChild(RemoteConfigUriElem);
- doc.DocumentElement.AppendChild(SecurityTokenElem);
- doc.DocumentElement.AppendChild(BaseUriElem);
- doc.DocumentElement.AppendChild(PayLoadElem);
- doc.DocumentElement.AppendChild(InfoTextElem);
-
- CheckIntervalElem.InnerText = _updateInterval.ToString(CultureInfo.CurrentCulture);
- RemoteConfigUriElem.InnerText = _updateURL;
- SecurityTokenElem.InnerText = _securityToken;
- BaseUriElem.InnerText = _baseUri;
- PayLoadElem.InnerText = _payload;
- InfoTextElem.InnerText = _infoText;
-
- doc.Save(Path.Combine(appDataPath, _updateConfigFileFileName));
- }
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
if (!File.Exists(Path.Combine(appDataPath, _settingsFileFileName)))
@@ -133,7 +90,7 @@ public SettingsReaderWriter()
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}; {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
}
@@ -142,16 +99,65 @@ public SettingsReaderWriter()
///
///
///
- public bool ReadSettings()
+ public void InitUpdateFile()
+ {
+ XmlWriter xmlWriter;
+ var xmlSettings = new XmlWriterSettings();
+ xmlSettings.Encoding = new UTF8Encoding(false);
+
+ xmlWriter = XmlWriter.Create(Path.Combine(appDataPath, _updateConfigFileFileName), xmlSettings);
+ xmlWriter.WriteStartDocument();
+ xmlWriter.WriteStartElement("Manifest");
+ xmlWriter.WriteAttributeString("version", string.Format("{0}.{1}.{2}", Version.Major, Version.Minor, Version.Build));
+
+ xmlWriter.WriteEndElement();
+ xmlWriter.Close();
+
+ var doc = new XmlDocument();
+ doc.Load(Path.Combine(appDataPath, _updateConfigFileFileName));
+
+ if (doc.SelectSingleNode("//CheckInterval") == null)
+ {
+ var CheckIntervalElem = doc.CreateElement("CheckInterval");
+ var RemoteConfigUriElem = doc.CreateElement("RemoteConfigUri");
+ var SecurityTokenElem = doc.CreateElement("SecurityToken");
+ var BaseUriElem = doc.CreateElement("BaseUri");
+ var PayLoadElem = doc.CreateElement("Payload");
+ var InfoTextElem = doc.CreateElement("VersionInfoText");
+
+ doc.DocumentElement.AppendChild(CheckIntervalElem);
+ doc.DocumentElement.AppendChild(RemoteConfigUriElem);
+ doc.DocumentElement.AppendChild(SecurityTokenElem);
+ doc.DocumentElement.AppendChild(BaseUriElem);
+ doc.DocumentElement.AppendChild(PayLoadElem);
+ doc.DocumentElement.AppendChild(InfoTextElem);
+
+ CheckIntervalElem.InnerText = _updateInterval.ToString(CultureInfo.CurrentCulture);
+ RemoteConfigUriElem.InnerText = _updateURL;
+ SecurityTokenElem.InnerText = _securityToken;
+ BaseUriElem.InnerText = _baseUri;
+ PayLoadElem.InnerText = _payload;
+ InfoTextElem.InnerText = _infoText;
+
+ doc.Save(Path.Combine(appDataPath, _updateConfigFileFileName));
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadSettings()
{
- return ReadSettings("");
+ await ReadSettings("").ConfigureAwait(false);
+ return;
}
///
///
///
///
- public bool ReadSettings(string _fileName)
+ public async Task ReadSettings(string _fileName)
{
TextReader reader;
int verInfo;
@@ -167,43 +173,38 @@ public bool ReadSettings(string _fileName)
try
{
- var serializer = new XmlSerializer(typeof(DefaultSpecification));
-
- if (string.IsNullOrWhiteSpace(_fileName) && File.Exists(Path.Combine(appDataPath, _settingsFileFileName)))
+ await Task.Run(() =>
{
- doc.Load(@Path.Combine(appDataPath, _settingsFileFileName));
+ var serializer = new XmlSerializer(typeof(DefaultSpecification));
- var node = doc.SelectSingleNode("//ManifestVersion");
- verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
+ if (string.IsNullOrWhiteSpace(_fileName) && File.Exists(Path.Combine(appDataPath, _settingsFileFileName)))
+ {
+ doc.Load(@Path.Combine(appDataPath, _settingsFileFileName));
- reader = new StreamReader(Path.Combine(appDataPath, _settingsFileFileName));
- }
- else
- {
- doc.Load(_fileName);
+ var node = doc.SelectSingleNode("//ManifestVersion");
+ verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
- var node = doc.SelectSingleNode("//ManifestVersion");
- verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
+ reader = new StreamReader(Path.Combine(appDataPath, _settingsFileFileName));
+ }
+ else
+ {
+ doc.Load(_fileName);
- reader = new StreamReader(_fileName);
- }
+ var node = doc.SelectSingleNode("//ManifestVersion");
+ verInfo = Convert.ToInt32(node.InnerText.Replace(".", string.Empty));
- if (verInfo > Convert.ToInt32(string.Format("{0}{1}{2}", Version.Major, Version.Minor, Version.Build)))
- {
- throw new Exception(
- string.Format("database that was tried to open is newer ({0}) than this version of rfidgear ({1})"
- , verInfo, Convert.ToInt32(string.Format("{0}{1}{2}", Version.Major, Version.Minor, Version.Build))
- )
- );
- }
+ reader = new StreamReader(_fileName);
+ }
+
+ defaultSpecification = (serializer.Deserialize(reader) as DefaultSpecification);
- defaultSpecification = (serializer.Deserialize(reader) as DefaultSpecification);
+ reader.Close();
- reader.Close();
+ }).ConfigureAwait(false);
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return true;
}
@@ -217,24 +218,32 @@ public bool ReadSettings(string _fileName)
///
///
///
- public bool SaveSettings(string _path = "")
+ public async Task SaveSettings(string _path = "")
{
try
{
- TextWriter textWriter;
- var serializer = new XmlSerializer(typeof(DefaultSpecification));
+ await Task.Run(() => {
+
+ if (defaultSpecification == null)
+ {
+ return;
+ }
- textWriter = new StreamWriter(!string.IsNullOrEmpty(_path) ? @_path : @Path.Combine(appDataPath, _settingsFileFileName), false);
+ TextWriter textWriter;
+ var serializer = new XmlSerializer(typeof(DefaultSpecification));
+
+ textWriter = new StreamWriter(!string.IsNullOrEmpty(_path) ? @_path : @Path.Combine(appDataPath, _settingsFileFileName), false);
- serializer.Serialize(textWriter, defaultSpecification);
+ serializer.Serialize(textWriter, defaultSpecification);
- textWriter.Close();
+ textWriter.Close();
+ }).ConfigureAwait(false);
return true;
}
catch (XmlException e)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return false;
}
}
@@ -247,25 +256,15 @@ protected virtual void Dispose(bool disposing)
{
try
{
- if (xmlWriter != null)
- {
- xmlWriter.Close();
- }
-
defaultSpecification = null;
- // Dispose any managed objects
- // ...
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(string.Format("{0}: {1}; {2}", DateTime.Now, e.Message, e.InnerException != null ? e.InnerException.Message : ""), FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
- // Now disposed of any unmanaged objects
- // ...
-
_disposed = true;
}
}
diff --git a/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs b/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs
index 287c630..5ed41b3 100644
--- a/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs
+++ b/RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs
@@ -1,28 +1,22 @@
-using Elatec.NET.Model;
-using Elatec.NET;
-
-using RFiDGear.Model;
-
-using Log4CSharp;
-
+//using Elatec.NET.Model;
using System;
-using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
-using System.Text;
+using System.Reflection;
+using System.Threading;
using System.Threading.Tasks;
-using System.Security.Cryptography;
using ByteArrayHelper.Extensions;
-using RFiDGear.ViewModel;
-using System.Runtime.InteropServices.WindowsRuntime;
+using Elatec.NET;
+using Elatec.NET.Cards.Mifare;
+using RFiDGear.Model;
namespace RFiDGear.DataAccessLayer.Remote.FromIO
{
public class ElatecNetProvider : ReaderDevice, IDisposable
{
- private static readonly string FacilityName = "RFiDGear";
-
- private readonly TWN4ReaderDevice readerDevice;
+ private TWN4ReaderDevice readerDevice;
+ private readonly EventLog eventLog = new EventLog("Application", ".", Assembly.GetEntryAssembly().GetName().Name);
private GenericChipModel hfTag;
private GenericChipModel lfTag;
@@ -30,259 +24,377 @@ public class ElatecNetProvider : ReaderDevice, IDisposable
private bool _disposed;
+ public override string ReaderUnitName
+ {
+ get; set;
+ }
+ public override string ReaderUnitVersion
+ {
+ get; set;
+ }
+
#region Constructor
- public ElatecNetProvider()
+ private async Task Initialize()
{
+ if (GenericChip == null)
+ {
+ GenericChip = new List();
+ }
+
try
{
- readerDevice = new TWN4ReaderDevice(PortNumber);
+ var readerList = TWN4ReaderDevice.Instance;
+
+ if (readerList != null && readerList.Count > 0)
+ {
+ readerDevice = readerList.FirstOrDefault();
+
+ if (readerDevice.IsConnected)
+ {
+ ReaderUnitVersion = await readerDevice.GetVersionStringAsync();
+ }
+ else if (readerDevice != null && readerDevice.AvailableReadersCount >= 1 && !readerDevice.IsConnected)
+ {
+ if (await readerDevice.ConnectAsync())
+ {
+ ReaderUnitVersion = await readerDevice.GetVersionStringAsync();
+ }
+ }
+ }
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
- public ElatecNetProvider(int _comPort)
+ public ElatecNetProvider()
{
- try
+ if (GenericChip == null)
{
- readerDevice = new TWN4ReaderDevice(_comPort);
+ GenericChip = new List();
}
- catch (Exception e)
- {
- LogWriter.CreateLogEntry(e, FacilityName);
- }
-
}
#endregion
#region Common
+ ///
+ ///
+ ///
+ public override bool IsConnected => readerDevice?.IsConnected == true;
+
///
///
///
///
- public override ERROR ReadChipPublic()
+ public async override Task ReadChipPublic()
{
try
{
- if (readerDevice != null)
+ if (readerDevice == null)
+ {
+ await Initialize();
+ }
+
+ else if (readerDevice != null)
{
+
if (!readerDevice.IsConnected)
{
- Instance.Connect();
+ await readerDevice.ConnectAsync();
}
- var tmpTag = readerDevice.GetSingleChip(true);
- hfTag = new GenericChipModel(tmpTag.UID, (RFiDGear.DataAccessLayer.CARD_TYPE)tmpTag.CardType, tmpTag.SAK, tmpTag.RATS, tmpTag.VersionL4);
- tmpTag = readerDevice.GetSingleChip(false);
- lfTag = new GenericChipModel(tmpTag.UID, (RFiDGear.DataAccessLayer.CARD_TYPE)tmpTag.CardType);
- tmpTag = readerDevice.GetSingleChip(true, true);
- legicTag = new GenericChipModel(tmpTag.UID, (RFiDGear.DataAccessLayer.CARD_TYPE)tmpTag.CardType);
- readerDevice.GetSingleChip(true);
+ await readerDevice.SetTagTypesAsync(LFTagTypes.NOTAG, HFTagTypes.AllHFTags & ~HFTagTypes.LEGIC);
+ var tmpTag = await readerDevice.GetSingleChipAsync();
- if (
- !(
- string.IsNullOrWhiteSpace(hfTag?.UID) &
- string.IsNullOrWhiteSpace(lfTag?.UID) &
- string.IsNullOrWhiteSpace(legicTag?.UID)
- )
- )
+ if (tmpTag != null && tmpTag.ChipType == ChipType.MIFARE)
{
- try
+ if ((MifareChipSubType)((byte)(tmpTag as MifareChip).SubType & 0xF0) == MifareChipSubType.MifareClassic)
+ {
+ hfTag = new MifareClassicChipModel(tmpTag.UIDHexString, (CARD_TYPE)((short)(tmpTag as MifareChip).SubType << 8));
+ }
+ else if ((MifareChipSubType)((byte)(tmpTag as MifareChip).SubType & 0x40) == MifareChipSubType.DESFire)
+ {
+ hfTag = new MifareDesfireChipModel(tmpTag.UIDHexString, (CARD_TYPE)((short)(tmpTag as MifareChip).SubType << 8),
+ ByteArrayConverter.GetStringFrom((tmpTag as MifareChip).SAK),
+ ByteArrayConverter.GetStringFrom((tmpTag as MifareChip).ATS),
+ ByteArrayConverter.GetStringFrom((tmpTag as MifareChip).VersionL4));
+ }
+ else
{
- readerDevice.GreenLED(true);
- readerDevice.RedLED(false);
+ hfTag = new GenericChipModel(tmpTag.UIDHexString, (CARD_TYPE)((short)(tmpTag as MifareChip).SubType << 8));
+ }
+ }
+ else if (tmpTag == null)
+ {
+ hfTag = null;
+ }
- GenericChip = new GenericChipModel(hfTag.UID,
- (CARD_TYPE)hfTag.CardType,
- hfTag.SAK,
- hfTag.RATS,
- hfTag.VersionL4
- );
+ await readerDevice.SetTagTypesAsync(LFTagTypes.AllLFTags, HFTagTypes.NOTAG);
+ tmpTag = await readerDevice.GetSingleChipAsync();
+ lfTag = tmpTag != null ? new GenericChipModel(tmpTag.UIDHexString, (CARD_TYPE)tmpTag.ChipType) : null;
- if (lfTag != null && lfTag?.CardType != CARD_TYPE.NOTAG)
- {
- if(GenericChip != null && GenericChip.CardType != CARD_TYPE.NOTAG)
- {
- GenericChip.Child = new GenericChipModel(lfTag.UID, lfTag.CardType);
- }
- else
- {
- GenericChip = new GenericChipModel(lfTag.UID, lfTag.CardType);
- }
- }
- else if (legicTag != null && legicTag?.CardType != CARD_TYPE.NOTAG)
- {
- if (GenericChip != null && GenericChip.CardType != CARD_TYPE.NOTAG)
- {
- GenericChip.Child = new GenericChipModel(legicTag.UID, legicTag.CardType);
- }
- else
- {
- GenericChip = new GenericChipModel(legicTag.UID, legicTag.CardType);
- }
- }
- //readerDevice.GetSingleChip(true);
+ await readerDevice.SetTagTypesAsync(LFTagTypes.NOTAG, HFTagTypes.LEGIC);
+ tmpTag = await readerDevice.GetSingleChipAsync();
+ legicTag = tmpTag != null ? new GenericChipModel(tmpTag.UIDHexString, (CARD_TYPE)tmpTag.ChipType) : null;
- return ERROR.NoError;
- }
- catch (Exception e)
+ await readerDevice.SetTagTypesAsync(LFTagTypes.NOTAG, HFTagTypes.AllHFTags);
+
+ if (!string.IsNullOrWhiteSpace(hfTag?.UID) && GenericChip.Any(x => x.UID == hfTag.UID))
+ {
+ return ERROR.NoError;
+ }
+
+ if (!string.IsNullOrWhiteSpace(hfTag?.UID) && !GenericChip.Any(x => x.UID == hfTag.UID))
+ {
+ GenericChip = new List();
+
+ if (!string.IsNullOrWhiteSpace(hfTag?.UID))
{
- LogWriter.CreateLogEntry(e, FacilityName);
- return ERROR.IOError;
+ GenericChip.Add(hfTag);
+
+ if (GenericChip[0].Childs == null)
+ {
+ GenericChip[0].Childs = new List();
+ }
}
}
- else
+
+ if (!string.IsNullOrEmpty(lfTag?.UID))
{
- readerDevice.Beep(3, 25, 600, 100);
- readerDevice.RedLED(true);
- GenericChip = null;
+ GenericChip[0].Childs.Add(lfTag);
+ }
- return ERROR.NotReadyError;
+ if (!string.IsNullOrEmpty(legicTag?.UID))
+ {
+ GenericChip[0].Childs.Add(legicTag);
}
}
- else
+ if (hfTag == null && lfTag == null && legicTag == null)
{
- return ERROR.IOError;
+ GenericChip = new List();
}
+
+ return ERROR.NoError;
}
catch (Exception e)
{
- if (readerDevice != null)
- {
- readerDevice.Dispose();
- }
-
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return ERROR.IOError;
}
}
+
///
///
///
///
- public override ERROR Connect()
+ public async override Task ConnectAsync()
{
- readerDevice.Beep(1, 50, 1000, 100);
- readerDevice.GreenLED(true);
- readerDevice.RedLED(false);
- return TWN4ReaderDevice.Instance.Connect() == true ? ERROR.NoError : ERROR.IOError;
+ readerDevice = TWN4ReaderDevice.Instance.FirstOrDefault();
+
+ if (readerDevice == null)
+ {
+ return ERROR.NotReadyError;
+ }
+
+ if (readerDevice != null && !readerDevice.IsConnected)
+ {
+ var result = false;
+
+ if (!readerDevice.IsConnected)
+ {
+ result = await readerDevice.ConnectAsync();
+ }
+
+ if (result)
+ {
+ ReaderUnitVersion = await readerDevice.GetVersionStringAsync();
+ return ERROR.NoError;
+ }
+ }
+
+ return ERROR.NotReadyError;
}
#endregion
#region MifareClassic
- public override ERROR WriteMifareClassicSingleBlock(int _blockNumber, string _aKey, string _bKey, byte[] buffer)
+
+ public async override Task WriteMifareClassicSingleBlock(int _blockNumber, string _aKey, string _bKey, byte[] buffer)
{
- if (!readerDevice.MifareClassicLogin(_aKey, 0, (byte)CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber))) // No Access Allowed, try bKey
+ return await Task.Run(async () =>
{
- readerDevice.MifareClassicLogin(_bKey, 1, (byte)CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber));
-
- } // Login
+ try
+ {
+ await readerDevice.MifareClassic_LoginAsync(_aKey, 0, (byte)CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber));
+ }
+ catch
+ {
+ try
+ {
+ await readerDevice.MifareClassic_LoginAsync(_bKey, 1, (byte)CustomConverter.GetSectorNumberFromChipBasedDataBlockNumber(_blockNumber));
+ }
+ catch
+ {
+ try
+ {
+ await readerDevice.MifareClassic_WriteBlockAsync(buffer, (byte)_blockNumber);
+ }
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+ }
+ } // Login
+ return ERROR.NoError;
+ });
- return readerDevice.MifareClassicWriteBlock(buffer, (byte)_blockNumber) == true ? ERROR.NoError : ERROR.AuthenticationError;
}
- public override ERROR ReadMifareClassicSingleSector(int sectorNumber, string aKey, string bKey)
+ public async override Task ReadMifareClassicSingleSector(int sectorNumber, string aKey, string bKey)
{
- return readWriteAccessOnClassicSector(sectorNumber, aKey, bKey, null);
+ return await ReadWriteAccessOnClassicSector(sectorNumber, aKey, bKey, null);
}
- public override ERROR WriteMifareClassicSingleSector(int sectorNumber, string aKey, string bKey, byte[] buffer)
+ public async override Task WriteMifareClassicSingleSector(int sectorNumber, string aKey, string bKey, byte[] buffer)
{
- return readWriteAccessOnClassicSector(sectorNumber, aKey, bKey, buffer);
+ return await ReadWriteAccessOnClassicSector(sectorNumber, aKey, bKey, buffer);
}
-
- public override ERROR WriteMifareClassicWithMAD(int _madApplicationID, int _madStartSector,
+
+ public async override Task WriteMifareClassicWithMAD(int _madApplicationID, int _madStartSector,
string _aKeyToUse, string _bKeyToUse, string _aKeyToWrite, string _bKeyToWrite,
- string _madAKeyToUse, string _madBKeyToUse, string _madAKeyToWrite,
- string _madBKeyToWrite, byte[] buffer, byte _madGPB, SectorAccessBits _sab,
+ string _madAKeyToUse, string _madBKeyToUse, string _madAKeyToWrite,
+ string _madBKeyToWrite, byte[] buffer, byte _madGPB, SectorAccessBits _sab,
bool _useMADToAuth, bool _keyToWriteUseMAD)
{
throw new NotImplementedException();
}
- public override ERROR ReadMifareClassicWithMAD(int madApplicationID, string _aKeyToUse,
- string _bKeyToUse, string _madAKeyToUse, string _madBKeyToUse, int _length, byte _madGPB,
+ public async override Task ReadMifareClassicWithMAD(int madApplicationID, string _aKeyToUse,
+ string _bKeyToUse, string _madAKeyToUse, string _madBKeyToUse, int _length, byte _madGPB,
bool _useMADToAuth, bool _aiToUseIsMAD)
{
throw new NotImplementedException();
}
-
- private ERROR readWriteAccessOnClassicSector(int sectorNumber, string aKey, string bKey, byte[] buffer)
- {
- Sector = new MifareClassicSectorModel();
- var elatecSpecificSectorNumber = sectorNumber > 31 ? (sectorNumber - 32) * 4 + 32 : sectorNumber; // elatec uses special sectornumbers
-
- for (byte k = 0; k < (sectorNumber > 31 ? 16 : 4); k++) // if sector > 31 is 16 blocks each sector i.e. mifare 4k else its 1k or 2k with 4 blocks each sector
+ private async Task ReadWriteAccessOnClassicSector(int sectorNumber, string aKey, string bKey, byte[] buffer)
+ {
+ if (readerDevice.IsConnected)
{
- DataBlock = new MifareClassicDataBlockModel(
- (byte)CustomConverter.GetChipBasedDataBlockNumber(sectorNumber, k),
- k);
-
- try
+ return await Task.Run(async () =>
{
- var isAuth = readerDevice.MifareClassicLogin(aKey, 0, (byte)elatecSpecificSectorNumber);
-
- if (buffer == null || buffer.Length != 16) // Read Mode
+ if (readerDevice.IsTWN4LegicReader)
{
- var data = readerDevice.MifareClassicReadBlock((byte)CustomConverter.GetChipBasedDataBlockNumber(sectorNumber, k));
-
- if (data.Length > 1)
+ try
{
- DataBlock.Data = data;
- DataBlock.IsAuthenticated = true;
- Sector.IsAuthenticated = isAuth;
- Sector.DataBlock.Add(DataBlock);
+ await readerDevice.SearchTagAsync();
}
+ catch { }
+ }
- else // No Read Access Allowed, try bKey
- {
- isAuth = readerDevice.MifareClassicLogin(bKey, 1, (byte)elatecSpecificSectorNumber);
+ Sector = new MifareClassicSectorModel();
+
+ var elatecSpecificSectorNumber = sectorNumber > 31 ? (sectorNumber - 32) * 4 + 32 : sectorNumber; // elatec uses special sectornumbers
- data = readerDevice.MifareClassicReadBlock(k);
+ for (byte k = 0; k < (sectorNumber > 31 ? 16 : 4); k++) // if sector > 31 is 16 blocks each sector i.e. mifare 4k else its 1k or 2k with 4 blocks each sector
+ {
+ DataBlock = new MifareClassicDataBlockModel(
+ (byte)CustomConverter.GetChipBasedDataBlockNumber(sectorNumber, k),
+ k);
- if (data.Length > 1)
+ try
+ {
+ var isAuth = false;
+
+ try
{
- DataBlock.Data = data;
- DataBlock.IsAuthenticated = true;
- Sector.IsAuthenticated = isAuth;
- Sector.DataBlock.Add(DataBlock);
+ await readerDevice.MifareClassic_LoginAsync(aKey, 0, (byte)elatecSpecificSectorNumber);
+ isAuth = true;
}
- else
+ catch
{
- Sector.IsAuthenticated = false;
- DataBlock.IsAuthenticated = false; // finally failed to read data
+ isAuth = false;
}
+
+ if (buffer == null || buffer.Length != 16 && isAuth) // Read Mode
+ {
+ try
+ {
+ var data = await readerDevice.MifareClassic_ReadBlockAsync((byte)CustomConverter.GetChipBasedDataBlockNumber(sectorNumber, k));
+
+ if (data.Length > 1)
+ {
+ DataBlock.Data = data;
+ DataBlock.IsAuthenticated = true;
+ Sector.IsAuthenticated = isAuth;
+ Sector.DataBlock.Add(DataBlock);
+ }
+ }
+ catch // No Read Access Allowed, try bKey
+ {
+ try
+ {
+ await readerDevice.MifareClassic_LoginAsync(bKey, 1, (byte)elatecSpecificSectorNumber);
+ isAuth = true;
+
+ var data = await readerDevice.MifareClassic_ReadBlockAsync((byte)CustomConverter.GetChipBasedDataBlockNumber(sectorNumber, k));
+
+ if (data.Length > 1)
+ {
+ DataBlock.Data = data;
+ DataBlock.IsAuthenticated = true;
+ Sector.IsAuthenticated = isAuth;
+ Sector.DataBlock.Add(DataBlock);
+ }
+ }
+ catch
+ {
+ isAuth = false;
+ Sector.IsAuthenticated = false;
+ DataBlock.IsAuthenticated = false; // finally failed to read data
+ }
+ }
+ } // read Data
+
+ else if (buffer != null && buffer.Length == 16)
+ {
+ try
+ {
+ await readerDevice.MifareClassic_WriteBlockAsync(buffer, k);
+ return ERROR.NoError;
+ }
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+ } // write Data
}
- } // read Data
+ catch
+ {
+ return ERROR.IOError; // IO ElatecError
+ }
+ }
- else if (buffer != null && buffer.Length == 16)
+ if (Sector.IsAuthenticated)
{
- return readerDevice.MifareClassicWriteBlock(buffer, k) == true ? ERROR.NoError : ERROR.AuthenticationError;
- } // write Data
- }
- catch
- {
- return ERROR.IOError; // IO ElatecError
- }
+ return ERROR.NoError; //NO ElatecError
+ }
+
+ return ERROR.AuthenticationError; // Auth ElatecError
+ });
}
- if(Sector.IsAuthenticated)
+ else
{
- return ERROR.NoError; //NO ElatecError
+ return ERROR.NotReadyError;
}
-
- return ERROR.AuthenticationError; // Auth ElatecError
}
#endregion
@@ -302,30 +414,58 @@ public override ERROR ReadMifareUltralightSinglePage(int _pageNo)
///
///
/// ElatecError Level
- public override ERROR GetMiFareDESFireChipAppIDs(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey)
+ public async override Task GetMiFareDESFireChipAppIDs(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey)
{
- if (DesfireChip == null)
+ if (readerDevice.IsConnected)
{
- DesfireChip = new MifareDesfireChipModel();
- }
+ return await Task.Run(async () =>
+ {
+ uint[] appArr;
- DesfireChip.AppList = new System.Collections.Generic.List();
- if (readerDevice.DesfireSelectApplication(0))
- {
- DesfireChip.FreeMemory = readerDevice.GetDesfireFreeMemory() ?? 0;
+ if (DesfireChip == null)
+ {
+ DesfireChip = new MifareDesfireChipModel();
+ }
- var appArr = readerDevice.GetDesfireAppIDs();
+ DesfireChip.AppList = new System.Collections.Generic.List();
- if (appArr != null)
- {
- foreach (var appid in appArr)
+ try
{
- DesfireChip.AppList.Add(new MifareDesfireAppModel(appid));
+ await readerDevice.SearchTagAsync();
+ await readerDevice.MifareDesfire_SelectApplicationAsync(0);
+ DesfireChip.FreeMemory = await readerDevice.MifareDesfire_GetFreeMemoryAsync();
}
- }
+ catch
+ {
+ DesfireChip.FreeMemory = 0;
+ }
+
+ try
+ {
+ appArr = await readerDevice.MifareDesfire_GetAppIDsAsync();
+
+ if (appArr != null)
+ {
+ foreach (var appid in appArr)
+ {
+ DesfireChip.AppList.Add(new MifareDesfireAppModel(appid));
+ }
+ }
+ }
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+
+ return ERROR.NoError;
+ });
+ }
+
+ else
+ {
+ return ERROR.NotReadyError;
}
- return ERROR.NoError;
}
///
@@ -336,17 +476,36 @@ public override ERROR GetMiFareDESFireChipAppIDs(string _appMasterKey, DESFireKe
///
///
///
- public override ERROR AuthToMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumber, int _appID)
+ public async override Task AuthToMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumber, int _appID)
{
-
- if (readerDevice.DesfireSelectApplication((uint)_appID))
+ if (readerDevice.IsConnected)
{
- return readerDevice.DesfireAuthenticate(
- _applicationMasterKey,
- (byte)_keyNumber,
- (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)),
- 1) == true ? ERROR.NoError : ERROR.AuthenticationError;
+ if (readerDevice.IsTWN4LegicReader)
+ {
+ try
+ {
+ await readerDevice.SearchTagAsync();
+ }
+ catch { }
+ }
+
+ try
+ {
+ await readerDevice.MifareDesfire_SelectApplicationAsync((uint)_appID);
+
+ await readerDevice.MifareDesfire_AuthenticateAsync(
+ _applicationMasterKey,
+ (byte)_keyNumber,
+ (byte)(int)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)),
+ 1);
+ return ERROR.NoError;
+ }
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
}
+
else
{
return ERROR.NotReadyError;
@@ -362,34 +521,66 @@ public override ERROR AuthToMifareDesfireApplication(string _applicationMasterKe
///
///
///
- public override ERROR GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent, int _appID)
+ public async override Task GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent, int _appID)
{
- if (readerDevice.DesfireSelectApplication((uint)_appID))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.GetDesFireKeySettings())
+ return await Task.Run(async () =>
{
- MaxNumberOfAppKeys = readerDevice.NumberOfKeys;
- EncryptionType = (DESFireKeyType)Enum.Parse(typeof(DESFireKeyType), Enum.GetName(typeof(Elatec.NET.DESFireKeyType), readerDevice.KeyType));
- DesfireAppKeySetting = (DESFireKeySettings)readerDevice.KeySettings;
+ if (readerDevice.IsTWN4LegicReader)
+ {
+ try
+ {
+ await readerDevice.SearchTagAsync();
+ }
+ catch { }
+ }
- return ERROR.NoError;
- } // Get Settings without authentication
- else
- {
- if (readerDevice.DesfireAuthenticate(_applicationMasterKey, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1))
+ try
{
- MaxNumberOfAppKeys = readerDevice.NumberOfKeys;
- EncryptionType = (DESFireKeyType)readerDevice.KeyType;
- DesfireAppKeySetting = (DESFireKeySettings)readerDevice.KeySettings;
+ await readerDevice.MifareDesfire_SelectApplicationAsync((uint)_appID);
- return ERROR.NoError;
+ try
+ {
+ var ks = await readerDevice.MifareDesfire_GetKeySettingsAsync();
+
+ MaxNumberOfAppKeys = (byte)ks.NumberOfKeys;
+ EncryptionType = (DESFireKeyType)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), ks.KeyType));
+ DesfireAppKeySetting = (DESFireKeySettings)ks.AccessRights;
+
+ return ERROR.NoError;
+ } // Get Settings without authentication
+ catch
+ {
+ try
+ {
+ await readerDevice.MifareDesfire_AuthenticateAsync(_applicationMasterKey, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1);
+ var ks = await readerDevice.MifareDesfire_GetKeySettingsAsync();
+
+ MaxNumberOfAppKeys = (byte)ks.NumberOfKeys;
+ EncryptionType = (DESFireKeyType)Enum.Parse(typeof(DESFireKeyType), Enum.GetName(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), ks.KeyType));
+ DesfireAppKeySetting = (DESFireKeySettings)ks.AccessRights;
+
+ return ERROR.NoError;
+ }
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+ } // needs Auth
}
- return ERROR.AuthenticationError;
- } // authenticate first
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+ });
+ }
+ else
+ {
+ return ERROR.NotReadyError;
}
- return ERROR.AuthenticationError;
}
///
@@ -403,79 +594,135 @@ public override ERROR GetMifareDesfireAppSettings(string _applicationMasterKey,
///
///
///
- public override ERROR CreateMifareDesfireApplication(string _piccMasterKey, DESFireKeySettings _keySettingsTarget,
+ public async override Task CreateMifareDesfireApplication(string _piccMasterKey, DESFireKeySettings _keySettingsTarget,
DESFireKeyType _keyTypePiccMasterKey, DESFireKeyType _keyTypeTargetApplication,
int _maxNbKeys, int _appID, bool authenticateToPICCFirst = true)
{
- if (readerDevice.DesfireSelectApplication(0))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireAuthenticate(_piccMasterKey, 0x00, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypePiccMasterKey)), 1))
+ if (readerDevice.IsTWN4LegicReader)
{
- if (readerDevice.DesfireCreateApplication(
- (Elatec.NET.DESFireKeySettings)_keySettingsTarget,
- (Elatec.NET.DESFireKeyType)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTargetApplication)),
- _maxNbKeys,
- _appID))
+ try
{
- return ERROR.NoError;
- }
- else
- {
- return ERROR.AuthenticationError;
+ await readerDevice.SearchTagAsync();
}
+ catch { }
}
- else
+
+ try
{
- if (readerDevice.DesfireCreateApplication((Elatec.NET.DESFireKeySettings)_keySettingsTarget, (Elatec.NET.DESFireKeyType)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTargetApplication)), _maxNbKeys, _appID))
+ await readerDevice.MifareDesfire_SelectApplicationAsync(0);
+
+ await readerDevice.MifareDesfire_CreateApplicationAsync(
+ (Elatec.NET.Cards.Mifare.DESFireAppAccessRights)_keySettingsTarget,
+ (Elatec.NET.Cards.Mifare.DESFireKeyType)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTargetApplication)),
+ _maxNbKeys,
+ _appID);
+ return ERROR.NoError;
+ } // free create ?
+ catch
+ {
+ try
{
+ await readerDevice.MifareDesfire_AuthenticateAsync(_piccMasterKey, 0, (byte)(int)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypePiccMasterKey)), 1);
+
+ await readerDevice.MifareDesfire_CreateApplicationAsync(
+ (Elatec.NET.Cards.Mifare.DESFireAppAccessRights)_keySettingsTarget,
+ (Elatec.NET.Cards.Mifare.DESFireKeyType)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTargetApplication)),
+ _maxNbKeys,
+ _appID);
+
return ERROR.NoError;
- }
- else
+ } // auth first ?
+ catch
{
return ERROR.AuthenticationError;
}
}
}
- return ERROR.IOError;
-
+
+ else
+ {
+ return ERROR.NotReadyError;
+ }
+
+
}
- public override ERROR ChangeMifareDesfireApplicationKey(string _applicationMasterKeyCurrent, int _keyNumberCurrent, DESFireKeyType _keyTypeCurrent,
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async override Task ChangeMifareDesfireApplicationKey(string _applicationMasterKeyCurrent, int _keyNumberCurrent, DESFireKeyType _keyTypeCurrent,
string _applicationMasterKeyTarget, int _keyNumberTarget, int selectedDesfireAppKeyVersionTargetAsIntint,
DESFireKeyType _keyTypeTarget, int _appIDCurrent, int _appIDTarget, DESFireKeySettings keySettings, int keyVersion)
{
- if (readerDevice.DesfireSelectApplication((uint)_appIDCurrent))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKeyCurrent, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeCurrent)), 1))
+ if (readerDevice.IsTWN4LegicReader)
{
- if (readerDevice.DesfireChangeKey(
- _applicationMasterKeyCurrent,
- _applicationMasterKeyTarget,
- (byte)keyVersion,
- _keyNumberCurrent == 0 ? (byte)keySettings : (byte)((byte)keySettings | 0xE0),
- (byte)_keyNumberTarget,
- 1,
- (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget))))
+ try
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKeyTarget, (byte)_keyNumberTarget, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)), 1))
- {
- readerDevice.DesfireChangeKeySettings((byte)keySettings, 0, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)));
- }
+ await readerDevice.SearchTagAsync();
+ }
+ catch { }
+ }
- return ERROR.NoError;
+ try
+ {
+ await readerDevice.MifareDesfire_SelectApplicationAsync((uint)_appIDCurrent);
+
+ await readerDevice.MifareDesfire_AuthenticateAsync(_applicationMasterKeyCurrent, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeCurrent)), 1);
+
+ if (_applicationMasterKeyCurrent == _applicationMasterKeyTarget)
+ {
+ await readerDevice.MifareDesfire_ChangeKeySettingsAsync(
+ (DESFireAppAccessRights)keySettings,
+ 0,
+ (Elatec.NET.Cards.Mifare.DESFireKeyType)Enum.Parse(
+ typeof(Elatec.NET.Cards.Mifare.DESFireKeyType),
+ Enum.GetName(typeof(DESFireKeyType), _keyTypeTarget)
+ )
+ );
}
+
else
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKeyTarget, (byte)_keyNumberTarget, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)), 1))
- {
- readerDevice.DesfireChangeKeySettings((byte)keySettings, 0, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)));
- }
-
- return ERROR.AuthenticationError;
+ await readerDevice.MifareDesfire_ChangeKeyAsync(
+ _applicationMasterKeyCurrent,
+ _applicationMasterKeyTarget,
+ (byte)keyVersion,
+ _keyNumberCurrent == 0 ? (byte)keySettings : (byte)((byte)keySettings | 0xE0),
+ (byte)_keyNumberTarget,
+ 1,
+ (Elatec.NET.Cards.Mifare.DESFireKeyType)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeTarget)));
}
+
+ return ERROR.NoError;
+ }
+ catch
+ {
+ return ERROR.AuthenticationError;
}
}
- return ERROR.NotReadyError;
+
+ else
+ {
+ return ERROR.NotReadyError;
+ }
+
+
}
///
@@ -485,34 +732,41 @@ public override ERROR ChangeMifareDesfireApplicationKey(string _applicationMaste
///
///
///
- public override ERROR DeleteMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyTypePiccMasterKey, int _appID)
+ public async override Task DeleteMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyTypePiccMasterKey, uint _appID)
{
- if (readerDevice.DesfireSelectApplication((uint)_appID))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKey, 0x00, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypePiccMasterKey)), 1))
+ if (readerDevice.IsTWN4LegicReader)
{
- if (readerDevice.DesfireDeleteApplication((uint)_appID))
+ try
{
- return ERROR.NoError;
+ await readerDevice.SearchTagAsync();
}
- else
+ catch
{
- return ERROR.AuthenticationError;
+ return ERROR.NotReadyError;
}
}
- else
+
+ try
{
- if (readerDevice.DesfireDeleteApplication((uint)_appID))
- {
- return ERROR.NoError;
- }
- else
+ if (await AuthToMifareDesfireApplication(_applicationMasterKey, _keyTypePiccMasterKey, 0, 0) == ERROR.NoError)
{
- return ERROR.AuthenticationError;
+ await readerDevice.MifareDesfire_DeleteApplicationAsync(_appID);
}
}
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+ return ERROR.NoError;
}
- return ERROR.IOError;
+
+ else
+ {
+ return ERROR.NotReadyError;
+ }
+
}
///
@@ -523,8 +777,9 @@ public override ERROR DeleteMifareDesfireApplication(string _applicationMasterKe
///
///
///
- public override ERROR DeleteMifareDesfireFile(string _applicationMasterKey, DESFireKeyType _keyType, int _appID, int _fileID)
+ public async override Task DeleteMifareDesfireFile(string _applicationMasterKey, DESFireKeyType _keyType, int _appID, int _fileID)
{
+ /*
if (readerDevice.DesfireSelectApplication((uint)_appID))
{
if (readerDevice.DesfireAuthenticate(_applicationMasterKey, 0x00, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1))
@@ -539,6 +794,7 @@ public override ERROR DeleteMifareDesfireFile(string _applicationMasterKey, DESF
}
}
}
+ */
return ERROR.NotReadyError;
}
@@ -550,23 +806,48 @@ public override ERROR DeleteMifareDesfireFile(string _applicationMasterKey, DESF
///
///
///
- public override ERROR FormatDesfireCard(string _applicationMasterKey, DESFireKeyType _keyType)
+ public async override Task FormatDesfireCard(string _applicationMasterKey, DESFireKeyType _keyType)
{
- if (readerDevice.DesfireSelectApplication(0))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKey, 0x00, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1))
+ if (readerDevice.IsTWN4LegicReader)
{
- if (readerDevice.DesfireFormatTag())
+ try
{
- return ERROR.NoError;
+ await readerDevice.SearchTagAsync();
+ }
+ catch
+ {
+ return ERROR.NotReadyError;
+ }
+ }
+
+ try
+ {
+ if (await AuthToMifareDesfireApplication(_applicationMasterKey, _keyType, 0, 0) == ERROR.NoError)
+ {
+ await readerDevice.MifareDesfire_FormatTagAsync();
}
else
{
return ERROR.AuthenticationError;
}
}
+
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+
+ return ERROR.NoError;
}
- return ERROR.NotReadyError;
+
+ else
+ {
+ return ERROR.NotReadyError;
+ }
+
+
}
///
@@ -577,26 +858,52 @@ public override ERROR FormatDesfireCard(string _applicationMasterKey, DESFireKey
///
///
///
- public override ERROR GetMifareDesfireFileList(string _applicationMasterKey, RFiDGear.DataAccessLayer.DESFireKeyType _keyType, int _keyNumberCurrent, int _appID)
+ public async override Task GetMifareDesfireFileList(string _applicationMasterKey, RFiDGear.DataAccessLayer.DESFireKeyType _keyType, int _keyNumberCurrent, int _appID)
{
- if (readerDevice.DesfireSelectApplication((uint)_appID))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKey, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1))
+ if (readerDevice.IsTWN4LegicReader)
{
- var appids = readerDevice.GetDesfireFileIDs();
- if (appids != null)
+ try
{
- FileIDList = appids;
- return ERROR.NoError;
+ await readerDevice.SearchTagAsync();
}
- else
+ catch { }
+ }
+
+ try
+ {
+ await readerDevice.MifareDesfire_SelectApplicationAsync((uint)_appID);
+
+ try
{
- return ERROR.AuthenticationError;
+ await readerDevice.MifareDesfire_AuthenticateAsync(_applicationMasterKey, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1);
+ } // try to auth first.
+ catch
+ {
+
+ }
+
+ var fids = await readerDevice.MifareDesfire_GetFileIDsAsync();
+
+ if (fids != null)
+ {
+ FileIDList = fids;
}
}
+ catch
+ {
+ return ERROR.NotReadyError;
+ }
+
+ return ERROR.NoError;
+ }
+
+ else
+ {
+ return ERROR.NotReadyError;
}
- return ERROR.NotReadyError;
}
///
@@ -608,30 +915,52 @@ public override ERROR GetMifareDesfireFileList(string _applicationMasterKey, RFi
///
///
///
- public override ERROR GetMifareDesfireFileSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent, int _appID, int _fileNo)
+ public async override Task GetMifareDesfireFileSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent, int _appID, int _fileNo)
{
- if (readerDevice.DesfireSelectApplication((uint)_appID))
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireAuthenticate(_applicationMasterKey, (byte)_keyNumberCurrent, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)), 1))
+ if (readerDevice.IsTWN4LegicReader)
{
- var fileSettings = readerDevice.GetDesFireFileSettings((byte)_fileNo);
- uint fileSize = 0x00000000;
+ try
+ {
+ await readerDevice.SearchTagAsync();
+ }
+ catch { }
+ }
+
+ try
+ {
+ await readerDevice.MifareDesfire_SelectApplicationAsync((uint)_appID);
- for (uint i = 9; i >= 6; i--)
+ try
{
- fileSize = fileSize << 8;
- fileSize |= (byte)(fileSettings[i]);
+ await readerDevice.MifareDesfire_AuthenticateAsync(
+ _applicationMasterKey,
+ (byte)_keyNumberCurrent,
+ (byte)(int)Enum.Parse(typeof(Elatec.NET.Cards.Mifare.DESFireKeyType),
+ Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)),
+ 1);
+ } // try to auth first.
+ catch
+ {
+
}
+
+ var fileSettings = await readerDevice.MifareDesfire_GetFileSettingsAsync((byte)_fileNo);
+
if (fileSettings != null)
{
DesfireFileSettings = new DESFireFileSettings();
- DesfireFileSettings.FileType = fileSettings[2];
- DesfireFileSettings.comSett = fileSettings[3];
- DesfireFileSettings.dataFile.fileSize = fileSize;
+ DesfireFileSettings.FileType = (byte)fileSettings.FileType;
+ DesfireFileSettings.comSett = (byte)fileSettings.ComSett;
+ DesfireFileSettings.dataFile.fileSize = fileSettings.DataFileSetting.FileSize;
DesfireFileSettings.accessRights = new byte[2];
- DesfireFileSettings.accessRights[0] = fileSettings[4];
- DesfireFileSettings.accessRights[1] = fileSettings[5];
+ DesfireFileSettings.accessRights[0] |= (byte)fileSettings.accessRights.ReadKeyNo;
+ DesfireFileSettings.accessRights[0] |= (byte)(fileSettings.accessRights.WriteKeyNo << 4);
+ DesfireFileSettings.accessRights[1] |= (byte)(fileSettings.accessRights.ReadWriteKeyNo);
+ DesfireFileSettings.accessRights[1] |= (byte)(fileSettings.accessRights.ChangeKeyNo << 4);
+
return ERROR.NoError;
}
else
@@ -639,9 +968,18 @@ public override ERROR GetMifareDesfireFileSettings(string _applicationMasterKey,
return ERROR.AuthenticationError;
}
}
+ catch
+ {
+ return ERROR.NotReadyError;
+ }
+ }
+
+ else
+ {
+ return ERROR.NotReadyError;
}
- return ERROR.AuthenticationError;
+
}
///
@@ -661,46 +999,62 @@ public override ERROR GetMifareDesfireFileSettings(string _applicationMasterKey,
///
///
///
- public override ERROR CreateMifareDesfireFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey, FileType_MifareDesfireFileType _fileType, DESFireAccessRights _accessRights, EncryptionMode _encMode,
+ public async override Task CreateMifareDesfireFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey, FileType_MifareDesfireFileType _fileType, DESFireAccessRights _accessRights, EncryptionMode _encMode,
int _appID, int _fileNo, int _fileSize,
int _minValue = 0, int _maxValue = 1000, int _initValue = 0, bool _isValueLimited = false,
int _maxNbOfRecords = 100)
{
- try
+ if (readerDevice.IsConnected)
{
- if (readerDevice.DesfireSelectApplication((uint)_appID))
+ try
{
- if (readerDevice.DesfireAuthenticate(_appMasterKey, (byte)0x00, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeAppMasterKey)), 1))
+ if (await AuthToMifareDesfireApplication(_appMasterKey, _keyTypeAppMasterKey, 0, _appID) == ERROR.NoError)
{
- UInt16 accessRights = 0x0000;
- accessRights |= (byte)((((byte)_accessRights.readAccess) & 0xF0) >> 4);
- accessRights |= (byte)((((byte)_accessRights.writeAccess) & 0x0F));
- accessRights |= (byte)((((byte)_accessRights.readAndWriteAccess) & 0xF0) >> 4); //lsb, upper nibble
- accessRights |= (byte)((((byte)_accessRights.changeAccess) & 0x0F)); //lsb , lower nibble
-
- if (readerDevice.DesfireCreateFile((byte)_fileNo, (byte)_fileType, (byte)_encMode, accessRights, (UInt32)_fileSize))
- {
- return ERROR.NoError;
- }
- else
+ switch (_fileType)
{
- return ERROR.AuthenticationError;
+ case FileType_MifareDesfireFileType.StdDataFile:
+ var ar = new DESFireFileAccessRights
+ {
+ ReadKeyNo = (byte)_accessRights.readAccess,
+ WriteKeyNo = (byte)_accessRights.writeAccess,
+ ReadWriteKeyNo = (byte)_accessRights.readAndWriteAccess,
+ ChangeKeyNo = (byte)_accessRights.changeAccess
+ };
+
+ try
+ {
+ await readerDevice.MifareDesfire_CreateStdDataFileAsync(
+ (byte)_fileNo,
+ (DESFireFileType)_fileType,
+ (Elatec.NET.Cards.Mifare.EncryptionMode)_encMode,
+ ar,
+ (UInt32)_fileSize);
+ }
+
+ catch
+ {
+ return ERROR.AuthenticationError;
+ }
+
+ break;
}
}
- else
- {
- return ERROR.AuthenticationError;
- }
+ }
+ catch (Exception e)
+ {
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
+ return ERROR.IOError;
}
- return ERROR.AuthenticationError;
-
+ return ERROR.NoError;
}
- catch (Exception e)
+
+ else
{
- LogWriter.CreateLogEntry(e, FacilityName);
- return ERROR.IOError;
+ return ERROR.NotReadyError;
}
+
+
}
///
@@ -719,7 +1073,7 @@ public override ERROR CreateMifareDesfireFile(string _appMasterKey, DESFireKeyTy
///
///
///
- public override ERROR ReadMiFareDESFireChipFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey,
+ public async override Task ReadMiFareDESFireChipFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey,
string _appReadKey, DESFireKeyType _keyTypeAppReadKey, int _readKeyNo,
string _appWriteKey, DESFireKeyType _keyTypeAppWriteKey, int _writeKeyNo,
EncryptionMode _encMode,
@@ -727,6 +1081,7 @@ public override ERROR ReadMiFareDESFireChipFile(string _appMasterKey, DESFireKey
{
try
{
+ /*
if (readerDevice.DesfireSelectApplication((uint)_appID))
{
if (readerDevice.DesfireAuthenticate(_appReadKey, (byte)_readKeyNo, (byte)(int)Enum.Parse(typeof(Elatec.NET.DESFireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyTypeAppReadKey)), 1))
@@ -747,18 +1102,18 @@ public override ERROR ReadMiFareDESFireChipFile(string _appMasterKey, DESFireKey
return ERROR.AuthenticationError;
}
}
-
+ */
return ERROR.AuthenticationError;
}
catch (Exception e)
{
- LogWriter.CreateLogEntry(e, FacilityName);
+ eventLog.WriteEntry(e.Message, EventLogEntryType.Error);
return ERROR.IOError;
}
}
- public override ERROR WriteMiFareDESFireChipFile(string _cardMasterKey, DESFireKeyType _keyTypeCardMasterKey,
+ public async override Task WriteMiFareDESFireChipFile(string _cardMasterKey, DESFireKeyType _keyTypeCardMasterKey,
string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey,
string _appReadKey, DESFireKeyType _keyTypeAppReadKey, int _readKeyNo,
string _appWriteKey, DESFireKeyType _keyTypeAppWriteKey, int _writeKeyNo,
diff --git a/RFiDGear/DataAccessLayer/Remote/FromIO/ReaderDevice.cs b/RFiDGear/DataAccessLayer/Remote/FromIO/ReaderDevice.cs
index cbb7c4b..fd05dbc 100644
--- a/RFiDGear/DataAccessLayer/Remote/FromIO/ReaderDevice.cs
+++ b/RFiDGear/DataAccessLayer/Remote/FromIO/ReaderDevice.cs
@@ -1,6 +1,9 @@
using RFiDGear.Model;
using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
namespace RFiDGear.DataAccessLayer.Remote.FromIO
{
@@ -37,12 +40,12 @@ public static ReaderDevice Instance
{
if (instance == null)
{
- instance = new ElatecNetProvider(PortNumber);
+ instance = new ElatecNetProvider();
return instance;
}
else if (instance != null && !(instance is ElatecNetProvider))
{
- instance = new ElatecNetProvider(PortNumber);
+ instance = new ElatecNetProvider();
return instance;
}
else
@@ -66,18 +69,20 @@ public static ReaderDevice Instance
private static object syncRoot = new object();
private static ReaderDevice instance;
+ public abstract bool IsConnected { get; }
public static ReaderTypes Reader { get; set; }
public static int PortNumber { get; set; }
public MifareClassicSectorModel Sector { get; set; }
public MifareClassicDataBlockModel DataBlock { get; set; }
- public GenericChipModel GenericChip { get; set; }
+ public List GenericChip { get; set; }
public MifareDesfireChipModel DesfireChip { get; set; }
public MifareClassicChipModel ClassicChip { get; set; }
public ReaderTypes ReaderProvider { get; set; }
- public string ReaderUnitName { get; set; }
+ public abstract string ReaderUnitName { get; set; }
+ public abstract string ReaderUnitVersion { get; set; }
public byte[] MifareClassicData { get; set; }
public bool DataBlockSuccessfullyAuth { get; set; }
public bool SectorSuccessfullyAuth { get; set; }
@@ -90,21 +95,21 @@ public static ReaderDevice Instance
public DESFireKeySettings DesfireAppKeySetting { get; set; }
#region Common
- public abstract ERROR Connect();
- public abstract ERROR ReadChipPublic();
+ public abstract Task ConnectAsync();
+ public abstract Task ReadChipPublic();
#endregion
#region MifareClassic
// Mifare Classic Method Definitions
- public abstract ERROR ReadMifareClassicSingleSector(int sectorNumber, string aKey, string bKey);
- public abstract ERROR WriteMifareClassicSingleSector(int sectorNumber, string _aKey, string _bKey, byte[] buffer);
- public abstract ERROR WriteMifareClassicSingleBlock(int _blockNumber, string _aKey, string _bKey, byte[] buffer);
- public abstract ERROR WriteMifareClassicWithMAD(int _madApplicationID, int _madStartSector,
+ public abstract Task ReadMifareClassicSingleSector(int sectorNumber, string aKey, string bKey);
+ public abstract Task WriteMifareClassicSingleSector(int sectorNumber, string _aKey, string _bKey, byte[] buffer);
+ public abstract Task WriteMifareClassicSingleBlock(int _blockNumber, string _aKey, string _bKey, byte[] buffer);
+ public abstract Task WriteMifareClassicWithMAD(int _madApplicationID, int _madStartSector,
string _aKeyToUse, string _bKeyToUse, string _aKeyToWrite, string _bKeyToWrite,
string _madAKeyToUse, string _madBKeyToUse, string _madAKeyToWrite, string _madBKeyToWrite,
byte[] buffer, byte _madGPB, SectorAccessBits _sab, bool _useMADToAuth, bool _keyToWriteUseMAD);
- public abstract ERROR ReadMifareClassicWithMAD(int madApplicationID, string _aKeyToUse, string _bKeyToUse,
+ public abstract Task ReadMifareClassicWithMAD(int madApplicationID, string _aKeyToUse, string _bKeyToUse,
string _madAKeyToUse, string _madBKeyToUse, int _length, byte _madGPB,
bool _useMADToAuth, bool _aiToUseIsMAD);
#endregion
@@ -115,24 +120,24 @@ public abstract ERROR ReadMifareClassicWithMAD(int madApplicationID, string _aKe
#endregion
#region MifareDesfire
- public abstract ERROR GetMiFareDESFireChipAppIDs(string _appMasterKey = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", DESFireKeyType _keyTypeAppMasterKey = DESFireKeyType.DF_KEY_DES);
- public abstract ERROR CreateMifareDesfireFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey, FileType_MifareDesfireFileType _fileType, DESFireAccessRights _accessRights, EncryptionMode _encMode,
+ public abstract Task GetMiFareDESFireChipAppIDs(string _appMasterKey = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", DESFireKeyType _keyTypeAppMasterKey = DESFireKeyType.DF_KEY_DES);
+ public abstract Task CreateMifareDesfireFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey, FileType_MifareDesfireFileType _fileType, DESFireAccessRights _accessRights, EncryptionMode _encMode,
int _appID, int _fileNo, int _fileSize,
int _minValue = 0, int _maxValue = 1000, int _initValue = 0, bool _isValueLimited = false,
int _maxNbOfRecords = 100);
- public abstract ERROR ReadMiFareDESFireChipFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey,
+ public abstract Task ReadMiFareDESFireChipFile(string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey,
string _appReadKey, DESFireKeyType _keyTypeAppReadKey, int _readKeyNo,
string _appWriteKey, DESFireKeyType _keyTypeAppWriteKey, int _writeKeyNo,
EncryptionMode _encMode,
int _fileNo, int _appID, int _fileSize);
- public abstract ERROR WriteMiFareDESFireChipFile(string _cardMasterKey, DESFireKeyType _keyTypeCardMasterKey,
+ public abstract Task WriteMiFareDESFireChipFile(string _cardMasterKey, DESFireKeyType _keyTypeCardMasterKey,
string _appMasterKey, DESFireKeyType _keyTypeAppMasterKey,
string _appReadKey, DESFireKeyType _keyTypeAppReadKey, int _readKeyNo,
string _appWriteKey, DESFireKeyType _keyTypeAppWriteKey, int _writeKeyNo,
EncryptionMode _encMode,
int _fileNo, int _appID, byte[] _data);
- public abstract ERROR AuthToMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumber, int _appID = 0);
- public abstract ERROR GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent = 0, int _appID = 0);
+ public abstract Task AuthToMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumber, int _appID = 0);
+ public abstract Task GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent = 0, int _appID = 0);
///
/// Creates a new Application
@@ -142,17 +147,17 @@ public abstract ERROR WriteMiFareDESFireChipFile(string _cardMasterKey, DESFireK
/// int max. number of keys
/// int application id
/// True if the Operation was successful, false otherwise
- public abstract ERROR CreateMifareDesfireApplication(string _piccMasterKey, DESFireKeySettings _keySettingsTarget, DESFireKeyType _keyTypePiccMasterKey, DESFireKeyType _keyTypeTargetApplication, int _maxNbKeys, int _appID, bool authenticateToPICCFirst = true);
+ public abstract Task CreateMifareDesfireApplication(string _piccMasterKey, DESFireKeySettings _keySettingsTarget, DESFireKeyType _keyTypePiccMasterKey, DESFireKeyType _keyTypeTargetApplication, int _maxNbKeys, int _appID, bool authenticateToPICCFirst = true);
- public abstract ERROR ChangeMifareDesfireApplicationKey(string _applicationMasterKeyCurrent, int _keyNumberCurrent, DESFireKeyType _keyTypeCurrent,
+ public abstract Task ChangeMifareDesfireApplicationKey(string _applicationMasterKeyCurrent, int _keyNumberCurrent, DESFireKeyType _keyTypeCurrent,
string _applicationMasterKeyTarget, int _keyNumberTarget, int selectedDesfireAppKeyVersionTargetAsIntint,
DESFireKeyType _keyTypeTarget, int _appIDCurrent, int _appIDTarget,
DESFireKeySettings keySettings, int keyVersion);
- public abstract ERROR DeleteMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyType, int _appID = 0);
- public abstract ERROR DeleteMifareDesfireFile(string _applicationMasterKey, DESFireKeyType _keyType, int _appID = 0, int _fileID = 0);
- public abstract ERROR FormatDesfireCard(string _applicationMasterKey, DESFireKeyType _keyType);
- public abstract ERROR GetMifareDesfireFileList(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent = 0, int _appID = 0);
- public abstract ERROR GetMifareDesfireFileSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent = 0, int _appID = 0, int _fileNo = 0);
+ public abstract Task DeleteMifareDesfireApplication(string _applicationMasterKey, DESFireKeyType _keyType, uint _appID = 0);
+ public abstract Task DeleteMifareDesfireFile(string _applicationMasterKey, DESFireKeyType _keyType, int _appID = 0, int _fileID = 0);
+ public abstract Task FormatDesfireCard(string _applicationMasterKey, DESFireKeyType _keyType);
+ public abstract Task GetMifareDesfireFileList(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent = 0, int _appID = 0);
+ public abstract Task GetMifareDesfireFileSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent = 0, int _appID = 0, int _fileNo = 0);
#endregion
diff --git a/RFiDGear/Model/Checkpoint.cs b/RFiDGear/Model/Checkpoint.cs
index ea584e9..2485876 100644
--- a/RFiDGear/Model/Checkpoint.cs
+++ b/RFiDGear/Model/Checkpoint.cs
@@ -26,6 +26,23 @@ public Checkpoint()
ErrorLevel = ERROR.Empty;
}
+ public string CheckpointIndex { get; set; }
+
+ public int CheckpointIndexAsInt
+ {
+ get {
+ int res;
+ if (int.TryParse(CheckpointIndex, out res))
+ {
+ return res;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+
public ERROR ErrorLevel { get; set; }
public string TaskIndex { get; set; }
diff --git a/RFiDGear/Model/GenericChipModel.cs b/RFiDGear/Model/GenericChipModel.cs
index 698b0a4..bfeaed6 100644
--- a/RFiDGear/Model/GenericChipModel.cs
+++ b/RFiDGear/Model/GenericChipModel.cs
@@ -11,7 +11,6 @@ public class GenericChipModel
{
public GenericChipModel()
{
-
}
public GenericChipModel(string uid, CARD_TYPE cardType)
@@ -20,29 +19,17 @@ public GenericChipModel(string uid, CARD_TYPE cardType)
CardType = cardType;
}
- public GenericChipModel(string uid, CARD_TYPE cardType, string sak, string rats)
+ public GenericChipModel(GenericChipModel chip)
{
- UID = uid;
- CardType = cardType;
- SAK = sak;
- RATS = rats;
- }
-
- public GenericChipModel(string uid, CARD_TYPE cardType, string sak, string rats, string versionL4)
- {
- UID = uid;
- CardType = cardType;
- SAK = sak;
- RATS = rats;
- VersionL4 = versionL4;
+ this.UID = chip.UID;
+ this.CardType = chip.CardType;
}
public string UID { get; set; }
public CARD_TYPE CardType { get; set; }
- public string SAK { get; set; }
- public string RATS { get; set; }
- public string VersionL4 { get; set; }
- public GenericChipModel Child { get; set; }
- public GenericChipModel GrandChild { get; set; }
+
+ public bool? HasChilds => Childs?.Count > 0;
+
+ public List Childs { get; set; }
}
}
\ No newline at end of file
diff --git a/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs b/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs
index dd6139b..d539ecc 100644
--- a/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs
+++ b/RFiDGear/Model/MifareClassic/MifareClassicChipModel.cs
@@ -24,6 +24,13 @@ public MifareClassicChipModel(string uid, CARD_TYPE cardType)
UID = uid;
}
+ public MifareClassicChipModel(GenericChipModel chip)
+ {
+ CardType = chip.CardType;
+ UID = chip.UID;
+ Childs = chip.Childs;
+ }
+
public uint FreeMemory { get; set; }
}
}
\ No newline at end of file
diff --git a/RFiDGear/Model/MifareDesfire/MifareDesfireChipModel.cs b/RFiDGear/Model/MifareDesfire/MifareDesfireChipModel.cs
index 1b558e1..41e5d49 100644
--- a/RFiDGear/Model/MifareDesfire/MifareDesfireChipModel.cs
+++ b/RFiDGear/Model/MifareDesfire/MifareDesfireChipModel.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System;
+using Org.BouncyCastle.Bcpg;
namespace RFiDGear.Model
{
@@ -42,17 +43,37 @@ public MifareDesfireChipModel(string uid, CARD_TYPE cardType)
CardType = cardType;
}
- public MifareDesfireChipModel(GenericChipModel genericChip)
+ public MifareDesfireChipModel(string uid, CARD_TYPE cardType, string sak, string rats)
+ {
+ UID = uid;
+ CardType = cardType;
+ SAK = sak;
+ RATS = rats;
+ }
+
+ public MifareDesfireChipModel(string uid, CARD_TYPE cardType, string sak, string rats, string versionL4)
+ {
+ UID = uid;
+ CardType = cardType;
+ SAK = sak;
+ RATS = rats;
+ VersionL4 = versionL4;
+ }
+
+ public MifareDesfireChipModel(MifareDesfireChipModel genericChip)
{
UID = genericChip.UID;
CardType = genericChip.CardType;
- RATS = genericChip.RATS;
SAK = genericChip.SAK;
- L4Version = genericChip.VersionL4;
- Child = genericChip.Child;
+ RATS = genericChip.RATS;
+ VersionL4 = genericChip.VersionL4;
+ Childs = genericChip.Childs;
}
- public string L4Version { get; set; }
+ public string SAK { get; set; }
+ public string RATS { get; set; }
+ public string VersionL4 { get; set; }
+
public uint FreeMemory { get; set; }
}
}
\ No newline at end of file
diff --git a/RFiDGear/Model/MifareUltralight/MifareUltralightChipModel.cs b/RFiDGear/Model/MifareUltralight/MifareUltralightChipModel.cs
index 3375ff6..2096b8f 100644
--- a/RFiDGear/Model/MifareUltralight/MifareUltralightChipModel.cs
+++ b/RFiDGear/Model/MifareUltralight/MifareUltralightChipModel.cs
@@ -32,5 +32,11 @@ public MifareUltralightChipModel(string uid, CARD_TYPE cardType)
CardType = cardType;
UID = uid;
}
+
+ public MifareUltralightChipModel(GenericChipModel chip)
+ {
+ CardType = chip.CardType;
+ UID = chip.UID;
+ }
}
}
\ No newline at end of file
diff --git a/RFiDGear/Properties/AssemblyInfo.cs b/RFiDGear/Properties/AssemblyInfo.cs
index cb93720..bce9144 100644
--- a/RFiDGear/Properties/AssemblyInfo.cs
+++ b/RFiDGear/Properties/AssemblyInfo.cs
@@ -11,9 +11,9 @@
[assembly: AssemblyTitle("RFiDGear")]
[assembly: AssemblyDescription("RFiD Encoding Frontend")]
[assembly: AssemblyConfiguration("x86")]
-[assembly: AssemblyCompany("")]
+[assembly: AssemblyCompany("Messgeraetetechnik Hansen")]
[assembly: AssemblyProduct("RFiDGear")]
-[assembly: AssemblyCopyright("Copyright 2023")]
+[assembly: AssemblyCopyright("Copyright 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
@@ -25,6 +25,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
-[assembly: AssemblyVersion("1.7.*")]
+[assembly: AssemblyVersion("1.8.*")]
[assembly: Guid("a34bc413-e349-4fd1-8b90-2eb95a333436")]
[assembly: NeutralResourcesLanguage("")]
diff --git a/RFiDGear/RFiDGear.csproj b/RFiDGear/RFiDGear.csproj
index 2697a68..523b242 100644
--- a/RFiDGear/RFiDGear.csproj
+++ b/RFiDGear/RFiDGear.csproj
@@ -8,10 +8,9 @@
WinExe
RFiDGear
RFiDGear
- v4.8
+ v4.8.1
Properties
- False
False
False
False
@@ -100,6 +99,9 @@
RFiDGear.snk
+
+ true
+
4.0
@@ -362,13 +364,9 @@
ByteArray
- {53fbd2f3-638e-4892-9f09-9a372c8f76d2}
+ {360f9af9-6717-45b6-9707-5974575fe96a}
Elatec.NET
-
- {786d71e7-4d92-43e4-a9eb-4e07ffe36f70}
- Log4CSharp
-
{ef56252e-257f-41d1-974b-c9015071ce7e}
MVVMDialogs
@@ -407,7 +405,7 @@
1.9.1.8
- 2.5.0
+ 3.0.0
7.0.0
diff --git a/RFiDGear/RFiDGear.csproj.user b/RFiDGear/RFiDGear.csproj.user
index d9b23aa..80deecb 100644
--- a/RFiDGear/RFiDGear.csproj.user
+++ b/RFiDGear/RFiDGear.csproj.user
@@ -1,7 +1,8 @@
- REPORTTARGETPATH="D:\CardCheck_data\KP-000005-5_final.pdf" REPORTTEMPLATEFILE="D:\CardCheck_data\KP-000005-5_.pdf" CUSTOMPROJECTFILE="D:\CardCheck_data\KPruefung_Vorlagen\00_RFID_Gear_Vorlage\CardCheckAssistant_FreeMem.rfPrj" %24JOBNUMBER="KP-000005" %24CHIPNUMBER="5" AUTORUN=1
+
+
D:\CardCheck_Data
@@ -16,7 +17,8 @@
D:\Seafile\Dokumente Privat\Steven\Projekte\Software\Windows\RFIDGear\RFiDGear\bin\Debug\
- "D:\Seafile\Dokumente Privat\Steven\Projekte\Software\Windows\RFIDGear\zipped.rfPrj"
+
+
REPORTTARGETPATH="D:\CardCheck_data\KP-000005-5_final.pdf" REPORTTEMPLATEFILE="D:\CardCheck_data\KP-000005-5_.pdf" CUSTOMPROJECTFILE="D:\CardCheck_data\KPruefung_Vorlagen\00_RFID_Gear_Vorlage\CardCheckAssistant_FreeMem.rfPrj" %24JOBNUMBER="KP-000005" %24CHIPNUMBER="5" AUTORUN=1
diff --git a/RFiDGear/Resources/Manifest.de.resx b/RFiDGear/Resources/Manifest.de.resx
index 5ab4c22..40ac47e 100644
--- a/RFiDGear/Resources/Manifest.de.resx
+++ b/RFiDGear/Resources/Manifest.de.resx
@@ -1087,7 +1087,7 @@ Wird benötigt von:
Mifare Plus SL3 4K
-
+
Mifare Desfire EV0
@@ -1511,4 +1511,154 @@ https://github.com/c3rebro/rfidgear
Changelog
+
+ Mifare Classic (alle)
+
+
+ Mifare Desfire
+
+
+ Mifare Plus (alle)
+
+
+ Mifare SAM (alle)
+
+
+ SmartMX Desfire (alle)
+
+
+ SmartMX MifareClassic 2K
+
+
+ Mifare Desfire EV0 1K
+
+
+ Mifare Desfire EV0 256
+
+
+ Mifare Desfire EV0 2K
+
+
+ Mifare Desfire EV0 4K
+
+
+ Desfire EV0 1K (Emulated - SmartMX)
+
+
+ Desfire EV0 256 Bytes (Emulated - SmartMX)
+
+
+ Desfire EV0 2K (Emulated - SmartMX)
+
+
+ Desfire EV0 4K (Emulated - SmartMX)
+
+
+ Desfire EV1 1K (Emulated - SmartMX)
+
+
+ Desfire EV1 256 Bytes (Emulated - SmartMX)
+
+
+ Desfire EV1 2K (Emulated - SmartMX)
+
+
+ Desfire EV1 4K (Emulated - SmartMX)
+
+
+ Desfire EV1 8K (Emulated - SmartMX)
+
+
+ Desfire EV2 16K (Emulated - SmartMX)
+
+
+ Desfire EV2 1K (Emulated - SmartMX)
+
+
+ Desfire EV2 2K (Emulated - SmartMX)
+
+
+ Desfire EV2 32K (Emulated - SmartMX)
+
+
+ Desfire EV2 4K (Emulated - SmartMX)
+
+
+ Desfire EV2 8K (Emulated - SmartMX)
+
+
+ Desfire EV3 16K (Emulated - SmartMX)
+
+
+ Desfire EV3 1K (Emulated - SmartMX)
+
+
+ Desfire EV3 2K (Emulated - SmartMX)
+
+
+ Desfire EV3 32K (Emulated - SmartMX)
+
+
+ Desfire EV3 4K (Emulated - SmartMX)
+
+
+ Desfire EV3 8K (Emulated - SmartMX)
+
+
+ Mifare Ultralight C EV1
+
+
+ NTAG 210
+
+
+ NTAG 211
+
+
+ NTAG 212
+
+
+ NTAG 213
+
+
+ NTAG 214
+
+
+ NTAG 215
+
+
+ NTAG 216
+
+
+ NTAG 424
+
+
+ NTAG 426
+
+
+ Mifare Desfire (alle)
+
+
+ CP Nr.
+
+
+ Kopieren
+
+
+ Einfügen
+
+
+ BESCHÄFTIGT
+
+
+ LEERLAUF
+
+
+ UNBEKANNT
+
+
+ Fehler
+
+
+ Es konnte kein Leser gefunden werden
+
\ No newline at end of file
diff --git a/RFiDGear/Resources/Manifest.en.resx b/RFiDGear/Resources/Manifest.en.resx
index 5022ce9..6508b38 100644
--- a/RFiDGear/Resources/Manifest.en.resx
+++ b/RFiDGear/Resources/Manifest.en.resx
@@ -1077,7 +1077,7 @@ Needed by:
Mifare Plus SL3 4K
-
+
Mifare Desfire EV0
@@ -1489,4 +1489,154 @@ https://github.com/c3rebro/rfidgear
Changelog
+
+ Mifare Classic (all)
+
+
+ Mifare Desfire
+
+
+ Mifare Plus (all)
+
+
+ Mifare SAM (all)
+
+
+ SmartMX Desfire (all)
+
+
+ SmartMX MifareClassic 2K
+
+
+ Mifare Desfire EV0 1K
+
+
+ Mifare Desfire EV0 256
+
+
+ Mifare Desfire EV0 2K
+
+
+ Mifare Desfire EV0 4K
+
+
+ Desfire EV0 1K (Emulated - SmartMX)
+
+
+ Desfire EV0 256 Bytes (Emulated - SmartMX)
+
+
+ Desfire EV0 2K (Emulated - SmartMX)
+
+
+ Desfire EV0 4K (Emulated - SmartMX)
+
+
+ Desfire EV1 1K (Emulated - SmartMX)
+
+
+ Desfire EV1 256 Bytes (Emulated - SmartMX)
+
+
+ Desfire EV1 2K (Emulated - SmartMX)
+
+
+ Desfire EV1 4K (Emulated - SmartMX)
+
+
+ Desfire EV1 8K (Emulated - SmartMX)
+
+
+ Desfire EV2 16K (Emulated - SmartMX)
+
+
+ Desfire EV2 1K (Emulated - SmartMX)
+
+
+ Desfire EV2 2K (Emulated - SmartMX)
+
+
+ Desfire EV2 32K (Emulated - SmartMX)
+
+
+ Desfire EV2 4K (Emulated - SmartMX)
+
+
+ Desfire EV2 8K (Emulated - SmartMX)
+
+
+ Desfire EV3 16K (Emulated - SmartMX)
+
+
+ Desfire EV3 1K (Emulated - SmartMX)
+
+
+ Desfire EV3 2K (Emulated - SmartMX)
+
+
+ Desfire EV3 32K (Emulated - SmartMX)
+
+
+ Desfire EV3 4K (Emulated - SmartMX)
+
+
+ Desfire EV3 8K (Emulated - SmartMX)
+
+
+ Mifare Ultralight C EV1
+
+
+ NTAG 210
+
+
+ NTAG 211
+
+
+ NTAG 212
+
+
+ NTAG 213
+
+
+ NTAG 214
+
+
+ NTAG 215
+
+
+ NTAG 216
+
+
+ NTAG 424
+
+
+ NTAG 426
+
+
+ Mifare Desfire (all)
+
+
+ CP Nr.
+
+
+ Copy
+
+
+ Paste
+
+
+ BUSY
+
+
+ IDLE
+
+
+ UNKNOWN
+
+
+ ReaderError
+
+
+ No Reader Found
+
\ No newline at end of file
diff --git a/RFiDGear/View/MainWindow.xaml b/RFiDGear/View/MainWindow.xaml
index 1b0d0be..a7a0265 100644
--- a/RFiDGear/View/MainWindow.xaml
+++ b/RFiDGear/View/MainWindow.xaml
@@ -5,7 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dal="clr-namespace:RFiDGear.DataAccessLayer"
- xmlns:dlgs="clr-namespace:MvvmDialogs.Behaviors;assembly=MVVMDialogs"
+ xmlns:dlgs="clr-namespace:MVVMDialogs.Behaviors;assembly=MVVMDialogs"
xmlns:local="clr-namespace:RFiDGear"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:RFiDGear.ViewModel"
@@ -321,7 +321,6 @@
CanUserReorderColumns="True"
CanUserSortColumns="True"
ItemsSource="{Binding ChipTasks.TaskCollection}"
- SelectedIndex="{Binding DataGridPosition}"
SelectedItem="{Binding Path=DataContext.SelectedSetupViewModel, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
SelectionMode="Single"
VirtualizingPanel.IsVirtualizing="True">
@@ -432,14 +431,17 @@
-
+
@@ -590,6 +592,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RFiDGear/View/SettingsView/SettingsTabPages/TabPageMiscReaderSettingsView.xaml b/RFiDGear/View/SettingsView/SettingsTabPages/TabPageMiscReaderSettingsView.xaml
index 60f7770..57b0438 100644
--- a/RFiDGear/View/SettingsView/SettingsTabPages/TabPageMiscReaderSettingsView.xaml
+++ b/RFiDGear/View/SettingsView/SettingsTabPages/TabPageMiscReaderSettingsView.xaml
@@ -89,7 +89,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
Content="{Binding LocalizationResourceSet, ConverterParameter=labelCheckForUpdatesOnStart, Converter={StaticResource Localization}}"
- IsChecked="{Binding CheckOnStart, Mode=TwoWay}" />
+ IsChecked="{Binding CheckOnStart, Mode=TwoWay}"/>
diff --git a/RFiDGear/View/TaskViews/CommonTask/CommonTaskView.xaml b/RFiDGear/View/TaskViews/CommonTask/CommonTaskView.xaml
index 42dc13c..0febc4e 100644
--- a/RFiDGear/View/TaskViews/CommonTask/CommonTaskView.xaml
+++ b/RFiDGear/View/TaskViews/CommonTask/CommonTaskView.xaml
@@ -6,7 +6,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dal="clr-namespace:RFiDGear.DataAccessLayer"
- xmlns:dlgs="clr-namespace:MvvmDialogs.Behaviors;assembly=MVVMDialogs"
+ xmlns:dlgs="clr-namespace:MVVMDialogs.Behaviors;assembly=MVVMDialogs"
xmlns:local="clr-namespace:RFiDGear"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:v="clr-namespace:RFiDGear.View"
diff --git a/RFiDGear/View/TaskViews/CommonTask/CommonTasksTabPages/TabPageLogicTaskView.xaml b/RFiDGear/View/TaskViews/CommonTask/CommonTasksTabPages/TabPageLogicTaskView.xaml
index 2832e20..7acd427 100644
--- a/RFiDGear/View/TaskViews/CommonTask/CommonTasksTabPages/TabPageLogicTaskView.xaml
+++ b/RFiDGear/View/TaskViews/CommonTask/CommonTasksTabPages/TabPageLogicTaskView.xaml
@@ -243,17 +243,26 @@
CanUserSortColumns="False"
ItemsSource="{Binding Checkpoints, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding SelectedCheckpoint, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
+
+
+
+
+
+
+
@@ -208,6 +229,8 @@
@@ -228,6 +251,8 @@
@@ -248,6 +273,8 @@
@@ -266,9 +293,11 @@
diff --git a/RFiDGear/View/TaskViews/RFIDTasks/GenericChipTask/GenericChipTaskTabPages/TabPageBasicChipCheckUpView.xaml b/RFiDGear/View/TaskViews/RFIDTasks/GenericChipTask/GenericChipTaskTabPages/TabPageBasicChipCheckUpView.xaml
index 9083ba9..aa5a642 100644
--- a/RFiDGear/View/TaskViews/RFIDTasks/GenericChipTask/GenericChipTaskTabPages/TabPageBasicChipCheckUpView.xaml
+++ b/RFiDGear/View/TaskViews/RFIDTasks/GenericChipTask/GenericChipTaskTabPages/TabPageBasicChipCheckUpView.xaml
@@ -28,7 +28,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
@@ -143,13 +147,15 @@ public RFiDChipChildLayerViewModel(
new MenuItem()
{
Header = "Read Sector using default Configuration",
- Command = null //_cmdReadSectorWithDefaults
+ Command = null,
+ Visibility = Visibility.Hidden
},
new MenuItem()
{
Header = "Edit Authentication Settings and Modify Sector",
- Command = null // _cmdEditAuthAndModifySector
+ Command = null,
+ Visibility = Visibility.Hidden
}
};
}));
@@ -178,7 +184,7 @@ public RFiDChipChildLayerViewModel(
_cardType = cardType;
_parentUid = parentUID?.UID;
- _cmdReadSectorWithDefaults = new RelayCommand(ReadSectorWithDefaults);
+ _cmdReadSectorWithDefaults = new AsyncRelayCommand(ReadSectorWithDefaults);
_cmdEditAuthAndModifySector = new RelayCommand(ReadSectorWithCustoms);
Application.Current.Dispatcher.BeginInvoke((Action)(() =>
@@ -188,13 +194,15 @@ public RFiDChipChildLayerViewModel(
new MenuItem()
{
Header = "Read Sector using default Configuration",
- Command = _cmdReadSectorWithDefaults
+ Command = _cmdReadSectorWithDefaults,
+ IsEnabled = false
},
new MenuItem()
{
Header = "Edit Authentication Settings and Modify Sector",
- Command = _cmdEditAuthAndModifySector
+ Command = _cmdEditAuthAndModifySector,
+ IsEnabled = false
}
};
}));
@@ -226,8 +234,9 @@ public RFiDChipChildLayerViewModel(string _childNodeHeader)
private List