/// <summary> /// Load free busy information from the public folder /// </summary> /// <param name="exchangeServerUrl">The exchange server to use</param> /// <param name="users">The set of users to get free busy info for</param> /// <param name="window">The DateTime range to get free busy info for</param> /// <returns>A set of FreeBusy information for each user</returns> public Dictionary <ExchangeUser, FreeBusy> LoadFreeBusy( string exchangeServerUrl, ExchangeUserDict users, DateTimeRange window) { DateTimeRange roundedWindow = DateUtil.RoundRangeToInterval(window, kFreeBusyInterval); string url = FreeBusyUrl.GenerateFreeBusyLookupUrl(exchangeServerUrl, users, roundedWindow, kFreeBusyInterval); Stream response = IssueRequest(url, Method.GET, string.Empty); Dictionary <ExchangeUser, FreeBusy> result = null; try { result = ParseRasterFreeBusyResponse(users, roundedWindow.Start, response); } finally { response.Close(); } return(result); }
/// <summary> /// Sync a users free busy information between Google Calendar and the /// SchedulePlus Public Folder store /// </summary> /// <param name="user">The user to synchronize</param> /// <param name="googleAppsFeed">The Google Calendar events for the user</param> /// <param name="exchangeGateway">The Exchange Gateway to use</param> /// <param name="window">The DateTimeRange to synchronize for</param> public void SyncUser( ExchangeUser user, EventFeed googleAppsFeed, ExchangeService exchangeGateway, DateTimeRange window) { if (_log.IsInfoEnabled) { _log.InfoFormat("Creating F/B message. [User={0}]", user.Email); _log.DebugFormat("The feed time zone is {0}", googleAppsFeed.TimeZone.Value); } string userFreeBusyUrl = FreeBusyUrl.GenerateUrlFromDN(_exchangeServerUrl, user.LegacyExchangeDN); List <string> busyMonthValues = new List <string>(); List <string> busyBase64Data = new List <string>(); List <string> tentativeMonthValues = new List <string>(); List <string> tentativeBase64Data = new List <string>(); ConvertEventsToFreeBusy(user, googleAppsFeed.Entries, window, busyMonthValues, busyBase64Data, tentativeMonthValues, tentativeBase64Data); string startDate = FreeBusyConverter.ConvertToSysTime(window.Start).ToString(); string endDate = FreeBusyConverter.ConvertToSysTime(window.End).ToString(); exchangeGateway.FreeBusy.CreateFreeBusyMessage(userFreeBusyUrl, user.FreeBusyCommonName, busyMonthValues, busyBase64Data, tentativeMonthValues, tentativeBase64Data, startDate, endDate); if (_log.IsInfoEnabled) { _log.Info("Free/Busy message with the right properties created successfully."); } }
public static void WriteFreeBusyMessage(string commonName) { ExchangeService gw = new ExchangeService( ConfigCache.ExchangeFreeBusyServerUrl, ConfigCache.ExchangeUserLogin, ConfigCache.ExchangeUserPassword); SchedulePlusFreeBusyWriter writer = new SchedulePlusFreeBusyWriter(); ExchangeUserDict users = QueryFreeBusy(commonName); if (users.Count < 1) { string msg = string.Format("User {0} not found", commonName); throw new Exception(msg); } if (users.Count > 1) { string msg = string.Format("More than one user matches {0}", commonName); throw new Exception(msg); } string userFreeBusyUrl = FreeBusyUrl.GenerateUrlFromDN( ConfigCache.ExchangeFreeBusyServerUrl, users[commonName].LegacyExchangeDN); List <string> emtpyList = new List <string>(); string nowMinus30Days = FreeBusyConverter.ConvertToSysTime(DateUtil.NowUtc.AddDays(-30)).ToString(); string nowPlus60Days = FreeBusyConverter.ConvertToSysTime(DateUtil.NowUtc.AddDays(60)).ToString(); gw.FreeBusy.CreateFreeBusyMessage(userFreeBusyUrl, commonName, emtpyList, emtpyList, emtpyList, emtpyList, nowMinus30Days, nowPlus60Days); }