Пример #1
0
        /// <summary>
        /// Should return information about the addresses
        /// </summary>
        /// <param name="hashedAddresses"></param>
        /// <returns></returns>
        public string GetPeopleDetails(string hashedAddresses)
        {
            var addresses = HelperMethods.DeserializeStringToObject<OSCSchema2.hashedAddresses>(hashedAddresses);

            Debug.WriteLine("ISocialSession2::GetPeopleDetails called for personsAddresses");
            foreach (var line in addresses.personAddresses)
                Debug.WriteLine("\t" + line.index + ": " + String.Join(", ", line.hashedAddress));

            var resultList = new List<OSCSchema.personType>();
            foreach (var personAddress in addresses.personAddresses) {
                if (personAddress.hashedAddress.Length == 0) continue;
                try {
                    // find gravatar for hashed addresses
                    var response = _gravatarService.Exists(personAddress.hashedAddress, true);
                    var index = HelperMethods.GetTrueIndex(response.MultipleOperationResponse);

                    // no gravatar found
                    if (index == -1) continue;

                    // get gravatar profile
                    var profile = GravatarService.GetGravatarProfile(personAddress.hashedAddress[index], true);
                    if (profile == null)
                        resultList.Add(new OSCSchema.personType {
                            userID = personAddress.hashedAddress[index],
                            pictureUrl = GravatarService.GetGravatarUrlForAddress(personAddress.hashedAddress[index], true),

                            index = personAddress.index,
                            indexSpecified = true
                        });
                    else
                        resultList.Add(new OSCSchema.personType {
                            userID = personAddress.hashedAddress[index],
                            pictureUrl = profile.ThumbnailUrl,
                            city = profile.CurrentLocation,
                            firstName = profile.GivenName,
                            lastName = profile.FamilyName,
                            nickname = profile.PreferredUsername,

                            index = personAddress.index,
                            indexSpecified = true
                        });
                } catch(Exception e) {
                    Debug.WriteLine(e.ToString());
                }
            }

            var friends = new OSCSchema.friends {person = resultList.ToArray()};

            var result = HelperMethods.SerializeObjectToString(friends);
            Debug.WriteLine(result);
            return result;
        }
Пример #2
0
        /// <summary>
        /// Should return information about the addresses
        /// </summary>
        /// <param name="hashedAddresses"></param>
        /// <returns></returns>
        public string GetPeopleDetails(string hashedAddresses)
        {
            var addresses = HelperMethods.DeserializeStringToObject <OSCSchema2.hashedAddresses>(hashedAddresses);

            Debug.WriteLine("ISocialSession2::GetPeopleDetails called for personsAddresses");
            foreach (var line in addresses.personAddresses)
            {
                Debug.WriteLine("\t" + line.index + ": " + String.Join(", ", line.hashedAddress));
            }

            var resultList = new List <OSCSchema.personType>();

            foreach (var personAddress in addresses.personAddresses)
            {
                if (personAddress.hashedAddress.Length == 0)
                {
                    continue;
                }
                try {
                    // find gravatar for hashed addresses
                    var response = _gravatarService.Exists(personAddress.hashedAddress, true);
                    if (response.IsError)
                    {
                        Debug.WriteLine("Encountered error when calling gravatar: " + response.ErrorCode);
                        continue;
                    }
                    var index = HelperMethods.GetTrueIndex(response.MultipleOperationResponse);

                    // no gravatar found
                    if (index == -1)
                    {
                        continue;
                    }

                    // get gravatar profile
                    var profile = GravatarService.GetGravatarProfile(personAddress.hashedAddress[index], true);
                    if (profile == null)
                    {
                        resultList.Add(new OSCSchema.personType {
                            userID     = personAddress.hashedAddress[index],
                            pictureUrl = GravatarService.GetGravatarUrlForAddress(personAddress.hashedAddress[index], true),

                            index          = personAddress.index,
                            indexSpecified = true
                        });
                    }
                    else
                    {
                        resultList.Add(new OSCSchema.personType {
                            userID     = personAddress.hashedAddress[index],
                            pictureUrl = profile.ThumbnailUrl,
                            city       = profile.CurrentLocation,
                            firstName  = profile.GivenName,
                            lastName   = profile.FamilyName,
                            nickname   = profile.PreferredUsername,

                            index          = personAddress.index,
                            indexSpecified = true
                        });
                    }
                } catch (Exception e) {
                    Debug.WriteLine(e.ToString());
                }
            }


            var friends = new OSCSchema.friends {
                person = resultList.ToArray()
            };

            var result = HelperMethods.SerializeObjectToString(friends);

            Debug.WriteLine(result);
            return(result);
        }