//
// Class: XtraLogic
// Current CLR: 4.0.30319.42000
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 11/21/2015 1:31:37 PM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Collections.Generic;
using log4net;
using bsmd.database;
namespace bsmd.herberg.FormService
{
public class XtraLogic
{
private static ILog _log = LogManager.GetLogger(typeof(XtraLogic));
///
/// Diese Klasse implementiert Logik, die von BSMD separat definiert wurde, z.B. zur Vereinfachung
/// der Bearbeitung. Diese Logik ist nicht Teil der NSW Spezifikation. Sie wird nach dem kompletten Einlesen / Update
/// eines Anlaufs ausgeführt (HE).
///
internal static void ProcessMessage(MessageCore core, Dictionary messageDict)
{
// Regel 1: 20.11.2015
// Fehlermeldung: MDH – List of Ports during the last 30 days = leer
// => Automatische Übernahme des Letzten Hafens und des entsprechenden Abfahrtsdatums (NOA_NOD),
// damit entfällt manuelle Nachbearbeitung.
if(messageDict.ContainsKey("MDH") && messageDict.ContainsKey("NOA_NOD"))
{
MDH mdh = null;
NOA_NOD noa_nod = null;
if (messageDict["MDH"].Elements.Count > 0)
mdh = messageDict["MDH"].Elements[0] as MDH;
if (messageDict["NOA_NOD"].Elements.Count > 0)
noa_nod = messageDict["NOA_NOD"].Elements[0] as NOA_NOD;
if ((mdh != null) && (noa_nod != null))
{
if (!(mdh.MDHSimplification ?? false))
{
if (mdh.PortOfCallLast30Days.Count == 0)
{
PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
poc30.PortOfCallLast30DaysCrewMembersJoined = false;
poc30.PortOfCallLast30DaysDateOfDeparture = noa_nod.ETDFromLastPort;
poc30.PortOfCallLast30DaysLocode = noa_nod.LastPort;
poc30.MDH = mdh;
mdh.PortOfCallLast30Days.Add(poc30);
DBManager.Instance.Save(poc30);
_log.InfoFormat("adding POCLast30Days for MDH. Port:{0} Departure:{1}", noa_nod.LastPort ?? "",
noa_nod.ETDFromLastPort ?? DateTime.MinValue);
}
}
}
}
/// Regel 2: Bei Transit wird der Port auf (ZZ)NOK gesetzt
/// In dashface wird "ETA" angezeigt, ich setze hier daher ETA auf ETAKielCanal
/// 20.11.2015
if (core.IsTransit)
{
core.Portname = "NOK";
core.PoC = "ZZNOK";
core.ETA = core.ETAKielCanal;
}
}
}
}