Version 3.0.9, kleinere Änderungen ExcelReader, Debugging
This commit is contained in:
parent
3ce90d643a
commit
315240e3c8
Binary file not shown.
@ -28,6 +28,9 @@
|
||||
<setting name="SleepSeconds" serializeAs="String">
|
||||
<value>300</value>
|
||||
</setting>
|
||||
<setting name="SendEMailSubject" serializeAs="String">
|
||||
<value>Reference Excel Sheet</value>
|
||||
</setting>
|
||||
</bsmd.ExcelReadService.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
@ -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<string> sendItems = new List<string>();
|
||||
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()
|
||||
|
||||
@ -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<string, Name> _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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -118,7 +118,7 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
<value>17, 56</value>
|
||||
</metadata>
|
||||
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>196, 17</value>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,5 +20,8 @@
|
||||
<Setting Name="SleepSeconds" Type="System.Int32" Scope="Application">
|
||||
<Value Profile="(Default)">300</Value>
|
||||
</Setting>
|
||||
<Setting Name="SendEMailSubject" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">Reference Excel Sheet</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -160,6 +160,11 @@ namespace bsmd.ExcelReadService
|
||||
messages.Remove(ataMessage);
|
||||
}
|
||||
|
||||
internal static string CreateConfirmationSheet(MessageCore messageCore)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ATD
|
||||
|
||||
@ -32,18 +32,24 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
|
||||
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="OpenPop, Version=2.0.6.1120, Culture=neutral, PublicKeyToken=6bdb97f144b7efc8, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenPop.NET.2.0.6.1120\lib\net40\OpenPop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SQLite">
|
||||
<HintPath>..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net45\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||
<package id="OpenPop.NET" version="2.0.6.1112" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.5" targetFramework="net45" />
|
||||
<package id="OpenPop.NET" version="2.0.6.1120" targetFramework="net45" />
|
||||
<package id="System.Data.SQLite.Core" version="1.0.99.0" targetFramework="net45" />
|
||||
</packages>
|
||||
@ -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("")]
|
||||
@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("3.0.8.*")]
|
||||
[assembly: AssemblyVersion("3.0.9.*")]
|
||||
|
||||
|
||||
@ -39,11 +39,13 @@
|
||||
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
|
||||
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="OpenPop">
|
||||
<HintPath>..\packages\OpenPop.NET.2.0.6.1114\lib\net40\OpenPop.dll</HintPath>
|
||||
<Reference Include="OpenPop, Version=2.0.6.1119, Culture=neutral, PublicKeyToken=6bdb97f144b7efc8, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenPop.NET.2.0.6.1119\lib\net40\OpenPop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="log4net" version="2.0.3" targetFramework="net45" />
|
||||
<package id="OpenPop.NET" version="2.0.6.1114" targetFramework="net45" />
|
||||
<package id="log4net" version="2.0.5" targetFramework="net45" />
|
||||
<package id="OpenPop.NET" version="2.0.6.1119" targetFramework="net45" />
|
||||
</packages>
|
||||
@ -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,
|
||||
|
||||
@ -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"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user