Version 3.30 zur parallelen Verarbeitung DE / DK Excel Sheets. Kein Branch, das ist jetzt eine einzige neue Version, die dann die aktuell stabil laufende 3.2.27 ersetzt. Dazu existieren zwei Instanzen auf SMNSW01.

This commit is contained in:
Daniel Schick 2016-12-23 11:55:55 +00:00
parent 2440ddda39
commit a9ce7aacb2
22 changed files with 327 additions and 104 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -37,6 +37,23 @@
<setting name="SendConfirmationSheet" serializeAs="String"> <setting name="SendConfirmationSheet" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="ConfirmationDE" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>E:\svnlager\BSMD\nsw\Deutschland\BSMD-Formblatt.xlsx</string>
</ArrayOfString>
</value>
</setting>
<setting name="ConfirmationDK" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>E:\svnlager\BSMD\nsw\Dänemark\NSW-DK-Excel-Arrival.xlsx</string>
<string>E:\svnlager\BSMD\nsw\Dänemark\NSW-DK-Excel-Departure.xlsx</string>
</ArrayOfString>
</value>
</setting>
</bsmd.ExcelReadService.Properties.Settings> </bsmd.ExcelReadService.Properties.Settings>
</applicationSettings> </applicationSettings>
</configuration> </configuration>

View File

