Esempio n. 1
0
        /// <summary>
        /// Creates the contact by email address
        /// </summary>
        /// <param name="contact">the contact</param>
        /// <param name="syncMode">the sync mode</param>
        /// <param name="src">the src</param>
        /// <param name="subscriptionPage">the subscription page</param>
        /// <param name="doi">the doi</param>
        /// <param name="doiPlus">the doi plus</param>
        /// <param name="doiMailingKey">the doi mailing key</param>
        public void CreateContact(Contact contact, SynchronizationMode syncMode, string src = null, string subscriptionPage = null, bool doi = false, bool doiPlus = false, string doiMailingKey = null)
        {
            if (contact == null)
            {
                throw new MaileonClientException("contact cannot be null", null);
            }
            if (contact.Email == null)
            {
                throw new MaileonClientException("email address cannot be null", null);
            }
            if (contact.Email != null && contact.ExternalId != null)
            {
                throw new MaileonClientException("ExternalId cannot be set when using CreateContact", null);
            }

            QueryParameters parameters = new QueryParameters();

            parameters.Add("permission", (int)contact.Permission);
            parameters.Add("sync_mode", (int)syncMode);
            parameters.Add("src", src);
            parameters.Add("subscription_page", subscriptionPage);
            parameters.Add("doi", doi);
            parameters.Add("doiplus", doiPlus);
            parameters.Add("doimailing", doiMailingKey);

            //this method doesn't accept permission in the contact body
            contact.PermissionSpecified         = false;
            contact.SerializeAnonymousSpecified = false;

            string xml = SerializationUtils <Contact> .ToXmlString(contact);

            Post("contacts/" + HttpUtility.UrlEncode(contact.Email), parameters, xml);
        }
 /// <summary>
 /// Sets the synchronization mode.
 /// </summary>
 /// <param name="synchronizationMode">The synchronization mode.</param>
 /// <param name="checkParentAnimator">if set to <c>true</c> [check parent animator].</param>
 /// <exception cref="System.InvalidOperationException">Property cannot be set while ParentAnimator is set to anything other than null.</exception>
 private void SetSynchronizationMode(SynchronizationMode synchronizationMode, bool checkParentAnimator)
 {
     if (this._syncMode == synchronizationMode)
     {
         return;
     }
     if (synchronizationMode == SynchronizationMode.ResetToCurrent)
     {
         if (!this.DesignMode)
         {
             return;
         }
         this.ResetValues();
     }
     else
     {
         if (this._parentAnimator != null && checkParentAnimator && !this._isInitializing)
         {
             throw new InvalidOperationException("Property cannot be set while ParentAnimator is set to anything other than null.");
         }
         this._syncMode = synchronizationMode;
         this.SynchronizeToSource();
         foreach (AnimatorBase childAnimator in this._childAnimators)
         {
             childAnimator.SetSynchronizationMode(synchronizationMode, false);
         }
         this.OnSynchronizationModeChanged(EventArgs.Empty);
     }
 }
        public static IInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> Create(
            IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> syncStateFactory,
            EntitySyncStateEnvironment <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> environment,
            SynchronizationMode synchronizationMode,
            ConflictResolution conflictResolution,
            Func <
                EntitySyncStateEnvironment <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity>,
                ConflictInitialSyncStateCreationStrategyAutomatic <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> > automaticConflictResolutionStrategyFactory)
        {
            switch (synchronizationMode)
            {
            case SynchronizationMode.MergeInBothDirections:
                var conflictResolutionStrategy = Create(syncStateFactory, environment, conflictResolution, automaticConflictResolutionStrategyFactory);
                return(new TwoWayInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (
                           syncStateFactory,
                           conflictResolutionStrategy
                           ));

            case SynchronizationMode.ReplicateOutlookIntoServer:
            case SynchronizationMode.MergeOutlookIntoServer:
                return(new OneWayInitialSyncStateCreationStrategy_AToB <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (
                           syncStateFactory,
                           synchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
                           ));

            case SynchronizationMode.ReplicateServerIntoOutlook:
            case SynchronizationMode.MergeServerIntoOutlook:
                return(new OneWayInitialSyncStateCreationStrategy_BToA <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (
                           syncStateFactory,
                           synchronizationMode == SynchronizationMode.ReplicateServerIntoOutlook ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
                           ));
            }
            throw new NotImplementedException();
        }
Esempio n. 4
0
        public void FixSynchronizationMode(OptionsModel options, TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        $"The specified Url is a read-only calendar. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'.",
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        $"The specified Url is a read-only addressbook. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'.",
                        OptionTasks.ConnectionTestCaption);
                }
            }
        }
 private IMemoizationStore CreateSQLiteMemoizationStore(AbsolutePath path, SynchronizationMode syncMode = SQLiteMemoizationStore.DefaultSyncMode)
 {
     return(new TestSQLiteMemoizationStore(Logger, _clock, new SQLiteMemoizationStoreConfiguration(path)
     {
         MaxRowCount = MaxRowCount, SyncMode = syncMode, JournalMode = JournalMode.OFF
     }));
 }
