internal static bool IsLocationInScope(IAaaUser user, string searchLocationID) { if (IsUserInternal(user)) return true; //location xx is hardcoded for getting min interval if (string.Compare(user.LocationAccountId, searchLocationID, true) == 0 || searchLocationID == "xx") return true; if (string.IsNullOrEmpty(user.LocationAccountId) || string.IsNullOrEmpty(searchLocationID)) { _Logger.LogWarn("STOpsConsole-IsLocationInScope - empty location user {0}, [User-{1}/Search-{2}]", user.UUID, user.LocationAccountId,searchLocationID); return false; } using (var uisCilent = new UserInfoServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { var locs = new List<LocationInfoRequest>(); locs.Add(new LocationInfoRequest { LocationAccountId = searchLocationID }); locs.Add(new LocationInfoRequest { LocationAccountId = user.LocationAccountId }); var locResp = uisCilent.GetLocations(locs); var userULT = locResp.Where(x => x.LocationId == user.LocationAccountId).Select(y => y.UltimateParentId).SingleOrDefault(); var srchULT = locResp.Where(x => x.LocationId == searchLocationID).Select(y => y.UltimateParentId).SingleOrDefault(); if (string.Compare(userULT, srchULT, true) == 0) { _Logger.LogInfo("STOpsConsole-IsLocationInScope - ULT location matched for user {0}, [User-{1}:{3}/Search-{2}:{4}]", user.UUID, user.LocationAccountId, searchLocationID,userULT,srchULT); return true; } _Logger.LogInfo("STOpsConsole-IsLocationInScope - ULT location not matched for user {0}, [User-{1}:{3}/Search-{2}:{4}]", user.UUID, user.LocationAccountId, searchLocationID, userULT, srchULT); } return false; }