コード例 #1
0
        /// <summary>
        /// Match using the profile identifiers - each profile identifier is expected to assigned to a unique entity
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("item.targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("item.sourceClient is null");
            }

            if (sourceStorePath == null)
            {
                throw new InvalidOperationException("sourceStorePath is null");
            }

            if (targetStorePath == null)
            {
                throw new InvalidOperationException("targetStorePath is null");
            }

            var baseline = baseliClient.GetAll(baselineStorePath);

            targetClient.WriteRange(
                MatchThisByProfileId(sourceClient.GetAll(sourceStorePath), baseline), targetStorePath);
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Normalizes content by using lookup tables and removes unneeded whitespace
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("item.targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("item.sourceClient is null");
            }

            var elements = sourceClient.GetAll(sourceStorePath);

            foreach (var element in elements)
            {
                this.LogProcessingEvent(element, "normalizing ... ");
                element.NormalizeContent();
            }

            targetClient.WriteRange(elements, targetStorePath);
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Updates test data inside a storage.
        ///   Overwrite existing entries
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("item.targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("item.sourceClient is null");
            }

            // delete existing elements
            targetClient.DeleteElements(targetClient.GetAll(targetStorePath), targetStorePath);

            var contacts = Contacts.GetStandardContactList(true);

            contacts.AddRange(Contacts.VariableContactList);

            targetClient.AddRange(contacts.ToStdElements(), targetStorePath);

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// This command does lookup contact ralations for a List of <see cref="StdContact"/>. The connector that does read the
        ///   data need to be specified inside the <paramref name="commandParameter"/> and must implement the interface <see cref="IExtendedReader"/>.
        ///   Only contacts that can be mapped to internal Ids using the <paramref name="baseliClient"/> will be collected - no additional
        ///   data is collected (there's no profile lookup for the unknown contacts).
        /// </summary>
        /// <param name="sourceClient"> The source client provides a set of <see cref="StdContact"/> entries for that the contact relations should be read. </param>
        /// <param name="targetClient"> The target client will write the processed list of <see cref="StdContact"/> that now does contain the contact relations. </param>
        /// <param name="baseliClient"> The baseline client provides lookup data for determine valid translations for the relation ids read from the connector specified in the <paramref name="commandParameter"/>. </param>
        /// <param name="sourceStorePath"> The source storage path. </param>
        /// <param name="targetStorePath"> The target storage path. </param>
        /// <param name="baselineStorePath"> The baseline storage path. </param>
        /// <param name="commandParameter"> The connector to the contact relations (must support <see cref="IExtendedReader"/>). </param>
        /// <returns> True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"  </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("item.targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("item.sourceClient is null");
            }

            if (baseliClient == null)
            {
                throw new InvalidOperationException("item.baseliClient is null");
            }

            var extendedClient = sourceClient as IExtendedReader;

            if (extendedClient == null)
            {
                throw new InvalidOperationException("sourceClient is null or not an IExtendedReader");
            }

            ((SyncComponent)extendedClient).ProcessingEvent += this.LogProcessingEvent;

            // get the baseline
            var baseline = baseliClient.GetAll(baselineStorePath);

            // get all source elements
            var elements = targetClient.GetAll(targetStorePath);

            // add the matching profile ids from the baseline as StdContact -
            // .ToContacts().ToStdElement() will convert each MatchingEntry
            // of the list into a StdContact
            elements.MergeHighEvidence(baseline.ToStdContacts().ToStdElements());

            // fill the extended contact information
            var matchEntities = baseline.ToMatchingEntries();

            extendedClient.FillAllContacts(elements, matchEntities);
            elements.ForEach(e => extendedClient.FillContacts(e, matchEntities));

            // copy to the target connector
            targetClient.AddRange(elements, targetStorePath);
            baseliClient.WriteRange(baseline, baselineStorePath);

            ((SyncComponent)extendedClient).ProcessingEvent -= this.LogProcessingEvent;

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ContactsFolder"/> class.
        /// </summary>
        /// <param name="connector">
        /// The connector to read from.
        /// </param>
        /// <param name="clientPath">
        /// The client path.
        /// </param>
        public ContactsFolder(IClientBase connector, string clientPath)
        {
            if (connector == null)
            {
                return;
            }

            this.Contacts = (IEnumerable <StdContact>)connector.GetAll(clientPath);
        }
