コード例 #1
0
        public void ToStringSimple01()
        {
            string     s;
            StdContact s0 = new StdContact();

            s0.PersonGender                      = Gender.Unspecified;
            s0.DateOfBirth                       = default(DateTime);
            s0.Name                              = (PersonName)null;
            s0.PersonalAddressPrimary            = (AddressDetail)null;
            s0.PersonalAddressSecondary          = (AddressDetail)null;
            s0.PersonalPhoneMobile               = (PhoneNumber)null;
            s0.PersonalEmailPrimary              = (string)null;
            s0.PersonalEmailSecondary            = (string)null;
            s0.PersonalHomepage                  = (string)null;
            s0.PersonalInstantMessengerAddresses = (InstantMessengerAddresses)null;
            s0.PersonalProfileIdentifiers        = (ProfileIdentifiers)null;
            s0.BusinessCompanyName               = (string)null;
            s0.BusinessDepartment                = (string)null;
            s0.BusinessAddressPrimary            = (AddressDetail)null;
            s0.BusinessAddressSecondary          = (AddressDetail)null;
            s0.BusinessPhoneMobile               = (PhoneNumber)null;
            s0.BusinessEmailPrimary              = (string)null;
            s0.BusinessEmailSecondary            = (string)null;
            s0.BusinessPosition                  = (string)null;
            s0.BusinessHomepage                  = (string)null;
            s0.BusinessInstantMessengerAddresses = (InstantMessengerAddresses)null;
            s0.AdditionalTextData                = (string)null;
            s0.PictureName                       = (string)null;
            s0.PictureData                       = (byte[])null;
            ((StdElement)s0).Id                  = default(Guid);
            ((StdElement)s0).InternalSyncData    = (SyncData)null;
            s = this.ToStringSimple(s0);
            Assert.AreEqual <string>("", s);
        }
コード例 #2
0
        public void PropertyPathWithNoNullToPropertyWithTransformation()
        {
            // register the property mapping of a source and a destination
            // type with trasformations (in this case we do add a string to
            // the name to generate a calendar title of "Birthday: Riddle, Tom")
            var mapper = new Mapper();

            mapper.Register <StdContact, StdCalendarItem>(
                contact => contact.PersonalAddressPrimary.Phone,
                (calendar, entity) => calendar.Title = entity == null ? "NULL detected" : "Call to " + entity);

            // setup a source and a destination object
            var source = new StdContact {
                PersonalAddressPrimary = new AddressDetail {
                    Phone = "0123-456789"
                }
            };
            var target = new StdCalendarItem();

            // perform the mapping
            mapper.Map(source, target);

            // test it
            Assert.AreEqual("Call to (123) 456789", target.Title);
        }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: Interface007/Sem.Sync
        /// <summary>
        /// Converts a list of standard contacts to a list of standard elements
        /// </summary>
        /// <param name="list">
        /// a list of standard contacts to cast
        /// </param>
        /// <returns>
        /// a list of casted elements
        /// </returns>
        public static List <StdContact> ToStdContacts(this IEnumerable <StdElement> list)
        {
            var result = new List <StdContact>();

            foreach (var element in list)
            {
                var e = element as StdContact;

                if (e == null)
                {
                    var m = element as MatchingEntry;
                    if (m != null)
                    {
                        e = new StdContact {
                            Id = element.Id, ExternalIdentifier = m.ProfileId
                        };
                    }
                }

                if (e != null)
                {
                    result.Add(e);
                }
            }

            return(result);
        }
コード例 #4
0
ファイル: Extensions.cs プロジェクト: Interface007/Sem.Sync
        /// <summary>
        /// Converts a <see cref="StdContact"/> to an Exchange API <see cref="Contact"/>
        /// </summary>
        /// <param name="contact">
        /// The contact to be converted.
        /// </param>
        /// <param name="service">
        /// The exchange service.
        /// </param>
        /// <returns>
        /// the converted contact element
        /// </returns>
        public static Contact ToExchangeContact(this StdContact contact, ExchangeService service)
        {
            var exchangeContact = new Contact(service);

            exchangeContact.UpdateFromStdContact(contact);
            return(exchangeContact);
        }
