public static List <string> SyncOutlookToCalDav_CalDavIsEmpty( IEntityRelationDataAccess <string, DateTime, Uri, string> entityRelationDataAccess = null, Action <Options> optionsModifier = null) { var calDavEvents = new List <string>(); ICalDavDataAccess calDavDataAccess = MockRepository.GenerateMock <ICalDavDataAccess>(); calDavDataAccess .Expect(r => r.GetEvents(null)) .IgnoreArguments() .Return(Task.FromResult <IReadOnlyList <EntityIdWithVersion <Uri, string> > > ( new EntityIdWithVersion <Uri, string>[] { })); calDavDataAccess .Expect(r => r.CreateEntity(null)) .IgnoreArguments() .Return(Task.FromResult( EntityIdWithVersion.Create(new Uri("http://bla.com"), "blubb"))) .WhenCalled(a => calDavEvents.Add((string)a.Arguments[0])); ISynchronizer synchronizer = CreateEventSynchronizer( SynchronizationMode.ReplicateOutlookIntoServer, calDavDataAccess, entityRelationDataAccess, optionsModifier); WaitForTask(synchronizer.Synchronize()); return(calDavEvents); }
/// <summary> /// Tracks the <see cref="target" /> for synchronization /// </summary> /// <param name="referencehe reference.</param> /// <remarks>The <see cref="target">reference's</see> synchronize-able child references are also tracked recursively</remarks> /// <exception cref="ArgumentNullException">reference</exception> public void Synchronize(object reference) { if (reference == null) { throw new ArgumentNullException(nameof(reference)); } SourceSynchronizer sourceSynchronizer = _referencePool.GetSyncSource(reference); if (sourceSynchronizer == null) { if (_pendingForSynchronization.Contains(reference)) { return; } Type referenceType = reference.GetType(); if (referenceType.HasElementType) { _typeEncoder.RegisterType(referenceType.GetElementType()); } _typeEncoder.RegisterType(referenceType); ISynchronizer sourceFactory = Settings.Synchronizers.FindSynchronizerByType(referenceType); var referenceId = _referenceIdIncrementer++; _pendingForSynchronization.Add(reference); sourceSynchronizer = sourceFactory.Synchronize(this, referenceId, reference); _pendingForSynchronization.Remove(reference); _referencePool.AddSyncSource(sourceSynchronizer); _pendingTrackedSyncSourceObjects.Add(sourceSynchronizer); } }
public static string SyncOutlookToCalDav_EventsExistsInCalDav(string existingEventData, IEntityRelationDataAccess <string, DateTime, Uri, string> entityRelationDataAccess = null) { string roundTrippedData = null; ICalDavDataAccess calDavDataAccess = MockRepository.GenerateMock <ICalDavDataAccess>(); var entityUri = new Uri("/e1", UriKind.Relative); calDavDataAccess .Expect(r => r.GetEvents(null)) .IgnoreArguments() .Return(Task.FromResult <IReadOnlyList <EntityIdWithVersion <Uri, string> > > ( new[] { EntityIdWithVersion.Create(entityUri, "v1") })); calDavDataAccess .Expect(r => r.GetEntities(Arg <ICollection <Uri> > .List.Equal(new[] { entityUri }))) .Return(Task.FromResult <IReadOnlyList <EntityWithVersion <Uri, string> > > ( new[] { EntityWithVersion.Create(entityUri, existingEventData) })); calDavDataAccess .Expect(r => r.UpdateEntity(new Uri("http://bla.com"), null)) .IgnoreArguments() .Return(Task.FromResult <EntityIdWithVersion <Uri, string> > ( EntityIdWithVersion.Create(new Uri("http://bla.com"), "blubb"))) .WhenCalled(a => { roundTrippedData = (string)a.Arguments[1]; }); ISynchronizer synchronizer = OutlookTestContext.CreateEventSynchronizer( SynchronizationMode.ReplicateOutlookIntoServer, calDavDataAccess, entityRelationDataAccess); WaitForTask(synchronizer.Synchronize()); return(roundTrippedData); }
public async Task RunNoThrowAndReschedule() { if (_inactive) { return; } try { using (AutomaticStopwatch.StartInfo(s_logger, string.Format("Running synchronization profile '{0}'", _profileName))) { try { await _synchronizer.Synchronize(); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } } } catch (Exception x) { ExceptionHandler.Instance.HandleException(x, s_logger); } finally { _lastRun = DateTime.UtcNow; } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await _synchronizer.Synchronize(stoppingToken); } }
public async Task Synchronize(ISynchronizationLogger logger) { var emailAddressCache = new EmailAddressCache(); emailAddressCache.Items = _emailAddressCacheDataAccess.Load(); using (var subLogger = logger.CreateSubLogger("Contacts")) { await _contactSynchronizer.Synchronize(subLogger, emailAddressCache); } var idsToQuery = emailAddressCache.GetIdsOfEntriesWithEmptyEmailAddress(); if (idsToQuery.Length > 0) { await _loggingCardDavRepositoryDecorator.Get(idsToQuery, NullLoadEntityLogger.Instance, emailAddressCache); } var cacheItems = emailAddressCache.Items; _emailAddressCacheDataAccess.Save(cacheItems); var distListContext = new DistributionListSychronizationContext(cacheItems, _outlookSession); using (var subLogger = logger.CreateSubLogger("DistLists")) { await _distributionListSynchronizer.Synchronize(subLogger, distListContext); } }
private void Synchronize() { try { _synchronizer.Synchronize(); } catch (Exception e) { _logger.Warn(e); } }
protected bool SynchronizeInternal(IInitialSyncStateCreationStrategy<string, int, string, string, int, string> strategy) { _synchronizer = new Synchronizer<string, int, string, string, int, string> ( _synchronizerSetup, strategy, NullTotalProgressFactory.Instance, EqualityComparer<string>.Default, EqualityComparer<string>.Default, MockRepository.GenerateMock<IExceptionLogger>() ); return _synchronizer.Synchronize().Result; }
protected bool SynchronizeInternal(IInitialSyncStateCreationStrategy <string, int, string, string, int, string> strategy) { _synchronizer = new Synchronizer <string, int, string, string, int, string> ( _synchronizerSetup, strategy, NullTotalProgressFactory.Instance, EqualityComparer <string> .Default, EqualityComparer <string> .Default, MockRepository.GenerateMock <IExceptionLogger>() ); return(_synchronizer.Synchronize().Result); }
public async Task Synchronize() { if (synchronizer != null) { SynchronizationResult result = await synchronizer.Synchronize(accounts); if (result.Accounts != null) { accounts = result.Accounts.ToList(); } await Persist(false); } }
public async Task Synchronize(CancellationToken cancellationToken) { try { await _inner.Synchronize(cancellationToken); } catch (OperationCanceledException) { throw; } catch (Exception exception) { _logger.LogError(exception, "Synchronization failed."); throw; } }
public async Task Synchronize(CancellationToken cancellationToken) { try { await _inner.Synchronize(cancellationToken); } catch (OperationCanceledException) { throw; } #pragma warning disable CA1031 // Do not catch general exception types -- required for robust operation catch { } #pragma warning restore CA1031 // Do not catch general exception types }
public async Task Synchronize(CancellationToken cancellationToken) { await _timeHolder.Wait(cancellationToken); var timer = Stopwatch.StartNew(); try { await _inner.Synchronize(cancellationToken); } catch (OperationCanceledException) when(!cancellationToken.IsCancellationRequested) { UpdateInterval(timer.Elapsed); throw; } UpdateInterval(timer.Elapsed); }
public async Task <ProductList> Synchronize(OperatorList operatorList) { string line = ""; _logger.StartMsg("Operators"); int i = 0; foreach (var op in operatorList.operators) { try { string input = op.CanonicalRegionUrlSegment + "/" + op.UrlSegment; ExOzOperatorResponse opDetails = new ExOzOperatorResponse(); string postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(input); if (postResponse != "0") { opDetails = Mapper <ExOzOperatorResponse> .MapFromJson(postResponse); } if (opDetails.Id != -1 && opDetails.Geolocations != null && opDetails.Geolocations[0].Address != null) { opDetails.RegionId = op.RegionId; opDetails.RegionUrlSegment = op.RegionUrlSegment; CommonFunctions.replaceSingleQuotes(opDetails.Name); CommonFunctions.replaceSingleQuotes(opDetails.PublicName); CommonFunctions.replaceSingleQuotes(opDetails.Summary); CommonFunctions.replaceSingleQuotes(opDetails.Tips); CommonFunctions.replaceSingleQuotes(opDetails.Description); CommonFunctions.replaceSingleQuotes(opDetails.Address); //operatorList.operators = new List<ExOzOperatorResponse>(); OperatorList operatorDetails = new OperatorList() { operators = new List <ExOzOperatorResponse>() }; operatorDetails.operators.Add(opDetails); SaveExOzOperatorCommandResult retOperators = new SaveExOzOperatorCommandResult() { OperatorList = new List <ExOzOperator>() }; retOperators = await _commandSender.Send <SaveExOzOperatorCommand, SaveExOzOperatorCommandResult>(new SaveExOzOperatorCommand { OperatorList = operatorDetails.operators, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44795") }); if (opDetails.Products != null) { ProductList productList = new ProductList { Products = new List <ExOzProductResponse>() }; foreach (var prod in opDetails.Products) { prod.CanonicalRegionUrlSegment = opDetails.CanonicalRegionUrlSegment; prod.OperatorUrlSegment = opDetails.UrlSegment; productList.Products.Add(prod); } _logger.StartMsg("Product"); SessionList sessionResponse = await _productSynchronizer.Synchronize(productList); } } i++; line = _logger.Update(i, operatorList.operators.Count, line); } catch (Exception e) { _logger.Log($"Exception: {e.Message}"); continue; } } ////Insert Operators here //try //{ // _logger.FinishMsg(retOperators.OperatorList.Count, "Operators"); // return productList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }
public async Task Synchronize() { await _hubspotSynchronizer.Synchronize(); return; }
public async Task <SessionList> Synchronize(ProductList productList) { string line = ""; int i = 0; foreach (var prod in productList.Products) { ProductList productDetails = new ProductList() { Products = new List <ExOzProductResponse>() }; string input = prod.CanonicalRegionUrlSegment + "/" + prod.OperatorUrlSegment + "/" + prod.UrlSegment; ExOzProductResponse objProduct = new ExOzProductResponse(); string postResponse = HttpWebRequestHelper.ExOz_WebRequestGet(input); if (postResponse != "0") { objProduct = Mapper <ExOzProductResponse> .MapFromJson(postResponse); } objProduct.Name = CommonFunctions.replaceSingleQuotes(objProduct.Name); objProduct.Summary = CommonFunctions.replaceSingleQuotes(objProduct.Summary); objProduct.OperatorPublicName = CommonFunctions.replaceSingleQuotes(objProduct.OperatorPublicName); objProduct.Title = CommonFunctions.replaceSingleQuotes(objProduct.Title); objProduct.Description = CommonFunctions.replaceSingleQuotes(objProduct.Description); objProduct.MoreInfo = CommonFunctions.replaceSingleQuotes(objProduct.MoreInfo); objProduct.Tips = CommonFunctions.replaceSingleQuotes(objProduct.Tips); productDetails.Products.Add(objProduct); SaveExOzProductCommandResult retProducts = new SaveExOzProductCommandResult() { ProductList = new List <Contracts.DataModels.ExOzProduct>() }; retProducts = await _commandSender.Send <SaveExOzProductCommand, SaveExOzProductCommandResult>(new SaveExOzProductCommand { ProductList = productDetails.Products, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44793") }); if (objProduct.ProductSessions != null) { SessionList sessionList = new SessionList() { ProductSessions = new List <ExOzSessionResponse>() }; foreach (var sess in objProduct.ProductSessions) { sess.ProductId = objProduct.Id; sessionList.ProductSessions.Add(sess); } _logger.StartMsg("Sessions"); ProductOptionList productOptionResponse = await _productSessionSynchronizer.Synchronize(sessionList); } i++; line = _logger.Update(i, productList.Products.Count, line); } //Insert Products Here //try //{ // _logger.FinishMsg(retProducts.ProductList.Count, "Products"); // return sessionList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }
public async Task <ProductOptionList> Synchronize(SessionList sessionList) { string line = ""; int i = 0; foreach (var sess in sessionList.ProductSessions) { SessionList sessionDetails = new SessionList() { ProductSessions = new List <ExOzSessionResponse>() }; sessionDetails.ProductSessions.Add(sess); SaveExOzSessionCommandResult retSessions = new SaveExOzSessionCommandResult() { SessionList = new List <ExOzProductSession>() }; retSessions = await _commandSender.Send <SaveExOzSessionCommand, SaveExOzSessionCommandResult>(new SaveExOzSessionCommand { SessionList = sessionDetails.ProductSessions, ModifiedBy = new Guid("C043DDEE-D0B1-48D8-9C3F-309A77F44793") }); if (sess.ProductOptions != null) { ProductOptionList optionList = new ProductOptionList() { ProductOptions = new List <ExOzProductOptionResponse>() }; foreach (var opt in sess.ProductOptions) { opt.SessionId = sess.Id; opt.SessionName = sess.SessionName; optionList.ProductOptions.Add(opt); } _logger.StartMsg("Options"); await _productOptionSynchronizer.Synchronize(optionList); } i++; line = _logger.Update(i, sessionList.ProductSessions.Count, line); } //Insert Sessions Here //try //{ // _logger.FinishMsg(retSessions.SessionList.Count, "Sessions"); // return optionList; //} //catch (Exception e) //{ // _logger.Log($"Exception: {e.Message}"); // throw; //} return(null); }