コード例 #6
0
        /// <summary>
        /// Detects merge conflicts and resolves them using user interaction
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("item.targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("item.sourceClient is null");
            }

            if (sourceStorePath == null)
            {
                throw new InvalidOperationException("sourceStorePath is null");
            }

            if (targetStorePath == null)
            {
                throw new InvalidOperationException("targetStorePath is null");
            }

            var targetList = targetClient.GetAll(targetStorePath);
            var sourceList = sourceClient.GetAll(sourceStorePath);
            var type       = targetList.Count > 0
                           ? targetList[0].GetType()
                           : sourceList.Count > 0 ? sourceList[0].GetType() : typeof(StdElement);

            var mergeResultList =
                ((IUiSyncInteraction)this.UiProvider).PerformAttributeMerge(
                    SyncTools.DetectConflicts(
                        SyncTools.BuildConflictTestContainerList(
                            sourceList,
                            targetList,
                            (baseliClient == null) ? null : baseliClient.GetAll(baselineStorePath),
                            type),
                        true),
                    targetList);

            // only write to target if we did get a merge result
            if (mergeResultList != null)
            {
                targetClient.WriteRange(mergeResultList, targetStorePath);
            }

            return(true);
        }
コード例 #7
0
        /// <summary>
        /// Copy all entries from the source client to the destination client;
        ///   Overwrite existing entries
        /// </summary>
        /// <param name="sourceClient"> The source client instance that is the source of data for the copy operation. </param>
        /// <param name="targetClient"> The source client instance that is the target for the data of the copy operation. </param>
        /// <param name="baseliClient"> The baseline client is not utilized in this command. </param>
        /// <param name="sourceStorePath"> The storage path for the source connector. </param>
        /// <param name="targetStorePath"> The storage path for the target connector </param>
        /// <param name="baselineStorePath"> The baseline client (and so the storage path) is not utilized in this command. </param>
        /// <param name="commandParameter"> In this command there is no need for a parameter. </param>
        /// <returns> Always true. </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            Bouncer.ForCheckData(() => sourceClient).Assert(new IsNotNullRule <IClientBase>());
            Bouncer.ForCheckData(() => targetClient).Assert(new IsNotNullRule <IClientBase>());

            targetClient.AddRange(sourceClient.GetAll(sourceStorePath), targetStorePath);

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// This command deletes files specified by one or more path pattern separated by a line break.
        ///   Deletes files from a folder using a search pattern. Use "*" as a place holder for any
        ///   number of any chars; use "?" as a placeholder for a single char.
        /// </summary>
        /// <param name="sourceClient">The source client - will delete "all elements" if this parameter is NULL.</param>
        /// <param name="targetClient">The target client - must not be null.</param>
        /// <param name="baseliClient">The baseline client - can be null, because there is no interaction with the baseline in this command.</param>
        /// <param name="sourceStorePath">The source storage path - the elements found in this path will be deleted.</param>
        /// <param name="targetStorePath">The target storage path - the deletion will take place in this path.</param>
        /// <param name="baselineStorePath">The baseline storage path - can be null, because there is no interaction with the baseline in this command.</param>
        /// <param name="commandParameter">The command parameter - can be null, because there is no parameter for this command.</param>
        /// <returns>True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue".</returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            Bouncer.ForCheckData(() => targetClient).Assert(new IsNotNullRule <IClientBase>());

            targetClient.DeleteElements(
                sourceClient != null
                ? sourceClient.GetAll(sourceStorePath)
                : null,
                targetStorePath);

            this.LogProcessingEvent("elements deleted from storage path {0}", targetStorePath);
            return(true);
        }
コード例 #9
0
        /// <summary>
        /// Inserts only missing elements, existing elements will not be altered
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("item.targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("item.sourceClient is null");
            }

            targetClient.MergeMissingRange(sourceClient.GetAll(sourceStorePath), targetStorePath);
            return(true);
        }
