예제 #1
0
        /// <summary>
        /// 将新浪返回的微博转换为本地微博类型(Item)
        /// </summary>
        /// <param name="status">新浪返回的微博</param>
        /// <param name="source">微博来源</param>
        /// <returns></returns>
        public static Item ConvertToItem(NetDimension.Weibo.Entities.status.Entity status, Enums.AuthorSource source, string CrawlID)
        {
            Item item = new Item();

            item.CrawlID = CrawlID;
            item.Crawler = ConfigurationManager.AppSettings["ServerLocation"] + CrawlID;

            //设置媒体信息
            WeiboUtilities.SetItemMediaInfo(item);

            #region 抓取任务数据

            item.FetchTime          = DateTime.Now;
            item.UpdateTime         = null;
            item.ContentDetailLevel = Enums.ContentDetailLevel.Weibo;

            #endregion 抓取任务数据
            try
            {
                #region 基础数据
                item.Url                = Utilities.GetItemUrl(status.User.ID, status.MID);
                item.ItemID             = Palas.Common.Utility.MD5Helper.getMd5Hash(item.Url);
                item.ClientItemID       = status.ID;
                item.CleanTitle         = status.Text;
                item.PubDate            = Utilities.ParseToDateTime(status.CreatedAt);
                item.Location           = null;
                item.PoID               = null;
                item.AuthorName         = status.User.Name;
                item.AuthorID           = status.User.ID;
                item.AuthorImg          = status.User.ProfileImageUrl;
                item.AuthorCertificated = Utilities.GetCertificationType(status.User.VerifiedType, status.User.Verified);
                item.Source             = status.Source;
                item.AttachImg          = status.OriginalPictureUrl;
                #endregion

                #region Item跟踪

                item.CurrentCount = new ItemCountData(DateTime.Now);
                item.CurrentCount.ForwardCount = status.RepostsCount;
                item.CurrentCount.ReplyCount   = status.CommentsCount;

                item.CountHistory    = new ItemCountData[1];
                item.CountHistory[0] = item.CurrentCount;

                WeiboUtilities.SetItemTrackingRule(item, source);
                #endregion Item跟踪

                if (status.RetweetedStatus != null)
                {
                    Item tmp = ConvertToItem(status.RetweetedStatus, source, CrawlID);
                    if (tmp.ItemID != null)
                    {
                        InsertOrUpdateItem(tmp);
                    }
                    item.ParentItemID = tmp.ItemID;
                }
            }
            catch (Exception) { }
            return(item);
        }
예제 #2
0
        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;
            }
        }