public Boolean insertUserBlog(NetDimension.Weibo.Entities.status.Entity blog_data, string sText) { userDAO.insertUserBlogParameter(CommonLib.DataTranslate.SinaDateToString(blog_data.CreatedAt), blog_data.ID, blog_data.MID, blog_data.ID, sText, blog_data.Source, Convert.ToInt32(blog_data.Favorited), Convert.ToInt32(blog_data.Truncated), blog_data.InReplyToStuatusID, blog_data.InReplyToUserID, blog_data.InReplyToScreenName, blog_data.ThumbnailPictureUrl, blog_data.RepostsCount, blog_data.CommentsCount); return true; }
public Boolean insertUser(NetDimension.Weibo.Entities.user.Entity user) { userDAO.insertUserParameter(user.ID, user.IDStr, user.ScreenName, user.Name, int.Parse(user.Province), int.Parse(user.City), user.Location, user.Description, user.Url, user.ProfileImageUrl, user.ProfileUrl, user.Domain, user.Weihao, user.Gender, user.FollowersCount, user.FriendsCount, user.StatusesCount, (int)user.FavouritesCount, CommonLib.DataTranslate.SinaDateToString(user.CreatedAt), Convert.ToInt32(user.Following), Convert.ToInt32(user.AllowAllActMsg), Convert.ToInt32(user.GEOEnabled), Convert.ToInt32(user.Verified), int.Parse(user.VerifiedType), user.Remark, Convert.ToInt32(user.AllowAllComment), user.AvatarLarge, user.VerifiedReason, Convert.ToInt32(user.FollowMe), user.OnlineStatus, user.BIFollowersCount, user.Lang); return true; }
public User(NetDimension.Weibo.Entities.user.Entity userInfo) { this.ID = userInfo.ID; this.Name = userInfo.Name; this.Province = userInfo.Province; this.City = userInfo.City; this.Location = userInfo.Location; this.Description = userInfo.Description; this.Gender = userInfo.Gender; this.FollowersCount = userInfo.FollowersCount; this.FriendsCount = userInfo.FriendsCount; this.StatusesCount = userInfo.StatusesCount; this.Verified = userInfo.Verified; this.VerifiedType = userInfo.VerifiedType; this.Lang = userInfo.Lang; }
public Status(NetDimension.Weibo.Entities.status.Entity statusInfo) { this.CreatedAt = statusInfo.CreatedAt; this.ID = statusInfo.ID; this.Text = statusInfo.Text; this.Source = statusInfo.Source; this.UserID = statusInfo.User.ID; this.Truncated = statusInfo.Truncated; this.ThumbnailPictureUrl = statusInfo.ThumbnailPictureUrl; this.MiddleSizePictureUrl = statusInfo.MiddleSizePictureUrl; this.OriginalPictureUrl = statusInfo.OriginalPictureUrl; this.RepostsCount = statusInfo.RepostsCount; this.CommentsCount = statusInfo.CommentsCount; if (statusInfo.RetweetedStatus != null) this.RetweetedStatusID = statusInfo.RetweetedStatus.ID; }
public static string buildtimelines(NetDimension.Weibo.Entities.status.Collection json) { StringBuilder statusBuilder = new StringBuilder(); if (json.Statuses != null) { foreach (var status in json.Statuses) { if (status.User == null) continue; //statusBuilder.AppendFormat(statusPattern, // status.User.ProfileImageUrl, // status.User.ScreenName, // status.Text); if (status.RetweetedStatus != null && status.RetweetedStatus.User != null) { statusBuilder.AppendFormat(statusPattern, status.User.ProfileImageUrl, status.User.ScreenName, status.Text, repostPattern.iFormat(status.RetweetedStatus.User.ScreenName, status.RetweetedStatus.Text, status.RetweetedStatus.ThumbnailPictureUrl.IsNullOrEmpty() ? "" : imageParttern.iFormat(status.RetweetedStatus.ThumbnailPictureUrl, status.RetweetedStatus.MiddleSizePictureUrl, status.RetweetedStatus.OriginalPictureUrl), status.RetweetedStatus.RepostsCount, status.RetweetedStatus.CommentsCount), bottomPattern.iFormat(status.ID, status.User.ScreenName, status.RepostsCount, status.CommentsCount), status.User.ID); } else { statusBuilder.AppendFormat(statusPattern, status.User.ProfileImageUrl, status.User.ScreenName, status.Text, status.ThumbnailPictureUrl.IsNullOrEmpty() ? "" : imageParttern.iFormat(status.ThumbnailPictureUrl, status.MiddleSizePictureUrl, status.OriginalPictureUrl), bottomPattern.iFormat(status.ID, status.User.ScreenName, status.RepostsCount, status.CommentsCount), status.User.ID); } } } //for test //System.IO.File.WriteAllText("Index.html", htmlPattern.Replace("<!--StatusesList-->", statusBuilder.ToString()), Encoding.UTF8); //System.Diagnostics.Process.Start(@"firefox.exe", @"D:\SinaWeiboClient\WeiboClient\bin\Debug\Index.html"); return htmlPattern.Replace("<!--StatusesList-->", statusBuilder.ToString()); }
public List<string> operation(Client client, NetDimension.Weibo.Entities.user.Entity user,int depth,string tagname) { List<string> list = new List<string>(); string userID = user.ID; try { var SinaClient = client; var userCollection = SinaClient.API.Entity.Friendships.FollowersInActive(userID, 200); for (int i = 0; i < userCollection.Count(); i++) { var followeruser = userCollection.ElementAt(i); string sql = "select * FROM sinauser WHERE uid = '" + followeruser.ID + "'"; bool isexist = db_SQLServer.SQLServerUnit.getInstance().isExist(sql); if (!isexist) { var usertags = SinaClient.API.Entity.Tags.Tags(followeruser.ID); if (checkTags(usertags, tagname)) { list.Add(followeruser.ID + " " + (depth + 1)); sql = "INSERT INTO sinauser(uid,statuses,depth) VALUES('" + followeruser.ID + "','" + followeruser.StatusesCount + "','" + (depth + 1) + "')"; db_SQLServer.SQLServerUnit.getInstance().insert(sql); } } } } catch (WeiboException e) { log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 异常 {0} :\n[" + e.Message + "]"); } catch (Exception e) { log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 异常 {0} :\n[" + e.Message + "]"); } return list; }
public void operation(Client client, NetDimension.Weibo.Entities.user.Entity user) { string userID = user.ID; try { var SinaClient = client; /* //保存用户信息 string sql = "select * FROM dbo.Users WHERE uid = '" + userID + "'"; bool isexist = db_SQLServer.SQLServerUnit.getInstance().isExist(sql); if (!isexist) { userService.insertUser(user); log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 保存用户信息: " + userID); } //保存用户标签 var usertags = SinaClient.API.Entity.Tags.Tags(user.ID); saveUserTags(user, usertags); log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 保存用户标签: " + userID); */ string statusID = "-1"; if (user.Status != null) { statusID = user.Status.ID; } bool endFlag = false; int pageNum = 1; int statusNum = 0; List<string> weibo_id_flag = new List<string>(); while (!endFlag && !statusID.Equals("-1")) { var statusCollection = client.API.Entity.Statuses.UserTimeline(userID, "", "", statusID, 100, 1, false, 0, true); log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 保存用户" + userID + "第" + (pageNum++) + "页微博,总" + statusCollection.Statuses.Count() + "条微博"); endFlag = true; List<NetDimension.Weibo.Entities.status.Entity> statuslist = new List<NetDimension.Weibo.Entities.status.Entity>(); foreach (NetDimension.Weibo.Entities.status.Entity status in statusCollection.Statuses) { statusID = status.ID; if (!weibo_id_flag.Contains(statusID)) { weibo_id_flag.Add(statusID); endFlag = false; if (CommonLib.CompareDate.lStartTime(CommonLib.DataTranslate.SinaDateToString(status.CreatedAt))) { endFlag = true; log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 用户" + userID + "抓取不在时间范围内,正在退出......"); break; } /*if (CommonLib.CompareDate.gEndTime(CommonLib.DataTranslate.SinaDateToString(status.CreatedAt))) { continue; }*/ if (!saveUserBlog(user, status)) { endFlag = true; break; } statusNum++; log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 保存用户" + userID + "微博,微博ID: " + statusID); } } }//while log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 用户" + userID + "微博抓取结束,总" + statusNum + "条微博......"); //sql = "UPDATE sinauser SET iscrawler = '1' WHERE uid = '" + userID + "'"; //db_SQLServer.SQLServerUnit.getInstance().update(sql); } catch (WeiboException e) { log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 异常 {0} :\n[" + e.Message + "]"); } catch (Exception e) { log.Info("线程: " + threadNo.ToString() + "-" + subThreadNo.ToString() + " 异常 {0} :\n[" + e.Message + "]"); } }
public Boolean saveUserTags(NetDimension.Weibo.Entities.user.Entity user, IEnumerable<NetDimension.Weibo.Entities.tag.Tag> usertags) { for (int i = 0; i < usertags.Count(); i++) { string sql = "SELECT * FROM dbo.User_tags WHERE uid='"+user.ID+"' AND tagid='"+usertags.ElementAt(i).ID+"'"; bool isexist = db_SQLServer.SQLServerUnit.getInstance().isExist(sql); if (!isexist) { userService.insertUserTags(user.ID, usertags.ElementAt(i).ID, usertags.ElementAt(i).Name, Convert.ToInt32(usertags.ElementAt(i).Weight)); } } return true; }
private Boolean saveUserBlog(NetDimension.Weibo.Entities.user.Entity user, NetDimension.Weibo.Entities.status.Entity blog_data) { //获取指定微博的信息 string retweeted_status = "0"; //处理微博 string sText = blog_data.Text; //处理转发微博 if (blog_data.RetweetedStatus != null) { retweeted_status = blog_data.RetweetedStatus.ID; sText = blog_data.RetweetedStatus.Text; } string sql = "select * from dbo.User_Blog_IDS where uid='" + user.ID + "' AND blogID='" + blog_data.ID + "'"; bool isexist = db_SQLServer.SQLServerUnit.getInstance().isExist(sql); //不存在 if (!isexist) { //写入用户微博总表 userService.insertUserBlogIDS(user, blog_data, retweeted_status); //写入用户微博数据 sql = "SELECT * FROM dbo.Blog WHERE blogid = '" + blog_data.ID + "'"; isexist = db_SQLServer.SQLServerUnit.getInstance().isExist(sql); if (!isexist) { userService.insertUserBlog(blog_data, sText); } return true; } return false; }
public frmLogin(NetDimension.Weibo.OAuth oauth) { InitializeComponent(); this.oauth = oauth; }
public WeiboLoginDialog(NetDimension.Weibo.OAuth oauth) { this.oauth = oauth; InitializeComponent(); }
/// <summary> /// 刷新用户信息界面 /// </summary> /// <param name="userInfo"></param> private void UIUpdateUserInfo(NetDimension.Weibo.Entities.user.Entity userInfo) { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(delegate() { UIUpdateUserInfo(userInfo); })); } else { lblScreenName.Text = userInfo.ScreenName; lblDesc.Text = userInfo.Description; imgProfile.ImageLocation = userInfo.ProfileImageUrl; lblUserStatus.Text = string.Format("关注({0}) 粉丝({1}) 微博({2})", userInfo.FriendsCount, userInfo.FollowersCount, userInfo.StatusesCount); } }
public frmChat(NetDimension.Weibo.OAuth oauth) { InitializeComponent(); this.oauth = oauth; Sina = new NetDimension.Weibo.Client(oauth); }
public Boolean insertUserBlogIDS(NetDimension.Weibo.Entities.user.Entity user, NetDimension.Weibo.Entities.status.Entity blog_data, string retweeted_status) { userDAO.insertUserBlogIDSParameter(user.ID, blog_data.ID, retweeted_status); return true; }
public frmLogin(NetDimension.Weibo.OAuth oauth) { // TODO: Complete member initialization InitializeComponent(); this.oauth = oauth; }
public Form1(NetDimension.OpenAuth.Sina.SinaWeiboClient client) { InitializeComponent(); this.openAuth = client; }
private void GetUser(MongoCollection<BsonDocument> col, NetDimension.Weibo.Client Sina, string uid) { var friends = Sina.API.Friendships.Friends(uid); int UserCount = 0; foreach (var friend in friends.Users) { col.Insert(friend); UserCount++; } foreach (var friend in friends.Users) { GetUser(col, Sina, friend.ID); } }