@ -0,0 +1,155 @@
using log4net;
using Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
using System;
using System.Drawing;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bsmd.ExcelReadService
{
/// <summary>
/// Kapselt die Implementierung / Schreiben des Bestätigungs-Sheets. Bisher wurde das Highlighting direkt in das ursprüngl. Sheet
/// übernommen. Da die Bestätigung aber anders aussieht und aus mehreren Sheets bestehen kann ist das jetzt abgetrennt in einer
/// eignenen Klasse. Der Pfad zu den Templates ist in den Settings hinterlegt, die Klasse wird mit der entspr. Collection aufgerufen
/// Das wiederum ergibt sich aus dem Zielhafen in PoC.
/// </summary>
internal class Confirmation : IDisposable
{
private ILog _log = LogManager.GetLogger(typeof(Confirmation));
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
private int whiteColor = ColorTranslator.ToOle(Color.White);
private List<Workbook> workbooks = new List<Workbook>();
private List<Dictionary<string, Name>> nameDicts = new List<Dictionary<string, Name>>();
private List<string> templateNames = new List<string>();
#region Construction
public Confirmation(System.Collections.Specialized.StringCollection sheetCollection, Application excelInstance)
{
foreach(string template in sheetCollection)
{
try
{
// die Templates sollten echte Excel Templates (.xlst) sein
Workbook aWorkbook = excelInstance.Workbooks.Open(template, 0, false, 5, "", "", false, XlPlatform.xlWindows, "", true, false, 0, false, false, false);
Dictionary<string, Name> nameDict = new Dictionary<string, Name>();
foreach (Name name in aWorkbook.Names)
{
nameDict[name.Name] = name;
}
workbooks.Add(aWorkbook);
nameDicts.Add(nameDict);
templateNames.Add(Path.GetFileNameWithoutExtension(template));
}
catch(Exception ex)
{
_log.ErrorFormat("Failure creating sheet from template {0}:{1}", template, ex.Message);
}
}
}
#endregion
#region public
public void ConfirmText(string lookup, string value, ExcelReader.ReadState state)
{
this.ConfirmValue(lookup, value, state);
}
public void ConfirmNumber(string lookup, double? value, ExcelReader.ReadState state)
{
this.ConfirmValue(lookup, value, state);
}
public void ConfirmDate(string lookup, DateTime? value, ExcelReader.ReadState state)
{
this.ConfirmValue(lookup, value, state);
}
public void ConfirmTime(string lookup, DateTime? value, ExcelReader.ReadState state)
{
this.ConfirmValue(lookup, value, state);
}
public List<string> SaveConfirmationSheets(string receivedFileName)
{
List<string> result = new List<string>();
for(int i=0;i<this.workbooks.Count;i++)
{
// construct file path
string fileNameWithPath = Path.Combine(Path.GetDirectoryName(receivedFileName),
string.Format("{0}_{1}.xlsx", this.templateNames[i], Path.GetFileNameWithoutExtension(receivedFileName)));
this.workbooks[i].SaveAs(fileNameWithPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
this.workbooks[i].Saved = true;
result.Add(fileNameWithPath);
this.workbooks[i].Close();
}
return result;
}
public void Dispose()
{
for (int i = 0; i < this.workbooks.Count; i++)
{
this.workbooks[i].Close();
this.workbooks[i] = null;
}
}
#endregion
#region private
private void ConfirmValue(string lookup, object value, ExcelReader.ReadState state)
{
for (int i = 0; i < this.nameDicts.Count; i++)
{
if (this.nameDicts[i].ContainsKey(lookup))
{
Range range = this.nameDicts[i][lookup].RefersToRange;
if (range != null)
{
range.Interior.Color = this.ColorForState(state);
range.Value = value;
}
Marshal.ReleaseComObject(range);
}
}
}
private int ColorForState(ExcelReader.ReadState state)
{
switch (state)
{
case ExcelReader.ReadState.FAIL:
return this.failColor;
case ExcelReader.ReadState.WARN:
return this.warnColor;
case ExcelReader.ReadState.OK:
return this.okColor;
case ExcelReader.ReadState.NONE:
default:
break;
}
return this.whiteColor;
}
#endregion
}
}

View File

@ -120,7 +120,7 @@ namespace bsmd.ExcelReadService
{ {
// try to read/import attachment // try to read/import attachment
using (ExcelReader reader = new ExcelReader(attachmentLocalPath)) using (ExcelReader reader = new ExcelReader(attachmentLocalPath))
{ {
readResult = Util.ProcessSheet(reader, out readMessage, out messageCore); readResult = Util.ProcessSheet(reader, out readMessage, out messageCore);
if (!readResult) if (!readResult)
{ {
@ -133,23 +133,18 @@ namespace bsmd.ExcelReadService
// Quittung / set messagecore to createreport and let reportGenerator create a reply? // Quittung / set messagecore to createreport and let reportGenerator create a reply?
if (Properties.Settings.Default.SendConfirmationSheet) if (Properties.Settings.Default.SendConfirmationSheet)
{ {
string confirmationFileName = Path.Combine(Path.GetDirectoryName(attachmentLocalPath),
string.Format("{0}_confirm.xls", Path.GetFileNameWithoutExtension(attachmentLocalPath)));
if (reader.SaveCopy(confirmationFileName)) List<string> localConfirmationSheets = reader.SaveConfirmationSheets(attachmentLocalPath);
{
List<string> sendItems = new List<string>();
sendItems.Add(confirmationFileName);
// get the ship's name // get the ship's name
string shipname = DBManager.Instance.GetShipNameFromCore(messageCore); string shipname = DBManager.Instance.GetShipNameFromCore(messageCore);
if (shipname.IsNullOrEmpty()) shipname = messageCore.IMO; if (shipname.IsNullOrEmpty()) shipname = messageCore.IMO;
string subject = string.Format("{0}: {1}", Properties.Settings.Default.SendEMailSubject, shipname); string subject = string.Format("{0}: {1}", Properties.Settings.Default.SendEMailSubject, shipname);
// send reply sheet back to sender
BSMDMail.SendNSWReportWithAttachments(subject, localConfirmationSheets, mailSender);
// send reply sheet back to sender
BSMDMail.SendNSWReportWithAttachments(subject, sendItems, mailSender);
}
} }
} }
} }

View File

@ -12,7 +12,8 @@ using Microsoft.Office.Interop.Excel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Drawing; using System.IO;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -28,24 +29,28 @@ namespace bsmd.ExcelReadService
private Application _excelApp; private Application _excelApp;
private Dictionary<string, Name> _nameDict; 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 }; internal enum ReadState { NONE, OK, WARN, FAIL };
public ExcelReader(string filePath) public ExcelReader(string filePath)
{ {
this._excelApp = new Application(); this._excelApp = new Application();
this._excelApp.DisplayAlerts = false;
this._excelWorkbooks = _excelApp.Workbooks; this._excelWorkbooks = _excelApp.Workbooks;
this._portcall = _excelWorkbooks.Open(filePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false); this._portcall = _excelWorkbooks.Open(filePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
_nameDict = new Dictionary<string, Name>(); _nameDict = new Dictionary<string, Name>();
foreach(Name name in _portcall.Names) foreach(Name name in _portcall.Names)
{ {
_nameDict[name.Name] = name; _nameDict[name.Name] = name;
} }
}
internal Confirmation Conf { get; set; }
internal void SetConfirmation(System.Collections.Specialized.StringCollection templatePaths)
{
this.Conf = new Confirmation(templatePaths, _excelApp);
} }
internal bool Save(string filePath) internal bool Save(string filePath)
@ -81,27 +86,11 @@ namespace bsmd.ExcelReadService
return result; return result;
} }
internal void HighlightLookup(string lookup, ReadState state) internal List<string> SaveConfirmationSheets(string attachmentLocalPath)
{ {
if (!_nameDict.ContainsKey(lookup)) return; return this.Conf.SaveConfirmationSheets(attachmentLocalPath);
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;
}
}
Marshal.ReleaseComObject(range);
} }
internal string ReadText(string lookup) internal string ReadText(string lookup)
{ {
@ -137,16 +126,16 @@ namespace bsmd.ExcelReadService
string portName = LocodeDB.PortNameFromLocode(val); string portName = LocodeDB.PortNameFromLocode(val);
if(portName == null) if(portName == null)
{ {
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, null, ReadState.WARN);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, portName, ReadState.OK);
} }
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, null, ReadState.FAIL);
} }
return val; return val;
} }
@ -158,23 +147,23 @@ namespace bsmd.ExcelReadService
if (val != null) if (val != null)
{ {
if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) { if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) {
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
result = 0; result = 0;
} }
else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase)) else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase))
{ {
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
result = 1; result = 1;
} }
else else
{ {
result = 2; result = 2;
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, val, ReadState.WARN);
} }
} }
if(result == null) if(result == null)
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, null, ReadState.FAIL);
} }
return result; return result;
} }
@ -194,13 +183,13 @@ namespace bsmd.ExcelReadService
if (val.Equals("ic", StringComparison.CurrentCultureIgnoreCase)) result = 0; if (val.Equals("ic", StringComparison.CurrentCultureIgnoreCase)) result = 0;
if (result == null) if (result == null)
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else else
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, null, ReadState.FAIL);
} }
return result; return result;
@ -216,13 +205,13 @@ namespace bsmd.ExcelReadService
if (val.IndexOf("europe", StringComparison.OrdinalIgnoreCase) >= 0) result = 1; if (val.IndexOf("europe", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
if (val.IndexOf("overseas", StringComparison.OrdinalIgnoreCase) >= 0) result = 2; if (val.IndexOf("overseas", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
if (result == null) if (result == null)
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else else
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, null, ReadState.FAIL);
} }
return result; return result;
} }
@ -237,13 +226,13 @@ namespace bsmd.ExcelReadService
if (val.IndexOf("single", StringComparison.OrdinalIgnoreCase) >= 0) result = 0; if (val.IndexOf("single", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
if (val.IndexOf("double", StringComparison.OrdinalIgnoreCase) >= 0) result = 2; if (val.IndexOf("double", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
if (result == null) if (result == null)
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else else
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, null, ReadState.FAIL);
} }
return result; return result;
} }
@ -258,13 +247,13 @@ namespace bsmd.ExcelReadService
if (val.IndexOf("empty", StringComparison.OrdinalIgnoreCase) >= 0) result = 1; if (val.IndexOf("empty", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
if (val.IndexOf("inerted", StringComparison.OrdinalIgnoreCase) >= 0) result = 2; if (val.IndexOf("inerted", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
if (result == null) if (result == null)
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else else
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, null, ReadState.FAIL);
} }
return result; return result;
} }
@ -280,13 +269,13 @@ namespace bsmd.ExcelReadService
if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) result = 1; if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) result = 2; if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
if (result == null) if (result == null)
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmText(lookup, val, ReadState.WARN);
else else
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, val, ReadState.FAIL);
} }
return result; return result;
} }
@ -356,16 +345,16 @@ namespace bsmd.ExcelReadService
if ((date.Value < new DateTime(1900, 1, 1)) || (date.Value > new DateTime(2030, 1, 1))) if ((date.Value < new DateTime(1900, 1, 1)) || (date.Value > new DateTime(2030, 1, 1)))
{ {
date = null; date = null;
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmDate(lookup, date, ReadState.WARN);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmDate(lookup, date, ReadState.OK);
} }
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmDate(lookup, null, ReadState.FAIL);
} }
} }
@ -373,7 +362,7 @@ namespace bsmd.ExcelReadService
} }
catch (Exception) catch (Exception)
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmDate(lookup, null, ReadState.FAIL);
_log.WarnFormat("error parsing datetime for lookup {0}", lookup); _log.WarnFormat("error parsing datetime for lookup {0}", lookup);
return null; return null;
} }
@ -458,18 +447,18 @@ namespace bsmd.ExcelReadService
} }
if (result != null) if (result != null)
{ {
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmTime(lookup, result, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.WARN); this.Conf.ConfirmTime(lookup, result, ReadState.WARN);
} }
} }
} }
catch (Exception) catch (Exception)
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmTime(lookup, null, ReadState.FAIL);
_log.WarnFormat("error reading time for lookup {0}", lookup); _log.WarnFormat("error reading time for lookup {0}", lookup);
} }
@ -499,17 +488,17 @@ namespace bsmd.ExcelReadService
} }
if (result != null) if (result != null)
{ {
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmNumber(lookup, result, ReadState.OK);
} }
else else
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmNumber(lookup, result, ReadState.FAIL);
} }
} }
} }
catch (Exception) catch (Exception)
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmNumber(lookup, null, ReadState.FAIL);
_log.WarnFormat("error reading number for lookup {0}", lookup); _log.WarnFormat("error reading number for lookup {0}", lookup);
} }
return result; return result;
@ -520,11 +509,11 @@ namespace bsmd.ExcelReadService
string val = this.ReadText(lookup); string val = this.ReadText(lookup);
if (val == null) if (val == null)
{ {
this.HighlightLookup(lookup, ReadState.FAIL); this.Conf.ConfirmText(lookup, val, ReadState.FAIL);
return null; return null;
} }
this.HighlightLookup(lookup, ReadState.OK); this.Conf.ConfirmText(lookup, val, ReadState.OK);
if ((val == "y") || (val == "Y") || val.Equals("yes", StringComparison.OrdinalIgnoreCase) || (val == "1") || (val == "x") || (val == "X")) if ((val == "y") || (val == "Y") || val.Equals("yes", StringComparison.OrdinalIgnoreCase) || (val == "1") || (val == "x") || (val == "X"))
return true; return true;