コード例 #5
0
        /// <summary>
        /// sets the correct IM address from a google contacts Ims
        /// </summary>
        /// <param name="stdEntry">The std entry.</param>
        /// <param name="instantMessengerAddress">The IM address.</param>
        public static void SetInstantMessenger(this StdContact stdEntry, IMAddress instantMessengerAddress)
        {
            if (stdEntry.PersonalInstantMessengerAddresses == null)
            {
                stdEntry.PersonalInstantMessengerAddresses = new InstantMessengerAddresses();
            }

            if (instantMessengerAddress.Home)
            {
                switch (instantMessengerAddress.Protocol)
                {
                case "msn":
                    stdEntry.PersonalInstantMessengerAddresses.MsnMessenger = instantMessengerAddress.Address;
                    break;
                }
            }

            if (instantMessengerAddress.Work)
            {
                switch (instantMessengerAddress.Protocol)
                {
                case "msn":
                    stdEntry.BusinessInstantMessengerAddresses.MsnMessenger = instantMessengerAddress.Address;
                    break;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// sets the correct phone number from a google contacts email
        /// </summary>
        /// <param name="stdEntry">The std entry.</param>
        /// <param name="phoneNumber">The phone number to set into the std entry.</param>
        public static void SetPhone(this StdContact stdEntry, global::Google.GData.Extensions.PhoneNumber phoneNumber)
        {
            var stdPhoneNumber = new PhoneNumber(phoneNumber.Value);

            if (phoneNumber.Home)
            {
                stdEntry.PersonalAddressPrimary       = stdEntry.PersonalAddressPrimary ?? new AddressDetail();
                stdEntry.PersonalAddressPrimary.Phone = stdPhoneNumber;
            }

            if (phoneNumber.Work)
            {
                stdEntry.BusinessAddressPrimary       = stdEntry.BusinessAddressPrimary ?? new AddressDetail();
                stdEntry.BusinessAddressPrimary.Phone = stdPhoneNumber;
            }

            if (phoneNumber.Rel == GoogleSchemaPrefix2005 + "mobile")
            {
                if (stdEntry.PersonalPhoneMobile == null)
                {
                    stdEntry.PersonalPhoneMobile = stdPhoneNumber;
                }
                else
                {
                    stdEntry.BusinessPhoneMobile = stdPhoneNumber;
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// doenloads the image for a contact
        /// </summary>
        /// <param name="stdEntry">The std entry.</param>
        /// <param name="googleContact">The google contact.</param>
        /// <param name="requester">The requester.</param>
        public static void SetPicture(this StdContact stdEntry, Contact googleContact, ContactsRequest requester)
        {
            if (googleContact == null || googleContact.PhotoUri == null)
            {
                return;
            }

            try
            {
                using (var stream = requester.GetPhoto(googleContact))
                {
                    if (stream != null)
                    {
                        var value = new StreamReader(stream).ReadToEnd();
                        stdEntry.PictureData = Encoding.ASCII.GetBytes(value);
                    }
                }
            }
            catch (GDataNotModifiedException)
            {
                var helper = HttpHelper.DefaultInstance;
                helper.ContentCredentials.LogOnDomain   = "[GOOGLE]";
                helper.ContentCredentials.LogOnPassword =
                    ((GDataGAuthRequestFactory)requester.Service.RequestFactory).GAuthToken;
                stdEntry.PictureData = helper.GetContentBinary(googleContact.PhotoUri.AbsoluteUri, string.Empty, string.Empty);
            }
        }
コード例 #8
0
        public string ToStringSimple([PexAssumeUnderTest] StdContact target)
        {
            // TODO: add assertions to method StdContactTest.ToStringSimple(StdContact)
            string result = target.ToStringSimple();

            return(result);
        }
コード例 #9
0
        /// <summary>
        /// Sets a postal address from the google contact into the std contact.
        /// </summary>
        /// <param name="stdEntry">The std entry to be updated.</param>
        /// <param name="address">The address to set.</param>
        public static void SetAddress(this StdContact stdEntry, StructuredPostalAddress address)
        {
            var stdAddress = new AddressDetail(address.FormattedAddress);

            if (address.Usage == "home")
            {
                if (stdEntry.PersonalAddressPrimary == null)
                {
                    stdEntry.PersonalAddressPrimary = stdAddress;
                }
                else
                {
                    stdEntry.PersonalAddressSecondary = stdAddress;
                }
            }

            if (address.Usage == "Work")
            {
                if (stdEntry.BusinessAddressPrimary == null)
                {
                    stdEntry.BusinessAddressPrimary = stdAddress;
                }
                else
                {
                    stdEntry.BusinessAddressSecondary = stdAddress;
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Overrides the method to read the full list of data.
        /// </summary>
        /// <param name="clientFolderName">
        /// The exchange folder name to read from.
        /// </param>
        /// <param name="result">
        /// The result list.
        /// </param>
        /// <returns>
        /// The list of <see cref="StdContact"/> elements from the source.
        /// </returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            var contactsFolder = this.GetContactsFolder(clientFolderName);

            var offset    = 0;
            var itemsLeft = true;

            while (itemsLeft)
            {
                var resultList =
                    contactsFolder.FindItems(
                        new ItemView(100, offset, OffsetBasePoint.Beginning)
                {
                    PropertySet = BasePropertySet.IdOnly,
                    Traversal   = ItemTraversal.Shallow
                });

                itemsLeft = resultList.Items.Count == 100;

                foreach (var element in resultList)
                {
                    var currentItem = element as Contact;
                    if (currentItem == null)
                    {
                        continue;
                    }

                    StdContact contact = null;
                    ExceptionHandler.Suppress(
                        () =>
                    {
                        var exchangeContact = Contact.Bind(contactsFolder.Service, currentItem.Id);
                        contact             = exchangeContact.ToStdContact();
                    },
                        (Exception ex) => true);

                    if (contact == null || string.IsNullOrEmpty(contact.Name.ToString()))
                    {
                        continue;
                    }

                    result.Add(contact);
                    this.LogProcessingEvent(contact, Properties.Resources.ElementLoaded);
                }

                CleanUpEntities(result);

                this.LogProcessingEvent(Properties.Resources.ElementsLoaded, result.Count);

                offset += 100;
            }

            return(result);
        }
コード例 #11
0
        /// <summary>
        /// Overrides the method to read the full list of data. This will read ALL data from the Google Contacts
        ///   account, even if it has already been downloaded in the past.
        /// </summary>
        /// <param name="clientFolderName">The parameter clientFolderName is ignored by this connector implementation.</param>
        /// <param name="result">A list of StdElements that will get the new imported entries.</param>
        /// <returns>The list with the added contacts</returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            try
            {
                this.LogProcessingEvent("downloading contacts ...");
                this.EnsureInitialization();

                var contactsCollection = this.requester.GetContacts();
                foreach (var googleContact in contactsCollection.Entries)
                {
                    try
                    {
                        // get the SemSync Contact ID from the google entity (if there is one)
                        var semSyncIdString =
                            (from x in googleContact.ExtendedProperties where x.Name == "SemSyncId" select x.Value)
                            .FirstOrDefault();

                        // if we didn't set one, create a new Guid, otherwise reconstruct the Guid from the string stored in th Google contact
                        var semSyncId = string.IsNullOrEmpty(semSyncIdString)
                                            ? Guid.NewGuid()
                                            : new Guid(semSyncIdString);

                        // create a new contact entity
                        var stdEntry = new StdContact
                        {
                            Id   = semSyncId,
                            Name = new PersonName(googleContact.Title),
                            ExternalIdentifier = new ProfileIdentifierDictionary(ProfileIdentifierType.Google, googleContact.Id)
                        };

                        this.LogProcessingEvent("mapping contact {0} ...", stdEntry.Name.ToString());
                        googleContact.SetSyncIdentifier(semSyncId);

                        // the ForEach is an extension method that calls the lambda for each element of an IEnumerable
                        googleContact.PostalAddresses.ForEach(stdEntry.SetAddress);
                        googleContact.Organizations.ForEach(stdEntry.SetBusiness);
                        googleContact.Phonenumbers.ForEach(stdEntry.SetPhone);
                        googleContact.Emails.ForEach(stdEntry.SetEmail);
                        googleContact.IMs.ForEach(stdEntry.SetInstantMessenger);

                        // downloads the image
                        this.LogProcessingEvent("downloading picture {0} ...", stdEntry.Name.ToString());
                        stdEntry.SetPicture(googleContact, this.requester);

                        result.Add(stdEntry);
                    }
                    catch (GDataRequestException ex)
                    {
                        this.LogProcessingEvent("Error while executing client: {0}", ex.Message);
                    }
                }
            }
            catch (GDataRequestException ex)
            {
                this.LogProcessingEvent("Error while executing client: {0}", ex.Message);
            }

            return(result);
        }
コード例 #12
0
        /// <summary>
        /// Extract contact information from an Active Directory entry
        /// </summary>
        /// <param name="resultProperties"> </param>
        /// <returns> a standard contact entity </returns>
        private static StdContact ConvertToContact(PropertyCollection resultProperties)
        {
            var result = new StdContact
            {
                Id = Guid.NewGuid(),
                InternalSyncData =
                    new SyncData
                {
                    DateOfCreation   = resultProperties.GetPropDate("whencreated"),
                    DateOfLastChange = resultProperties.GetPropDate("whenchanged"),
                },
                BusinessAddressPrimary =
                    new AddressDetail
                {
                    CountryName = resultProperties.GetPropString("co"),
                    StateName   = resultProperties.GetPropString("st"),
                    PostalCode  = resultProperties.GetPropString("postalcode"),
                    CityName    = resultProperties.GetPropString("l"),
                    StreetName  = resultProperties.GetPropString("streetaddress"),
                    Phone       = new PhoneNumber(resultProperties.GetPropString("telephonenumber")),
                    Room        = resultProperties.GetPropString("physicaldeliveryofficename", "roomnumber"),
                },
                BusinessPhoneMobile    = new PhoneNumber(resultProperties.GetPropString("mobile")),
                BusinessPosition       = resultProperties.GetPropString("title"),
                BusinessCompanyName    = resultProperties.GetPropString("company"),
                BusinessDepartment     = resultProperties.GetPropString("department"),
                BusinessEmailPrimary   = resultProperties.GetPropString("mail"),
                PersonalAddressPrimary =
                    new AddressDetail
                {
                    Phone = new PhoneNumber(resultProperties.GetPropString("homephone")),
                },
                Name =
                    new PersonName
                {
                    FirstName = resultProperties.GetPropString("givenname"),
                    LastName  = resultProperties.GetPropString("sn"),
                },
                PersonGender       = SyncTools.GenderByText(resultProperties.GetPropString("personaltitle")),
                AdditionalTextData = resultProperties.GetPropString("info"),
                ImageEntries       = new List <ImageEntry>
                {
                    new ImageEntry
                    {
                        ImageData = resultProperties.GetPropBytes("thumbnailPhoto"),
                        ImageName = "ActiveDirectory",
                    }
                }
            };

            result.ExternalIdentifier.SetProfileId(ProfileIdentifierType.ActiveDirectoryId, resultProperties.GetPropString("CN"));
            result.NormalizeContent();

            return(result);
        }
コード例 #13
0
        /// <summary>
        /// Convert MeinVZ contact url to <see cref="StdContact"/>
        /// </summary>
        /// <param name="contactUrl">
        /// The contact url.
        /// </param>
        /// <returns>
        /// the downloaded information inserted into a <see cref="StdContact"/>
        /// </returns>
        private StdContact DownloadContact(string contactUrl)
        {
            var result = new StdContact();

            var content  = this.httpRequester.GetContent(contactUrl, contactUrl, string.Empty);
            var imageUrl = Regex.Match(content, this.ContactImageSelector, RegexOptions.Singleline);

            if (imageUrl != null)
            {
                var url = imageUrl.Groups[1].ToString();
                if (!string.IsNullOrEmpty(url))
                {
                    result.PictureName = url.Substring(url.LastIndexOf('/') + 1);
                    result.PictureData = this.httpRequester.GetContentBinary(url, url);
                }
            }

            foreach (Match match in Regex.Matches(content, ContactContentSelector, RegexOptions.Singleline))
            {
                var key   = match.Groups[1].ToString();
                var value = match.Groups[2].ToString();
                try
                {
                    if (key != "Geburtstag:" && value.Contains(">"))
                    {
                        value = value.Substring(value.IndexOf('>') + 1);
                    }

                    if (value.Contains("<"))
                    {
                        value = value.Substring(0, value.IndexOf('<'));
                    }

                    MapKeyValuePair(result, value, key);
                }
                catch (Exception ex)
                {
                    throw new TechnicalException(
                              "Problem mapping key value pair from web page.",
                              ex,
                              new KeyValuePair <string, object>("key", key),
                              new KeyValuePair <string, object>("value", value));
                }
            }

            result.ExternalIdentifier.SetProfileId(
                ProfileIdentifierType.MeinVZ,
                contactUrl.Substring(contactUrl.LastIndexOf("/", StringComparison.Ordinal) + 1));

            this.ThinkTime(1000);

            this.LogProcessingEvent(result, "downloaded");

            return(result);
        }
コード例 #14
0
        /// <summary>
        /// Sets the organization info including the business position.
        /// </summary>
        /// <param name="stdEntry">The std entry.</param>
        /// <param name="organization">The organization information from the google contact.</param>
        public static void SetBusiness(this StdContact stdEntry, Organization organization)
        {
            if (!organization.Primary &&
                !string.IsNullOrEmpty(stdEntry.BusinessCompanyName))
            {
                return;
            }

            stdEntry.BusinessPosition    = organization.Title;
            stdEntry.BusinessCompanyName = organization.Name;
        }
コード例 #15
0
        public void TestCategorySelectorWrite()
        {
            var contact = new StdContact();

            Tools.SetPropertyValue(contact, "Categories", "cat1|category 1|!important!");

            Assert.AreEqual("cat1|category 1|!important!", Tools.GetPropertyValueString(contact, "Categories"));
            Assert.AreEqual("cat1", contact.Categories[0]);
            Assert.AreEqual("category 1", contact.Categories[1]);
            Assert.AreEqual("!important!", contact.Categories[2]);
        }
コード例 #16
0
        /// <summary>
        /// Creates a <see cref="StdContact"/> entity with only the Xing profile ID specified for matching simulation.
        /// </summary>
        /// <param name="profileTypeId"></param>
        /// <param name="profileId">
        ///   The profile id.
        /// </param>
        /// <param name="id"> The <see cref="StdElement.Id"/>. </param>
        /// <returns> The entity created with a Xing profile id. </returns>
        private static StdContact CreateIdOnlyContact(ProfileIdentifierType profileTypeId, string profileId, string id)
        {
            var result = new StdContact
            {
                Name = new PersonName(profileId),
                Id   = new Guid(id),
                ExternalIdentifier = new ProfileIdentifierDictionary(profileTypeId, profileId),
            };

            return(result);
        }
コード例 #17
0
        public void TestCategorySelectorRead()
        {
            var contact = new StdContact {
                Categories = new List <string> {
                    "cat1", "category 1", "!important!"
                }
            };

            Assert.AreEqual("cat1", Tools.GetPropertyValueString(contact, "Categories[0]"));
            Assert.AreEqual("category 1", Tools.GetPropertyValueString(contact, "Categories[1]"));
            Assert.AreEqual("!important!", Tools.GetPropertyValueString(contact, "Categories[2]"));
            Assert.AreEqual("cat1|category 1|!important!", Tools.GetPropertyValueString(contact, "Categories"));
        }
コード例 #18
0
        /// <summary>
        /// sets the correct email address from a google contacts email
        /// </summary>
        /// <param name="stdEntry">The std entry.</param>
        /// <param name="email">The email address.</param>
        public static void SetEmail(this StdContact stdEntry, EMail email)
        {
            if (email.Home)
            {
                stdEntry.PersonalEmailPrimary = email.Address;
            }

            if (email.Work)
            {
                stdEntry.BusinessEmailPrimary = email.Address;
            }

            if (!email.Home && !email.Work && string.IsNullOrEmpty(stdEntry.PersonalEmailPrimary))
            {
                stdEntry.PersonalEmailPrimary = email.Address;
            }
        }
コード例 #19
0
        /// <summary>
        /// Performs a match by comparing email addresses
        /// </summary>
        /// <param name="element1">
        /// The first element to test.
        /// </param>
        /// <param name="element2">
        /// The second element to test.
        /// </param>
        /// <returns>
        /// true in case of a match in one or more email addresses
        /// </returns>
        private static bool IsEmailMatch(StdContact element1, StdContact element2)
        {
            if (IsValidEmailAddress(element1.PersonalEmailPrimary) &&
                element1.PersonalEmailPrimary.IsOneOf(
                    element2.PersonalEmailPrimary,
                    element2.PersonalEmailSecondary,
                    element2.BusinessEmailPrimary,
                    element2.PersonalEmailSecondary))
            {
                return(true);
            }

            if (IsValidEmailAddress(element1.PersonalEmailSecondary) &&
                element1.PersonalEmailPrimary.IsOneOf(
                    element2.PersonalEmailPrimary,
                    element2.PersonalEmailSecondary,
                    element2.BusinessEmailPrimary,
                    element2.PersonalEmailSecondary))
            {
                return(true);
            }

            if (IsValidEmailAddress(element1.BusinessEmailPrimary) &&
                element1.PersonalEmailPrimary.IsOneOf(
                    element2.PersonalEmailPrimary,
                    element2.PersonalEmailSecondary,
                    element2.BusinessEmailPrimary,
                    element2.PersonalEmailSecondary))
            {
                return(true);
            }

            if (IsValidEmailAddress(element1.BusinessEmailSecondary) &&
                element1.PersonalEmailPrimary.IsOneOf(
                    element2.PersonalEmailPrimary,
                    element2.PersonalEmailSecondary,
                    element2.BusinessEmailPrimary,
                    element2.PersonalEmailSecondary))
            {
                return(true);
            }

            return(false);
        }
コード例 #20
0
        /// <summary>
        /// Reads all data from the configured table and maps it to the <see cref="StdContact"/> entity.
        ///   This method does use an unconditional SELECT * FROM ..., so it might affect performance
        ///   in case of large result sets.
        /// </summary>
        /// <param name="clientFolderName">
        /// the configuration file for the data source
        /// </param>
        /// <param name="result">
        /// The list of elements that should get the elements. The elements
        ///   will be added to the list instead of replacing it.
        /// </param>
        /// <returns>
        /// The list with the newly added elements
        /// </returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            var description = GetDescription(clientFolderName);

            var mappings = description.ColumnDefinitions;

            using (var con = new OleDbConnection(GetConnectionString(description)))
            {
                con.Open();
                using (var cmd = con.CreateCommand())
                {
                    cmd.CommandText = GenerateSelectStatement(description);

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        var newContact = new StdContact();
                        foreach (var mappingItem in mappings)
                        {
                            try
                            {
                                var value = reader[mappingItem.Title].ToString();

                                if (mappingItem.TransformationFromDatabase != null)
                                {
                                    value =
                                        mappingItem.TransformationFromDatabase.Compile()(mappingItem, value).ToString();
                                }

                                Tools.SetPropertyValue(newContact, mappingItem.Selector, value);
                            }
                            catch (Exception ex)
                            {
                                this.LogException(ex);
                            }
                        }

                        result.Add(newContact);
                    }
                }
            }

            return(result);
        }
コード例 #21
0
        /// <summary>
        /// Creates or updates photo information for a google contact with the information found in the std-contact.
        /// </summary>
        /// <param name="googleContact">The google contact.</param>
        /// <param name="contact">The contact containing the image information.</param>
        /// <param name="credentials">The credentials providing object.</param>
        public static void UpdatePhoto(this Contact googleContact, StdContact contact, ContactClient credentials)
        {
            if (contact.PictureData == null || contact.PictureData.Length <= 0 || string.IsNullOrEmpty(googleContact.Id))
            {
                return;
            }

            var rs = new RequestSettings("Sem.Sync.Connector.Google", credentials.LogOnUserId, credentials.LogOnPassword)
            {
                AutoPaging = true
            };
            var cr = new ContactsRequest(rs);

            using (var photoStream = new MemoryStream(contact.PictureData))
            {
                for (var i = 0; i < 3; i++)
                {
                    try
                    {
                        cr.SetPhoto(googleContact, photoStream);
                        break;
                    }
                    catch (GDataRequestException ex)
                    {
                        credentials.LogError(ex);
                        if (string.IsNullOrEmpty(ex.ResponseString))
                        {
                            break;
                        }
                    }
                    catch (CaptchaRequiredException)
                    {
                        UnlockCaptch();
                    }
                    catch (Exception ex)
                    {
                        credentials.LogError(ex);
                        break;
                    }
                }
            }
        }
コード例 #22
0
        /// <summary>
        /// Adds profile ids to a contacts "contact list" with filtering its own
        /// profile id and preventing doubletts.
        /// </summary>
        /// <param name="contact"> The contact (source of the link). </param>
        /// <param name="profileIds"> The profile ids to be added as link targets. </param>
        /// <param name="baseline"> The baseline. </param>
        /// <param name="added"> The number of targets added so far. </param>
        /// <returns> The number of links added </returns>
        private int AddContactIdsToStdContact(StdContact contact, List <string> profileIds, IEnumerable <MatchingEntry> baseline, int added)
        {
            var profileIdentifierType = this.WebSideParameters.ProfileIdentifierType;

            contact.Contacts = contact.Contacts ?? new List <ContactReference>(profileIds.Count);

            foreach (var extract in profileIds)
            {
                var profileId = string.Format(this.WebSideParameters.ProfileIdFormatter, extract);
                var stdId     =
                    (from x in baseline
                     where x.ProfileId.GetProfileId(profileIdentifierType) == profileId
                     select x.Id).FirstOrDefault();

                // we ignore contacts we donn't know
                if (stdId == default(Guid))
                {
                    continue;
                }

                // lookup an existing entry in this contacts contact-list
                var contactInList = (from x in contact.Contacts where x.Target == stdId select x).FirstOrDefault();

                if (contactInList == null)
                {
                    // add a new one if no existing entry has been found
                    contactInList = new ContactReference {
                        Target = stdId
                    };
                    contact.Contacts.Add(contactInList);
                    added++;
                }

                // update the flag that this entry is a private contact
                var connectorDescriptionAttribute = this.ConnectorDescription;
                contactInList.IsPrivateContact  = connectorDescriptionAttribute.ContentIsPrivate;
                contactInList.IsBusinessContact = connectorDescriptionAttribute.ContentIsBusiness;
            }

            return(added);
        }
コード例 #23
0
        private static bool UpdateUser(StdContact newItem, DirectoryEntry user)
        {
            var oldItem = ConvertToContact(user.Properties);

            var dirty = false;

            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.Name.FirstName, x => user.SetPropertyValue("givenname", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.Name.LastName, x => user.SetPropertyValue("sn", x));

            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessAddressPrimary.CountryName, x => user.SetPropertyValue("co", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessAddressPrimary.StateName, x => user.SetPropertyValue("st", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessAddressPrimary.PostalCode, x => user.SetPropertyValue("postalcode", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessAddressPrimary.StreetName, x => user.SetPropertyValue("streetaddress", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessAddressPrimary.Phone.ToString(), x => user.SetPropertyValue("telephonenumber", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessAddressPrimary.Room, x => user.SetPropertyValue("physicaldeliveryofficename", x));

            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessPhoneMobile.ToString(), x => user.SetPropertyValue("mobile", x));

            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessPosition, x => user.SetPropertyValue("title", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessCompanyName, x => user.SetPropertyValue("company", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessDepartment, x => user.SetPropertyValue("department", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.BusinessEmailPrimary, x => user.SetPropertyValue("mail", x));

            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.PersonalAddressPrimary.Phone.ToString(), x => user.SetPropertyValue("homephone", x));
            MappingHelper.MapIfDiffers(ref dirty, oldItem, newItem, x => x.AdditionalTextData, x => user.SetPropertyValue("info", x));

            if (newItem.ImageEntries != null &&
                newItem.ImageEntries.Count > 0 &&
                newItem.ImageEntries[0] != null &&
                (oldItem.ImageEntries == null ||
                 oldItem.ImageEntries.Count == 0 ||
                 oldItem.ImageEntries[0] == null ||
                 newItem.ImageEntries[0].ImageData.Length > oldItem.ImageEntries[0].ImageData.Length))
            {
                user.Properties["thumbnailPhoto"].Value = newItem.ImageEntries[0].ImageData;
                dirty = true;
            }

            return(dirty);
        }
コード例 #24
0
        public void FunctionCallToPropertyWithTransformation()
        {
            // register the property mapping of a source and a destination
            // type with trasformations (in this case we do add a string to
            // the name to generate a calendar title of "Birthday: Riddle, Tom")
            var mapper = new Mapper();

            mapper.Register <StdContact, StdCalendarItem>(contact => contact.Id, (calendar, entity) => calendar.Id = (Guid)entity);
            mapper.Register <StdContact, StdCalendarItem>(contact => contact.GetFullName(), (calendar, entity) => calendar.Title = "Birthday: " + entity);

            // setup a source and a destination object
            var source = new StdContact {
                Name = new PersonName("Tom Riddle")
            };
            var target = new StdCalendarItem();

            // perform the mapping
            mapper.Map(source, target);

            // test it
            Assert.AreEqual(source.Id, target.Id);
            Assert.AreEqual("Birthday: " + source.GetFullName(), target.Title);
        }
コード例 #25
0
        /// <summary>
        /// writes a contact to outlook
        /// </summary>
        /// <param name="contactsEnum">
        /// The contacts enum.
        /// </param>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="skipIfExisting">
        /// The skip if existing.
        /// </param>
        /// <param name="contactsList">
        /// The contacts list.
        /// </param>
        /// <returns>
        /// a value indicating if the contact has been saved
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// in case of contactsEnum or element being null
        /// </exception>
        internal static bool WriteContactToOutlook(
            Items contactsEnum, StdContact element, bool skipIfExisting, IEnumerable <ContactsItemContainer> contactsList)
        {
            if (contactsEnum == null)
            {
                throw new ArgumentNullException("contactsEnum");
            }

            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            var outlookContact =
                (from x in contactsList where x.Id == element.Id.ToString() select x.Item).FirstOrDefault();

            if (skipIfExisting && outlookContact != null)
            {
                return(false);
            }

            if (outlookContact == null)
            {
                outlookContact = (ContactItem)contactsEnum.Add(OlItemType.olContactItem);
            }

            // convert StdContact to Outlook contact
            if (ConvertToNativeContact(element, outlookContact))
            {
                outlookContact.Save();
                GCRelevantCall();
                return(true);
            }

            GCRelevantCall();
            return(false);
        }
コード例 #26
0
ファイル: CheckAgent.cs プロジェクト: Interface007/Sem.Sync
        /// <summary>
        /// Compares two contact instances and reports the difference.
        /// </summary>
        /// <param name="baselineContact">
        /// The contact from the base line (how it has been read last time).
        /// </param>
        /// <param name="currentContact">
        /// The contact currently read from the source.
        /// </param>
        private void CompareEntities(StdContact baselineContact, StdContact currentContact)
        {
            var changes =
                SyncTools.DetectConflicts(
                    SyncTools.BuildConflictTestContainerList(
                        new List <StdElement>(new[] { currentContact }),
                        new List <StdElement>(new[] { baselineContact }),
                        null,
                        typeof(StdContact)),
                    true);

            var changeSet = new ChangeInfo();

            foreach (var change in changes)
            {
                changeSet.ChangedProperties.Add(
                    change.PathToProperty + " " + change.PropertyConflict + ": " + change.SourceElement);
            }

            if (changeSet.ChangedProperties.Count <= 0)
            {
                return;
            }

            changeSet.DisplayName = string.Format(
                CultureInfo.InvariantCulture,
                "{0} has {1} properties changed.",
                baselineContact.Name,
                changeSet.ChangedProperties.Count);
            this.DetectedChanges.Add(changeSet);

            while (this.DetectedChanges.Count > this.MaxEntries)
            {
                this.DetectedChanges.RemoveAt(0);
            }
        }
コード例 #27
0
        private static bool ConvertToNativeContact(StdContact stdNewContact, ContactItem outlookContact)
        {
            var dirty         = false;
            var stdOldContact = ConvertToStandardContact(outlookContact, null);
            var gender        = stdNewContact.PersonGender == Gender.Unspecified
                             ? OlGender.olUnspecified
                             : ((stdNewContact.PersonGender == Gender.Male) ? OlGender.olMale : OlGender.olFemale);

            SyncTools.ClearNulls(stdNewContact, typeof(StdContact));
            SyncTools.ClearNulls(stdOldContact, typeof(StdContact));

            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.DateOfBirth, x => outlookContact.Birthday = x);
            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.PersonGender, x => outlookContact.Gender = gender);

            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.Name.FirstName, x => outlookContact.FirstName = x);
            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.Name.MiddleName, x => outlookContact.MiddleName = x);
            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.Name.LastName, x => outlookContact.LastName = x);
            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.Name.AcademicTitle, x => outlookContact.Title = x);

            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessEmailPrimary,
                x => outlookContact.Email2Address = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalEmailPrimary,
                x => outlookContact.Email1Address = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessHomepage,
                x => outlookContact.BusinessHomePage = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalHomepage,
                x => outlookContact.PersonalHomePage = x);
            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.BusinessCompanyName, x => outlookContact.CompanyName = x);
            MappingHelper.MapIfDiffers(
                ref dirty, stdNewContact, stdOldContact, x => x.BusinessPosition, x => outlookContact.JobTitle = x);

            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessAddressPrimary.CityName,
                x => outlookContact.BusinessAddressCity = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessAddressPrimary.CountryName,
                x => outlookContact.BusinessAddressCountry = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessAddressPrimary.PostalCode,
                x => outlookContact.BusinessAddressPostalCode = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessAddressPrimary.StateName,
                x => outlookContact.BusinessAddressState = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessAddressPrimary.StreetName,
                x => outlookContact.BusinessAddressStreet = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessAddressPrimary.Phone.ToString(),
                x => outlookContact.BusinessTelephoneNumber = x);

            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalAddressPrimary.CityName,
                x => outlookContact.HomeAddressCity = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalAddressPrimary.CountryName,
                x => outlookContact.HomeAddressCountry = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalAddressPrimary.PostalCode,
                x => outlookContact.HomeAddressPostalCode = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalAddressPrimary.StateName,
                x => outlookContact.HomeAddressState = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalAddressPrimary.StreetName,
                x => outlookContact.HomeAddressStreet = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalAddressPrimary.Phone.ToString(),
                x => outlookContact.HomeTelephoneNumber = x);

            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalPhoneMobile.ToString(),
                x => outlookContact.MobileTelephoneNumber = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.BusinessPhoneMobile.ToString(),
                x => outlookContact.Business2TelephoneNumber = x);
            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.PersonalInstantMessengerAddresses.MsnMessenger,
                x => outlookContact.IMAddress = x);

            MappingHelper.MapIfDiffers(
                ref dirty,
                stdNewContact,
                stdOldContact,
                x => x.AdditionalTextData.Replace("\r\n", "\n"),
                x => outlookContact.Body = x);

            if (stdOldContact.Id != stdNewContact.Id)
            {
                outlookContact.UserProperties.Add(ContactIdOutlookPropertyName, OlUserPropertyType.olText, true, 1).
                Value = stdNewContact.Id.ToString();
                dirty = true;
            }

            // import pictures if we have more data inside the new contact
            if (stdNewContact.PictureData != null && stdNewContact.PictureData.Length > stdOldContact.PictureData.Length)
            {
                var fullName = Path.GetTempFileName() + ".jpg";
                File.WriteAllBytes(fullName, stdNewContact.PictureData);
                outlookContact.AddPicture(fullName);
                File.Delete(fullName);
                dirty = true;
            }

            if (stdNewContact.Categories != null &&
                (stdOldContact.Categories == null || stdNewContact.Categories.Count != stdOldContact.Categories.Count))
            {
                outlookContact.Categories = string.Join(
                    ";", stdNewContact.Categories.MergeList(stdOldContact.Categories));
                dirty = true;
            }

            return(dirty);
        }
