示例#1
0
        /// <summary>
        /// Run BART API ingress to configured OMF endpoints
        /// </summary>
        public static void RunIngress()
        {
            var data = BartApi.GetRealTimeEstimates(Settings.BartApiKey, Settings.BartApiOrig, Settings.BartApiDest);

            OmfServices.SendOmfData(data);
            Console.WriteLine($"{DateTime.Now}: Sent value for {data.Keys.Count} stream{(data.Keys.Count > 1 ? "s" : string.Empty)}");
        }
示例#2
0
        /// <summary>
        /// Loads configuration from the appsettings.json file and sets up configured OMF endpoints
        /// </summary>
        public static void LoadConfiguration()
        {
            Settings = JsonConvert.DeserializeObject <AppSettings>(File.ReadAllText(Directory.GetCurrentDirectory() + "\\appsettings.json"));

            OmfServices = new OmfServices();

            if (Settings.SendToOcs)
            {
                OmfServices.ConfigureOcsOmfIngress(Settings.OcsUri, Settings.OcsTenantId, Settings.OcsNamespaceId, Settings.OcsClientId, Settings.OcsClientSecret);
            }

            if (Settings.SendToEds)
            {
                OmfServices.ConfigureEdsOmfIngress(Settings.EdsPort);
            }

            if (Settings.SendToPi)
            {
                OmfServices.ConfigurePiOmfIngress(Settings.PiWebApiUri, Settings.Username, Settings.Password, Settings.ValidateEndpointCertificate);
            }

            // Send OMF Type Message
            OmfServices.SendOmfType(typeof(BartStationEtd));

            // Send OMF Container Message
            var data   = BartApi.GetRealTimeEstimates(Settings.BartApiKey, Settings.BartApiOrig, Settings.BartApiDest);
            var typeId = ClrToOmfTypeConverter.Convert(typeof(BartStationEtd)).Id;

            OmfServices.SendOmfContainersForData(data, typeId);
        }