diff --git a/Signature/AddDigitalSignature/.editorconfig b/Signature/AddDigitalSignature/.editorconfig new file mode 100644 index 0000000..3126322 --- /dev/null +++ b/Signature/AddDigitalSignature/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS0618: Type or member is obsolete +dotnet_diagnostic.CS0618.severity = warning diff --git a/Signature/AddDigitalSignature/AddDigitalSignature.csproj b/Signature/AddDigitalSignature/AddDigitalSignature.csproj new file mode 100644 index 0000000..ba3dc1c --- /dev/null +++ b/Signature/AddDigitalSignature/AddDigitalSignature.csproj @@ -0,0 +1,105 @@ + + + + + Debug + AnyCPU + {2EAC8F00-1327-4327-8E48-E6A90D04D66F} + WinExe + AddDigitalSignature + AddDigitalSignature + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + \ No newline at end of file diff --git a/Signature/AddDigitalSignature/AddDigitalSignature.sln b/Signature/AddDigitalSignature/AddDigitalSignature.sln new file mode 100644 index 0000000..ea152a4 --- /dev/null +++ b/Signature/AddDigitalSignature/AddDigitalSignature.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignature", "AddDigitalSignature.csproj", "{2EAC8F00-1327-4327-8E48-E6A90D04D66F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2EAC8F00-1327-4327-8E48-E6A90D04D66F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2EAC8F00-1327-4327-8E48-E6A90D04D66F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2EAC8F00-1327-4327-8E48-E6A90D04D66F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2EAC8F00-1327-4327-8E48-E6A90D04D66F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Signature/AddDigitalSignature/AddDigitalSignature_NET.csproj b/Signature/AddDigitalSignature/AddDigitalSignature_NET.csproj new file mode 100644 index 0000000..0ed0a83 --- /dev/null +++ b/Signature/AddDigitalSignature/AddDigitalSignature_NET.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + enable + enable + true + + + + + + + + diff --git a/Signature/AddDigitalSignature/AddDigitalSignature_NET.sln b/Signature/AddDigitalSignature/AddDigitalSignature_NET.sln new file mode 100644 index 0000000..8885bce --- /dev/null +++ b/Signature/AddDigitalSignature/AddDigitalSignature_NET.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddDigitalSignature_NET", "AddDigitalSignature_NET.csproj", "{075D44C0-3D4B-49B7-AC77-F6CB196B12BF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {075D44C0-3D4B-49B7-AC77-F6CB196B12BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {075D44C0-3D4B-49B7-AC77-F6CB196B12BF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {075D44C0-3D4B-49B7-AC77-F6CB196B12BF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {075D44C0-3D4B-49B7-AC77-F6CB196B12BF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Signature/AddDigitalSignature/App.config b/Signature/AddDigitalSignature/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/Signature/AddDigitalSignature/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Signature/AddDigitalSignature/App.xaml b/Signature/AddDigitalSignature/App.xaml new file mode 100644 index 0000000..f8b3c87 --- /dev/null +++ b/Signature/AddDigitalSignature/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Signature/AddDigitalSignature/App.xaml.cs b/Signature/AddDigitalSignature/App.xaml.cs new file mode 100644 index 0000000..a33773a --- /dev/null +++ b/Signature/AddDigitalSignature/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace AddDigitalSignature +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Signature/AddDigitalSignature/Data/Barcode.pdf b/Signature/AddDigitalSignature/Data/Barcode.pdf new file mode 100644 index 0000000..6d10bb5 Binary files /dev/null and b/Signature/AddDigitalSignature/Data/Barcode.pdf differ diff --git a/Signature/AddDigitalSignature/ExtensionMethods.cs b/Signature/AddDigitalSignature/ExtensionMethods.cs new file mode 100644 index 0000000..aadbe14 --- /dev/null +++ b/Signature/AddDigitalSignature/ExtensionMethods.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AddDigitalSignature +{ + public static class ExtensionMethods + { + + public static void Clear(this BlockingCollection blockingCollection) + { + try + { + if (blockingCollection == null) + { + return; + } + + while (blockingCollection.Count > 0) + { + string item; + blockingCollection.TryTake(out item); + item = null; + } + + blockingCollection.Dispose(); + } + catch (System.Exception ex) + { + //cGlobalSettings.oLogger.WriteLogException("Clear", ex); + } + + } + + + public static void Clear(this BlockingCollection blockingCollection) + { + try + { + if (blockingCollection == null) + { + return; + } + + while (blockingCollection.Count > 0) + { + int item; + blockingCollection.TryTake(out item); + } + + blockingCollection.Dispose(); + } + catch (System.Exception ex) + { + //cGlobalSettings.oLogger.WriteLogException("Clear", ex); + } + + } + + public static IEnumerable Distinct(this IEnumerable @this, Func keySelector) + { + return @this.GroupBy(keySelector).Select(grps => grps).Select(e => e.First()); + } + + + public static Dictionary + Merge(Dictionary[] dicts, + Func, TValue> resolveDuplicates) + { + if (resolveDuplicates == null) + resolveDuplicates = new Func, TValue>(group => group.First()); + + return dicts.SelectMany, KeyValuePair>(dict => dict) + .ToLookup(pair => pair.Key, pair => pair.Value) + .ToDictionary(group => group.Key, group => resolveDuplicates(group)); + } + + + + + + + + + public static Dictionary Merge(this IEnumerable> dicts, + Func, TValue> resolveDuplicates) + { + if (resolveDuplicates == null) + resolveDuplicates = new Func, TValue>(group => group.First()); + + return dicts.SelectMany, KeyValuePair>(dict => dict) + .ToLookup(pair => pair.Key, pair => pair.Value) + .ToDictionary(group => group.Key, group => resolveDuplicates(group)); + } + + public static long ToLong(long nFileSizeHigh, long nFileSizeLow) + { + return (long)((nFileSizeHigh << 0x20) | (nFileSizeLow & 0xffffffffL)); + + } + + public static DateTime ToDateTime(this System.Runtime.InteropServices.ComTypes.FILETIME filetime) + { + long highBits = filetime.dwHighDateTime; + highBits = highBits << 32; + return DateTime.FromFileTimeUtc(highBits + (long)filetime.dwLowDateTime); + } + + + public static long ToLong(this System.Runtime.InteropServices.ComTypes.FILETIME filetime) + { + long highBits = filetime.dwHighDateTime; + highBits = highBits << 32; + return DateTime.FromFileTimeUtc(highBits + (long)filetime.dwLowDateTime).Ticks; + } + + /// + /// http://stackoverflow.com/questions/419019/split-list-into-sublists-with-linq + /// + /// + /// + /// + /// + /// + public static List> Split(this List source, int groupSize) + { + return source + .Select((x, i) => new { Index = i, Value = x }) + .GroupBy(x => x.Index / groupSize/*3*/) + .Select(x => x.Select(v => v.Value).ToList()) + .ToList(); + } + + + // public static string SafeGetString(this SQLiteDataReader reader, int colIndex) + // { + // if (!reader.IsDBNull(colIndex)) + // return reader.GetString(colIndex); + // else + // return string.Empty; + // } + + // public static Int32 SafeGetInt32(this SQLiteDataReader reader, int colIndex, Int32 defaultReturnValue) + // { + // if (!reader.IsDBNull(colIndex)) + // return reader.GetInt32(colIndex); + // else + // return defaultReturnValue; + // } + + // public static Int64 SafeGetInt64(this SQLiteDataReader reader, int colIndex, Int64 defaultReturnValue) + // { + // if (!reader.IsDBNull(colIndex)) + // return reader.GetInt64(colIndex); + // else + // return defaultReturnValue; + // } + + // public static T SafeGetValue(this SQLiteDataReader reader, int colIndex, T defaultReturnValue) + // { + // if (!reader.IsDBNull(colIndex)) + // { + // if (typeof(T) == typeof(int)) + // { + // return (T)Convert.ChangeType(reader.GetInt32(colIndex), typeof(T)); + // } + // else if (typeof(T) == typeof(long)) + // { + // return (T)Convert.ChangeType(reader.GetInt64(colIndex), typeof(T)); + // } + // else if (typeof(T) == typeof(string)) + // { + // return (T)Convert.ChangeType(reader.GetString(colIndex), typeof(T)); + // } + // else + // { + ////#error "not defined" + // Debug.Assert(false); + // } + + + // } + + // return defaultReturnValue; + // } + + public static List> Split(this Dictionary source, int groupSize) + { + return source + .Select((x, i) => new { Index = i, Value = x }) + .GroupBy(x => x.Index / groupSize/*3*/) + .Select(x => x.Select(v => v.Value).ToDictionary(z => z.Key, z => z.Value)) + .ToList(); + } + + + + public static IEnumerable Split(this string str, int n) + { + if (String.IsNullOrEmpty(str) || n < 1) + { + throw new ArgumentException(); + } + + for (int i = 0; i < str.Length; i += n) + { + yield return str.Substring(i, Math.Min(n, str.Length - i)); + } + } + } + + static class DataRowExtensions + { + public static object GetValueWithContainsCheck(this DataRow row, string column) + { + return row.Table.Columns.Contains(column) ? row?[column] : null; + } + } +} diff --git a/Signature/AddDigitalSignature/MainWindow.xaml b/Signature/AddDigitalSignature/MainWindow.xaml new file mode 100644 index 0000000..5d69ce6 --- /dev/null +++ b/Signature/AddDigitalSignature/MainWindow.xaml @@ -0,0 +1,22 @@ + + + + + + + + +