コード例 #28
0
        /// <summary>
        /// Converts an outlook contact to a standard contact.
        /// </summary>
        /// <param name="outlookContact">
        /// The outlook contact to be converted.
        /// </param>
        /// <param name="contactList">
        /// The contact List to lookup duplicates.
        /// </param>
        /// <returns>
        /// a new standard contact
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// if the outlook contact is null
        /// </exception>
        internal static StdContact ConvertToStandardContact(
            ContactItem outlookContact, IEnumerable <StdContact> contactList)
        {
            if (outlookContact == null)
            {
                throw new ArgumentNullException("outlookContact");
            }

            // generate the new id this contact will get in case there is no contact id in outlook
            var newId = GetStandardContactId(outlookContact, contactList);

            // read the picture data and name of this contact
            string pictureName;
            var    pictureData = SaveOutlookContactPicture(outlookContact, out pictureName);

            StdContact returnValue;

            try
            {
                // create a new contact and assign the corresponding values from the outlook contact
                returnValue = new StdContact
                {
                    Id = newId,
                    InternalSyncData =
                        new SyncData
                    {
                        DateOfLastChange = outlookContact.LastModificationTime,
                        DateOfCreation   = outlookContact.CreationTime
                    },
                    PersonGender =
                        (outlookContact.Gender == OlGender.olMale)
                                ? Gender.Male
                                : (outlookContact.Gender == OlGender.olFemale)
                                      ? Gender.Female
                                      : SyncTools.GenderByText(outlookContact.Title),
                    DateOfBirth = outlookContact.Birthday,
                    Name        =
                        new PersonName
                    {
                        FirstName     = outlookContact.FirstName,
                        LastName      = outlookContact.LastName,
                        MiddleName    = outlookContact.MiddleName,
                        AcademicTitle =
                            outlookContact.Title.IsOneOf("Herr", "Mr.", "Frau", "Mrs.")
                                            ? null
                                            : outlookContact.Title,
                    },
                    PersonalAddressPrimary =
                        new AddressDetail
                    {
                        Phone =
                            (!string.IsNullOrEmpty(outlookContact.HomeTelephoneNumber))
                                            ? new PhoneNumber(outlookContact.HomeTelephoneNumber)
                                            : null,
                        CountryName = outlookContact.HomeAddressCountry,
                        PostalCode  = outlookContact.HomeAddressPostalCode,
                        CityName    = outlookContact.HomeAddressCity,
                        StateName   = outlookContact.HomeAddressState,
                        StreetName  = outlookContact.HomeAddressStreet,
                    },
                    PersonalHomepage     = outlookContact.PersonalHomePage,
                    PersonalEmailPrimary = outlookContact.Email1Address,
                    PersonalInstantMessengerAddresses =
                        string.IsNullOrEmpty(outlookContact.IMAddress)
                                ? null
                                : new InstantMessengerAddresses(outlookContact.IMAddress),
                    PersonalPhoneMobile =
                        (!string.IsNullOrEmpty(outlookContact.MobileTelephoneNumber))
                                ? new PhoneNumber(outlookContact.MobileTelephoneNumber)
                                : null,
                    BusinessCompanyName    = outlookContact.CompanyName,
                    BusinessPosition       = outlookContact.JobTitle,
                    BusinessAddressPrimary =
                        new AddressDetail
                    {
                        Phone =
                            (!string.IsNullOrEmpty(outlookContact.BusinessTelephoneNumber))
                                            ? new PhoneNumber(outlookContact.BusinessTelephoneNumber)
                                            : null,
                        CountryName = outlookContact.BusinessAddressCountry,
                        PostalCode  = outlookContact.BusinessAddressPostalCode,
                        CityName    = outlookContact.BusinessAddressCity,
                        StateName   = outlookContact.BusinessAddressState,
                        StreetName  = outlookContact.BusinessAddressStreet,
                    },
                    BusinessHomepage     = outlookContact.BusinessHomePage,
                    BusinessEmailPrimary = outlookContact.Email2Address,
                    BusinessPhoneMobile  =
                        (!string.IsNullOrEmpty(outlookContact.Business2TelephoneNumber))
                                ? new PhoneNumber(outlookContact.Business2TelephoneNumber)
                                : null,
                    AdditionalTextData = outlookContact.Body,
                    PictureName        = pictureName,
                    PictureData        = pictureData
                };
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == -2147467260)
                {
                    return(null);
                }

                throw;
            }

            if (!string.IsNullOrEmpty(outlookContact.Categories))
            {
                returnValue.Categories = MergeStrings(returnValue.Categories, outlookContact.Categories);
            }

            if (string.IsNullOrEmpty(returnValue.PersonalAddressPrimary.ToString()))
            {
                returnValue.PersonalAddressPrimary = null;
            }

            if (string.IsNullOrEmpty(returnValue.BusinessAddressPrimary.ToString()))
            {
                returnValue.PersonalAddressPrimary = null;
            }

            // return the newly generated standard contact
            return(returnValue);
        }