Esempio n. 6
0
        public void FixSynchronizationMode(TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(_syncSettingsControl.SynchronizationMode))
                {
                    _syncSettingsControl.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        string.Format(
                            "The specified Url is a read-only calendar. Synchronization mode set to '{0}'.",
                            _syncSettingsControl.AvailableSynchronizationModes.Single(m => m.Value == readOnlyDefaultMode).Name),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(_syncSettingsControl.SynchronizationMode))
                {
                    _syncSettingsControl.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        string.Format(
                            "The specified Url is a read-only addressbook. Synchronization mode set to '{0}'.",
                            _syncSettingsControl.AvailableSynchronizationModes.Single(m => m.Value == readOnlyDefaultMode).Name),
                        OptionTasks.ConnectionTestCaption);
                }
            }
        }
 public static IInitialSyncStateCreationStrategy<string, DateTime, ContactItemWrapper, Uri, string, vCard> Create (IEntitySyncStateFactory<string, DateTime, ContactItemWrapper, Uri, string, vCard> syncStateFactory, EntitySyncStateEnvironment<string, DateTime, ContactItemWrapper, Uri, string, vCard> environment, SynchronizationMode synchronizationMode, ConflictResolution conflictResolution)
 {
   switch (synchronizationMode)
   {
     case SynchronizationMode.MergeInBothDirections:
       var conflictResolutionStrategy = Create (syncStateFactory, environment, conflictResolution);
       return new TwoWayInitialSyncStateCreationStrategy<string, DateTime, ContactItemWrapper, Uri, string, vCard> (
           syncStateFactory,
           conflictResolutionStrategy
           );
     case SynchronizationMode.ReplicateOutlookIntoServer:
     case SynchronizationMode.MergeOutlookIntoServer:
       return new OneWayInitialSyncStateCreationStrategy_AToB<string, DateTime, ContactItemWrapper, Uri, string, vCard> (
           syncStateFactory,
           synchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
           );
     case SynchronizationMode.ReplicateServerIntoOutlook:
     case SynchronizationMode.MergeServerIntoOutlook:
       return new OneWayInitialSyncStateCreationStrategy_BToA<string, DateTime, ContactItemWrapper, Uri, string, vCard> (
           syncStateFactory,
           synchronizationMode == SynchronizationMode.ReplicateServerIntoOutlook ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
           );
   }
   throw new NotImplementedException();
 }
Esempio n. 8
0
        public void SynchronizeDirectories(SessionOptions options,
                                           string remoteFolder,
                                           string localFolder,
                                           bool removeFiles         = false,
                                           SynchronizationMode mode = SynchronizationMode.Remote,
                                           bool mirror = false,
                                           SynchronizationCriteria criteria = SynchronizationCriteria.Time,
                                           TransferOptions transferOptions  = null)
        {
            options.AddRawSettings("LocalDirectory", _context.Environment.WorkingDirectory.FullPath);

            using (var session = new Session())
            {
                session.FileTransferred += OnFileTransferred;
                session.Open(options);
                if (!session.FileExists(remoteFolder))
                {
                    session.CreateDirectory(remoteFolder);
                }
                var result = session.SynchronizeDirectories(mode, localFolder, remoteFolder, removeFiles, mirror, criteria, transferOptions);
                result.Check();

                Logger.Log($"{localFolder} and {remoteFolder} were synchronized");
            }
        }
        public static IndexDifferences FindDifferences(
            IFileSystem fileSystem,
            IEnumerable<LucenePackage> indexedPackages,
            CancellationToken cancellationToken,
            Action<SynchronizationState> setState,
            SynchronizationMode mode)
        {
            setState(SynchronizationState.ScanningFiles);

            var fileSystemPackages = fileSystem.GetFiles(string.Empty, "*" + Constants.PackageExtension, true)
                                               .WithCancellation(cancellationToken)
                                               .Where(file => !fileSystem.IsTempFile(file))
                                               .ToArray();

            setState(SynchronizationState.ScanningIndex);

            var indexedPackagesByPath = indexedPackages
                                            .WithCancellation(cancellationToken)
                                            .ToDictionary(pkg => pkg.Path, StringComparer.InvariantCultureIgnoreCase);

            setState(SynchronizationState.Comparing);

            var calc = new IndexDifferenceCalculator(fileSystem, fileSystemPackages, indexedPackagesByPath);

            return calc.Calculate(mode);
        }
Esempio n. 10
0
        public void FixSynchronizationMode(TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.CalendarProperties.HasFlag(CalendarProperties.IsWriteable) &&
                    SelectedModeRequiresWriteableServerResource)
                {
                    _synchronizationModeComboBox.SelectedValue = readOnlyDefaultMode;
                    MessageBox.Show(
                        string.Format(
                            "The specified Url is a read-only calendar. Synchronization mode set to '{0}'.",
                            _availableSynchronizationModes.Single(m => m.Value == readOnlyDefaultMode).Name),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AddressBookProperties.HasFlag(AddressBookProperties.IsWriteable) &&
                    SelectedModeRequiresWriteableServerResource)
                {
                    _synchronizationModeComboBox.SelectedValue = readOnlyDefaultMode;
                    MessageBox.Show(
                        string.Format(
                            "The specified Url is a read-only addressbook. Synchronization mode set to '{0}'.",
                            _availableSynchronizationModes.Single(m => m.Value == readOnlyDefaultMode).Name),
                        OptionTasks.ConnectionTestCaption);
                }
            }
        }