コード例 #10
0
        /// <summary>
        /// Match internally without user interaction by comparing the email addresses
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// returns always true
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            if (targetClient == null)
            {
                throw new InvalidOperationException("targetClient is null");
            }

            if (sourceClient == null)
            {
                throw new InvalidOperationException("sourceClient is null");
            }

            if (sourceStorePath == null)
            {
                throw new InvalidOperationException("sourceStorePath is null");
            }

            if (targetStorePath == null)
            {
                throw new InvalidOperationException("targetStorePath is null");
            }

            targetClient.WriteRange(
                this.MatchThisByEMail(
                    sourceClient.GetAll(sourceStorePath).ToStdContacts(),
                    targetClient.GetAll(targetStorePath).ToStdContacts()),
                targetStorePath);

            return(true);
        }
コード例 #11
0
        /// <summary>
        /// Opens the matching window and matches using a baseline client
        /// </summary>
        /// <param name="sourceClient">
        /// The source client.
        /// </param>
        /// <param name="targetClient">
        /// The target client.
        /// </param>
        /// <param name="baseliClient">
        /// The baseline client.
        /// </param>
        /// <param name="sourceStorePath">
        /// The source storage path.
        /// </param>
        /// <param name="targetStorePath">
        /// The target storage path.
        /// </param>
        /// <param name="baselineStorePath">
        /// The baseline storage path.
        /// </param>
        /// <param name="commandParameter">
        /// The command parameter.
        /// </param>
        /// <returns>
        /// True if the response from the <see cref="SyncComponent.UiProvider"/> is "continue"
        /// </returns>
        public bool ExecuteCommand(
            IClientBase sourceClient,
            IClientBase targetClient,
            IClientBase baseliClient,
            string sourceStorePath,
            string targetStorePath,
            string baselineStorePath,
            string commandParameter)
        {
            CheckParameters(
                targetClient, sourceClient, baseliClient, baselineStorePath, sourceStorePath, targetStorePath);

            var backupConnector = targetClient as IBackupStorage;

            if (backupConnector != null)
            {
                backupConnector.BackupStorage(targetStorePath);
            }

            // todo: split the command parameter in oder to specify whether to add orphaned source entries or skip them.
            var sourceTypeAttributes = sourceClient.GetType().GetCustomAttributes(
                typeof(ConnectorDescriptionAttribute), false);
            var identifierToUse = (!string.IsNullOrEmpty(commandParameter))
                                      ? (ProfileIdentifierType)
                                  Enum.Parse(typeof(ProfileIdentifierType), commandParameter, true)
                                      : (sourceTypeAttributes != null && sourceTypeAttributes.Length > 0)
                                            ? ((ConnectorDescriptionAttribute)sourceTypeAttributes[0]).
                                  MatchingIdentifier
                                            : ProfileIdentifierType.Default;

            var targetMatchList = targetClient.GetAll(targetStorePath);
            var sourceMatchList = sourceClient.GetAll(sourceStorePath);
            var matchResultList = ((IUiSyncInteraction)this.UiProvider).PerformEntityMerge(
                sourceMatchList, targetMatchList, baseliClient.GetAll(baselineStorePath), identifierToUse);

            // only write to target if we did get a merge result
            if (targetMatchList != null && matchResultList != null)
            {
                targetClient.WriteRange(targetMatchList, targetStorePath);
            }

            // only write to target if we did get a merge result
            if (matchResultList != null)
            {
                var sourceContactList = sourceMatchList.ToStdContacts();
                var matchingEntryList = matchResultList.ToMatchingEntries();

                // Check for new (not matched) contacts and generate new matching entries for such new entries.
                var orphanSource = from x in sourceContactList
                                   join matchEntry in matchingEntryList on x.ExternalIdentifier equals
                                   matchEntry.ProfileId into matchGroup
                                   from y in matchGroup.DefaultIfEmpty()
                                   where
                                   y == null &&
                                   !string.IsNullOrEmpty(x.ExternalIdentifier.GetProfileId(identifierToUse))
                                   select new MatchingEntry {
                    Id = x.Id, ProfileId = x.ExternalIdentifier
                };

                // add all new contacts matching entries to the base line
                orphanSource.ForEach(matchResultList.Add);

                // write baseline to base line connector
                baseliClient.WriteRange(matchResultList, baselineStorePath);
            }

            return(true);
        }