コード例 #29
0
        //private NotesDatabase _serverDatabase = null;
        //private NotesView _peopleView = null;
        //private string _lotusCientPassword = null;
        //private string _lotusnotesserverName = null;
        //private bool _IsfetchServerData = false;

        #region Methods

        /// <summary>
        /// Overrides virtual read method for full list of elements
        /// </summary>
        /// <param name="clientFolderName">
        /// the information from where inside the source the elements should be read -
        ///   This does not need to be a real "path", but need to be something that can be expressed as a string
        /// </param>
        /// <param name="result">
        /// The list of elements that should get the elements. The elements should be added to
        ///   the list instead of replacing it.
        /// </param>
        /// <returns>
        /// The list with the newly added elements
        /// </returns>
        protected override List <StdElement> ReadFullList(string clientFolderName, List <StdElement> result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            string currentElementName = string.Empty;

            try
            {
                this.LogProcessingEvent(Resources.uiLogginIn);
                //Lotus Notes Object Creation
                _lotesNotesSession = new Domino.NotesSessionClass();
                //Initializing Lotus Notes Session
                _lotesNotesSession.Initialize(this.LogOnPassword);                       //Passwort
                _localDatabase = _lotesNotesSession.GetDatabase("", "names.nsf", false); //Database for Contacts default names.nsf

                this.LogProcessingEvent(Resources.uiPreparingList);

                string viewname = "$People";
                _contactsView = _localDatabase.GetView(viewname);
                // TODO: implement reading from the Lotus Notes server and map the entities to StdContact instances
                if (_contactsView == null)
                {
                    this.LogProcessingEvent(Resources.uiNoViewFound, viewname);
                }
                else
                {
                    NotesViewEntryCollection notesViewCollection = _contactsView.AllEntries;
                    //ArrayList notesUIDSList = new ArrayList();
                    for (int rowCount = 1; rowCount <= notesViewCollection.Count; rowCount++)
                    {
                        //Get the nth entry of the selected view according to the iteration.
                        NotesViewEntry viewEntry = notesViewCollection.GetNthEntry(rowCount);
                        //Get the first document of particular entry.
                        NotesDocument document = viewEntry.Document;

                        object documentItems = document.Items;
                        Array  itemArray     = (System.Array)documentItems;

                        StdContact elem = new StdContact();
                        PersonName name = new PersonName();
                        elem.Name = name;
                        AddressDetail businessAddress = new AddressDetail();
                        elem.BusinessAddressPrimary = businessAddress;
                        AddressDetail address = new AddressDetail();
                        elem.PersonalAddressPrimary = address;

                        elem.ExternalIdentifier.SetProfileId(ProfileIdentifierType.LotusNotesId, document.NoteID);

                        for (int itemCount = 0; itemCount < itemArray.Length; itemCount++)
                        {
                            NotesItem notesItem = (Domino.NotesItem)itemArray.GetValue(itemCount);
                            string    itemname  = notesItem.Name;
                            string    text      = notesItem.Text;
                            switch (notesItem.Name)
                            {
                            //Name
                            case "FirstName":
                                name.FirstName = notesItem.Text;
                                break;

                            case "LastName":
                                name.LastName = notesItem.Text;
                                break;

                            case "Titel":
                            {
                                if (notesItem.Text != "0")
                                {
                                    name.AcademicTitle = notesItem.Text;
                                }
                            }
                            break;

                            //Geburtstag
                            case "Birthday":
                                DateTime dt;
                                if (DateTime.TryParse(notesItem.Text, out dt))
                                {
                                    elem.DateOfBirth = dt;
                                }
                                break;

                            case "Comment":
                                elem.AdditionalTextData = notesItem.Text;
                                break;

                            //Business adress
                            case "InternetAddress":
                                elem.BusinessEmailPrimary = notesItem.Text;
                                break;

                            case "OfficePhoneNumber":
                                businessAddress.Phone = new PhoneNumber();
                                businessAddress.Phone.DenormalizedPhoneNumber = notesItem.Text;
                                break;

                            case "OfficeStreetAddress":
                                businessAddress.StreetName = notesItem.Text;
                                break;

                            case "OfficeState":
                                businessAddress.StateName = notesItem.Text;
                                break;

                            case "OfficeCity":
                                businessAddress.CityName = notesItem.Text;
                                break;

                            case "OfficeZIP":
                                businessAddress.PostalCode = notesItem.Text;
                                break;

                            case "OfficeCountry":
                                businessAddress.CountryName = notesItem.Text;
                                break;

                            //Business
                            case "Department":
                                elem.BusinessDepartment = notesItem.Text;
                                break;

                            case "CompanyName":
                                elem.BusinessCompanyName = notesItem.Text;
                                break;

                            case "JobTitle":
                                elem.BusinessPosition = notesItem.Text;
                                break;

                            case "WebSite":
                                elem.PersonalHomepage = notesItem.Text;
                                break;

                            //Address
                            case "PhoneNumber":
                                address.Phone = new PhoneNumber();
                                address.Phone.DenormalizedPhoneNumber = notesItem.Text;
                                break;

                            case "StreetAddress":
                                address.StreetName = notesItem.Text;
                                break;

                            case "State":
                                address.StateName = notesItem.Text;
                                break;

                            case "City":
                                address.CityName = notesItem.Text;
                                break;

                            case "Zip":
                                address.PostalCode = notesItem.Text;
                                break;

                            case "country":
                                address.CountryName = notesItem.Text;
                                break;

                            //Mobile
                            case "CellPhoneNumber":
                                elem.PersonalPhoneMobile = new PhoneNumber();
                                elem.PersonalPhoneMobile.DenormalizedPhoneNumber = notesItem.Text;
                                break;

                            //Categories
                            case "Categories":
                                elem.Categories = new List <string>(notesItem.Text.Split(';'));
                                break;
                            }
                        }
                        this.LogProcessingEvent("mapping contact {0} ...", elem.Name.ToString());
                        result.Add(elem);
                    }

                    this.ThinkTime(1000);
                    result.Sort();
                }
            }
            catch (Exception ex)
            {
                this.LogProcessingEvent(
                    string.Format(CultureInfo.CurrentCulture, Resources.uiErrorAtName, currentElementName, ex.Message));
            }
            finally
            {
                //outlookNamespace.Logoff();
                _lotesNotesSession = null;
            }
            return(result);
        }
コード例 #30
0
ファイル: DgmlNode.cs プロジェクト: Interface007/Sem.Sync
 /// <summary>
 /// Initializes a new instance of the <see cref="Node"/> class.
 /// </summary>
 /// <param name="stdContact"> The <see cref="StdContact"/> to generate the node for. </param>
 /// <param name="category"> The category for this node. </param>
 public Node(StdContact stdContact, string category)
     : this(stdContact as StdElement)
 {
     this.Category = category;
 }