// Обработчик данных из ок private void FromOk(JToken user_data) { ok_id = user_data["uid"].ToString(); first_name = user_data["first_name"].ToString(); last_name = user_data["last_name"].ToString(); sex = user_data["gender"].ToString() == "male" ? true : false; //domain = user_data["domain"].ToString(); city = new City(); social = new Social(); contacts = new Contacts(); if (user_data["birthday"] != null) { int[] splited_date = user_data["birthday"].ToString().Split('-').Select(Int32.Parse).ToArray(); { try { bdate = (splited_date.Length == 3) ? new DateTime(splited_date[0], splited_date[1], splited_date[2]) : new DateTime(DateTime.MinValue.Year, splited_date[0], splited_date[1]); } catch (ArgumentOutOfRangeException) { Console.WriteLine("Невозможно получить год рождения id:" + user_data["uid"] + " bdate:" + user_data["birthday"]); } } } if (user_data["location"] != null) { city.city_id = -1; city.city_title = user_data["location"]["city"].ToString(); } //contacts.mobile_phone = null; //contacts.home_phone = null; contacts.emails = new HashSet <string>(); contacts.emails.Add(user_data["email"] != null ? user_data["email"].ToString() : null); contacts.sites = new HashSet <string>(); //social.instagram = user_data["instagram"] != null ? user_data["instagram"].ToString() : null; //social.skype = user_data["skype"] != null ? user_data["skype"].ToString() : null; //social.facebook = user_data["facebook"] != null ? user_data["facebook"].ToString() : null; //social.livejournal = user_data["livejournal"] != null ? user_data["livejournal"].ToString() : null; //social.twitter = user_data["twitter"] != null ? user_data["twitter"].ToString() : null; if (user_data["pic128x128"].ToString() == "https://i.mycdn.me/res/stub_128x128.gif") { // TODO мб что-нибудь другое юзать photo_100 = "http://asiamountains-hotels.com/am2/wp-content/themes/asiamountainshotel/images/noavatar.png"; } else { photo_100 = user_data["pic128x128"].ToString(); } // TODO Пока поставим, что они из миэта universities = new List <University>(); University university = new University(); university.university_id = 241; university.university_name = "МИЭТ"; universities.Add(university); arrived_from = "Ok"; // Вычисляем плюсабилити CalcPlausibility(); }
// Обработчик данных из вк private void FromVk(JToken user_data) { vk_id = (int)user_data["id"]; first_name = user_data["first_name"].ToString(); last_name = user_data["last_name"].ToString(); sex = (int)user_data["sex"] == 2 ? true : false; domain = user_data["domain"].ToString(); city = new City(); social = new Social(); contacts = new Contacts(); if (user_data["bdate"] != null) { int[] splited_date = user_data["bdate"].ToString().Split('.').Select(Int32.Parse).ToArray(); { try { bdate = (splited_date.Length == 3) ? new DateTime(splited_date[2], splited_date[1], splited_date[0]) : new DateTime(DateTime.MinValue.Year, splited_date[1], splited_date[0]); } catch (ArgumentOutOfRangeException) { Console.WriteLine("Невозможно получить год рождения id:" + user_data["id"] + " bdate:" + user_data["bdate"]); } } } if (user_data["city"] != null) { city.city_id = (int)user_data["city"]["id"]; city.city_title = user_data["city"]["title"].ToString(); } contacts.mobile_phone = user_data["mobile_phone"] != null && user_data["mobile_phone"].ToString().Length > 8 ? Regex.Replace(user_data["mobile_phone"].ToString(), @"\t|\n|\r", "") : null; contacts.home_phone = user_data["home_phone"] != null && user_data["home_phone"].ToString().Length > 8 ? Regex.Replace(user_data["home_phone"].ToString(), @"\t|\n|\r", "") : null; contacts.emails = new HashSet <string>(); contacts.emails.Add(user_data["email"] != null ? user_data["email"].ToString() : null); contacts.sites = new HashSet <string>(); social.instagram = user_data["instagram"] != null ? user_data["instagram"].ToString() : null; social.skype = user_data["skype"] != null ? user_data["skype"].ToString() : null; social.facebook = user_data["facebook"] != null ? user_data["facebook"].ToString() : null; social.livejournal = user_data["livejournal"] != null ? user_data["livejournal"].ToString() : null; social.twitter = user_data["twitter"] != null ? user_data["twitter"].ToString() : null; photo_100 = user_data["photo_100"].ToString(); universities = new List <University>(); if (user_data["universities"] != null) { foreach (JToken university_data in user_data["universities"]) { if (university_data.Type != JTokenType.Null) { AddUniversity(university_data); } } } if (user_data["university"] != null) { AddUniversity(user_data); } if (user_data["occupation"] != null && user_data["occupation"]["type"].ToString() == "university") { University occupation = new University(); occupation.university_id = (int)user_data["occupation"]["id"]; occupation.university_name = user_data["occupation"]["name"].ToString(); universities.Add(occupation); } arrived_from = user_data["arrived_from"].ToString(); // Вычисляем плюсабилити CalcPlausibility(); }