Exemplo n.º 1
0
        /// <summary>
        /// ->Grid实体
        /// </summary>
        /// <param name="torrnet"></param>
        /// <returns></returns>
        public PTInfoGridEntity ToGridEntity()
        {
            PTInfoGridEntity entity = new PTInfoGridEntity();

            entity.Id           = this.Id;
            entity.Bonus        = this.Bonus;
            entity.DownSize     = this.DownSize;
            entity.DownTimes    = this.DownTimes;
            entity.RealDownSize = YUUtils.ParseB(this.DownSize);
            entity.LastSyncDate = this.LastSyncDate;
            entity.Name         = this.Name;

            string regEx = "[^a-zA-Z]";

            entity.Rank          = Regex.Replace(this.Rank, regEx, "");
            entity.RealDownTimes = YUUtils.ParseMilliSecond(this.DownTimes);
            entity.RealSeedTimes = YUUtils.ParseMilliSecond(this.SeedTimes);
            entity.RegisterDate  = this.RegisterDate;
            entity.SeedNumber    = this.SeedNumber.Trim().TryPareValue <int>();
            entity.SeedRate      = this.SeedRate.Trim().TryPareValue <double>();
            entity.SeedTimes     = this.SeedTimes;
            entity.ShareRate     = this.ShareRate.Trim().TryPareValue <double>();
            entity.SiteId        = this.SiteId;
            entity.UpSize        = this.UpSize;
            entity.RealUpSize    = YUUtils.ParseB(this.UpSize);

            return(entity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// ->Grid实体
        /// </summary>
        /// <param name="torrnet"></param>
        /// <returns></returns>
        public PTInfoGridEntity ToGridEntity()
        {
            string defaultValue = "--";

            PTInfoGridEntity entity = new PTInfoGridEntity();

            entity.Id            = this.UserId == 0 ? defaultValue : this.UserId.TryPareValue <string>();
            entity.Url           = this.Url;
            entity.Bonus         = this.Bonus;
            entity.Bonus_Display = GetPropertyDisplay(this.Bonus);

            entity.DownSize_Display = GetPropertyDisplay(this.DownSize);
            entity.DownSize         = YUUtils.ParseB(this.DownSize);
            entity.UpSize_Display   = GetPropertyDisplay(this.UpSize);
            entity.UpSize           = YUUtils.ParseB(this.UpSize);

            entity.DownTimes         = YUUtils.ParseMilliSecond(this.DownTimes);
            entity.DownTimes_Display = entity.DownTimes <= 0 ? defaultValue : YUUtils.RetainNDecimal(TimeSpan.FromMilliseconds(entity.DownTimes).TotalDays);

            entity.SeedTimes         = YUUtils.ParseMilliSecond(this.SeedTimes);
            entity.SeedTimes_Display = entity.SeedTimes <= 0 ? defaultValue : YUUtils.RetainNDecimal(TimeSpan.FromMilliseconds(entity.SeedTimes).TotalDays);

            entity.LastSyncDate         = this.LastSyncDate;
            entity.LastSyncDate_Display = GetPropertyDisplay(this.LastSyncDate);

            entity.RegisterDate         = this.RegisterDate;
            entity.RegisterDate_Display = GetPropertyDisplay(this.RegisterDate);

            int registerDays = DateTime.Now.Subtract(this.RegisterDate).Duration().Days;

            entity.RegisterWeek = this.RegisterDate;
            if (this.RegisterDate == DateTime.MinValue)
            {
                entity.RegisterWeek_Display = defaultValue;
            }
            else
            {
                entity.RegisterWeek_Display = registerDays == 0 ? "0天" : string.Format("{0}周", registerDays / 7) + ((registerDays % 7) > 0 ? string.Format("{0}天", registerDays % 7) : string.Empty);
            }

            string regEx = "/^[A-Za-z\\s]+$/";

            entity.Rank = Regex.Replace(this.Rank, regEx, "");
            //如果过滤之后为空字符串,则直接用站点的。
            if (entity.Rank.IsNullOrEmptyOrWhiteSpace())
            {
                entity.Rank = this.Rank.IsNullOrEmptyOrWhiteSpace() ? defaultValue : this.Rank;
            }

            entity.SeedNumber         = GetPropertyValue <int>(this.SeedNumber);
            entity.SeedNumber_Display = GetPropertyDisplay(this.SeedNumber);

            entity.SeedRate         = GetPropertyValue <double>(this.SeedRate);
            entity.SeedRate_Display = GetPropertyDisplay(this.SeedRate);

            if (entity.DownSize == 0 && entity.UpSize == 0)
            {
                entity.ShareRate         = 0D;
                entity.ShareRate_Display = defaultValue;
            }
            else if (entity.UpSize > 0 && entity.DownSize == 0)
            {
                entity.ShareRate         = double.MaxValue;
                entity.ShareRate_Display = "inf";
            }
            else
            {
                entity.ShareRate         = GetPropertyValue <double>(this.ShareRate);
                entity.ShareRate_Display = GetPropertyDisplay(this.ShareRate);
            }

            entity.Name     = GetPropertyDisplay(this.Name);
            entity.SiteId   = (int)this.SiteId;
            entity.SiteName = GetPropertyDisplay(this.SiteName);

            return(entity);
        }