Erste Version Excel-Reader deployment (3.2.0)
This commit is contained in:
parent
dad76beb2c
commit
384dad5950
Binary file not shown.
@ -66,11 +66,7 @@ namespace bsmd.ExcelReadService
|
||||
|
||||
using (BSMDPopClient bsmdPopClient = new BSMDPopClient())
|
||||
{
|
||||
if (!bsmdPopClient.IsConnected)
|
||||
{
|
||||
_log.Error("cannot connect to pop3 server!");
|
||||
}
|
||||
else
|
||||
if(bsmdPopClient.IsConnected)
|
||||
{
|
||||
|
||||
|
||||
|
||||
@ -121,70 +121,142 @@ namespace bsmd.ExcelReadService
|
||||
|
||||
internal byte? ReadGender(string lookup)
|
||||
{
|
||||
byte? result = null;
|
||||
string val = this.ReadText(lookup);
|
||||
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
|
||||
if (val != null)
|
||||
{
|
||||
if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) {
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
result = 0;
|
||||
}
|
||||
else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 2;
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
}
|
||||
}
|
||||
if(result == null)
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal byte? ReadIdentityDocumentType(string lookup)
|
||||
{
|
||||
byte? result = null;
|
||||
string val = this.ReadText(lookup);
|
||||
if (val == null) return null;
|
||||
if (val.Equals("identity_card", StringComparison.CurrentCultureIgnoreCase)) return 0;
|
||||
if (val.Equals("passport", StringComparison.CurrentCultureIgnoreCase)) return 1;
|
||||
if (val.Equals("muster_book", StringComparison.CurrentCultureIgnoreCase)) return 2;
|
||||
if (val.Equals("picture_id", StringComparison.CurrentCultureIgnoreCase)) return 3;
|
||||
if (val.Equals("residental_permit", StringComparison.CurrentCultureIgnoreCase)) return 4;
|
||||
if (val.Equals("other_legal_identity_document", StringComparison.CurrentCultureIgnoreCase)) return 5;
|
||||
if (val != null)
|
||||
{
|
||||
if (val.Equals("identity_card", StringComparison.CurrentCultureIgnoreCase)) result = 0;
|
||||
if (val.Equals("passport", StringComparison.CurrentCultureIgnoreCase)) result = 1;
|
||||
if (val.Equals("muster_book", StringComparison.CurrentCultureIgnoreCase)) result = 2;
|
||||
if (val.Equals("picture_id", StringComparison.CurrentCultureIgnoreCase)) result = 3;
|
||||
if (val.Equals("residental_permit", StringComparison.CurrentCultureIgnoreCase)) result = 4;
|
||||
if (val.Equals("other_legal_identity_document", StringComparison.CurrentCultureIgnoreCase)) result = 5;
|
||||
if (val.Equals("ic", StringComparison.CurrentCultureIgnoreCase)) result = 0;
|
||||
|
||||
return 5; // default?
|
||||
if (result == null)
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
else
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal byte? ReadShippingArea(string lookup)
|
||||
{
|
||||
string val = this.ReadText(lookup);
|
||||
if (val == null) return null;
|
||||
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;
|
||||
byte? result = null;
|
||||
if (val != null)
|
||||
{
|
||||
if (val.IndexOf("baltic", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
|
||||
if (val.IndexOf("europe", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
|
||||
if (val.IndexOf("overseas", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
|
||||
if (result == null)
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
else
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal byte? ReadHullConfiguration(string lookup)
|
||||
{
|
||||
string val = this.ReadText(lookup);
|
||||
if (val == null) return null;
|
||||
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;
|
||||
byte? result = null;
|
||||
if (val != null)
|
||||
{
|
||||
if (val.IndexOf("sbt", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
|
||||
if (val.IndexOf("single", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
|
||||
if (val.IndexOf("double", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
|
||||
if (result == null)
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
else
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal byte? ReadConditionTanks(string lookup)
|
||||
{
|
||||
string val = this.ReadText(lookup);
|
||||
if (val == null) return null;
|
||||
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;
|
||||
byte? result = null;
|
||||
if (val != null)
|
||||
{
|
||||
if (val.IndexOf("full", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
|
||||
if (val.IndexOf("empty", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
|
||||
if (val.IndexOf("inerted", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
|
||||
if (result == null)
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
else
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal byte? ReadDelivery(string lookup)
|
||||
{
|
||||
string val = this.ReadText(lookup);
|
||||
if (val == null) return null;
|
||||
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;
|
||||
byte? result = null;
|
||||
|
||||
if (val != null)
|
||||
{
|
||||
if (val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) result = 0;
|
||||
if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) result = 1;
|
||||
if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) result = 2;
|
||||
if (result == null)
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
else
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -199,18 +271,45 @@ namespace bsmd.ExcelReadService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_nameDict.ContainsKey(lookup)) return null;
|
||||
var val = _nameDict[lookup].RefersToRange.Value;
|
||||
if (val is DateTime) return val;
|
||||
if (val is double)
|
||||
return DateTime.FromOADate(val);
|
||||
DateTime date;
|
||||
if (DateTime.TryParse(val, out date))
|
||||
return date;
|
||||
// TODO: weitere varianten ausprobieren
|
||||
DateTime? date = null;
|
||||
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
return null;
|
||||
if (_nameDict.ContainsKey(lookup))
|
||||
{
|
||||
var val = _nameDict[lookup].RefersToRange.Value;
|
||||
if (val is DateTime) return val;
|
||||
if (val is double)
|
||||
{
|
||||
try
|
||||
{
|
||||
date = DateTime.FromOADate(val);
|
||||
}
|
||||
catch (ArgumentException) { /* .. */ }
|
||||
if(date == null)
|
||||
{
|
||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||
string dateString = val.ToString();
|
||||
string format = "yyyyMMdd";
|
||||
DateTime tmpDate;
|
||||
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out tmpDate))
|
||||
date = tmpDate;
|
||||
}
|
||||
}
|
||||
|
||||
if (date == null)
|
||||
{
|
||||
DateTime tmpDate;
|
||||
if (DateTime.TryParse(val, out tmpDate))
|
||||
date = tmpDate;
|
||||
}
|
||||
|
||||
// TODO: weitere varianten ausprobieren
|
||||
if (date != null)
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
else
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -237,54 +336,106 @@ namespace bsmd.ExcelReadService
|
||||
}
|
||||
|
||||
internal DateTime? ReadTime(string lookup)
|
||||
{
|
||||
{
|
||||
DateTime? result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (!_nameDict.ContainsKey(lookup)) return null;
|
||||
var val = _nameDict[lookup].RefersToRange.Value;
|
||||
if (val is DateTime) return val;
|
||||
if (val is double)
|
||||
return DateTime.FromOADate(val);
|
||||
DateTime date;
|
||||
if (DateTime.TryParseExact(val, "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out date))
|
||||
return date;
|
||||
if (DateTime.TryParseExact(val, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out date))
|
||||
return date;
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
return null;
|
||||
if (_nameDict.ContainsKey(lookup))
|
||||
{
|
||||
var val = _nameDict[lookup].RefersToRange.Value;
|
||||
if (val is DateTime)
|
||||
{
|
||||
result = val;
|
||||
}
|
||||
if (val is double)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = DateTime.FromOADate(val);
|
||||
}
|
||||
catch(ArgumentException) { }
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||
string dateString = val.ToString();
|
||||
string format = "HHmm";
|
||||
DateTime tmpDate;
|
||||
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out tmpDate))
|
||||
result = tmpDate;
|
||||
}
|
||||
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
DateTime date;
|
||||
if (DateTime.TryParseExact(val, "HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out date))
|
||||
result = date;
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
DateTime date;
|
||||
if (DateTime.TryParseExact(val, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault, out date))
|
||||
return date;
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
_log.WarnFormat("error reading time for lookup {0}", lookup);
|
||||
return null;
|
||||
_log.WarnFormat("error reading time for lookup {0}", lookup);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal double? ReadNumber(string lookup)
|
||||
{
|
||||
double result;
|
||||
double? result = null;
|
||||
try
|
||||
{
|
||||
if (!_nameDict.ContainsKey(lookup)) return null;
|
||||
var val = _nameDict[lookup].RefersToRange.Value;
|
||||
if (val is double) return val;
|
||||
if (val is string)
|
||||
if (_nameDict.ContainsKey(lookup))
|
||||
{
|
||||
if (double.TryParse(val, NumberStyles.None, CultureInfo.InvariantCulture, out result))
|
||||
return result;
|
||||
if (double.TryParse(val, out result))
|
||||
return result;
|
||||
}
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
return null;
|
||||
var val = _nameDict[lookup].RefersToRange.Value;
|
||||
if (val is double) result = val;
|
||||
if (val is string)
|
||||
{
|
||||
double tmpDouble;
|
||||
if (double.TryParse(val, NumberStyles.None, CultureInfo.InvariantCulture, out tmpDouble))
|
||||
result = tmpDouble;
|
||||
if (result == null)
|
||||
{
|
||||
if (double.TryParse(val, out tmpDouble))
|
||||
result = tmpDouble;
|
||||
}
|
||||
}
|
||||
if (result != null)
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
_log.WarnFormat("error reading number for lookup {0}", lookup);
|
||||
return null;
|
||||
_log.WarnFormat("error reading number for lookup {0}", lookup);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal bool? ReadBoolean(string lookup)
|
||||
@ -292,13 +443,15 @@ namespace bsmd.ExcelReadService
|
||||
string val = this.ReadText(lookup);
|
||||
if (val == null)
|
||||
{
|
||||
this.HighlightLookup(lookup, ReadState.WARN);
|
||||
this.HighlightLookup(lookup, ReadState.FAIL);
|
||||
return null;
|
||||
}
|
||||
|
||||
this.HighlightLookup(lookup, ReadState.OK);
|
||||
|
||||
if ((val == "y") || (val == "Y") || (val == "yes") || (val == "YES") || (val == "1") || (val == "x") || (val == "X"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -949,7 +949,8 @@ namespace bsmd.ExcelReadService
|
||||
result = DBManager.Instance.GetMessageCoreByTransitId(visitTransitId);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if(result == null)
|
||||
{
|
||||
// lookup poc, imo, eta
|
||||
poc = reader.ReadText("Visit.PortOfCall");
|
||||
@ -972,10 +973,15 @@ namespace bsmd.ExcelReadService
|
||||
if(poc.Contains(',')) // irgendwas wie "Hamburg, Germany"
|
||||
{
|
||||
aGermanPortName = poc.Split(',')[0];
|
||||
}
|
||||
}
|
||||
|
||||
// somehow lookup LOCODE from the port's name!
|
||||
poc = LocodeDB.LocodeGERFromCity(aGermanPortName);
|
||||
if (RuleEngine.IsGermanLocode(aGermanPortName))
|
||||
poc = aGermanPortName;
|
||||
else
|
||||
{
|
||||
// somehow lookup LOCODE from the port's name!
|
||||
poc = LocodeDB.LocodeGERFromCity(aGermanPortName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1028,6 +1034,15 @@ namespace bsmd.ExcelReadService
|
||||
_log.WarnFormat("IMO {0} is longer than 7 chars, truncating!", result.IMO);
|
||||
result.IMO = result.IMO.Substring(0, 7);
|
||||
}
|
||||
|
||||
if(visitTransitId != null)
|
||||
{
|
||||
if (bsmd.database.Util.IsVisitId(visitTransitId))
|
||||
result.VisitId = visitTransitId;
|
||||
else
|
||||
result.TransitId = visitTransitId;
|
||||
}
|
||||
|
||||
DBManager.Instance.Save(result);
|
||||
}
|
||||
|
||||
|
||||
@ -459,8 +459,8 @@ namespace bsmd.database
|
||||
{
|
||||
case NotificationClass.BKRA: return 5;
|
||||
case NotificationClass.BKRD: return 5;
|
||||
case NotificationClass.LADG: return 5;
|
||||
case NotificationClass.CREW: return 30;
|
||||
case NotificationClass.LADG: return 36;
|
||||
case NotificationClass.CREW: return 40;
|
||||
case NotificationClass.PAS: return 30;
|
||||
|
||||
default:
|
||||
|
||||
@ -21,6 +21,7 @@ namespace bsmd.email
|
||||
private Pop3Client pop3Client;
|
||||
private bool _connected = false;
|
||||
private ILog _log = LogManager.GetLogger(typeof(BSMDPopClient));
|
||||
private int currentMail = 1;
|
||||
|
||||
public BSMDPopClient()
|
||||
{
|
||||
@ -34,6 +35,7 @@ namespace bsmd.email
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorFormat("Error connecting to POP3 Server: {0}", ex.Message);
|
||||
_log.DebugFormat("User:{0} Pw:{1}", Properties.Settings.Default.POP3User, Properties.Settings.Default.POP3Password);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +52,7 @@ namespace bsmd.email
|
||||
int messageCount = this.pop3Client.GetMessageCount();
|
||||
if (messageCount > 0)
|
||||
{
|
||||
Message mailMessage = this.pop3Client.GetMessage(1);
|
||||
Message mailMessage = this.pop3Client.GetMessage(this.currentMail);
|
||||
|
||||
if ((mailMessage.Headers.Sender != null) && mailMessage.Headers.Sender.HasValidMailAddress)
|
||||
sender = mailMessage.Headers.Sender.MailAddress.Address;
|
||||
@ -69,6 +71,8 @@ namespace bsmd.email
|
||||
}
|
||||
}
|
||||
|
||||
this.currentMail++; // advance message pointer
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user