/// <summary> /// Changes the pass code. /// </summary> /// <param name="newPassCode">The new pass code.</param> /// <returns>Returns true if operation was successful.</returns> public Card ChangePassCode(int newPassCode) { ImageUrl.Replace(PassCode.ToString(), newPassCode.ToString()); SmallImageUrl.Replace(PassCode.ToString(), newPassCode.ToString()); PassCode = newPassCode; return(this); }
/// <summary> /// 获取图片路径 /// </summary> /// <param name="days">倒数第几天</param> /// <returns></returns> public string GetBingURL(int days = 0) { string InfoUrl = $"http://cn.bing.com/HPImageArchive.aspx?idx={days}&n=1"; CoreEngine.Current.Logger.Info($"Bing查询接口:{InfoUrl}"); string ImageUrl; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(InfoUrl); request.Method = "GET"; request.ContentType = "text/html;charset=UTF-8"; string XmlString; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream myResponseStream = response.GetResponseStream(); using (StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8)) { XmlString = myStreamReader.ReadToEnd(); } } //===------ // 定义正则表达式用来匹配标签 Regex regImg = new Regex("<Url>(?<imgUrl>.*?)</Url>", RegexOptions.IgnoreCase); // 搜索匹配的字符串 MatchCollection matches = regImg.Matches(XmlString); // 取得匹配项列表 ImageUrl = "http://www.bing.com" + matches[0].Groups["imgUrl"].Value; //===------ if (days == 0)//保存copyright { CoreEngine.Current.Logger.Info("Bing查询接口:保存Image Copyright"); // 定义正则表达式用来匹配标签 Regex regCopyright = new Regex("<copyright>(?<imgCopyright>.*?)</copyright>", RegexOptions.IgnoreCase); // 搜索匹配的字符串 MatchCollection matchesCopyright = regCopyright.Matches(XmlString); // 取得匹配项列表 var copyright = matchesCopyright[0].Groups["imgCopyright"].Value; CoreEngine.Current.AppSetting.SetCopyright(copyright); CoreEngine.Current.Logger.Info($"Bing查询接口:Copyright:{copyright}"); } //===------ if (CoreEngine.Current.AppSetting.GetSizeMode == Model.ImageSizeType._720p) { ImageUrl = ImageUrl.Replace("1920x1080", "1366x768"); } else if (CoreEngine.Current.AppSetting.GetSizeMode == Model.ImageSizeType._1200p) { ImageUrl = ImageUrl.Replace("1920x1080", "1920x1200"); } CoreEngine.Current.Logger.Info($"Bing获取到接口的壁纸链接:{ImageUrl}"); return ImageUrl; } catch { return null; } }
public ModUpdateInfo(ReleaseSettings settings, string workspacePath, string targetPath) { Path = workspacePath; ///// Get the update title Console.Write("\nPlease enter a title for your update/release or Press ENTER to continue : "); title = RemoveSpecialCharacters(Console.ReadLine()); ///// Get the update description Console.Write("\nPlease enter a description for your update/release or Press ENTER to continue : "); Description = ""; Description = Console.ReadLine(); Console.WriteLine(); ///// Get the Steam URL if (settings.HandleSteam) { var steamPublishIDPath = Path + @"\About\PublishedFileId.txt"; if (File.Exists(steamPublishIDPath)) { var steamPublishID = File.ReadLines(steamPublishIDPath).First(); SteamURL = @"https://steamcommunity.com/sharedfiles/filedetails/?id=" + steamPublishID; } } ///// Get the Patreon URL, Patron info, and Patrons message List <string> patrons = new List <string>(); if (settings.HandlePatreon) { var patreonPath = Path + @"\About\PatreonURL.txt"; if (!File.Exists(patreonPath)) { if (Program.UserAccepts("Patreon URL file not detected. Create new one? (Y/N): ")) { Console.Write("\nPlease enter the Patreon URL or Press ENTER to continue : "); PatreonURL = ""; PatreonURL = Console.ReadLine(); Console.WriteLine(); File.WriteAllText(patreonPath, PatreonURL + "\n"); } } else { PatreonURL = File.ReadLines(patreonPath).First(); } if (File.Exists(settings.PatronsFilePath)) { var lines = File.ReadLines(settings.PatronsFilePath).Skip(1); var activeOnly = lines.ToList().FindAll(x => x.Split(',')[3] == "Active patron"); var sorted = activeOnly.Select(line => { var s = line.Split(',')[5]; //Console.WriteLine(s); var replace = s.Replace("$", "").Replace("\"", ""); //Console.WriteLine(replace); return(new { SortKey = float.Parse(replace), Line = line }); }) .OrderBy(x => x.SortKey) .Select(x => x.Line); foreach (var line in sorted) { var newLine = line.Split(',').FirstOrDefault(); patrons.Add(newLine); } Console.WriteLine("Patreons: "); Console.WriteLine(String.Join(", ", patrons) + "\n"); } else { Console.WriteLine("Patrons file not found."); } } ///// Get the Discord URL if (settings.HandleDiscord) { var discordPath = Path + @"\About\DiscordURL.txt"; if (!File.Exists(discordPath)) { if (Program.UserAccepts("Discord URL file not detected. Create new one? (Y/N): ")) { Console.Write("\nPlease enter the Discord invite URL or Press ENTER to continue : "); DiscordURL = ""; DiscordURL = Console.ReadLine(); Console.WriteLine(); File.WriteAllText(discordPath, DiscordURL + "\n"); } } else { DiscordURL = File.ReadLines(discordPath).First(); } } ///// Get the Ludeon URL if (settings.HandleLudeon) { var ludeonPath = Path + @"\About\LudeonURL.txt"; if (!File.Exists(ludeonPath)) { if (Program.UserAccepts("Ludeon URL file not detected. Create new one? (Y/N): ")) { Console.Write("\nPlease enter the Ludeon thread URL or Press ENTER to continue : "); LudeonURL = ""; LudeonURL = Console.ReadLine(); Console.WriteLine(); File.WriteAllText(ludeonPath, LudeonURL + "\n"); } } else { LudeonURL = File.ReadLines(ludeonPath).First(); } } ///// Get the Discord Webhook if (settings.HandleDiscordWebhook) { var sourcePath = Path + @"\Source"; var webhookPath = sourcePath + @"\DiscordWebhookToken.txt"; if (!File.Exists(webhookPath)) { if (Program.UserAccepts("Discord Webhook Tokens not detected. Create new ones? (Y/N): ")) { Console.Write("\nPlease enter the Discord Webhook link or Press ENTER to continue : "); DiscordWebhookTokens = new List <string>(); DiscordWebhookTokens.Add(Console.ReadLine().Trim()); Console.WriteLine(); if (!Directory.Exists(sourcePath)) { Directory.CreateDirectory(sourcePath); } for (int i = 0; i < 999; i++) { if (!Program.UserAccepts("Add additional webhooks? (Y/N): ")) { break; } Console.Write("\nPlease enter the Discord Webhook link or Press ENTER to continue : "); var input = Console.ReadLine(); if (input == "") { break; } DiscordWebhookTokens.Add(input.Trim()); } File.WriteAllLines(webhookPath, DiscordWebhookTokens); } } else { DiscordWebhookTokens = new List <string>(File.ReadAllLines(webhookPath)); Console.WriteLine("\nFound " + DiscordWebhookTokens.Count + " Webhook token(s)."); //Console.WriteLine(webhookToken); } } ///// Get the name var modName = ParseAboutXMLFor("name", workspacePath); var modAuthor = ParseAboutXMLFor("author", workspacePath); //Console.WriteLine(modName); //Console.WriteLine(modAuthor); Name = modName; //path.Substring(path.LastIndexOf("\\", StringComparison.Ordinal) + 1); Team = modAuthor; ///// Get the date PublishDate = DateTime.Now; PublishDateString = $"{PublishDate:MM-dd-yyyy}"; ///// Ask or autoset a version number var versionPath = workspacePath + @"\About\Version.txt"; var versionPathTwo = targetPath + @"\About\Version.txt"; var manifestXMLPath = workspacePath + @"\About\Manifest.xml"; var manifestXMLPathTarget = targetPath + @"\About\Manifest.xml"; if (settings.AskForVersionNum) { if (!File.Exists(versionPath)) { if (Program.UserAccepts("Version number file not detected. Create new one? (Y/N): ")) { Console.Write( "\nPlease enter the current version number of the mod or Press ENTER to continue : "); Version = ""; while (true) { var input = Console.ReadLine(); if (input == "") { var daysSinceStarted = (DateTime.Now - FirstPublishDate).Days; Version = settings.TargetVersion + '.' + daysSinceStarted; break; } Version = input; Console.WriteLine("Set version to: " + input); break; } File.WriteAllText(versionPath, Version + "\n"); File.WriteAllText(versionPathTwo, Version + "\n"); } } else { Version = File.ReadLines(versionPath).First(); Console.WriteLine("Current version detected: " + Version); Console.WriteLine("Enter new version or press ENTER to generate one: "); Version = Console.ReadLine(); if (Version == "") { var daysSinceStarted = (DateTime.Now - FirstPublishDate).Days; Version = settings.TargetVersion + '.' + daysSinceStarted; } Console.WriteLine("Set version to: " + Version); File.WriteAllText(versionPath, Version + "\n"); File.WriteAllText(versionPathTwo, Version + "\n"); } } else { var daysSinceStarted = (DateTime.Now - FirstPublishDate).Days; Version = settings.TargetVersion + '.' + daysSinceStarted; } //Adjust the version number in Manifest.xml (if it exists) if (File.Exists(manifestXMLPath)) { XmlDocument doc; using (XmlTextReader reader = new XmlTextReader(manifestXMLPath)) { doc = new XmlDocument(); doc.Load(reader); doc.SelectSingleNode("Manifest/version").InnerText = Version; } doc.Save(manifestXMLPath); File.Delete(manifestXMLPathTarget); File.Copy(manifestXMLPath, manifestXMLPathTarget); } var changelogPath = workspacePath + @"\About\Changelog.txt"; if (settings.autoGenerateChangelog) { ///// Generate a mod description var updateContents = new string[] { Version + " (" + PublishDateString + ")", "========================", Description, "" }; if (!File.Exists(changelogPath)) { if (Program.UserAccepts("Changelog file not detected. Create new one? (Y/N): ")) { File.WriteAllLines(changelogPath, updateContents); } } else { var lines = new List <string>(updateContents); foreach (var line in File.ReadAllLines(changelogPath)) { lines.Add(line); } File.WriteAllLines(changelogPath, lines.ToArray()); } } ///// Generate a mod description var descriptionPath = workspacePath + @"\About\Description.txt"; var descriptionPathTwo = targetPath + @"\About\Description.txt"; if (settings.autoGenerateDescription) { if (!File.Exists(descriptionPath)) { if (Program.UserAccepts("Raw description file not detected. Create new one? (Y/N): ")) { Console.WriteLine("Please input a description. Use \\n to input new lines."); File.WriteAllText(descriptionPath, Console.ReadLine()); File.Copy(descriptionPath, descriptionPathTwo); } else { goto generateDescriptionOut; } } var aboutXMLPath = workspacePath + @"\About\About.xml"; var aboutXMLPathTarget = targetPath + @"\About\About.xml"; XmlDocument doc; var newDescription = Version + " (" + this.PublishDateString + ")" + "\n\n" + File.ReadAllText(descriptionPath); if (!String.IsNullOrEmpty(settings.PatronsFilePath)) { newDescription = newDescription + "\n\n" + settings.PatronsMessage + "\n"; newDescription = newDescription + "\nThese are the most excellent rim dwellers who support me: \n" + String.Join(", ", patrons); } if (settings.autoGenerateChangelog && File.Exists(changelogPath)) { newDescription = newDescription + "\n\n========================\nChangelog\n========================\n" + File.ReadAllText(changelogPath); } //Adjust the version number in the about.xml using (XmlTextReader reader = new XmlTextReader(aboutXMLPath)) { doc = new XmlDocument(); doc.Load(reader); //Assuming reader is your XmlReader doc.SelectSingleNode("ModMetaData/description").InnerText = newDescription; doc.SelectSingleNode("ModMetaData/targetVersion").InnerText = settings.TargetVersion; } doc.Save(aboutXMLPath); File.Delete(aboutXMLPathTarget); File.Copy(aboutXMLPath, aboutXMLPathTarget); Console.WriteLine("Autogenerated Description: "); Console.WriteLine(newDescription); Console.WriteLine("Description Generated.\n"); } generateDescriptionOut: if (settings.HandleGitHub) { var gitConfigPath = workspacePath + @"\.git\config"; if (!File.Exists(gitConfigPath)) { Console.WriteLine("Warning - No .git folder detected."); } else { var lines = File.ReadAllLines(gitConfigPath); var urlLine = lines.FirstOrDefault(x => x.Contains("url =")); urlLine = urlLine.ClearWhiteSpace(); //https://github.com/jecrell/Call-of-Cthulhu---Cosmic-Horrors.git urlLine = urlLine.Replace("url=", "").Replace("https://github.com/", "").Replace(".git", ""); lines = urlLine.Split('/'); GitRepoAuthor = lines[0]; GitRepoName = lines[1]; } Console.WriteLine(".git Config Detected."); Console.Write("Repository: " + GitRepoName + " Author: " + GitRepoAuthor); Client = new GitHubClient(new ProductHeaderValue("RimworldModReleaseTool")); var auth = GitRepoAuthor; if (Program.UserAccepts("\nLogin to GitHub? (Y/N): ")) { Console.WriteLine( "\nConnecting to GitHub requires a login.\nPlease enter your credentials to proceed."); Console.WriteLine("Username: "******"Password: "******"/master/About/Preview.png"; ImageUrl = ImageUrl.Replace("https://github.com/", "https://raw.githubusercontent.com/"); } }
private void SetUpZoomImage() { SetUpJavaScript("ZoomScript", "~/ClientScripts/easyzoom/easyzoom.js"); if (!UrlManager.IsMobileDevice(Request)) { SetUpJavaScript("ThickBoxScript", "~/ClientScripts/ThickBox/thickbox.js"); } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ThickboxInit", "tb_init('a.zoom, area.zoom, input.zoom');", true); Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, new StoreRetriever().GetCurrentStoreID()); IList <ProductImage> imageList = product.ProductImages; if (product.ProductImages.Count != 0) { if (ImageUrl == null) { bool checkFirst = true; foreach (ProductImage image in imageList) { HyperLink hyLink = new HyperLink(); if (checkFirst) { hyLink.Attributes.Add("class", "zoom"); HtmlGenericControl div = new HtmlGenericControl("div"); div.ID = "len"; div.Attributes.Add("class", "zoom_len"); hyLink.Controls.Add(div); } else { hyLink.Style.Add("display", "none"); } hyLink.Attributes.Add("rel", "gallery" + product.ProductID); if (!UrlManager.IsMobileDevice(Request)) { hyLink.NavigateUrl = "~/" + image.LargeImage; } if (image.Locales[StoreContext.Culture].TitleTag != null) { hyLink.ToolTip = image.Locales[StoreContext.Culture].TitleTag; } else { hyLink.ToolTip = product.Name; } if (image.Locales[StoreContext.Culture].AltTag != null) { hyLink.Attributes.Add("alt", image.Locales[StoreContext.Culture].AltTag); } Image HtmlImage = new Image(); HtmlImage = SetUpImage(HtmlImage, image.RegularImage); HtmlImage.ImageUrl = "~/" + image.RegularImage; hyLink.Controls.Add(HtmlImage); PlaceHolder1.Controls.Add(hyLink); if (checkFirst) { RegisterZoomScript(hyLink); checkFirst = false; } } } else { foreach (ProductImage image in imageList) { HyperLink hyLink = new HyperLink(); if (image.Locales[StoreContext.Culture].TitleTag != null) { hyLink.ToolTip = image.Locales[StoreContext.Culture].TitleTag; } else { hyLink.ToolTip = product.Name; } if (image.Locales[StoreContext.Culture].AltTag != null) { hyLink.Attributes.Add("alt", image.Locales[StoreContext.Culture].AltTag); } if (!UrlManager.IsMobileDevice(Request)) { hyLink.NavigateUrl = "~/" + image.LargeImage; } hyLink.Attributes.Add("rel", "gallery" + product.ProductID); if (!image.RegularImage.Equals(ImageUrl.Replace("~/", ""))) { hyLink.Style.Add("display", "none"); } else { hyLink.Attributes.Add("class", "zoom"); HtmlGenericControl div = new HtmlGenericControl("div"); div.ID = "len"; div.Attributes.Add("class", "zoom_len"); hyLink.Controls.Add(div); } Image HtmlImage = new Image(); HtmlImage = SetUpImage(HtmlImage, image.RegularImage); HtmlImage.ImageUrl = "~/" + image.RegularImage; hyLink.Controls.Add(HtmlImage); PlaceHolder1.Controls.Add(hyLink); if (image.RegularImage.Equals(ImageUrl.Replace("~/", ""))) { RegisterZoomScript(hyLink); } } } } else { ImageUrl = "~/" + DataAccessContext.Configurations.GetValue("DefaultImageUrl"); Image HtmlImage = new Image(); HtmlImage.ImageUrl = ImageUrl; PlaceHolder1.Controls.Add(HtmlImage); } }