Exemple #1
0
        /// <summary>
        /// ->Grid实体
        /// </summary>
        /// <returns></returns>
        public PTTorrentGridEntity ToGridEntity()
        {
            PTTorrentGridEntity entity = new PTTorrentGridEntity();

            entity.Id             = this.Id;
            entity.DownUrl        = this.DownUrl;
            entity.LinkUrl        = this.LinkUrl;
            entity.LeecherNumber  = this.LeecherNumber;
            entity.PromotionType  = this.PromotionType;
            entity.ResourceType   = this.ResourceType;
            entity.SeederNumber   = this.SeederNumber;
            entity.SiteId         = this.SiteId;
            entity.Size           = this.Size;
            entity.RealSize       = YUUtils.ParseB(this.Size);
            entity.SnatchedNumber = this.SnatchedNumber;
            entity.UpLoader       = this.UpLoader;
            entity.UpLoadTime     = this.UpLoadTime;
            entity.IsHR           = this.IsHR;
            if (YUConst.PromotionImgDict.ContainsKey(entity.PromotionType) && !YUConst.PromotionImgDict[entity.PromotionType].IsNullOrEmptyOrWhiteSpace())
            {
                entity.image = FormUtils.GetImage(YUConst.PromotionImgDict[entity.PromotionType]);
            }

            StringBuilder sb = new StringBuilder();

            if (!this.Title.IsNullOrEmptyOrWhiteSpace())
            {
                sb.AppendLine(this.Title);
            }
            if (!this.Title.IsNullOrEmptyOrWhiteSpace())
            {
                sb.AppendLine(this.Subtitle);
            }

            string title     = sb.ToString();
            int    lastIndex = title.LastIndexOf("\r\n");

            if (lastIndex > -1)
            {
                title = title.Substring(0, lastIndex);
            }
            entity.Title = title;
            return(entity);
        }
Exemple #2
0
        /// <summary>
        /// ->Grid实体
        /// </summary>
        /// <returns></returns>
        public PTTorrentGridEntity ToGridEntity()
        {
            PTTorrentGridEntity entity = new PTTorrentGridEntity();

            entity.Id             = this.Id;
            entity.DownUrl        = this.DownUrl;
            entity.LinkUrl        = this.LinkUrl;
            entity.LeecherNumber  = this.LeecherNumber;
            entity.ResourceType   = this.ResourceType;
            entity.SeederNumber   = this.SeederNumber;
            entity.SiteId         = (int)this.SiteId;
            entity.SiteName       = this.SiteName;
            entity.ForumName      = this.ForumName;
            entity.Size_Display   = this.Size;
            entity.Size           = YUUtils.ParseB(this.Size);
            entity.SnatchedNumber = this.SnatchedNumber;
            entity.UpLoader       = this.UpLoader;
            entity.UpLoadTime     = this.UpLoadTime;
            entity.IsHR           = this.IsHR;

            if (PTSiteConst.RESOURCE_HRIMG.ContainsKey(entity.IsHR) && !PTSiteConst.RESOURCE_HRIMG[entity.IsHR].IsNullOrEmptyOrWhiteSpace())
            {
                //缓存处理
                if (!HRImages.ContainsKey(entity.IsHR))
                {
                    var image = ImageUtils.GetImage(PTSiteConst.RESOURCE_HRIMG[entity.IsHR]);
                    HRImages[entity.IsHR] = image;
                }
                entity.IsHR_Display = HRImages[entity.IsHR];
            }

            entity.PromotionType = this.PromotionType;
            if (PTSiteConst.RESOURCE_PROMOTIONIMG.ContainsKey(entity.PromotionType) && !PTSiteConst.RESOURCE_PROMOTIONIMG[entity.PromotionType].IsNullOrEmptyOrWhiteSpace())
            {
                //缓存处理
                if (!PromotionImages.ContainsKey(entity.PromotionType))
                {
                    var image = ImageUtils.GetImage(PTSiteConst.RESOURCE_PROMOTIONIMG[entity.PromotionType]);
                    PromotionImages[entity.PromotionType] = image;
                }
                entity.PromotionType_Display = PromotionImages[entity.PromotionType];
            }


            StringBuilder sb = new StringBuilder();

            if (!this.Title.IsNullOrEmptyOrWhiteSpace())
            {
                if (!this.FreeTime.IsNullOrEmptyOrWhiteSpace())
                {
                    sb.AppendLine(string.Format("{0} [{1}]", this.Title, this.FreeTime));
                }
                else
                {
                    sb.AppendLine(this.Title);
                }
            }

            if (!this.Title.IsNullOrEmptyOrWhiteSpace())
            {
                sb.AppendLine(this.Subtitle.Trim());
            }

            string title     = sb.ToString();
            int    lastIndex = title.LastIndexOf("\r\n");

            if (lastIndex > -1)
            {
                title = title.Substring(0, lastIndex);
            }
            entity.Title = title.Trim();
            return(entity);
        }