Exemple #1
0
        /// <summary>
        /// Get a free busy writer for the set of users
        /// </summary>
        /// <param name="users">List of the users to write f/b info for</param>
        /// <returns>A FreeBusyWriter</returns>
        public static IFreeBusyWriter GetWriter(List <ExchangeUser> users)
        {
            IFreeBusyWriter writer = null;

            switch (ConfigCache.FreeBusyWriter.ToUpperInvariant())
            {
            default:
            case "SCHEDULEPLUS":
                writer = new SchedulePlusFreeBusyWriter();
                break;

            case "APPOINTMENT":
                writer = new AppointmentWriter();
                break;
            }

            return(writer);
        }
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));
            }
        }