Esempio n. 11
0
        private void SetSynchronizationMode(SynchronizationMode synchronizationMode, bool checkParentAnimator)
        {
            if (_syncMode == synchronizationMode)
            {
                return;
            }

            if (synchronizationMode == SynchronizationMode.ResetToCurrent)
            {
                if (!Program.IsDesign)
                {
                    return;
                }

                ResetValues();

                return;
            }

            if (_parentAnimator != null && checkParentAnimator && !_isInitializing)
            {
                throw new InvalidOperationException(SET_PROP_WITH_PARENT_ANIMATOR_ERROR_MESSAGE);
            }

            _syncMode = synchronizationMode;
            SynchronizeToSource();

            foreach (AnimatorBase childAnimator in _childAnimators)
            {
                childAnimator.SetSynchronizationMode(synchronizationMode, false);
            }

            OnSynchronizationModeChanged(EventArgs.Empty);
        }
        public static IndexDifferences FindDifferences(
            IFileSystem fileSystem,
            IEnumerable <LucenePackage> indexedPackages,
            CancellationToken cancellationToken,
            Action <SynchronizationState> setState,
            SynchronizationMode mode)
        {
            setState(SynchronizationState.ScanningFiles);

            var fileSystemPackages = fileSystem.GetFiles(string.Empty, "*" + Constants.PackageExtension, true)
                                     .WithCancellation(cancellationToken)
                                     .Where(file => !fileSystem.IsTempFile(file))
                                     .ToArray();

            setState(SynchronizationState.ScanningIndex);

            var indexedPackagesByPath = indexedPackages
                                        .WithCancellation(cancellationToken)
                                        .ToDictionary(pkg => pkg.Path, StringComparer.InvariantCultureIgnoreCase);

            setState(SynchronizationState.Comparing);

            var calc = new IndexDifferenceCalculator(fileSystem, fileSystemPackages, indexedPackagesByPath);

            return(calc.Calculate(mode));
        }
Esempio n. 13
0
        public static IOutlookSynchronizer CreateEventSynchronizer(
            SynchronizationMode mode,
            ICalDavDataAccess calDavDataAccess,
            IEntityRelationDataAccess <string, DateTime, WebResourceName, string> entityRelationDataAccess = null,
            Action <Options> optionsModifier = null)
        {
            var options = new Options()
            {
                ConflictResolution             = ConflictResolution.Automatic,
                EmailAddress                   = "*****@*****.**",
                IgnoreSynchronizationTimeRange = true,
                OutlookFolderEntryId           = s_outlookFolderEntryId,
                OutlookFolderStoreId           = s_outlookFolderStoreId,
                SynchronizationMode            = mode,
                CalenderUrl = "http://invalidurl.net"
            };

            if (optionsModifier != null)
            {
                optionsModifier(options);
            }

            return(s_synchronizerFactory.CreateEventSynchronizer(
                       options,
                       calDavDataAccess,
                       entityRelationDataAccess ?? MockRepository.GenerateStub <IEntityRelationDataAccess <string, DateTime, WebResourceName, string> >()));
        }
Esempio n. 14
0
        /// <summary>
        /// Used to keep two ObservableCollections in sync.
        /// </summary>
        /// <param name="source">The source collection.</param>
        /// <param name="target">The target collection.</param>
        /// <param name="sourceCreator">Function to create a source type.</param>
        /// <param name="targetCreator">Function to create a target type.</param>
        /// <param name="syncMode">The synchronization mode. (Defaults to TwoWay)</param>
        public CollectionSynchronizer(
            ObservableCollection <TSource> source,
            ObservableCollection <TTarget> target,
            Func <TTarget, TSource> sourceCreator,
            Func <TSource, TTarget> targetCreator,
            SynchronizationMode syncMode = SynchronizationMode.TwoWay)
        {
            ThrowOnNull(source, "source");
            ThrowOnNull(target, "target");
            ThrowOnNull(sourceCreator, "sourceCreator");
            ThrowOnNull(targetCreator, "targetCreator");

            _sourceCreator = sourceCreator;
            _targetCreator = targetCreator;

            Source   = source;
            Target   = target;
            SyncMode = syncMode;

            if (SyncMode == SynchronizationMode.OneWayToTarget ||
                SyncMode == SynchronizationMode.TwoWay)
            {
                Source.CollectionChanged += Source_CollectionChanged;
            }

            if (SyncMode == SynchronizationMode.OneWayToSource ||
                SyncMode == SynchronizationMode.TwoWay)
            {
                Target.CollectionChanged += Target_CollectionChanged;
            }
        }
    public static IOutlookSynchronizer CreateEventSynchronizer (
        SynchronizationMode mode,
        ICalDavDataAccess calDavDataAccess,
        IEntityRelationDataAccess<string, DateTime, Uri, string> entityRelationDataAccess = null,
        Action<Options> optionsModifier = null)
    {
      var options = new Options()
                    {
                        ConflictResolution = ConflictResolution.Automatic,
                        EmailAddress = "*****@*****.**",
                        IgnoreSynchronizationTimeRange = true,
                        OutlookFolderEntryId = s_outlookFolderEntryId,
                        OutlookFolderStoreId = s_outlookFolderStoreId,
                        SynchronizationMode = mode,
                        CalenderUrl = "http://invalidurl.net"
                    };

      if (optionsModifier != null)
        optionsModifier (options);

      return s_synchronizerFactory.CreateEventSynchronizer (
          options,
          calDavDataAccess,
          entityRelationDataAccess ?? MockRepository.GenerateStub<IEntityRelationDataAccess<string, DateTime, Uri, string>>());
    }
