public static EventFeed QueryGCalFreeBusy(
            string gcalUserEmail)
        {
            IConnectionThrottle throttle = new FakeThrottle();
            GCalGateway gw = new GCalGateway(ConfigCache.GoogleAppsLogin,
                                             ConfigCache.GoogleAppsPassword,
                                             ConfigCache.GoogleAppsDomain,
                                             throttle);

            DateTime now = DateTime.Now;
            DateTime start = now.AddDays(-7);
            DateTime end = now.AddDays(+7);
            DateTimeRange range = new DateTimeRange(start, end);

            EventFeed feed = gw.QueryGCal(gcalUserEmail,
                                          GCalVisibility.Private,
                                          GCalProjection.FreeBusy,
                                          DateTime.MinValue,
                                          range);
            return feed;
        }
Exemple #2
0
        /// <summary>
        /// Run the sync process from Google Calendar to Exchange
        /// </summary>
        /// <param name="threadCount">Number of threads to use to sync</param>
        public void RunSyncProcess(int threadCount)
        {
            log.Info("Exchange synchronization process started.");

            using (BlockTimer bt = new BlockTimer("RunSyncProcess"))
            {
                gcalGateway =
                    new GCalGateway(googleAppsLogin, googleAppsPassword, googleAppsDomain, null);
                exchangeGateway =
                    new ExchangeService(exchangeServer, networkLogin, networkPassword);

                ExchangeUserDict users;

                using (BlockTimer loadUserTimer = new BlockTimer("LoadUserList"))
                {
                    users = QueryExchangeForValidUsers();
                }

                exchangeUsers = new List <ExchangeUser>();

                freeBusyWriter = FreeBusyWriterFactory.GetWriter(exchangeUsers);

                foreach (ExchangeUser user in users.Values)
                {
                    exchangeUsers.Add(user);
                }

                if (exchangeUsers.Count == 0)
                {
                    log.Warn("No eligible users found for synchronization.  Aborting sync process.");
                    return;
                }

                if (threadCount < 1)
                {
                    threadCount = 1;
                }

                modifiedDateUtil = new ModifiedDateUtil(ConfigCache.ServiceModifiedXmlFileName);
                modifiedDateUtil.LoadModifiedTimes();

                if (threadCount == 1)
                {
                    SyncUsers();
                }
                else
                {
                    StartSyncUserThreads(threadCount);
                }

                modifiedDateUtil.PersistModifiedTimes();

                gcalGateway      = null;
                exchangeGateway  = null;
                freeBusyWriter   = null;
                modifiedDateUtil = null;
                exchangeUsers    = null;

                System.GC.Collect();
                log.DebugFormat("Memory after sync: {0}", System.GC.GetTotalMemory(false));
            }
        }
        /// <summary>
        /// Run the sync process from Google Calendar to Exchange
        /// </summary>
        /// <param name="threadCount">Number of threads to use to sync</param>
        public void RunSyncProcess( int threadCount )
        {
            log.Info( "Exchange synchronization process started." );

            using ( BlockTimer bt = new BlockTimer( "RunSyncProcess" ) )
            {
                gcalGateway =
                    new GCalGateway(googleAppsLogin, googleAppsPassword, googleAppsDomain, null);
                exchangeGateway =
                    new ExchangeService(exchangeServer, networkLogin, networkPassword);

                ExchangeUserDict users;

                using ( BlockTimer loadUserTimer = new BlockTimer( "LoadUserList" ) )
                {
                    users = QueryExchangeForValidUsers();
                }

                exchangeUsers = new List<ExchangeUser>();

                freeBusyWriter = FreeBusyWriterFactory.GetWriter( exchangeUsers );

                foreach ( ExchangeUser user in users.Values )
                {
                    exchangeUsers.Add( user );
                }

                if ( exchangeUsers.Count == 0 )
                {
                    log.Warn( "No eligible users found for synchronization.  Aborting sync process." );
                    return;
                }

                if ( threadCount < 1 )
                    threadCount = 1;

                modifiedDateUtil = new ModifiedDateUtil( ConfigCache.ServiceModifiedXmlFileName );
                modifiedDateUtil.LoadModifiedTimes();

                if ( threadCount == 1 )
                {
                    SyncUsers();
                }
                else
                {
                    StartSyncUserThreads( threadCount );
                }

                modifiedDateUtil.PersistModifiedTimes();

                gcalGateway = null;
                exchangeGateway = null;
                freeBusyWriter = null;
                modifiedDateUtil = null;
                exchangeUsers = null;

                System.GC.Collect();
                log.DebugFormat("Memory after sync: {0}", System.GC.GetTotalMemory(false));
            }
        }