private async Task PostTheLocation(GeoTags vGeoTags) { GeoTagList GTL = Caster.ConvertToGeoTagList(vGeoTags); List <LiveLocation> locations = GTL.List.ConvertToLiveLocationList(); await new LocationService().PostMyLocation(locations.ToArray()); }
public static TrackingSession ConvertServerGeoTags(GeoTags geoTags) { if (geoTags.LocCnt <= 0) { return(null); } TrackingSession session = new TrackingSession(); session.ProfileId = geoTags.PID.ToString(); session.SessionId = geoTags.Id; session.GeoTags = new List <GeoTagLite>(); for (int i = 0; i < geoTags.LocCnt; i++) { session.GeoTags.Add(new GeoTagLite() { Lat = Convert.ToDouble(geoTags.Lat[i]), Long = Convert.ToDouble(geoTags.Long[i]), Alt = (geoTags.Alt != null) ? Convert.ToDouble(geoTags.Alt[i]) : 0, TimeStamp = geoTags.TS[i], IsSOS = geoTags.IsSOS[i], Accuracy = geoTags.Accuracy[i], Speed = geoTags.Spd != null?geoTags.Spd[i] != null ? geoTags.Spd[i].ToString() : "0":"0" }); } return(session); }
/// <summary> /// </summary> /// <param name="profileID"></param> /// <param name="lastUpdateTime"></param> /// <returns></returns> public async Task <GeoTags> GetUserLocationArray(string profileID, string lastUpdateTime) { long ProfileID = Convert.ToInt64(profileID); long LastUpdateTime = Convert.ToInt64(lastUpdateTime); GeoTags result = null; ProfileLite returnList = await GetUserLocation(profileID, lastUpdateTime); // LiveLocationData if (returnList != null && returnList.LastLocs != null && returnList.LastLocs.Count > 0) { int cnt = returnList.LastLocs.Count; var isSOSArr = new bool[cnt]; var latArr = new string[cnt]; var longArr = new string[cnt]; var timeArr = new long[cnt]; var speedArr = new int[cnt]; var accuracyArr = new double[cnt]; var altArr = new string[cnt]; int i = 0; foreach (GeoTag gt in returnList.LastLocs) { isSOSArr[i] = gt.IsSOS == null ? false : gt.IsSOS.Value; latArr[i] = gt.Lat; longArr[i] = gt.Long; timeArr[i] = gt.TimeStamp; speedArr[i] = gt.Speed; accuracyArr[i] = gt.Accuracy; altArr[i] = gt.Alt; i++; } result = new GeoTags { PID = ProfileID, IsSOS = isSOSArr, Lat = latArr, Long = longArr, TS = timeArr, LocCnt = cnt, Spd = speedArr, Accuracy = accuracyArr, Alt = altArr }; } return(result); }
public async Task <bool> PostMyLocation(GeoTags vGeoTags) { string liveUserID = WebOperationContext.Current.IncomingRequest.Headers["LiveUserID"]; bool isAuthorizedForSelf = await _authService.SelfAccess(liveUserID, vGeoTags.PID); if (isAuthorizedForSelf) { await PostTheLocation(vGeoTags); return(true); } return(false); }
public async Task SwitchOnSOSviaSMS(string ProfileID, string sessionID, string SOS, string ticks, string lat, string lng, string utcTicks) { long profileID = Convert.ToInt64(ProfileID); lat = lat == "-1" ? string.Empty : lat; lng = lng == "-1" ? string.Empty : lng; long outticks; long outUtcTicks; bool isSOS = (SOS == "1") ? true : false; try { if (long.TryParse(ticks, out outticks) && long.TryParse(utcTicks, out outUtcTicks)) { //to check whether current time outUtcTicks is lessthan 4 hours to current utc time var localUtcTime = new DateTime(outUtcTicks); DateTime serverUtcTime = DateTime.UtcNow; TimeSpan ticksDifference = serverUtcTime - localUtcTime; int differenceHours = Convert.ToInt32(ticksDifference.TotalHours); if (!(await _locRepository.IsSosAlreadyOn(profileID, sessionID, outticks)) && (await _memberRepository.IsProfileValidAsync(profileID)) && !(GpsaAccess.IsEntryThereInHistoryTable(profileID.ToString(), sessionID, outticks)) && (outUtcTicks == 0 || differenceHours < 4)) { var geotag = new GeoTags { PID = profileID, Id = sessionID, Alt = new string[] { null }, Lat = new[] { lat }, Long = new[] { lng }, TS = new[] { outticks }, IsSOS = new[] { isSOS }, Accuracy = new double[] { 0 } //Spd = new int[]{0} }; await PostTheLocation(geotag); } } } catch (Exception ex) { Trace.TraceError(string.Format("Error in {0} : {1}", "SwitchOnSOSviaSMS", ex.Message)); throw ex; } }
public override void SaveData(JObject json) { base.SaveData(json); json[@"city"] = City; if (GeoTags != null) { json[@"geotags"] = GeoTags.ToJObject(); } else { json.Remove(@"geotags"); } json[@"length"] = SpecsLength; json[@"width"] = SpecsWidth; json[@"pitboxes"] = SpecsPitboxes; }
public void GeoUpdates_PostMyLocationUnitTest() { try { GeoTags geoTag = new GeoTags { Id = "3a9bbae1-f0ef-4658-a3f8-14546be6fa0c", PID = 6, Lat = new string[] { "17.435943700000000000", "17.435943700000000000", "17.435943700000000000", "17.435943700000000000" }, Long = new string[] { "79.121673099999980000", "79.121673099999980000", "79.121673099999980000", "79.121673099999980000" }, TS = new long[] { DateTime.Now.AddMilliseconds(1).Ticks, DateTime.Now.AddMilliseconds(2).Ticks, DateTime.Now.AddMilliseconds(3).Ticks, DateTime.Now.AddMilliseconds(4).Ticks }, IsSOS = new bool[] { true, true, true, true }, LocCnt = 4, Alt = new string[] { null, null, null, null }, Spd = new int[] { 0, 10, 20, 30 } }; HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(BaseUrl + "PostMyLocation"); webrequest.Method = "POST"; string postData = JsonConvert.SerializeObject(geoTag); byte[] byteArray = Encoding.UTF8.GetBytes(postData); Stream dataStream = webrequest.GetRequestStream(); // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); webrequest.ContentType = "application/json"; webrequest.Headers.Add("AuthID", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6IjEifQ.eyJ2ZXIiOjEsImlzcyI6InVybjp3aW5kb3dzOmxpdmVpZCIsImV4cCI6MTQyNzE5Nzc0OCwidWlkIjoiODY2OTFhYjUwZWEzMWIzY2JhODIxNTRkOTUxZDRlNzMiLCJhdWQiOiJndWFyZGlhbnBvcnRhbC1kZXYuY2xvdWRhcHAubmV0IiwidXJuOm1pY3Jvc29mdDphcHB1cmkiOiJhcHBpZDovLzAwMDAwMDAwNDAxMEE2MjciLCJ1cm46bWljcm9zb2Z0OmFwcGlkIjoiMDAwMDAwMDA0MDEwQTYyNyJ9.JFoXACFa1JnZatb1Nao2piXZwTTu4DRNPsd5Gu8yY2I"); var response = webrequest.GetResponse() as HttpWebResponse; Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); } catch (Exception ex) { } }