Esempio n. 16
0
        protected override async void OnAfterSynchronizationFinished(SynchronizationMode mode, bool AutoSync)
        {
            // Handle the initial sync
            if (mode == SynchronizationMode.Initial)
            {
                // Clear out current MAC ID config
                SettingsDataService.ClearCurrentMobileConfigurationID();

                // Check count of MACs
                var configurations = await _mobileAppConfigDataService.GetMobileAppConfigs();

                if (configurations.Count > 1)
                {
                    // Pop the control open to select an appropriate MAC
                    ControlBarViewModel.IsSelectConfigurationPopupOpen = true;
                }
                else  // Auto set
                {
                    // Auto set the only Mac available
                    await SettingsDataService.SetCurrentMobileConfigurationID(configurations[0].Id);
                }
            }
            else  // If Full or Delta sync options
            {
                if (!AutoSync)
                {
                    await _dialogService.ShowMessage("Synchronization completed successfully", "Synchronization completed");
                }
            }
            Task.Factory.StartNew(AttachmentsFolder.Instance.DeleteOldVersionsWithContent);
            Task.Factory.StartNew(VersionDataFolder.Instance.DeleteOldVersionsWithContent);
        }
Esempio n. 17
0
 internal SynchronizationResult Synchronize(SynchronizationMode mode, string localPath, string remotePath, string fileMask = "")
 {
     return(_session.SynchronizeDirectories(mode, localPath, remotePath, false, false, SynchronizationCriteria.Time, new TransferOptions()
     {
         FileMask = fileMask,
         OverwriteMode = OverwriteMode.Overwrite
     }));
 }
Esempio n. 18
0
 public ModSynchronizationWindow(SynchronizationMode synchronizationMode, Mod mod)
 {
     Mod = mod;
     InitializeComponent();
     ResetComponents();
     _synchronizationMode = synchronizationMode;
     _localModPath        = Path.Combine(Mod.ModDirectory);
     _remoteModPath       = Path.Combine(Settings.Default.RepositoryStoragePath, Mod.Name);
 }
Esempio n. 19
0
        public SceneLoading(string bundleName, string assetName, SynchronizationMode mode, bool isAdditive)
            : base(AssetLoadingPattern.Scene, bundleName, assetName, null)
        {
            _mode             = mode;
            _isAdditive       = isAdditive;
            _asyncLoadRequest = null;

            AssetGroup = AssetGroup.Scene;
        }
Esempio n. 20
0
		public static void Synchronize(FileSystem SourceFileSystem, String SourcePath, FileSystem DestinationFileSystem, String DestinationPath, SynchronizationMode _SynchronizationMode, ReferenceMode _ReferenceMode)
		{
			lock (SourceFileSystem)
			{
				lock (DestinationFileSystem)
				{
					var Synchronizer = new Synchronizer(SourceFileSystem, SourcePath, DestinationFileSystem, DestinationPath, _SynchronizationMode, _ReferenceMode);
					Synchronizer.SynchronizeFolder("/");
				}
			}
		}
        private IMemoizationStore CreateSQLiteMemoizationStore(AbsolutePath path, SynchronizationMode syncMode = SQLiteMemoizationStore.DefaultSyncMode)
        {
            var memoConfig = new SQLiteMemoizationStoreConfiguration(path)
            {
                MaxRowCount = MaxRowCount
            };

            memoConfig.Database.SyncMode    = syncMode;
            memoConfig.Database.JournalMode = JournalMode.OFF;
            return(new TestSQLiteMemoizationStore(Logger, _clock, memoConfig));
        }
        private IndexDifferences Calculate(SynchronizationMode mode)
        {
            var newPackages = fileSystemPackages.Except(indexedPackagesByPath.Keys, StringComparer.InvariantCultureIgnoreCase);
            var missingPackages = indexedPackagesByPath.Keys.Except(fileSystemPackages, StringComparer.InvariantCultureIgnoreCase);
            var modifiedPackages = fileSystemPackages.Intersect(indexedPackagesByPath.Keys, StringComparer.InvariantCultureIgnoreCase);

            if (mode == SynchronizationMode.Incremental)
            {
                modifiedPackages = modifiedPackages.Where(ModifiedDateMismatch);
            }

            return new IndexDifferences(newPackages.ToList(), missingPackages.ToList(), modifiedPackages.ToList());
        }
