public static void Cache(string picUrl, string format) { if (picUrl.Contains("/0/0-0-/0?")) { return; } SFixedSetService.Cache("PicCache", $"{picUrl}||{format}"); }
public static string Random() { while (true) { var pics = SFixedSetService.Get <string>("PicCache"); var picCache = pics.RandElement(); var strs = picCache.Split("||"); var picUrl = strs[0]; var format = strs.Length > 1 ? strs[1] : "jpg"; var guid = Guid.NewGuid().ToString(); var localPath = $"./images/RandCache/{guid}.{format}"; if (!Utility.DownloadImage(picUrl, localPath)) { continue; } return(localPath); } }
static void Main() { var assemblies = new List <Assembly>() { Assembly.GetAssembly(typeof(IDependency)), // Dolany.Ai.Common Assembly.GetAssembly(typeof(Program)), // DoremiDesktop Assembly.GetAssembly(typeof(IWorldLine)), // Dolany.Ai.Core Assembly.GetAssembly(typeof(DbBaseEntity)), // Dolany.Database Assembly.GetAssembly(typeof(DoremiWorldLine)), // Dolany.Ai.Doremi Assembly.GetAssembly(typeof(StandardWorldLine)), // Dolany.WorldLine.Standard Assembly.GetAssembly(typeof(KindomStormWorldLine)) // Dolany.WorldLine.KindomStorm }; try { AutofacSvc.RegisterAutofac(assemblies); AutofacSvc.RegisterDataRefresher(assemblies); Global.MsgPublish = PrintMsg; SFixedSetService.SetMaxCount("PicCache_Doremi", 200); AIAnalyzer.Sys_StartTime = DateTime.Now; CrossWorldAiSvc.InitWorlds(assemblies); CrossWorldAiSvc.DefaultWorldLine = CrossWorldAiSvc["Doremi"]; WaiterSvc.Listen(); } catch (Exception e) { Console.WriteLine(e.GetFullDetailMsg()); } var command = Console.ReadLine(); while (command != "Exit") { command = Console.ReadLine(); } }