diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index f4f2d72a..9f4a62de 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/bsmd.ExcelReadService/App.config b/nsw/Source/bsmd.ExcelReadService/App.config index cec102d4..0e3620b0 100644 --- a/nsw/Source/bsmd.ExcelReadService/App.config +++ b/nsw/Source/bsmd.ExcelReadService/App.config @@ -28,6 +28,9 @@ 300 + + Reference Excel Sheet + \ No newline at end of file diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs index 9e2a4389..d2b9f12a 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs @@ -18,7 +18,6 @@ using bsmd.email; namespace bsmd.ExcelReadService { - public partial class ExcelReadService : ServiceBase { private Timer _timer; @@ -37,7 +36,11 @@ namespace bsmd.ExcelReadService this.EventLog.Source = this.ServiceName; this.EventLog.Log = "Application"; this.Init(args); - this.EventLog.WriteEntry("EU-NOAD Excel Read Service started.", EventLogEntryType.Information); + this.EventLog.WriteEntry("NSW Excel Read Service started.", EventLogEntryType.Information); + System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); + FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); + string version = fvi.FileVersion; + this._log.InfoFormat("Starting NSW Excel Read Service. v.{0}", version); this.DoOnce(); } @@ -74,7 +77,7 @@ namespace bsmd.ExcelReadService // this.Stop(); //} - // just for testing + // --- BEGIN ------------ TEST ExcelReader er = new ExcelReader(@"E:\work\bsmd\nsw\Source\bsmd.ExcelReadService\2016_01_08_BMSD - EUNoAD Tool Rev 3.0_mit Testdaten.xls"); string amsg; @@ -82,6 +85,8 @@ namespace bsmd.ExcelReadService bool aReadResult = Util.ProcessSheet(er, out amsg, out aCore); er.Dispose(); + // --- END --------------- TEST + // check and download next e-Mail, saving attachment while (bsmdPopClient.ReceiveSingleMail(out attachmentLocalPath, out messageId, out mailSender)) { @@ -98,7 +103,15 @@ namespace bsmd.ExcelReadService _log.Error("Excel sheet could not be interpreted"); } - // set messagecore to createreport and let reportGenerator create a reply? + // TODO: Quittung / set messagecore to createreport and let reportGenerator create a reply? + + // create a reply sheet (template + scanned highlighted content for verification + + string confirmationExcelFilePath = Util.CreateConfirmationSheet(messageCore); + List sendItems = new List(); + sendItems.Add(confirmationExcelFilePath); + // send reply sheet back to sender + BSMDMail.SendNSWReportWithAttachments(Properties.Settings.Default.SendEMailSubject, sendItems); // remove e-Mail _log.InfoFormat("deleting mail with messageId {0}", messageId); @@ -108,9 +121,7 @@ namespace bsmd.ExcelReadService _log.InfoFormat("removing local file {0}", attachmentLocalPath); // File.Delete(attachmentLocalPath); - // create a reply sheet (template + scanned highlighted content for verification - - // send reply sheet back to sender + } @@ -138,6 +149,7 @@ namespace bsmd.ExcelReadService protected override void OnStop() { + this._log.Info("Stopping NSW Excel Read Service."); } internal void DoOnce() diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs index 39bad43d..a83bd3aa 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs @@ -12,6 +12,7 @@ using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; using System.Data; +using System.Drawing; using System.Globalization; using System.Linq; @@ -24,6 +25,14 @@ namespace bsmd.ExcelReadService private Application _excelApp; private Dictionary _nameDict; + private int okColor = ColorTranslator.ToOle(Color.FromArgb(200, 255, 200)); // light green + private int warnColor = ColorTranslator.ToOle(Color.FromArgb(255, 255, 200)); // yellow + private int failColor = ColorTranslator.ToOle(Color.FromArgb(255, 150, 150)); // light red + + internal enum ReadState { NONE, OK, WARN, FAIL }; + + + public ExcelReader(string filePath) { this._excelApp = new Application(); @@ -36,6 +45,32 @@ namespace bsmd.ExcelReadService } } + internal void Save(string filePath) + { + if (this._excelApp == null) return; + this._excelApp.SaveWorkspace(filePath); + } + + internal void HighlightLookup(string lookup, ReadState state) + { + Range range = _nameDict[lookup].RefersToRange; + if(range != null) + { + switch(state) + { + case ReadState.FAIL: + range.Interior.Color = this.failColor; break; + case ReadState.WARN: + range.Interior.Color = this.warnColor; break; + case ReadState.OK: + range.Interior.Color = this.okColor; break; + case ReadState.NONE: + default: + break; + } + } + } + internal string ReadText(string lookup) { if (!_nameDict.ContainsKey(lookup)) return null; @@ -61,6 +96,7 @@ namespace bsmd.ExcelReadService if (val == null) return null; if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) return 0; if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase)) return 1; + this.HighlightLookup(lookup, ReadState.WARN); return 2; // whatever } @@ -84,6 +120,7 @@ namespace bsmd.ExcelReadService if (val.IndexOf("baltic", StringComparison.OrdinalIgnoreCase) >= 0) return 0; if (val.IndexOf("europe", StringComparison.OrdinalIgnoreCase) >= 0) return 1; if (val.IndexOf("overseas", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + this.HighlightLookup(lookup, ReadState.FAIL); return null; } @@ -93,6 +130,7 @@ namespace bsmd.ExcelReadService if (val.IndexOf("sbt", StringComparison.OrdinalIgnoreCase) >= 0) return 1; if (val.IndexOf("single", StringComparison.OrdinalIgnoreCase) >= 0) return 0; if (val.IndexOf("double", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + this.HighlightLookup(lookup, ReadState.FAIL); return null; } @@ -102,6 +140,7 @@ namespace bsmd.ExcelReadService if (val.IndexOf("full", StringComparison.OrdinalIgnoreCase) >= 0) return 0; if (val.IndexOf("empty", StringComparison.OrdinalIgnoreCase) >= 0) return 1; if (val.IndexOf("inerted", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + this.HighlightLookup(lookup, ReadState.FAIL); return null; } @@ -111,6 +150,7 @@ namespace bsmd.ExcelReadService if (val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) return 0; if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) return 1; if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + this.HighlightLookup(lookup, ReadState.FAIL); return null; } @@ -135,10 +175,12 @@ namespace bsmd.ExcelReadService return date; // TODO: weitere varianten ausprobieren + this.HighlightLookup(lookup, ReadState.WARN); return null; } catch (Exception) { + this.HighlightLookup(lookup, ReadState.FAIL); _log.WarnFormat("error parsing datetime for lookup {0}", lookup); return null; } @@ -173,10 +215,12 @@ namespace bsmd.ExcelReadService return date; if (DateTime.TryParseExact(val, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out date)) return date; + this.HighlightLookup(lookup, ReadState.WARN); return null; } catch (Exception) { + this.HighlightLookup(lookup, ReadState.FAIL); _log.WarnFormat("error reading time for lookup {0}", lookup); return null; } @@ -196,10 +240,12 @@ namespace bsmd.ExcelReadService if (double.TryParse(val, out result)) return result; } + this.HighlightLookup(lookup, ReadState.WARN); return null; } catch (Exception) { + this.HighlightLookup(lookup, ReadState.FAIL); _log.WarnFormat("error reading number for lookup {0}", lookup); return null; } @@ -208,7 +254,11 @@ namespace bsmd.ExcelReadService internal bool? ReadBoolean(string lookup) { string val = this.ReadText(lookup); - if (val == null) return null; + if (val == null) + { + this.HighlightLookup(lookup, ReadState.WARN); + return null; + } if ((val == "y") || (val == "Y") || (val == "yes") || (val == "YES") || (val == "1") || (val == "x") || (val == "X")) return true; return false; diff --git a/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.Designer.cs b/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.Designer.cs index f02870a3..366ba076 100644 --- a/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.Designer.cs +++ b/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.Designer.cs @@ -39,7 +39,7 @@ // serviceInstaller1 // this.serviceInstaller1.Description = "Receives and processes Excel reports send via e-mail"; - this.serviceInstaller1.DisplayName = "EU-NOAD Excel Report Service"; + this.serviceInstaller1.DisplayName = "NSW Excel Report Service"; this.serviceInstaller1.ServiceName = "ExcelReadService"; // // ProjectInstaller diff --git a/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.resx b/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.resx index f3cbaaba..a5c17521 100644 --- a/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.resx +++ b/nsw/Source/bsmd.ExcelReadService/ProjectInstaller.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 17, 17 + 17, 56 196, 17 diff --git a/nsw/Source/bsmd.ExcelReadService/Properties/Settings.Designer.cs b/nsw/Source/bsmd.ExcelReadService/Properties/Settings.Designer.cs index f1e91ac4..1186b7da 100644 --- a/nsw/Source/bsmd.ExcelReadService/Properties/Settings.Designer.cs +++ b/nsw/Source/bsmd.ExcelReadService/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ namespace bsmd.ExcelReadService.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -76,5 +76,14 @@ namespace bsmd.ExcelReadService.Properties { return ((int)(this["SleepSeconds"])); } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Reference Excel Sheet")] + public string SendEMailSubject { + get { + return ((string)(this["SendEMailSubject"])); + } + } } } diff --git a/nsw/Source/bsmd.ExcelReadService/Properties/Settings.settings b/nsw/Source/bsmd.ExcelReadService/Properties/Settings.settings index c0ea01a8..da840a0c 100644 --- a/nsw/Source/bsmd.ExcelReadService/Properties/Settings.settings +++ b/nsw/Source/bsmd.ExcelReadService/Properties/Settings.settings @@ -20,5 +20,8 @@ 300 + + Reference Excel Sheet + \ No newline at end of file diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index 89ba59fb..df42838e 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -160,6 +160,11 @@ namespace bsmd.ExcelReadService messages.Remove(ataMessage); } + internal static string CreateConfirmationSheet(MessageCore messageCore) + { + throw new NotImplementedException(); + } + #endregion #region ATD diff --git a/nsw/Source/bsmd.ExcelReadService/bsmd.ExcelReadService.csproj b/nsw/Source/bsmd.ExcelReadService/bsmd.ExcelReadService.csproj index b5210965..24cf7ba9 100644 --- a/nsw/Source/bsmd.ExcelReadService/bsmd.ExcelReadService.csproj +++ b/nsw/Source/bsmd.ExcelReadService/bsmd.ExcelReadService.csproj @@ -32,18 +32,24 @@ 4 - - ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + ..\packages\log4net.2.0.5\lib\net45-full\log4net.dll + True True + + ..\packages\OpenPop.NET.2.0.6.1120\lib\net40\OpenPop.dll + True + ..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net45\System.Data.SQLite.dll + diff --git a/nsw/Source/bsmd.ExcelReadService/packages.config b/nsw/Source/bsmd.ExcelReadService/packages.config index 05cddc35..16339648 100644 --- a/nsw/Source/bsmd.ExcelReadService/packages.config +++ b/nsw/Source/bsmd.ExcelReadService/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index 82192967..55bf2779 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs @@ -2,6 +2,6 @@ [assembly: AssemblyCompany("Informatikbüro Daniel Schick")] [assembly: AssemblyProduct("BSMD NSW interface")] -[assembly: AssemblyInformationalVersion("3.0.8")] +[assembly: AssemblyInformationalVersion("3.0.9")] [assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")] [assembly: AssemblyTrademark("")] \ No newline at end of file diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs index 62c22fea..efed2f11 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.0.8.*")] +[assembly: AssemblyVersion("3.0.9.*")] diff --git a/nsw/Source/bsmd.email/bsmd.email.csproj b/nsw/Source/bsmd.email/bsmd.email.csproj index af58db1f..a6cfdd66 100644 --- a/nsw/Source/bsmd.email/bsmd.email.csproj +++ b/nsw/Source/bsmd.email/bsmd.email.csproj @@ -39,11 +39,13 @@ ..\bsmdKey.snk - - ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + ..\packages\log4net.2.0.5\lib\net45-full\log4net.dll + True - - ..\packages\OpenPop.NET.2.0.6.1114\lib\net40\OpenPop.dll + + ..\packages\OpenPop.NET.2.0.6.1119\lib\net40\OpenPop.dll + True diff --git a/nsw/Source/bsmd.email/packages.config b/nsw/Source/bsmd.email/packages.config index 065ed4a3..ec3514f5 100644 --- a/nsw/Source/bsmd.email/packages.config +++ b/nsw/Source/bsmd.email/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/nsw/Source/bsmd.herberg.FormService/Enums.cs b/nsw/Source/bsmd.herberg.FormService/Enums.cs index 876e975c..a44ec8d8 100644 --- a/nsw/Source/bsmd.herberg.FormService/Enums.cs +++ b/nsw/Source/bsmd.herberg.FormService/Enums.cs @@ -115,6 +115,19 @@ namespace bsmd.herberg.FormService OTHER_LEGAL_IDENTITY_DOCUMENT } + public static byte? ParseIdentityDocumentType(string val) + { + if (val.Equals("IDENTITY_CARD", StringComparison.OrdinalIgnoreCase)) return 0; + if (val.Equals("Id Card", StringComparison.OrdinalIgnoreCase)) return 0; + if (val.Equals("PASSPORT", StringComparison.OrdinalIgnoreCase)) return 1; + if (val.Equals("MUSTER_BOOK", StringComparison.OrdinalIgnoreCase)) return 2; + if (val.Equals("PICTURE_ID", StringComparison.OrdinalIgnoreCase)) return 3; + if (val.Equals("RESIDENTAL_PERMIT", StringComparison.OrdinalIgnoreCase)) return 4; + if (val.Equals("OTHER_LEGAL_IDENTITY_DOCUMENT", StringComparison.OrdinalIgnoreCase)) return 5; + + return null; + } + public enum INFShipClass : byte { INF1, diff --git a/nsw/Source/bsmd.herberg.FormService/Util.cs b/nsw/Source/bsmd.herberg.FormService/Util.cs index 0a7636fe..63452947 100644 --- a/nsw/Source/bsmd.herberg.FormService/Util.cs +++ b/nsw/Source/bsmd.herberg.FormService/Util.cs @@ -1046,7 +1046,7 @@ namespace bsmd.herberg.FormService if (pDict.ContainsKey("PassengerDateOfBirth")) pas.PassengerDateOfBirth = Extensions.TryParseDateTime(pDict["PassengerDateOfBirth"]); if (pDict.ContainsKey("PassengerGender")) pas.PassengerGender = Enums.ParseGender(pDict["PassengerGender"]); if (pDict.ContainsKey("PassengerNationalityCode")) pas.PassengerNationality = pDict["PassengerNationalityCode"]; - if (pDict.ContainsKey("PassengerIdentityDocumentType")) pas.PassengerIdentityDocumentType = (byte)Enum.Parse(typeof(Enums.PassengerIdentityDocumentType), pDict["PassengerIdentityDocumentType"], true); + if (pDict.ContainsKey("PassengerIdentityDocumentType")) pas.PassengerIdentityDocumentType = Enums.ParseIdentityDocumentType(pDict["PassengerIdentityDocumentType"]); if (pDict.ContainsKey("PassengerIdentityDocumentId")) pas.PassengerIdentityDocumentId = pDict["PassengerIdentityDocumentId"]; if (pDict.ContainsKey("PassengerVisaNumber")) pas.PassengerVisaNumber = pDict["PassengerVisaNumber"]; if (pDict.ContainsKey("PassengerPortCodeOfEmbarkation") && pDict.ContainsKey("PassengerCountryCodeOfEmbarkation"))