Beispiel #1
0
        private static User _parseUser(JObject data)
        {
            User    user     = new User();
            JObject content  = (JObject)data["profile"]["content"];
            JObject userData = (JObject)data["profile"]["user"];

            user.userId    = (string)data["profile"]["obfuscatedGaiaId"];
            user.name      = (string)data["profile"]["displayName"];
            user.given     = (string)userData["name"]["given"];
            user.family    = (string)userData["name"]["family"];
            user.avatarUrl = Other.parseLink((string)content["photoUrl"]);
            user.gender    = (string)userData["gender"]["value"];

            if (userData["otherNames"] != null)
            {
                foreach (var nick in (JArray)userData["otherNames"]["name"])
                {
                    user.nicks.Add((string)nick["value"]);
                }
            }

            user.occupation     = (string)userData["occupation"]["value"];
            user.skills         = (string)userData["skills"]["value"];
            user.braggingRights = (string)userData["braggingRights"]["value"];
            user.tagline        = (string)content["tagLine"]["value"];
            user.intro          = (string)content["introduction"]["value"];

            if (userData["employments"] != null)
            {
                foreach (var employment in userData["employments"]["employment"])
                {
                    User.HistoryElement element = new User.HistoryElement();
                    element.name  = (string)employment["employer"];
                    element.title = (string)employment["title"];
                    if (employment["dateInfo"] != null)
                    {
                        if (employment["dateInfo"]["end"] != null)
                        {
                            element.end = //((int)employment["dateInfo"]["end"]["day"]).ToString() + "-" +
                                          //((int)employment["dateInfo"]["end"]["month"]).ToString() + "-" +
                                          ((int)employment["dateInfo"]["end"]["year"]).ToString();
                        }
                        if (employment["dateInfo"]["start"] != null)
                        {
                            element.start = //((int)employment["dateInfo"]["start"]["day"]).ToString() + "-" +
                                            //((int)employment["dateInfo"]["start"]["month"]).ToString() + "-" +
                                            ((int)employment["dateInfo"]["start"]["year"]).ToString();
                        }
                    }
                    element.description = (string)employment["description"];
                    user.employment.Add(element);
                }
            }

            if (userData["educations"] != null)
            {
                foreach (var school in userData["educations"]["education"])
                {
                    User.HistoryElement element = new User.HistoryElement();
                    element.name        = (string)school["school"];
                    element.title       = (string)school["majorConcentration"];
                    element.description = (string)school["description"];

                    if (school["dateInfo"] != null)
                    {
                        if (school["dateInfo"]["end"] != null)
                        {
                            element.end = //((int)school["dateInfo"]["end"]["day"]).ToString() + "-" +
                                          //((int)school["dateInfo"]["end"]["month"]).ToString() + "-" +
                                          ((int)school["dateInfo"]["end"]["year"]).ToString();
                        }
                        if (school["dateInfo"]["start"] != null)
                        {
                            element.start = //((int)school["dateInfo"]["start"]["day"]).ToString() + "-" +
                                            //((int)school["dateInfo"]["start"]["month"]).ToString() + "-" +
                                            ((int)school["dateInfo"]["start"]["year"]).ToString();
                        }
                    }
                    user.education.Add(element);
                }
            }

            if (userData["locations"] != null)
            {
                user.mapUrl          = Other.parseLink((string)userData["locations"]["locationMapUrl"]);
                user.currentLocation = (string)userData["locations"]["currentLocation"];
                if (userData["locations"]["otherLocation"] != null)
                {
                    foreach (var other in userData["locations"]["otherLocation"])
                    {
                        user.olderLocation.Add((string)other);
                    }
                }
            }

            if (content["links"] != null)
            {
                foreach (var l in content["links"]["link"])
                {
                    User.Link link = new User.Link();
                    link.link       = (string)(l["normalizedUri"].First());
                    link.faviconUrl = Other.parseLink((string)l["faviconImgUrl"]);
                    link.label      = (string)l["label"];
                    link.rel        = (string)l["rel"];
                    //link.type = (string)l[]
                    switch ((string)l["type"])
                    {
                    case "ME": user.links.Add(link);
                        break;

                    case "CONTRIBUTOR": user.contributeTo.Add(link);
                        break;

                    case "OTHER": user.otherProfiles.Add(link);
                        break;
                    }
                    user.otherProfiles.Add(link);
                }
            }

            user.backgroundUrl = (string)content["scrapbook"]["defaultCoverPhotoUrl"];

            if (content["contacts"] != null)
            {
                if (content["contacts"]["phone"] != null)
                {
                    foreach (var item in content["contacts"]["phone"])
                    {
                        User.Contact contact = new User.Contact();
                        contact.value = (string)item["value"];
                        contact.type  = (string)item["type"];
                        user.phone.Add(contact);
                    }
                }

                if (content["contacts"]["address"] != null)
                {
                    foreach (var item in content["contacts"]["address"])
                    {
                        User.Contact address = new User.Contact();
                        address.value = (string)item["value"];
                        user.address.Add(address);
                    }
                }
                if (content["contacts"]["instantMessage"] != null)
                {
                    foreach (var item in content["contacts"]["instantMessage"])
                    {
                        User.Contact im = new User.Contact();
                        im.value = (string)item["value"];
                        //contact.type = (string)item["type"];
                        im.protocol = (string)item["protocol"];
                        user.IM.Add(im);
                    }
                }
            }

            user.relationship = (string)userData["relationshipStatus"]["value"];

            if (userData["relationshipInterests"]["interest"] != null)
            {
                foreach (var interest in userData["relationshipInterests"]["interest"])
                {
                    user.lookingFor.Add((string)interest["value"]);
                }
            }
            return(user);
        }
