Example #1
0
        static void Main(string[] args)
        {
            bool preview = true;

            Console.Write("(P)review or (S)ync: ");
            var c = Console.ReadKey();

            if (c.KeyChar == 'p')
            {
                preview = true;
            }
            else
            {
                preview = false;
            }

            Console.WriteLine();

            while (true)
            {
                SyncConfiguration.RevertConfigurationChanges();

                SyncManager sync = new SyncManager(@"E:\SyncTest");

                sync.SyncProgress += new EventHandler <SyncProgressEventArgs>(sync_SyncProgress);
                sync.ItemProgress += new EventHandler <ItemProgressEventArgs>(sync_ItemProgress);
                sync.ItemConflict += new EventHandler <ConflictEventArgs>(sync_ItemConflict);

                sync.Synchronize(preview);

                var results = sync.SyncResults;

                Console.WriteLine();
                Console.WriteLine();

                if (results != null)
                {
                    foreach (var item in results)
                    {
                        Console.WriteLine("{0}\t{1}\t{2}\t{3}", item.Name, item.Type, item.Status, item.LastModified);
                    }
                }

                Console.Write("(P)review or (S)ync: ");
                c = Console.ReadKey();
                if (c.KeyChar == 'p')
                {
                    preview = true;
                }
                else
                {
                    preview = false;
                }

                Console.WriteLine();
            }
        }
        private static SyncConfiguration GetConfiguration()
        {
            SyncConfiguration.RevertConfigurationChanges();
            var configPair = SyncConfiguration.AllConfigurations.FirstOrDefault();

            if (configPair.Value == null)
            {
                throw new Exception("No Configuration found for sharepoint sync process.");
            }
            var config = configPair.Value;

            return(config);
        }