/// <summary> /// 将新浪返回的动态类转换为Author类 /// </summary> /// <param name="user">动态类用户</param> /// <param name="source">用户来源</param> /// <returns>转换后的用户</returns> public static Author ConvertToAuthor(dynamic user, Enums.AuthorSource source) { Author author = new Author(); #region 注册信息 try { author.AuthorID = user.id; author.AuthorName = user.screen_name; //是昵称还是? author.RealName = user.name; author.Certification = Utilities.GetCertificationType(user.verified_type, user.verified); author.CertificationInfo = user.verified_reason; author.Gender = Utilities.GetGender(user.gender); author.RegisterTime = Utilities.ParseToDateTime(user.created_at); author.RegionID = RegionDBManager.GetRegionID(user.location); author.Description = user.description; author.AuthorImg = user.profile_image_url; author.Homepage = user.profile_url; if (!string.IsNullOrEmpty(author.Homepage) && !author.Homepage.Contains("http:")) { if (author.Homepage.Contains('/')) { author.Homepage = "http://weibo.com/" + author.Homepage; } else { author.Homepage = "http://blog.sina.com.cn/" + author.Homepage; } } } catch (Exception) { } #endregion #region 行为数据 try { author.FansCount = int.Parse(user.followers_count); author.FollowCount = int.Parse(user.friends_count); author.CloseFriendsCount = int.Parse(user.bi_followers_count); author.PostCount = int.Parse(user.statuses_count); author.AvgForward = author.AvgReply = author.AvgFansCountOfFans; } catch (Exception) { } #endregion SetAuthorCrawlInfo(author, source); return(author); }
/// <summary> /// 将新浪返回的用户类型转换为Author类型 /// </summary> /// <param name="user">新浪返回的用户</param> /// <param name="source">用户来源</param> /// <returns>转换后的用户</returns> public static Author ConvertToAuthor(NetDimension.Weibo.Entities.user.Entity user, Enums.AuthorSource source) { Author author = new Author(); #region 注册信息 author.AuthorID = user.ID; author.AuthorName = user.ScreenName; author.RealName = user.Name; author.Certification = Utilities.GetCertificationType(user.VerifiedType, user.Verified); author.CertificationInfo = user.VerifiedReason; author.Gender = Utilities.GetGender(user.Gender); author.RegionID = RegionDBManager.GetRegionID(user.Location); author.Description = user.Description; author.AuthorImg = user.ProfileImageUrl; author.Homepage = user.ProfileUrl; if (!string.IsNullOrEmpty(author.Homepage) && !author.Homepage.Contains("http:")) { if (author.Homepage.Contains('/')) { author.Homepage = "http://weibo.com/" + author.Homepage; } else { author.Homepage = "http://blog.sina.com.cn/" + author.Homepage; } } author.RegisterTime = Utilities.ParseToDateTime(user.CreatedAt); #endregion #region 行为数据 author.FansCount = user.FollowersCount; author.FollowCount = user.FriendsCount; author.CloseFriendsCount = user.BIFollowersCount; author.PostCount = user.StatusesCount; author.AvgForward = author.AvgReply = author.AvgFansCountOfFans = 0; #endregion SetAuthorCrawlInfo(author, source); return(author); }