Esempio n. 23
0
 public static IEnumerable <ComparisonDifference> WinScpCompare(this ICakeContext context,
                                                                SessionOptions options,
                                                                string remoteFolder,
                                                                string localFolder,
                                                                bool logDifferences      = false,
                                                                bool removeFiles         = false,
                                                                SynchronizationMode mode = SynchronizationMode.Remote,
                                                                bool mirror = false,
                                                                SynchronizationCriteria criteria = SynchronizationCriteria.Time,
                                                                TransferOptions transferOptions  = null)
 {
     return(new WinScpRunner(context).CompareDirectories(options, remoteFolder, localFolder, logDifferences, removeFiles, mode, mirror, criteria, transferOptions));
 }
        private IndexDifferences Calculate(SynchronizationMode mode)
        {
            var newPackages      = fileSystemPackages.Except(indexedPackagesByPath.Keys, StringComparer.InvariantCultureIgnoreCase);
            var missingPackages  = indexedPackagesByPath.Keys.Except(fileSystemPackages, StringComparer.InvariantCultureIgnoreCase);
            var modifiedPackages = fileSystemPackages.Intersect(indexedPackagesByPath.Keys, StringComparer.InvariantCultureIgnoreCase);

            if (mode == SynchronizationMode.Incremental)
            {
                modifiedPackages = modifiedPackages.Where(ModifiedDateMismatch);
            }

            return(new IndexDifferences(newPackages.ToList(), missingPackages.ToList(), modifiedPackages.ToList()));
        }
Esempio n. 25
0
 public static ICakeContext WinScpSync(this ICakeContext context,
                                       SessionOptions options,
                                       string remoteFolder,
                                       string localFolder,
                                       bool removeFiles         = false,
                                       SynchronizationMode mode = SynchronizationMode.Remote,
                                       bool mirror = false,
                                       SynchronizationCriteria criteria = SynchronizationCriteria.Time,
                                       TransferOptions transferOptions  = null)
 {
     new WinScpRunner(context).SynchronizeDirectories(options, remoteFolder, localFolder, removeFiles, mode, mirror, criteria, transferOptions);
     return(context);
 }
 /// <summary>
 /// Initialize SynchronizationStateManager instance will all default values except the business logic and the endpointConfigurationName
 /// </summary>
 /// <param name="synchronizationBusinessLogic">The business logic instance provide by the consumer</param>
 /// <param name="endpointConfigurationName">the endpointConfigurationName that will used to obtain the wcf configuration and create the channel, if not provide the default is SyncDefaultEndpointConfigurationName</param>
 /// <param name="synchronizationMode">the synchronization mode that will used , if not provide the default is SynchronizationMode.Reliable</param>
 /// <param name="reSyncInterval">The interval in milliseconds that the peer try to re-sync itself - work only when synchronizationMode is Reliable</param>
 public SynchronizationStateManager(ISynchronizationBusinessLogic synchronizationBusinessLogic,
                                    string endpointConfigurationName,
                                    SynchronizationMode synchronizationMode,
                                    double reSyncInterval = Defaults.ReSyncDefaultInterval
                                    )
 {
     Contract.Requires <ArgumentNullException>(synchronizationBusinessLogic != null);
     Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(endpointConfigurationName));
     Contract.Requires <ArgumentOutOfRangeException>(synchronizationMode != SynchronizationMode.Reliable || reSyncInterval > 0, Properties.Resources.SynchronizationModeReliableReSyncIntervalBiggerThenZero);
     this.endpointConfigurationName = endpointConfigurationName;
     this.businessLogic             = synchronizationBusinessLogic;
     this.synchronizationMode       = synchronizationMode;
     this.reSyncInterval            = reSyncInterval;
 }
Esempio n. 27
0
        public IEnumerable <ComparisonDifference> CompareDirectories(SessionOptions options,
                                                                     string remoteFolder,
                                                                     string localFolder,
                                                                     bool logDifferences      = false,
                                                                     bool removeFiles         = false,
                                                                     SynchronizationMode mode = SynchronizationMode.Remote,
                                                                     bool mirror = false,
                                                                     SynchronizationCriteria criteria = SynchronizationCriteria.Time,
                                                                     TransferOptions transferOptions  = null)
        {
            options.AddRawSettings("LocalDirectory", _context.Environment.WorkingDirectory.FullPath);

            using (var session = new Session())
            {
                session.Open(options);
                Logger.Log($"{localFolder} and {remoteFolder} are being compared");
                var result = session.CompareDirectories(mode, localFolder, remoteFolder, removeFiles, mirror, criteria, transferOptions) as IEnumerable <ComparisonDifference>;
                if (logDifferences)
                {
                    if (result == null)
                    {
                        Logger.Log("Compare Result was Null");
                        return(result);
                    }
                    Logger.Log(String.Format("|{0,16}|{1,10}|{2,20}|{3,20}|", "Action".PadRight(16), "Directory".PadRight(10), "Local File Name".PadRight(20), "Remote File Name".PadRight(20)));
                    foreach (var diff in result)
                    {
                        var localFile = diff?.Local?.FileName;
                        if (String.IsNullOrEmpty(localFile))
                        {
                            localFile = Path.GetFileName(localFile);
                        }

                        var remoteFile = diff?.Remote?.FileName;
                        if (!String.IsNullOrEmpty(remoteFile))
                        {
                            remoteFile = Path.GetFileName(remoteFile);
                        }

                        Logger.Log(String.Format("|{0,16}|{1,10}|{2,20}|{3,20}|",
                                                 diff?.Action.ToString().PadRight(16),
                                                 diff?.IsDirectory.ToString().PadRight(10),
                                                 localFile?.PadRight(20),
                                                 remoteFile?.PadRight(20)));
                    }
                }
                return(result);
            }
        }
