Esempio n. 1
0
        //TBD to send to Azure Event Hubs
        //static readonly string EventHubName = Properties.Settings.Default.EventHubName;

        public static void SendEventDirectToServiceFabricMicroservice(GPSCoordinatesEvent gpsCoordVehicleEvent)
        {            
            GPSCoordinates coordinates = new GPSCoordinates();
            coordinates.Latitude = gpsCoordVehicleEvent.Latitude;
            coordinates.Longitude = gpsCoordVehicleEvent.Longitude;

            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(gpsCoordVehicleEvent.VehicleId, coordinates);

        }
Esempio n. 2
0
        // PUT api/LiveVehicle/3/GPSCoordinates        
        // HttpPut "{vehicleId}/GPSCoordinates"
        private static void UpdateGPSCoordinates(string vehicleID, GPSCoordinates coordinates)
        {
            Uri serviceAddress = new Uri(SeatMapGatewayServiceUrl + "LiveVehicle/" + vehicleID.ToString() + "/GPSCoordinates");
            HttpWebRequest req = WebRequest.CreateHttp(serviceAddress);

            string data = JsonConvert.SerializeObject(coordinates);
            //This gives you the byte array.

            var dataToSend = Encoding.UTF8.GetBytes(data);

            req.ContentType = "application/json";
            req.ContentLength = dataToSend.Length;
            req.Method = "PUT";

            //Send data
            req.GetRequestStream().Write(dataToSend, 0, dataToSend.Length);

            var response = req.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();                                 
        }
Esempio n. 3
0
        static void UpdateCoordinatesBackward()
        {
            Console.WriteLine("\nUpdating vehicles' coordinates backward");

            //UPDATE COORDINATES VEHICLE 1 //////////////////////////////////////////
            int vehicleId1 = 1;
            GPSCoordinates coordinates1 = new GPSCoordinates();
            //Seattle Pike's Place --> --> 47.608875, -122.340098
            coordinates1.Latitude = 47.608875;
            coordinates1.Longitude = -122.340098;
            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(vehicleId1, coordinates1);
            /////////////////////////////////////////////////////////////////////////

            //UPDATE COORDINATES VEHICLE 2 //////////////////////////////////////////
            int vehicleId2 = 2;
            GPSCoordinates coordinates2 = new GPSCoordinates();
            //Seattle STARBUCKS ORIGINAL coordinates 47.610021, -122.342649
            coordinates2.Latitude = 47.610021;
            coordinates2.Longitude = -122.342649;
            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(vehicleId2, coordinates2);
            /////////////////////////////////////////////////////////////////////////

            //UPDATE COORDINATES VEHICLE 3 //////////////////////////////////////////
            int vehicleId3 = 3;
            GPSCoordinates coordinates3 = new GPSCoordinates();
            //Seattle CONVENTION CENTER coordinates 47.612283, -122.331918
            coordinates3.Latitude = 47.612283;
            coordinates3.Longitude = -122.331918;
            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(vehicleId3, coordinates3);
            /////////////////////////////////////////////////////////////////////////

            Console.WriteLine("##### END OF COORDINATES FORWARD UPDATE #####");
            Console.WriteLine("#############################################");

        }
Esempio n. 4
0
        static void UpdateCoordinatesForward()
        {
            Console.WriteLine("\nUpdating vehicles' coordinates forward");

            //UPDATE COORDINATES VEHICLE 1 //////////////////////////////////////////
            int vehicleId1 = 1;
            GPSCoordinates coordinates1 = new GPSCoordinates();
            //Seattle Pike's Place --> move to North to 2nd Av. --> 47.609321, -122.339041
            coordinates1.Latitude = 47.609321;
            coordinates1.Longitude = -122.339041;
            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(vehicleId1, coordinates1);
            /////////////////////////////////////////////////////////////////////////

            //UPDATE COORDINATES VEHICLE 2 //////////////////////////////////////////
            int vehicleId2 = 2;
            GPSCoordinates coordinates2 = new GPSCoordinates();
            //Starbucks 1st --> move to Virginia St. --> 47.610515, -122.343569
            coordinates2.Latitude = 47.610515;
            coordinates2.Longitude = -122.343569;
            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(vehicleId2, coordinates2);
            /////////////////////////////////////////////////////////////////////////

            //UPDATE COORDINATES VEHICLE 3 //////////////////////////////////////////
            int vehicleId3 = 3;
            GPSCoordinates coordinates3 = new GPSCoordinates();
            //Seattle Convention Center --> move to 7th Av. --> 47.611636, -122.333409
            coordinates3.Latitude = 47.611636;
            coordinates3.Longitude = -122.333409;
            //Call Http Service to update GPS coordinates
            UpdateGPSCoordinates(vehicleId3, coordinates3);
            /////////////////////////////////////////////////////////////////////////

            Console.WriteLine("##### END OF COORDINATES FORWARD UPDATE #####");
            Console.WriteLine("#############################################");

        }