private TResult ExchangeServiceExecuteWithImpersonationCheck <TResult>(string roomAddress, Func <ExchangeService, TResult> action) { var targetUser = _impersonateForAllCalls ? roomAddress : string.Empty; return(_exchangeServiceManager.Execute(targetUser, action)); }
/// <summary> /// Get all room lists defined on the Exchange server. /// </summary> /// <returns></returns> public IEnumerable <RoomList> GetRoomLists() { return(_simpleTimedCache.GetCachedValue("RoomLists", TimeSpan.FromHours(24), () => Task.FromResult(_exchangeServiceManager.Execute(string.Empty, svc => svc.GetRoomLists() .Select(i => new RoomList { Address = i.Address, Name = i.Name }) .ToArray()))).Result); }
public string[] LookupAddresses(string[] emailAddresses) { var phoneNumbers = _exchangeServiceManager.Execute("", svc => { var re = new Regex("[^0-9]"); return(emailAddresses .Select(i => svc.ResolveName(i, ResolveNameSearchLocation.DirectoryOnly, true)) .Select(i => i.SingleOrDefault().ChainIfNotNull(ii => ii.Contact)) .Where(i => i != null && i.PhoneNumbers.Contains(PhoneNumberKey.MobilePhone)) .Select(i => i.PhoneNumbers[PhoneNumberKey.MobilePhone]) .Where(i => i != null) .Select(i => re.Replace(i, "")) .Select(i => i.Length == 9 ? "1" + i : i) .ToArray()); }); log.DebugFormat("Looked up {0} into {1}", string.Join(", ", emailAddresses), string.Join(", ", phoneNumbers)); return(phoneNumbers); }