/// <summary> /// </summary> /// <param name="ProfileID"></param> /// <param name="LastUpdateTime"></param> /// <returns>Returns null if no location detials</returns> public async Task <ProfileLite> GetUserLocation(string profileID, string lastUpdateTime) { string liveUserID = WebOperationContext.Current.IncomingRequest.Headers["LiveUserID"]; long ProfileID = Convert.ToInt64(profileID); long LastUpdateTime = Convert.ToInt64(lastUpdateTime); ProfileLite rMemLite = new ProfileLite(); bool isAuthorizedForSelf = await _authService.SelfAccess(liveUserID, ProfileID); bool isAuthorizedForLocateBuddy = await _authService.LocateBuddyAccess(liveUserID, ProfileID); if (isAuthorizedForSelf || isAuthorizedForLocateBuddy) { var geoLiveLocation = await _locRepository.GetLocationData(ProfileID, LastUpdateTime); if (geoLiveLocation == null && geoLiveLocation.ToList().Count == 0) { ResultsManager.AddResultInfo(rMemLite, ResultTypeEnum.Information, "NOLOCDTL:" + profileID); return(rMemLite); } if (geoLiveLocation != null && geoLiveLocation.ToList().Count > 0) { List <GeoTag> sGeo = geoLiveLocation.ToList().ConvertToGeoTagList(); rMemLite.LastLocs = sGeo; } } else { Utility.ResultsManager.AddResultInfo(rMemLite, ResultTypeEnum.AuthError, "You are not authorized to view locations for this profile"); } return(rMemLite); }
public async Task <ProfileLite> GetLocationDetails(string ProfileID, string GroupID, string LastUpdateDateTicks) { //note: here only location details are returned, no profile and user details var resProfileLite = new ProfileLite(); GeoTagList listLocationData = await GetUserLocations(ProfileID, LastUpdateDateTicks, GroupID); if (listLocationData == null || listLocationData.List == null || listLocationData.List.Count < 1) { resProfileLite.IsSOSOn = false; resProfileLite.IsTrackingOn = false; } else { resProfileLite.ProfileID = Convert.ToInt64(ProfileID); //just passing avaialable info, imp is location details alone GeoTag latest = listLocationData.List[listLocationData.List.Count - 1]; resProfileLite.IsSOSOn = latest.IsSOS.Value; resProfileLite.IsTrackingOn = !latest.IsSOS.Value || !string.IsNullOrEmpty(latest.Lat); resProfileLite.LastLocs = listLocationData.List; ResultsManager.AddResultInfo(resProfileLite, ResultTypeEnum.Success, "Location details filled."); } if (!resProfileLite.IsSOSOn && !resProfileLite.IsTrackingOn) { ResultsManager.AddResultInfo(resProfileLite, ResultTypeEnum.Success, "No Tracking or SOS Details found"); } return(resProfileLite); }
//List of all Marshals associated to Group //gm,profile and user public async Task <MarshalList> GetMarshalList(string groupID) { int GroupID = 0; var marshals = new MarshalList { List = new List <Marshal>() }; try { if (int.TryParse(groupID, out GroupID)) { if (GroupID == 0) { return(null); } List <model.Profile> marshalProfiles = await _GroupRepository.GetLiveMarshalsByGroupID(GroupID); foreach (model.Profile marshalProfile in marshalProfiles) { ProfileLite marshalProfileLite = Caster.MakeProfileLiteOnCombination(marshalProfile, marshalProfile.User); if (marshalProfile.LiveLocations != null && marshalProfile.LiveLocations.ToList().Count > 0) { List <GeoTag> sGeo = marshalProfile.LiveLocations.ToList().ConvertToGeoTagList(); marshalProfileLite.IsSOSOn = sGeo[0].IsSOS.HasValue ? sGeo[0].IsSOS.Value : false; //1 marshalProfileLite.IsTrackingOn = !(sGeo[0].IsSOS.HasValue ? sGeo[0].IsSOS.Value : false) || !string.IsNullOrEmpty(sGeo[0].Lat); marshalProfileLite.LastLocs = sGeo; } List <ProfileLite> locateBuddyProfiles = await _LocationService.GetLocateBuddies(marshalProfileLite.UserID); if (marshalProfileLite != null) { marshals.List.Add(Caster.MakeContractMarshal(marshalProfileLite, locateBuddyProfiles, true)); } else { utility.ResultsManager.AddResultInfo(marshals, ResultTypeEnum.Error, "Invalid IDs"); } } utility.ResultsManager.AddResultInfo(marshals, ResultTypeEnum.Success, "Success"); } else { utility.ResultsManager.AddResultInfo(marshals, ResultTypeEnum.Error, "Invalid Group ID"); } } catch (Exception e) { utility.ResultsManager.AddResultInfo(marshals, ResultTypeEnum.Exception, "Failed-" + e.Message); } return(marshals); }
/// <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); }