View File

@ -28,31 +28,31 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); this.serviceProcessInstallerTestExcel = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); this.serviceInstallerTestExcel = new System.ServiceProcess.ServiceInstaller();
// //
// serviceProcessInstaller1 // serviceProcessInstallerTestExcel
// //
this.serviceProcessInstaller1.Password = null; this.serviceProcessInstallerTestExcel.Password = null;
this.serviceProcessInstaller1.Username = null; this.serviceProcessInstallerTestExcel.Username = null;
// //
// serviceInstaller1 // serviceInstallerTestExcel
// //
this.serviceInstaller1.Description = "Receives and processes Excel reports send via e-mail"; this.serviceInstallerTestExcel.Description = "Test-Instance: Receives and processes Excel reports send via e-mail";
this.serviceInstaller1.DisplayName = "NSW Excel Report Service"; this.serviceInstallerTestExcel.DisplayName = "NSW Excel Report Test-Service ";
this.serviceInstaller1.ServiceName = "ExcelReadService"; this.serviceInstallerTestExcel.ServiceName = "ExcelReadTestService";
// //
// ProjectInstaller // ProjectInstaller
// //
this.Installers.AddRange(new System.Configuration.Install.Installer[] { this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1, this.serviceInstallerTestExcel,
this.serviceInstaller1}); this.serviceProcessInstallerTestExcel});
} }
#endregion #endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstallerTestExcel;
private System.ServiceProcess.ServiceInstaller serviceInstaller1; private System.ServiceProcess.ServiceInstaller serviceInstallerTestExcel;
} }
} }