Esempio n. 28
0
 /// <summary>
 /// Initialize the callback instance
 /// </summary>
 /// <param name="synchronizationBusinessLogic">The business logic instance provide by the consumer</param>
 /// <param name="synchronizationMode">the synchronization mode that will used , if not provide the default is SynchronizationMode.Reliable</param>
 /// <param name="reSyncInterval">The interval in milliseconds that the peer try to re-sync itself - work only when synchronizationMode is Reliable</param>
 public SynchronizationCallback(ISynchronizationBusinessLogic synchronizationBusinessLogic,
                                SynchronizationMode synchronizationMode = Defaults.DefaultSynchronizationMode,
                                double reSyncInterval = Defaults.ReSyncDefaultInterval)
 {
     Contract.Requires <ArgumentNullException>(synchronizationBusinessLogic != null);
     Contract.Requires <ArgumentOutOfRangeException>(synchronizationMode != SynchronizationMode.Reliable || reSyncInterval > 0, Properties.Resources.SynchronizationModeReliableReSyncIntervalBiggerThenZero);
     businessLogic            = synchronizationBusinessLogic;
     this.synchronizationMode = synchronizationMode;
     if (synchronizationMode == SynchronizationMode.Reliable)
     {
         reSyncTimer = new Timer(reSyncInterval)
         {
             AutoReset = false
         };
         reSyncTimer.Elapsed += OnSyncTimerElapsed;
     }
 }
Esempio n. 29
0
        private SyncType GetSyncType(SynchronizationMode syncMode)
        {
            switch (syncMode)
            {
            case SynchronizationMode.Full:
                return(SyncType.Full);

            case SynchronizationMode.Delta:
                return(SyncType.Delta);

            case SynchronizationMode.Initial:
                return(SyncType.Initial);

            default:
                return(SyncType.Delta);
            }
        }
        /// <remarks>
        /// InitializeData has to set fields instead of properties, since properties can encapsulate business logic and can interfer with each other!
        /// </remarks>
        private void InitializeData(Contracts.Options data)
        {
            _name     = data.Name;
            _isActive = !data.Inactive;

            _enableChangeTriggeredSynchronization = data.EnableChangeTriggeredSynchronization;

            InitializeFolder(data);

            FolderAccountName = data.OutlookFolderAccountName;

            _calenderUrl        = data.CalenderUrl;
            _userName           = data.UserName;
            _password           = data.Password;
            _emailAddress       = data.EmailAddress;
            _useAccountPassword = data.UseAccountPassword;

            _useGoogleNativeApi = data.ServerAdapterType == ServerAdapterType.GoogleContactApi || data.ServerAdapterType == ServerAdapterType.GoogleTaskApi;

            _synchronizationMode = data.SynchronizationMode;
            _conflictResolution  = data.ConflictResolution;
            _synchronizationIntervalInMinutes = data.SynchronizationIntervalInMinutes;
            _isChunkedSynchronizationEnabled  = data.IsChunkedSynchronizationEnabled;
            _chunkSize = data.ChunkSize;

            _useSynchronizationTimeRange  = !data.IgnoreSynchronizationTimeRange;
            _daysToSynchronizeInThePast   = data.DaysToSynchronizeInThePast;
            _daysToSynchronizeInTheFuture = data.DaysToSynchronizeInTheFuture;
            _useWebDavCollectionSync      = data.UseWebDavCollectionSync;
            _profileTypeOrNull            = data.ProfileTypeOrNull;

            var proxyOptions = data.ProxyOptions ?? new ProxyOptions();

            _closeConnectionAfterEachRequest = data.CloseAfterEachRequest;
            _preemptiveAuthentication        = data.PreemptiveAuthentication;
            _forceBasicAuthentication        = data.ForceBasicAuthentication;
            _proxyUseDefault = proxyOptions.ProxyUseDefault;
            _proxyUseManual  = proxyOptions.ProxyUseManual;
            _proxyUrl        = proxyOptions.ProxyUrl;
            _proxyUserName   = proxyOptions.ProxyUserName;
            _proxyPassword   = proxyOptions.ProxyPassword;

            MappingConfigurationModelOrNull = data.MappingConfiguration?.Accept(_mappingConfigurationModelFactory);
            CoerceMappingConfiguration();
        }
Esempio n. 31
0
        public Synchronizer(FileSystem SourceFileSystem, String SourcePath, FileSystem DestinationFileSystem, String DestinationPath, SynchronizationMode _SynchronizationMode, ReferenceMode _ReferenceMode)
        {
            this.SourceFileSystem      = SourceFileSystem;
            this.DestinationFileSystem = DestinationFileSystem;
            this.SourcePath            = SourcePath;
            this.DestinationPath       = DestinationPath;
            this._SynchronizationMode  = _SynchronizationMode;
            this._ReferenceMode        = _ReferenceMode;

            OnStep += delegate(double Value, String Details) {
                //Console.WriteLine("OnStep: " + Value + "; " + Details);
            };

            OnError += delegate(Exception Exception)
            {
                Console.Error.WriteLine(Exception);
            };
        }
