コード例 #1
0
        /// <summary>
        /// Config Datei wird eingelesen und für für jedes Postfach werden die Jahrestage und Geburtstage überprüft und syncroniesiert.
        /// Danach werden die Kontakte Syncronisiert.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Config config = ReadConfig();

            ExchangeSync.writeLog("##################################################################");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            foreach (var m in config.mailboxes)
            {
                ExchangeSync.writeLog("---------- " + m.smtpAdresse.ToUpper() + " ----------");
                ExchangeService service = ExchangeConnect(config.username, config.password, config.domain, m.smtpAdresse, config.exUri);

                if (m.birthday || m.anniversary)
                {
                    ExchangeSync.writeLog("---------- SyncRun Start - Appointment ----------");
                    Stopwatch sWatch = new Stopwatch();
                    sWatch.Start();

                    var BASync = new AppointmentSync(service, m.smtpAdresse);

                    // Aktiviren wenn alle Termine gelöscht werden sollen
                    //BASync.runDelete();

                    if (m.birthday)
                    {
                        BASync.runBirthdaySync();
                    }
                    if (m.anniversary)
                    {
                        BASync.runAnniversarySync();
                    }

                    sWatch.Stop();
                    ExchangeSync.writeLog("---------- SyncRun End - " + stopWatch.Elapsed + " ----------");
                }

                if (m.folder.Count > 0 && m.folder[0] != "")
                {
                    foreach (var f in m.folder)
                    {
                        var SyncRun = new ExchangeSync(service, m.smtpAdresse, f);
                        SyncRun.writePublicIdInExProp();
                        bool changes = SyncRun.Sync();

                        if (changes)
                        {
                            MatchingList.Create(service, m.smtpAdresse, f);
                            ExchangeSync.writeLog("Matching List created: " + m.smtpAdresse + " - " + f);
                        }
                    }
                }
            }

            stopWatch.Stop();
            ExchangeSync.writeLog("Complete Sync - Time: " + stopWatch.Elapsed);
        }