public void CopyTestsGenericConnector()
        {
            var connector        = new ContactClient();
            var genericConnector = new GenericClient <StdContact>();
            var tempFolder       = PrepareFolder(false);
            var file1            = Path.Combine(tempFolder, "file1");
            var file2            = Path.Combine(tempFolder, "file2");
            var path1            = Path.Combine(tempFolder, "vCards");

            var originalList = connector.GetAll(file1);

            originalList.Add(new StdContact());
            genericConnector.WriteRange(originalList, path1);
            var copyList = genericConnector.GetAll(path1);

            copyList.Add(new StdContact());
            connector.WriteRange(copyList, file2);

            AssertOriginalAndCopyCompare(originalList, copyList, false);
        }
Example #2
0
        /// <summary>
        /// Implements a read of the full list of contacts for the specifies folder.
        /// </summary>
        /// <param name="clientFolderName">
        /// The client folder name for the memory connector.
        /// </param>
        /// <param name="result">
        /// The result list of contacts.
        /// </param>
        /// <returns>
        /// the search results
        /// </returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            var connector  = new GenericClient();
            var listToScan = connector.GetAll(clientFolderName);

            this.xingRequester.UiDispatcher = this.UiDispatcher;

            result = new List <StdElement>();

            foreach (StdContact element in listToScan)
            {
                if (!string.IsNullOrEmpty(element.ExternalIdentifier.GetProfileId(ProfileIdentifierType.XingNameProfileId)) ||
                    string.IsNullOrEmpty(element.Name.LastName))
                {
                    continue;
                }

                var guesses = GuessProfileUrls(element.Name);
                foreach (var guess in guesses)
                {
                    for (var i = 0; i < 9; i++)
                    {
                        var profileUrl =
                            "http://www.xing.com/profile/"
                            + guess
                            + ((i > 0) ? i.ToString(CultureInfo.InvariantCulture) : string.Empty);

                        var publicProfile = this.xingRequester.GetContent(profileUrl);

                        if (publicProfile.Contains("Die gesuchte Seite konnte nicht gefunden werden."))
                        {
                            break;
                        }

                        var imageUrl = MapRegexToProperty(
                            publicProfile,
                            @"id=""photo"" src=""(?<info>/img/users/[^""]/[^""]/[^""]*)"" class=""photo profile-photo""");
                        var newContact = new StdContact
                        {
                            Name =
                                MapRegexToProperty(
                                    publicProfile, "\\<meta name=\"author\" content=\"(?<info>[^\"]*)\""),
                            BusinessPosition =
                                MapRegexToProperty(
                                    publicProfile,
                                    "\\<p class=\"profile-work-descr\"\\>(\\<[^>]*>)*(?<info>[^<]*)\\</"),
                            BusinessAddressPrimary =
                                new AddressDetail
                            {
                                PostalCode =
                                    MapRegexToProperty(publicProfile, "zip_code=\\%22(?<info>[^%]*)\\%22"),
                                CityName =
                                    MapRegexToProperty(
                                        publicProfile, "search&amp;city=%22(?<info>[^%]*)%22")
                            },
                            PictureData =
                                string.IsNullOrEmpty(imageUrl)
                                        ? null
                                        : this.xingRequester.GetContentBinary(
                                    MapRegexToProperty(
                                        publicProfile,
                                        @"id=""photo"" src=""(?<info>/img/users/[^""]/[^""]/[^""]*)"" class=""photo profile-photo"""))
                        };

                        if (string.IsNullOrEmpty(newContact.Name.ToString()))
                        {
                            continue;
                        }

                        this.LogProcessingEvent(newContact, "adding new contact candidate");

                        result.Add(newContact);
                    }
                }
            }

            return(result);
        }