164 lines
5.3 KiB
C#
164 lines
5.3 KiB
C#
// Copyright (c) 2023 schick Informatik
|
|
// Description: Static lists used everywhere
|
|
//
|
|
|
|
using BreCalClient.misc.Model;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace BreCalClient
|
|
{
|
|
public static class BreCalLists
|
|
{
|
|
|
|
#region Fields
|
|
|
|
private static readonly List<Participant> aList = new();
|
|
private static readonly List<Participant> mList = new();
|
|
private static readonly List<Participant> pList = new();
|
|
private static readonly List<Participant> tList = new();
|
|
private static readonly List<Participant> terList = new();
|
|
|
|
private static readonly List<Berth> _berths = new();
|
|
private static List<Berth> _allBerths = new();
|
|
private static List<Participant> _participants = new();
|
|
private static readonly List<ShipModel> _ships = new();
|
|
private static readonly List<ShipModel> _allShips = new();
|
|
|
|
private readonly static ConcurrentDictionary<int, ShipModel> _shipLookupDict = new();
|
|
private readonly static ConcurrentDictionary<int, Berth> _berthLookupDict = new();
|
|
private readonly static Dictionary<int, Participant> _participantLookupDict = new();
|
|
|
|
/// <summary>
|
|
/// List of TimeRef points
|
|
/// </summary>
|
|
// TODO: To make this portable the list of texts should come from a configuration file
|
|
private readonly static List<string> _timeRefs = new List<string>
|
|
{
|
|
"ETB",
|
|
"Geeste",
|
|
"TN-Weser"
|
|
};
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public static ConcurrentDictionary<int, ShipModel> ShipLookupDict { get { return _shipLookupDict; } }
|
|
|
|
public static ConcurrentDictionary<int, Berth> BerthLookupDict { get { return _berthLookupDict; } }
|
|
|
|
public static Dictionary<int, Participant> ParticipantLookupDict { get { return _participantLookupDict; } }
|
|
|
|
/// <summary>
|
|
/// Participants that are agents
|
|
/// </summary>
|
|
public static List<Participant> Participants_Agent { get { return aList; } }
|
|
|
|
/// <summary>
|
|
/// Participants that are mooring companies
|
|
/// </summary>
|
|
public static List<Participant> Participants_Mooring { get { return mList; } }
|
|
|
|
/// <summary>
|
|
/// Participants that are pilots
|
|
/// </summary>
|
|
public static List<Participant> Participants_Pilot { get { return pList; } }
|
|
|
|
/// <summary>
|
|
/// Participants that are tug shipping companies
|
|
/// </summary>
|
|
public static List<Participant> Participants_Tug { get { return tList; } }
|
|
|
|
/// <summary>
|
|
/// Participants that are terminals
|
|
/// </summary>
|
|
public static List<Participant> Participants_Terminal { get { return terList; } }
|
|
|
|
/// <summary>
|
|
/// All participants
|
|
/// </summary>
|
|
public static List<Participant> Participants { get { return _participants; } }
|
|
|
|
/// <summary>
|
|
/// All active berths
|
|
/// </summary>
|
|
public static List<Berth> Berths { get { return _berths; } }
|
|
|
|
/// <summary>
|
|
/// All berths including deleted berths
|
|
/// </summary>
|
|
public static List<Berth> AllBerths { get { return _allBerths; } }
|
|
|
|
/// <summary>
|
|
/// All active ships
|
|
/// </summary>
|
|
public static List<ShipModel> Ships { get { return _ships; } }
|
|
|
|
/// <summary>
|
|
/// All ships including deleted ships
|
|
/// </summary>
|
|
public static List<ShipModel> AllShips { get { return _allShips; } }
|
|
|
|
/// <summary>
|
|
/// List of display values for TimeRef points
|
|
/// </summary>
|
|
public static List<string> TimeRefs { get { return _timeRefs; } }
|
|
|
|
#endregion
|
|
|
|
#region methods
|
|
|
|
internal static void InitializeParticipants(List<Participant> participants)
|
|
{
|
|
_participants = participants;
|
|
|
|
aList.Clear();
|
|
mList.Clear();
|
|
pList.Clear();
|
|
tList.Clear();
|
|
terList.Clear();
|
|
|
|
foreach (Participant p in participants)
|
|
{
|
|
_participantLookupDict[p.Id] = p;
|
|
if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p);
|
|
if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p);
|
|
if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p);
|
|
if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p);
|
|
if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p);
|
|
}
|
|
}
|
|
|
|
internal static void InitializeBerths(List<Berth> berths)
|
|
{
|
|
foreach (var berth in berths)
|
|
{
|
|
_berthLookupDict[berth.Id] = berth;
|
|
if(!berth.Deleted)
|
|
_berths.Add(berth);
|
|
}
|
|
_allBerths = berths;
|
|
}
|
|
|
|
internal static void InitializeShips(List<Ship> ships)
|
|
{
|
|
_ships.Clear();
|
|
_allShips.Clear();
|
|
|
|
foreach (var ship in ships)
|
|
{
|
|
ShipModel sm = new(ship);
|
|
_shipLookupDict[ship.Id] = sm;
|
|
if (!ship.Deleted)
|
|
_ships.Add(sm);
|
|
_allShips.Add(sm);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|