public TwinIonEngineMkII() : base() { Types.Add(UpgradeType.Modification); Name = "Twin Ion Engine Mk. II"; ImageUrl = ImageUrls.GetImageUrl(this, "twin-ion-engine-mkii.png"); Cost = 1; }
public override string GetUpgradeImageUrl(GenericUpgrade upgrade, string filename = null) { return(RootUrlForImages + "upgrades/" + ImageUrls.FormatUpgradeTypes(upgrade.UpgradeInfo.UpgradeTypes) + "/" + ImageUrls.FormatName(filename ?? ImageUrls.FormatUpgradeName(upgrade.UpgradeInfo.Name)) + ".png"); }
public BlackEightSqPilot() : base() { PilotName = "Black Eight Sq. Pilot"; ImageUrl = ImageUrls.GetImageUrl(this, "black-eight-squadron-pilot.png"); PilotSkill = 4; Cost = 23; }
/// <summary> /// 初始化,用于绑定 /// </summary> /// <param name="productId">商品Id</param> public ProductAlbumUploadData(long productId) : this() { // 获取当前相册的图片列表 var albumManager = Application.Ioc.Resolve <ProductAlbumManager>(); for (int x = 1; x <= MaxImageCount; ++x) { ImageUrls.Add(albumManager.GetAlbumImageWebPath(productId, x, ProductAlbumImageType.Thumbnail)); } // 获取主图路径,不存在时返回 var mainPath = albumManager.GetAlbumImageStoragePath(productId, null, ProductAlbumImageType.Normal); var mainFileInfo = new FileInfo(mainPath); if (!mainFileInfo.Exists) { return; } // 判断相册中哪张图片的大小和修改时间和原图一致 // 没有时默认选择第一张 for (int x = 1; x <= MaxImageCount; ++x) { var path = albumManager.GetAlbumImageStoragePath(productId, x, ProductAlbumImageType.Normal); var fileInfo = new FileInfo(path); if (fileInfo.Exists && fileInfo.Length == mainFileInfo.Length && fileInfo.LastWriteTimeUtc.Truncate() == mainFileInfo.LastWriteTimeUtc.Truncate()) { MainImageIndex = x; return; } } MainImageIndex = 1; }
public static async void GetIllustDetail(SoraMessage e, int id) { var detail = await Illust.Get(id); if (detail == null) { await e.ReplyToOriginal("数据获取失败,请稍后再试"); } else { ArrayList msg = new(); foreach (var img in detail.Images) { msg.Add(CQCode.CQImage(ImageUrls.ToPixivCat(img.Medium))); } msg.Add(new StringBuilder().AppendLine() .AppendLine(detail.Title) .AppendLine($"Author: {detail.Author}") .AppendLine(detail.Caption) .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}") .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd hh:mm:ss}") .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}") .Append(detail.Url) .ToString()); await e.Reply(msg.ToArray()); await e.RemoveCoins(5); } }
/// <summary> /// 初始化,用于绑定 /// </summary> /// <param name="productId">商品Id</param> public ProductAlbumUploadData(Guid productId) : this() { // 获取当前相册的图片列表 var albumManager = Application.Ioc.Resolve <ProductAlbumManager>(); for (int x = 1; x <= MaxImageCount; ++x) { ImageUrls.Add(albumManager.GetAlbumImageWebPath( productId, x, ProductAlbumImageType.Thumbnail)); } // 主图不存在时返回 if (!albumManager.GetAlbumImageStorageFile( productId, null, ProductAlbumImageType.Normal).Exists) { return; } // 判断相册中哪张图片的大小和修改时间和原图一致 // 没有时默认选择第一张 for (int x = 1; x <= MaxImageCount; ++x) { var fileEntry = albumManager.GetAlbumImageStorageFile(productId, x, ProductAlbumImageType.Normal); if (fileEntry.Exists && fileEntry.Length == fileEntry.Length && fileEntry.LastWriteTimeUtc.Truncate() == fileEntry.LastWriteTimeUtc.Truncate()) { MainImageIndex = x; return; } } MainImageIndex = 1; }
public async Task Reload() { try { var sw = Stopwatch.StartNew(); var obj = JObject.Parse( File.ReadAllText(Path.Combine(_basePath, "images.json"))); ImageUrls = obj.ToObject <ImageUrls>(); var t = new ImageLoader(_http, _con, GetKey) .LoadAsync(obj); var loadCards = Task.Run(async() => { await _db.StringSetAsync(Directory.GetFiles(_cardsPath) .ToDictionary( x => GetKey("card_" + Path.GetFileNameWithoutExtension(x)), x => (RedisValue)File.ReadAllBytes(x)) // loads them and creates <name, bytes> pairs to store in redis .ToArray()) .ConfigureAwait(false); }); await Task.WhenAll(t, loadCards).ConfigureAwait(false); sw.Stop(); _log.Info($"Images reloaded in {sw.Elapsed.TotalSeconds:F2}s"); } catch (Exception ex) { _log.Error(ex); throw; } }
public static Trip GenerateTrip(string hostId) => new Trip { Name = $"{Activities.GetRandom()} {TripTypes.GetRandom()}", Country = Countries.GetRandom(), HostId = hostId, ImageUrl = ImageUrls.GetRandom(), };
public AdvancedTargetingComputer() : base() { Type = UpgradeType.System; Name = "Adv. Targeting Computer"; Cost = 5; ImageUrl = ImageUrls.GetImageUrl(this, "advanced-targeting-computer.png"); }
public TwinIonEngineMkII() : base() { Types.Add(UpgradeType.Modification); Name = "Twin Ion Engine Mk. II"; ImageUrl = ImageUrls.GetImageUrl(this, "twin-ion-engine-mkii.png"); Cost = 1; UpgradeAbilities.Add(new Abilities.TreatAllBanksAsGreenAbility()); }
public string GetImage(string id) { if (ImageUrls.TryGetValue(id, out var result)) { return(result); } return(null); }
public string GetImage(string id) { if (!string.IsNullOrEmpty(id) && ImageUrls.TryGetValue(id, out var result)) { return(result); } return(null); }
public RedisImagesCache(ConnectionMultiplexer con, IBotCredentials creds) { _con = con; _creds = creds; _http = new HttpClient(); Migrate(); ImageUrls = JsonConvert.DeserializeObject <ImageUrls>( File.ReadAllText(Path.Combine(_basePath, "images.json"))); }
public AdvancedTargetingComputer() : base() { Types.Add(UpgradeType.System); Name = "Adv. Targeting Computer"; Cost = 5; ImageUrl = ImageUrls.GetImageUrl(this, "advanced-targeting-computer.png"); UpgradeAbilities.Add(new AdvancedTargetingComputerAbility()); }
public GhostV2() : base() { Types.Add(UpgradeType.Title); Name = "Ghost (Phantom II)"; NameCanonical = "ghost-swx72"; ImageUrl = ImageUrls.GetImageUrl(this, NameCanonical + ".png"); Cost = 0; isUnique = true; }
public RedisImagesCache(ConnectionMultiplexer con, IBotCredentials creds) { _con = con; _creds = creds; _log = LogManager.GetCurrentClassLogger(); Migrate(); ImageUrls = JsonConvert.DeserializeObject <ImageUrls>( File.ReadAllText(Path.Combine(_basePath, "images.json"))); }
public async Task Reload() { try { realImageUrls = JsonConvert.DeserializeObject <ImageUrls>( File.ReadAllText(Path.Combine(_basePath, "images.json"))); var loadCoins = Task.Run(async() => { Heads = await Task.WhenAll(ImageUrls.Coins.Heads .Select(x => _http.GetByteArrayAsync(x))); Tails = await Task.WhenAll(ImageUrls.Coins.Tails .Select(x => _http.GetByteArrayAsync(x))); }); var loadDice = Task.Run(async() => Dice = (await Task.WhenAll(ImageUrls.Dice .Select(x => _http.GetByteArrayAsync(x)))) .ToArray()); SlotBackground = File.ReadAllBytes(_slotBackgroundPath); SlotNumbers = Directory.GetFiles(_slotNumbersPath) .OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f))) .Select(x => File.ReadAllBytes(x)) .ToArray(); SlotEmojis = Directory.GetFiles(_slotEmojisPath) .OrderBy(f => int.Parse(Path.GetFileNameWithoutExtension(f))) .Select(x => File.ReadAllBytes(x)) .ToArray(); var loadRategirl = Task.Run(async() => { WifeMatrix = await _http.GetByteArrayAsync(ImageUrls.Rategirl.Matrix); RategirlDot = await _http.GetByteArrayAsync(ImageUrls.Rategirl.Dot); }); var loadXp = Task.Run(async() => XpCard = await _http.GetByteArrayAsync(ImageUrls.Xp.Bg) ); Rip = File.ReadAllBytes(_ripPath); FlowerCircle = File.ReadAllBytes(_ripFlowersPath); await Task.WhenAll(loadCoins, loadRategirl, loadXp, loadDice); } catch (Exception ex) { _log.Error(ex); throw; } }
public TwinIonEngineMkII() : base() { UpgradeInfo = new UpgradeCardInfo( "Twin Ion Engine Mk. II", UpgradeType.Modification, cost: 1, abilityType: typeof(Abilities.FirstEdition.TwinIonEngineMkIIAbility) ); ImageUrl = ImageUrls.GetImageUrl(this, "twin-ion-engine-mkii"); }
public static string geturlbypolicy(ImageUrls urls) { switch (Data.AppDataHelper.GetValue("PreviewImageSize")) { default: case 0: return(urls.Medium); case 1: return(urls.SquareMedium ?? urls.Small); } }
public AdvancedTargetingComputer() : base() { UpgradeInfo = new UpgradeCardInfo( "Adv. Targeting Computer", UpgradeType.Sensor, cost: 5, abilityType: typeof(Abilities.FirstEdition.AdvancedTargetingComputerAbility), restriction: new ShipRestriction(typeof(Ship.FirstEdition.TIEAdvanced.TIEAdvanced)) ); ImageUrl = ImageUrls.GetImageUrl(this, "advanced-targeting-computer"); }
public Bossk() : base() { Type = UpgradeType.Crew; Name = "Bossk"; Cost = 2; isUnique = true; ImageUrl = ImageUrls.GetImageUrl(this, "bossk-crew.png"); UpgradeAbilities.Add(new BosskCrewAbility()); }
void ParseLinks(string text) { ImageUrls.Clear(); var urls = text.Split(';'); foreach (var item in urls) { if (item.IsValidUrl()) { ImageUrls.Add(item); } } }
public GhostV2() : base() { UpgradeInfo = new UpgradeCardInfo( "Ghost (Phantom II)", UpgradeType.Title, cost: 0, isLimited: true, restriction: new ShipRestriction(typeof(Ship.FirstEdition.VCX100.VCX100)), abilityType: typeof(Abilities.FirstEdition.GhostV2Ability) ); NameCanonical = "ghost-swx72"; ImageUrl = ImageUrls.GetImageUrl(this, NameCanonical); }
public Bossk() : base() { Types.Add(UpgradeType.Crew); Name = "Bossk"; Cost = 2; isUnique = true; ImageUrl = ImageUrls.GetImageUrl(this, "bossk-crew.png"); AvatarOffset = new Vector2(47, 1); UpgradeAbilities.Add(new BosskCrewAbility()); }
public ActionResult UpdateImages(int id, [FromBody] JsonElement jsonElement) { // Converts json element to string string json = System.Text.Json.JsonSerializer.Serialize(jsonElement); // Converts json string to dataset DataSet dataSet = JsonConvert.DeserializeObject <DataSet>(json); try { if (dataSet != null) { // Get through every table from dataset // Tables includes type ID and new URL for image foreach (DataTable dataTable in dataSet.Tables) { DataRow row = dataTable.Rows[0]; int typeId = int.Parse(row["TypeID"].ToString()); string newUrl = row["Url"].ToString(); ImageUrls oldImage = (from iu in _context.ImageUrls where iu.UserId == id && iu.TypeId == typeId select iu).FirstOrDefault(); // If image url has changed, it will be updated to database if (newUrl != oldImage.Url) { oldImage.Url = newUrl; _context.SaveChanges(); } } return(Ok("Image has updated succesfully!")); } else { return(NotFound("Content not found.")); } } catch (Exception ex) { return(BadRequest("Problem detected while updating images. Error message: " + ex.Message)); } finally { _context.Dispose(); } }
/// <summary> /// Checks the image. /// </summary> /// <param name="baseUrl">The base url URL.</param> /// <param name="match">The match.</param> void CheckIsValidImage(string baseUrl, string imgUrl) { var extension = System.IO.Path.GetExtension(imgUrl).ToLowerInvariant(); if (extension == ".jpg" || extension == ".png") { if (!imgUrl.StartsWith("http://") || !imgUrl.StartsWith("https://") || !imgUrl.StartsWith("www")) { imgUrl = imgUrl.Insert(0, baseUrl); } if (imgUrl.IsValidUrl()) { ImageUrls.Insert(0, imgUrl); } } }
private ImageUrls UpdateImage(ImageUrls img, string link) { if (link.EndsWith(".thumbnail.png")) { img.ThumbnailUrl = link; } else { if (string.IsNullOrWhiteSpace(img.ThumbnailUrl)) { img.ThumbnailUrl = link; } img.Url = link; } return(img); }
public void Insert() { AttendanceObj.AttendanceTypeID = SelectedAttendanceTypeID; AttendanceObj.EstateID = SelectedPropertyid; if (!string.IsNullOrWhiteSpace(ImageUrls)) { AttendanceObj.urlString = ImageUrls.Trim(); } AttendanceObj.VisitDate = VisitDate; AttendanceObj.VisitDescription = AttendanceDescription; AttendanceObj.FireAlarmTest = FireAlarm; AttendanceObj.NotifyCustomer = SendCustomerNotification; AttendanceObj.PortalViewable = PortalViewable; AttendanceObj.Insert(GlobalVariables.GetConnection()); if (AttendanceObj.id > 0) { try { AttendanceVisits.AttendanceNotifications notification = new AttendanceVisits.AttendanceNotifications(GlobalVariables.GetConnection(), AttendanceObj.EstateID, AttendanceObj.id, AttendanceObj.AttendingUser, 2); notification.SendColleagueNotifications(); //System.Threading.Thread t = // new System.Threading.Thread(new System.Threading.ThreadStart(notification.SendColleagueNotifications)); //t.Start(); } catch (Exception ex) { string h = ex.Message; } } else { //error } }
public async Task GetIllustDetail(int id) { if (await Context.User.CheckCoins(5)) { var msg = await ReplyAsync("``数据检索中……``"); var detail = await Illust.Get(id); if (detail == null) { await msg.ModifyAsync(x => x.Content = "数据获取失败,请稍后再试"); } else { StringBuilder sb = new(); foreach (var img in detail.Images) { sb.AppendLine(ImageUrls.ToPixivCat(img.Medium)); } sb.AppendLine(detail.Title) .AppendLine($"Author: {detail.Author}") .AppendLine(detail.Caption) .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}") .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd hh:mm:ss}") .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}") .Append(detail.Url); await msg.ModifyAsync(x => x.Content = msg.ToString()); await Context.User.RemoveCoins(5); } } else { await ReplyAsync("幻币数量不足"); } }
public AdminControllerIntegrationTests() { #region MockData Manufacturer manufacturer = new Manufacturer { /* Id = 1,*/ Name = "manufacturerName" }; ItemDepartment itemDept = new ItemDepartment { /* Id = 1,*/ DeptName = "DeptName" }; ItemType itemType = new ItemType { /* Id = 1,*/ Name = "itemTypeName", ItemTypeHeaderImageUrl = "itemTypeHeaderImageUrl", ItemGroupName = "itemGroupName" }; ItemTypeSub itemSubType = new ItemTypeSub { /* Id = 1,*/ SubTypeName = "itemSubTypeName", ItemType = itemType }; Specs spec = new Specs { /* Id = 1, */ Description = "Description", Specification = "Specification", }; Model model = new Model { /* Id = 1,*/ ItemDepartment = itemDept, SpecsId = spec, TypeId = itemType, Name = "modelName" }; Items item = new Items { /* Id = 1, */ Availability = 1, Color = "itemColor", Price = 12, Discount = 0, ManuModel = manufacturer, Model = model, ItemTypeSub = itemSubType }; Reviews review = new Reviews { /* Id = 1,*/ /* DayOfReview = DateTime.UtcNow,*/ Item = item, Rating = 5.0, Text = "reviewText" }; ImageUrls imageUrl = new ImageUrls { /* Id = 1,*/ Item = item, Url = "imageUrl" }; #endregion adminModel = new AdminModel { Availibility = item.Availability, Price = item.Price, Discount = item.Discount, Manufacturer = manufacturer, Model = model, ImageUrls = imageUrl.Url, Color = item.Color, ItemSubType = itemSubType, ItemDepartment = itemDept, ModelName = model.Name, Specs = spec, ItemType = itemType, Review = review }; var provider = new ServiceCollection().AddEntityFrameworkSqlServer().BuildServiceProvider(); var options = new DbContextOptionsBuilder <StoreContext>(); options.UseSqlServer($"Server=(localdb)\\MSSQLLocalDB;Database=Store_DTB_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=True; ") .UseInternalServiceProvider(provider).EnableSensitiveDataLogging(); _context = new StoreContext(options.Options); _context.Database.Migrate(); }