Esempio n. 32
0
        public Synchronizer(FileSystem SourceFileSystem, String SourcePath, FileSystem DestinationFileSystem, String DestinationPath, SynchronizationMode _SynchronizationMode, ReferenceMode _ReferenceMode)
        {
            this.SourceFileSystem = SourceFileSystem;
            this.DestinationFileSystem = DestinationFileSystem;
            this.SourcePath = SourcePath;
            this.DestinationPath = DestinationPath;
            this._SynchronizationMode = _SynchronizationMode;
            this._ReferenceMode = _ReferenceMode;

            OnStep += delegate(double Value, String Details) {
                //Console.WriteLine("OnStep: " + Value + "; " + Details);
            };

            OnError += delegate(Exception Exception)
            {
                Console.Error.WriteLine(Exception);
            };
        }
        public void FixSynchronizationMode(OptionsModel options, TestResult result)
        {
            const SynchronizationMode readOnlyDefaultMode = SynchronizationMode.ReplicateServerIntoOutlook;

            if (result.ResourceType.HasFlag(ResourceType.Calendar))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        Strings.Get($"The specified URL is a read-only calendar. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'."),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (result.ResourceType.HasFlag(ResourceType.AddressBook))
            {
                if (!result.AccessPrivileges.HasFlag(AccessPrivileges.Modify) &&
                    OptionTasks.DoesModeRequireWriteableServerResource(options.SynchronizationMode))
                {
                    options.SynchronizationMode = readOnlyDefaultMode;
                    MessageBox.Show(
                        Strings.Get($"The specified URL is a read-only addressbook. Synchronization mode set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}'."),
                        OptionTasks.ConnectionTestCaption);
                }
            }

            if (options.SynchronizationMode == readOnlyDefaultMode && options.SelectedFolderOrNull?.ItemCount > 0)
            {
                MessageBox.Show(
                    Strings.Get($"Synchronization mode is set to '{_enumDisplayNameProvider.Get(readOnlyDefaultMode)}' and the selected Outlook folder is not empty. Are you sure, you want to select this folder because all items will be overwritten with the DAV server resources!"),
                    OptionTasks.ConnectionTestCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (options.SynchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer && options.SelectedFolderOrNull?.ItemCount == 0)
            {
                MessageBox.Show(
                    Strings.Get($"Synchronization mode is set to '{_enumDisplayNameProvider.Get(SynchronizationMode.ReplicateOutlookIntoServer)}' and the selected Outlook folder is empty. Are you sure, you want to select this folder, because all items on the DAV server will be deleted!"),
                    OptionTasks.ConnectionTestCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public async Task MixSyncModes(SynchronizationMode fromSyncMode, SynchronizationMode toSyncMode)
        {
            var context = new Context(Logger);

            using (var testDirectory = new DisposableDirectory(FileSystem))
            {
                StrongFingerprint sfp = StrongFingerprint.Random();
                ContentHashListWithDeterminism value = new ContentHashListWithDeterminism(ContentHashList.Random(), CacheDeterminism.None);
                await RunTestAsync(
                    context,
                    testDirectory,
                    async (store, session) =>
                {
                    // Add a value to a store with one sync mode
                    AddOrGetContentHashListResult addResult = await session.AddOrGetContentHashListAsync(context, sfp, value, Token);
                    Assert.True(addResult.Succeeded);
                    Assert.Null(addResult.ContentHashListWithDeterminism.ContentHashList);
                },
                    testDir => CreateSQLiteMemoizationStore(testDirectory.Path, fromSyncMode));

                await RunTestAsync(
                    context,
                    testDirectory,
                    async (store, session) =>
                {
                    // Make sure the same value can still be read from another sync mode
                    GetContentHashListResult getResult = await session.GetContentHashListAsync(context, sfp, Token);
                    getResult.ShouldBeSuccess();
                    Assert.Equal(value, getResult.ContentHashListWithDeterminism);

                    // Make sure a new value can be written in another sync mode
                    StrongFingerprint newSfp = StrongFingerprint.Random();
                    ContentHashListWithDeterminism newValue =
                        new ContentHashListWithDeterminism(ContentHashList.Random(), CacheDeterminism.None);
                    AddOrGetContentHashListResult addResult = await session.AddOrGetContentHashListAsync(context, newSfp, newValue, Token);
                    Assert.True(addResult.Succeeded);
                    Assert.Null(addResult.ContentHashListWithDeterminism.ContentHashList);
                },
                    testDir => CreateSQLiteMemoizationStore(testDirectory.Path, toSyncMode));
            }
        }
Esempio n. 35
0
        public void StartSynchronization(SynchronizationMode syncType)
        {
            if (DsaSyncLog.Instance.IsSyncStarted() || !SfdcConfig.SyncLogsEnable)
            {
                return;
            }

            var account           = AccountManager.GetAccount();
            var deviceInfo        = new EasClientDeviceInformation();
            var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
            var version           = Package.Current.Id.Version;
            var logObject         = new SyncLog
            {
                AppVersion     = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}",
                DeviceType     = deviceInfo.SystemManufacturer + deviceInfo.SystemProductName,
                ConnectionType = GetConnectionType(connectionProfile),
                SyncType       = GetSyncType(syncType),
                StartTime      = DateTime.UtcNow,
                Username       = account.UserName
            };

            DsaSyncLog.Instance.StartSynchronization(logObject);
        }
Esempio n. 36
0
        public async Task SynchronizeIndexWithFileSystemAsync(SynchronizationMode mode, CancellationToken cancellationToken)
        {
            lock (synchronizationStatusLock)
            {
                if (synchronizationStatus.SynchronizationState != SynchronizationState.Idle)
                {
                    throw new InvalidOperationException("Already running");
                }
                UpdateSynchronizationStatus(SynchronizationState.ScanningFiles);
            }

            try
            {
                var differences = IndexDifferenceCalculator.FindDifferences(
                    FileSystem, PackageRepository.LucenePackages, cancellationToken, UpdateSynchronizationStatus, mode);

                await SynchronizeIndexWithFileSystemAsync(differences, cancellationToken);
            }
            finally
            {
                UpdateSynchronizationStatus(SynchronizationState.Idle);
            }
        }
 public Task SynchronizeWithFileSystem(SynchronizationMode mode, CancellationToken cancellationToken)
 {
     Log.Info(m => m("Synchronizing packages with filesystem."));
     return Indexer.SynchronizeIndexWithFileSystemAsync(mode, cancellationToken);
 }
Esempio n. 38
0
        public SynchronizationResult SynchronizeDirectories(
            SynchronizationMode mode, string localPath, string remotePath,
            bool removeFiles, bool mirror = false, SynchronizationCriteria criteria = SynchronizationCriteria.Time,
            TransferOptions options = null)
        {
            using (Logger.CreateCallstackAndLock())
            {
                if (options == null)
                {
                    options = new TransferOptions();
                }

                CheckOpened();

                if (removeFiles && (mode == SynchronizationMode.Both))
                {
                    throw new ArgumentException("Cannot delete files in synchronization mode Both");
                }

                if (mirror && (mode == SynchronizationMode.Both))
                {
                    throw new ArgumentException("Cannot mirror files in synchronization mode Both");
                }

                if ((criteria != SynchronizationCriteria.Time) && (mode == SynchronizationMode.Both))
                {
                    throw new ArgumentException("Only Time criteria is allowed in synchronization mode Both");
                }

                string modeName;
                switch (mode)
                {
                    case SynchronizationMode.Local:
                        modeName = "local";
                        break;
                    case SynchronizationMode.Remote:
                        modeName = "remote";
                        break;
                    case SynchronizationMode.Both:
                        modeName = "both";
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("mode");
                }

                List<string> criteriaNames = new List<string>();
                if ((criteria & SynchronizationCriteria.Time) == SynchronizationCriteria.Time)
                {
                    criteria -= SynchronizationCriteria.Time;
                    criteriaNames.Add("time");
                }

                if ((criteria & SynchronizationCriteria.Size) == SynchronizationCriteria.Size)
                {
                    criteria -= SynchronizationCriteria.Size;
                    criteriaNames.Add("size");
                }

                if (criteria != 0)
                {
                    throw new ArgumentOutOfRangeException("criteria");
                }

                WriteCommand(
                    string.Format(CultureInfo.InvariantCulture,
                        "synchronize {0} {1} {2} {3} {4} -- \"{5}\" \"{6}\"",
                        modeName,
                        BooleanSwitch(removeFiles, "delete"),
                        BooleanSwitch(mirror, "mirror"),
                        options.ToSwitches(),
                        FormatSwitch("criteria", string.Join(",", criteriaNames.ToArray())),
                        ArgumentEscape(localPath), ArgumentEscape(remotePath)));

                return ReadSynchronizeDirectories();
            }
        }
Esempio n. 39
0
        private void SetSynchronizationMode(SynchronizationMode synchronizationMode, bool checkParentAnimator)
        {
            if (_syncMode == synchronizationMode)
                return;

            if (synchronizationMode == SynchronizationMode.ResetToCurrent)
            {
                if (!Program.IsDesign)
                    return;

                ResetValues();

                return;
            }

            if (_parentAnimator != null && checkParentAnimator && !_isInitializing)
                throw new InvalidOperationException(SET_PROP_WITH_PARENT_ANIMATOR_ERROR_MESSAGE);

            _syncMode = synchronizationMode;
            SynchronizeToSource();

            foreach (AnimatorBase childAnimator in _childAnimators)
                childAnimator.SetSynchronizationMode(synchronizationMode, false);

            OnSynchronizationModeChanged(EventArgs.Empty);
        }
 private static bool RequiresWriteableServerResource (SynchronizationMode synchronizationMode)
 {
   return synchronizationMode == SynchronizationMode.MergeInBothDirections
          || synchronizationMode == SynchronizationMode.MergeOutlookIntoServer
          || synchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer;
 }