Beispiel #2
0
        static async Task <JObject> buildPost(string content, List <AclItem> list, string link, string emoticon, string reshareId, Location.Place place, string imageContent)
        {
            JObject json = new JObject(
                new JProperty("updateText", content),
                new JProperty("externalId", Other.getTicks().ToString() + ":" + PasswordGenerator(32, false)),
                new JProperty("sharingRoster", new JObject(
                                  new JProperty("sharingTargetId", _getAclItems(list))
                                  )
                              ));
            var square = (from item in list
                          where item.extraId != null
                          select item).FirstOrDefault();

            if (square != null)
            {
                json["squareStreams"] = new JArray(new JObject(new JProperty("squareId", square.id), new JProperty("streamId", square.extraId)));
            }
            if (link != null)
            {
                json["embed"] = await getMedia(link);
            }
            if (emoticon != null)
            {
                json["embed"] = new JObject(
                    new JProperty("emotishare", new JObject(
                                      new JProperty("emotion", emoticon.ToUpper()),
                                      new JProperty("url", "http://www.gstatic.com/s2/oz/images/emotishare/hdpi/" + emoticon + "_image.gif"),
                                      new JProperty("proxiedImage", new JObject(
                                                        new JProperty("imageUrl", "http://www.gstatic.com/s2/oz/images/emotishare/hdpi/" + emoticon + "_image.gif")
                                                        ))
                                      )),
                    new JProperty("thing", new JObject(
                                      new JProperty("url", "http://www.gstatic.com/s2/oz/images/emotishare/hdpi/" + emoticon + "_image.gif"),
                                      new JProperty("imageUrl", "http://www.gstatic.com/s2/oz/images/emotishare/hdpi/" + emoticon + "_image.gif"),
                                      new JProperty("name", emoticon.ToUpperInvariant())
                                      )),
                    new JProperty("type", new JArray(
                                      "EMOTISHARE",
                                      "THING")
                                  ));
            }
            if (reshareId != null)
            {
                json["resharedUpdateId"] = reshareId;
            }
            if (place != null)
            {
                /*
                 * "latitudeE7":516207510,
                 * "locationTag":"Widok, Ostrów Wielkopolski, wielkopolskie",
                 * "longitudeE7":177878380
                 *
                 */
                json["location"] = new JObject(
                    new JProperty("latitudeE7", place.latitude),
                    new JProperty("locationTag", place.locationTag),
                    new JProperty("longitudeE7", place.longitude));
            }
            if (imageContent != null)
            {
                /*
                 * "imageStatus":"1",
                 * "mediaType":"1",
                 * "timestamp":-{"creationTimestampMs":1.406375684079E12
                 * }
                 */
                json["photosShareData"] = new JObject(
                    new JProperty("mediaRef", new JArray(
                                      new JObject(
                                          new JProperty("clientAssignedUniqueId", "cs_01_" + PasswordGenerator(32, false)),
                                          new JProperty("imageData", imageContent),
                                          new JProperty("imageStatus", "1"),
                                          new JProperty("mediaType", "1")
                                          )
                                      )
                                  ));
            }
            return(json);
        }