View File

@ -117,10 +117,10 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="serviceProcessInstallerTestExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value> <value>17, 56</value>
</metadata> </metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="serviceInstallerTestExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>196, 17</value> <value>196, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -83,5 +83,30 @@ namespace bsmd.ExcelReadService.Properties {
return ((bool)(this["SendConfirmationSheet"])); return ((bool)(this["SendConfirmationSheet"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsi=\"http://www.w3." +
"org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n <s" +
"tring>E:\\svnlager\\BSMD\\nsw\\Deutschland\\BSMD-Formblatt.xlsx</string>\r\n</ArrayOfSt" +
"ring>")]
public global::System.Collections.Specialized.StringCollection ConfirmationDE {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["ConfirmationDE"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(@"<?xml version=""1.0"" encoding=""utf-16""?>
<ArrayOfString xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<string>E:\svnlager\BSMD\nsw\Dänemark\NSW-DK-Excel-Arrival.xlsx</string>
<string>E:\svnlager\BSMD\nsw\Dänemark\NSW-DK-Excel-Departure.xlsx</string>
</ArrayOfString>")]
public global::System.Collections.Specialized.StringCollection ConfirmationDK {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["ConfirmationDK"]));
}
}
} }
} }

View File

@ -27,5 +27,18 @@
<Setting Name="SendConfirmationSheet" Type="System.Boolean" Scope="Application"> <Setting Name="SendConfirmationSheet" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="ConfirmationDE" Type="System.Collections.Specialized.StringCollection" Scope="Application">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;string&gt;E:\svnlager\BSMD\nsw\Deutschland\BSMD-Formblatt.xlsx&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="ConfirmationDK" Type="System.Collections.Specialized.StringCollection" Scope="Application">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;string&gt;E:\svnlager\BSMD\nsw\Dänemark\NSW-DK-Excel-Arrival.xlsx&lt;/string&gt;
&lt;string&gt;E:\svnlager\BSMD\nsw\Dänemark\NSW-DK-Excel-Departure.xlsx&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -26,7 +26,7 @@ namespace bsmd.ExcelReadService
messageCore = Util.LookupMessageCore(reader, out readMessage); messageCore = Util.LookupMessageCore(reader, out readMessage);
if (messageCore == null) return false; // cannot work with this sheet or create one if (messageCore == null) return false; // cannot work with this sheet or create one
// load messages if already present // load messages if already present
List<Message> messages = DBManager.Instance.GetMessagesForCore(messageCore, DBManager.MessageLoad.EXCEL); List<Message> messages = DBManager.Instance.GetMessagesForCore(messageCore, DBManager.MessageLoad.EXCEL);
@ -285,7 +285,7 @@ namespace bsmd.ExcelReadService
poi.PortOfItineraryLocode = reader.ReadLoCode(bpolLocode); poi.PortOfItineraryLocode = reader.ReadLoCode(bpolLocode);
if (!poi.PortOfItineraryLocode.IsNullOrEmpty() && (poi.PortOfItineraryLocode.Length > 5)) if (!poi.PortOfItineraryLocode.IsNullOrEmpty() && (poi.PortOfItineraryLocode.Length > 5))
{ {
reader.HighlightLookup(bpolLocode, ExcelReader.ReadState.WARN); reader.Conf.ConfirmText(bpolLocode, poi.PortOfItineraryLocode, ExcelReader.ReadState.WARN);
} }
poi.PortOfItineraryETA = reader.ReadDate(bpolETA); poi.PortOfItineraryETA = reader.ReadDate(bpolETA);
@ -388,7 +388,7 @@ namespace bsmd.ExcelReadService
} }
if (!stat.Flag.IsNullOrEmpty() && (stat.Flag.Length > 2)) if (!stat.Flag.IsNullOrEmpty() && (stat.Flag.Length > 2))
reader.HighlightLookup("STAT.Flag", ExcelReader.ReadState.FAIL); reader.Conf.ConfirmText("STAT.Flag", stat.Flag, ExcelReader.ReadState.FAIL);
string transportMode = reader.ReadText("STAT.TransportMode"); string transportMode = reader.ReadText("STAT.TransportMode");
if(transportMode != null) if(transportMode != null)
@ -1098,7 +1098,7 @@ namespace bsmd.ExcelReadService
crew.CrewMemberDuty = reader.ReadText(crewDuty); crew.CrewMemberDuty = reader.ReadText(crewDuty);
crew.CrewMemberNationality = reader.ReadText(crewNationality); crew.CrewMemberNationality = reader.ReadText(crewNationality);
if (!crew.CrewMemberNationality.IsNullOrEmpty() && (crew.CrewMemberNationality.Length > 2)) if (!crew.CrewMemberNationality.IsNullOrEmpty() && (crew.CrewMemberNationality.Length > 2))
reader.HighlightLookup(crewNationality, ExcelReader.ReadState.FAIL); reader.Conf.ConfirmText(crewNationality, crew.CrewMemberNationality, ExcelReader.ReadState.FAIL);
crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth); crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth);
crew.CrewMemberDateOfBirth = reader.ReadDate(crewDateOfBirth); crew.CrewMemberDateOfBirth = reader.ReadDate(crewDateOfBirth);
crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType); crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType);
@ -1148,7 +1148,7 @@ namespace bsmd.ExcelReadService
pas.PassengerGender = reader.ReadGender(pasGender); pas.PassengerGender = reader.ReadGender(pasGender);
pas.PassengerNationality = reader.ReadText(pasNationality); pas.PassengerNationality = reader.ReadText(pasNationality);
if (!pas.PassengerNationality.IsNullOrEmpty() && pas.PassengerNationality.Length > 2) if (!pas.PassengerNationality.IsNullOrEmpty() && pas.PassengerNationality.Length > 2)
reader.HighlightLookup(pasNationality, ExcelReader.ReadState.FAIL); reader.Conf.ConfirmText(pasNationality, pas.PassengerNationality, ExcelReader.ReadState.FAIL);
// TODO: Nicht klar ob hier LOCODEs kommen oder nicht // TODO: Nicht klar ob hier LOCODEs kommen oder nicht
pas.PassengerPortOfEmbarkation = reader.ReadTextNoWhitespace(pasEmbarkation); pas.PassengerPortOfEmbarkation = reader.ReadTextNoWhitespace(pasEmbarkation);
pas.PassengerPortOfDisembarkation = reader.ReadTextNoWhitespace(pasDebarkation); pas.PassengerPortOfDisembarkation = reader.ReadTextNoWhitespace(pasDebarkation);
@ -1255,8 +1255,16 @@ namespace bsmd.ExcelReadService
} }
} }
if(result == null) if (result != null)
{ {
// setup returning confirmation sheets according to PoC
if (result.PoC.Substring(0, 2) == "DK")
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDK);
else
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE);
}
else
{
// lookup poc, imo, eta // lookup poc, imo, eta
poc = reader.ReadText("Visit.PortOfCall"); poc = reader.ReadText("Visit.PortOfCall");
@ -1265,6 +1273,7 @@ namespace bsmd.ExcelReadService
// Prüfen auf Transit // Prüfen auf Transit
if (poc.ToUpper().Contains("CANAL") || poc.ToUpper().Equals("ZZNOK")) if (poc.ToUpper().Contains("CANAL") || poc.ToUpper().Equals("ZZNOK"))
{ {
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE);
poc = "ZZNOK"; poc = "ZZNOK";
isTransit = true; isTransit = true;
} }
@ -1281,19 +1290,32 @@ namespace bsmd.ExcelReadService
} }
if (RuleEngine.IsGermanLocode(aGermanPortName)) if (RuleEngine.IsGermanLocode(aGermanPortName))
{
poc = aGermanPortName; poc = aGermanPortName;
}
else else
{ {
// somehow lookup LOCODE from the port's name! // somehow lookup LOCODE from the port's name!
poc = LocodeDB.LocodeGERFromCity(aGermanPortName); poc = LocodeDB.LocodeGERFromCity(aGermanPortName);
} }
} }
if (poc != null)
{
// setup returning confirmation sheets according to PoC
if (poc.Substring(0, 2) == "DK")
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDK);
else
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE);
}
} }
imo = reader.ReadText("Visit.IMONumber"); imo = reader.ReadText("Visit.IMONumber");
// ETA // ETA
eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall"); if(poc != null)
eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall");
if ((imo != null) && (eta.HasValue) && (poc != null)) if ((imo != null) && (eta.HasValue) && (poc != null))
{ {

View File

@ -71,6 +71,7 @@
<Compile Include="..\bsmd.database\Properties\AssemblyProjectKeyInfo.cs"> <Compile Include="..\bsmd.database\Properties\AssemblyProjectKeyInfo.cs">
<Link>Properties\AssemblyProjectKeyInfo.cs</Link> <Link>Properties\AssemblyProjectKeyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="Confirmation.cs" />
<Compile Include="ExcelReader.cs" /> <Compile Include="ExcelReader.cs" />
<Compile Include="ExcelReadService.cs"> <Compile Include="ExcelReadService.cs">
<SubType>Component</SubType> <SubType>Component</SubType>

View File

@ -2,9 +2,6 @@
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace bsmd.database namespace bsmd.database

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")] [assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("BSMD NSW interface")] [assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.2.27")] [assembly: AssemblyInformationalVersion("3.3.0")]
[assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")] [assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("3.2.27.*")] [assembly: AssemblyVersion("3.3.0.*")]

View File

@ -0,0 +1,9 @@
Ich hatte Weihnachten 16 größere Probleme den TestService installiert zu bekommen.
So hat es dann geklappt:
- ein Batch-File braucht man nicht
- Eingabeaufforderung als Admin starten
- C:\work\Services\ExcelReadService_Test>C:\Windows\Microsoft.NET\Framework\v4.0.3
0319\installutil.exe /ShowCallStack bsmd.ExcelReadService.Test.exe
- Dann erscheint ein Dialog, in dem man Username + Passwort für den Service angeben muss. Das hat nicht
funktioniert für den Admin, auch nicht für meinen User ohne die Domäne vorne dran.
mit BSMD\daniel.schick# hat es dann geklappt.