using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; using static SDRGatewayService.LIP; namespace SDRGatewayService { public static class ConfigHelper { private static readonly String REG_PORT_KEY = "regPort"; private static readonly String GW_ID_KEY = "id"; private static readonly String GW_IP_KEY = "thisIP"; private static readonly String GW_NAME_KEY = "name"; private static readonly String DB_IP_KEY = "dbIP"; private static readonly String DB_SCHEMA_KEY = "dbSchema"; private static readonly String DB_USER_KEY = "dbUser"; private static readonly String DB_PASSWORD_KEY = "dbPassword"; private static readonly String DB_PORT_KEY = "dbPort"; private static readonly String MSGBUS_IP_KEY = "busIP"; private static readonly String MSGBUS_PORT_KEY = "busPort"; private static readonly String SDR_IP_KEY = "SDR_IP"; private static readonly String SDR_PORT_KEY = "SDR_port"; private static readonly String SDR_ISSI_KEY = "SDR_ISSI"; private static readonly String SDR_PASS_KEY = "SDR_pass"; private static readonly String GPS_TYPE_KEY = "GPS_type"; private static readonly String SDR_PING_KEY = "SDR_ping"; private static readonly String SDR_TIMEOUT_KEY = "SDR_TimeOut"; private static readonly String SDR_STORETM_KEY = "SDR_StoreTM"; private static readonly String SDR_SFSERVER_KEY = "SDR_SFServer"; private static readonly String SDR_CALLOUT_KEY = "SDR_CallOut"; private static readonly String SDR_AUTOCONNECT_KEY = "SDR_Autoconnect"; private static readonly String SERVER_IP_KEY = "ServerIP"; public static PositionError SDR_PositionErrorTolerance = PositionError.Unknown; public static string ServerIP { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SERVER_IP_KEY)) return ConfigurationManager.AppSettings[SERVER_IP_KEY]; else return "127.0.0.1"; } } public static bool HasServerIp => ConfigurationManager.AppSettings.AllKeys.Contains(SERVER_IP_KEY); public static string SdrAutoconnect { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_AUTOCONNECT_KEY)) return ConfigurationManager.AppSettings[SDR_AUTOCONNECT_KEY]; else return "true"; } } public static bool HasSdrAutoconnect => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_AUTOCONNECT_KEY); public static int SdrCallOut { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_CALLOUT_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_CALLOUT_KEY]); else return 0; } } public static bool HasSdrCallOut => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_CALLOUT_KEY); public static int SdrSfServer { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_SFSERVER_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_SFSERVER_KEY]); else return 13999999; } } public static bool HasSdrSfServer => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_SFSERVER_KEY); public static int SdrStoreTM { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_STORETM_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_STORETM_KEY]); else return 0; } } public static bool HasSdrStoreTM => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_STORETM_KEY); public static int SdrTimeout { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_TIMEOUT_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_TIMEOUT_KEY]); else return 120; } } public static bool HasSdrTimeout => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_TIMEOUT_KEY); public static int SdrPing { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_PING_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_PING_KEY]); else return 1; } } public static bool HasSdrPing => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_PING_KEY); public static string GpsType { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(GPS_TYPE_KEY)) return ConfigurationManager.AppSettings[GPS_TYPE_KEY]; else return "LIP"; } } public static bool HasGpsType => ConfigurationManager.AppSettings.AllKeys.Contains(GPS_TYPE_KEY); public static string GatewayName { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(GW_NAME_KEY)) return ConfigurationManager.AppSettings[GW_NAME_KEY]; else return "Tetra SDR"; } } public static bool HasGatewayName => ConfigurationManager.AppSettings.AllKeys.Contains(GW_NAME_KEY); public static int GatewayId { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(GW_ID_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[GW_ID_KEY]); else return -1; } } public static bool HasGatewayId => ConfigurationManager.AppSettings.AllKeys.Contains(GW_ID_KEY); public static string GatewayIp { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(GW_IP_KEY)) return ConfigurationManager.AppSettings[GW_IP_KEY]; else return "127.0.0.1"; } } public static bool HasGatewayIp => ConfigurationManager.AppSettings.AllKeys.Contains(GW_IP_KEY); public static Int16 RegPort { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(REG_PORT_KEY)) return Int16.Parse(ConfigurationManager.AppSettings[REG_PORT_KEY]); else return 5680; } } public static bool HasRegPort => ConfigurationManager.AppSettings.AllKeys.Contains(REG_PORT_KEY); public static string DBip { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(DB_IP_KEY)) return ConfigurationManager.AppSettings[DB_IP_KEY]; else return "127.0.0.1"; } } public static bool HasDbIP => ConfigurationManager.AppSettings.AllKeys.Contains(DB_IP_KEY); public static string DBSchema { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(DB_SCHEMA_KEY)) return ConfigurationManager.AppSettings[DB_SCHEMA_KEY]; else return "safedispatchdb"; } } public static bool HasDbSchema => ConfigurationManager.AppSettings.AllKeys.Contains(DB_SCHEMA_KEY); public static string DBUser { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(DB_USER_KEY)) return ConfigurationManager.AppSettings[DB_USER_KEY]; else return "postgres"; } } public static bool HasDbUser => ConfigurationManager.AppSettings.AllKeys.Contains(DB_USER_KEY); public static string DBPassword { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(DB_PASSWORD_KEY)) return ConfigurationManager.AppSettings[DB_PASSWORD_KEY]; else return "wizdemo26"; } } public static bool HasDbPassword => ConfigurationManager.AppSettings.AllKeys.Contains(DB_PASSWORD_KEY); public static string DBPort { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(DB_PORT_KEY)) return ConfigurationManager.AppSettings[DB_PORT_KEY]; else return "5432"; } } public static bool HasDbPort => ConfigurationManager.AppSettings.AllKeys.Contains(DB_PORT_KEY); public static int SdrIssi { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_ISSI_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_ISSI_KEY]); else return 7; } } public static bool HasSdrIssi => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_ISSI_KEY); public static string SdrPass { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_PASS_KEY)) return ConfigurationManager.AppSettings[SDR_PASS_KEY]; else return "0"; } } public static bool HasSdrPass => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_PASS_KEY); public static int MsgBusPort { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(MSGBUS_PORT_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[MSGBUS_PORT_KEY]); else return 17233; } } public static bool HasMsgBusPort => ConfigurationManager.AppSettings.AllKeys.Contains(MSGBUS_PORT_KEY); public static string MsgBusIp { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(MSGBUS_IP_KEY)) return ConfigurationManager.AppSettings[MSGBUS_IP_KEY]; else return "224.30.0.1"; } } public static bool HasMsgBusIp => ConfigurationManager.AppSettings.AllKeys.Contains(MSGBUS_IP_KEY); public static string SdrIp { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_IP_KEY)) return ConfigurationManager.AppSettings[SDR_IP_KEY]; else return "127.0.0.1"; } } public static bool HasSdrIp => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_IP_KEY); public static int SdrPort { get { if (ConfigurationManager.AppSettings.AllKeys.Contains(SDR_PORT_KEY)) return Int32.Parse(ConfigurationManager.AppSettings[SDR_PORT_KEY]); else return 6006; } } public static bool HasSdrPort => ConfigurationManager.AppSettings.AllKeys.Contains(SDR_PORT_KEY); } }