/// <summary> /// Loop for the worker thread to scan the sources for changes. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The event arguments for this thread. /// </param> private void Worker_DoWork(object sender, DoWorkEventArgs e) { do { var engine = new SyncEngine(); var listOfSources = Tools.LoadFromFile <List <SyncDescription> >("sources.xml"); if (listOfSources == null) { listOfSources = new List <SyncDescription> { new SyncDescription { SourceConnector = "Sem.Sync.Test.DataGenerator.Contacts", SourceStorePath = "somepath", SourceCredentials = new Credentials { LogOnDomain = "the domain", LogOnUserId = "user name", LogOnPassword = "******" }, BaselineConnector = "Sem.Sync.Test.DataGenerator.Contacts", BaselineStorePath = "somepath", BaselineCredentials = new Credentials { LogOnDomain = "the domain", LogOnUserId = "user name", LogOnPassword = "******" }, } }; Tools.SaveToFile(listOfSources, "sources.xml"); } // pause the thread - we don't need to query the connectors too often. Thread.Sleep(2000); if (this.lastRun.AddMinutes(10) >= DateTime.Now) { continue; } foreach (var syncDescription in listOfSources) { var sourceList = engine.SetupConnector(syncDescription.SourceConnector, syncDescription.SourceCredentials).GetAll (syncDescription.SourceStorePath).ToStdContacts(); var baselineConnector = engine.SetupConnector( syncDescription.BaselineConnector, syncDescription.BaselineCredentials); var baselineList = baselineConnector.GetAll(syncDescription.BaselineStorePath).ToStdContacts(); var contactsToCompare = from s in sourceList join t in baselineList on s.ExternalIdentifier equals t.ExternalIdentifier select new { source = s, Baseline = t }; foreach (var toCompare in contactsToCompare) { this.CompareEntities(toCompare.source, toCompare.Baseline); } baselineConnector.WriteRange(sourceList.ToStdElements(), syncDescription.BaselineStorePath); if (this.DataChanged != null) { this.DataChanged(this, new EventArgs()); } } }while (!this.Abort); }