/// <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); }
private bool Save() { var pt = PTFactory.GetPT(User.Site.Id, User) as AbstractPT; try { if (AppService.UpdateOrInsertUser(User) <= 0) { FormUtils.ShowErrMessage("很抱歉,由于未知原因保存失败。"); return(false); } else { if (!rtbInput.Text.IsNullOrEmptyOrWhiteSpace()) { YUUtils.WriteCookiesToDisk(pt.GetCookieFilePath(), rtbInput.Text); } return(true); } } catch (System.Data.SQLite.SQLiteException ex) { string errMsg = ex.GetInnerExceptionMessage(); FormUtils.ShowErrMessage(string.Format("保存失败,失败原因:{0}", errMsg)); Logger.Error(string.Format("用户[{0}]保存失败。", User.UserName), ex); return(false); } }
/// <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); }
public AboutFrm() { InitializeComponent(); DateTime now = YUUtils.GetWebSiteDateTime("https://www.baidu.com"); string licYear = string.Empty; if (now.Year > 2018) { licYear = string.Format("2018-{0}", now.Year); } else { licYear = "2018"; } lblVersion.Text = string.Format("版本 {0}", YUUtils.GetVersion()); lblLicence.Text = string.Format("yearlingvirus 版权所有 {0}。保留所有权利。", licYear); }
/// <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); }
/// <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); }