void getAuthorID() { connection(); string OID = "SELECT AUT_ID FROM AUTHOR ORDER BY AUT_ID"; string AuthorName; int AuthorID; string format = "000000"; SqlDataAdapter ad = new SqlDataAdapter(OID, consql); DataSet ds = new DataSet(); ad.Fill(ds, "Author"); if (ds.Tables["Author"].Rows.Count > 0) { AuthorName = ds.Tables["Author"].Rows[ds.Tables["Author"].Rows.Count - 1][0].ToString(); AuthorID = int.Parse(AuthorName.Substring(2, (AuthorName.Length - 2))); authorid = "AU" + ((AuthorID + 1).ToString(format)); } else { authorid = "AU000001"; } }
public async Task Load(string url) { IsValid = false; url = url.Trim().ToLower(); if (!url.Contains("://steamcommunity.com/sharedfiles/filedetails/") && !url.Contains("://steamcommunity.com/workshop/filedetails/")) { return; } Url = url; HtmlWeb web = new HtmlWeb(); var htmlDoc = web.Load(Url); if (htmlDoc == null) { return; } Title = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='workshopItemTitle']")?.InnerHtml; Tags = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='rightDetailsBlock']")?.Descendants("a")?.Select(x => x.InnerHtml).ToArray(); Singleplayer = false; foreach (var tag in Tags) { if (tag == "Singleplayer") { Singleplayer = true; } if (tag == "Cooperative") { Singleplayer = false; } } Description = FormatLineBreaks(htmlDoc.DocumentNode.SelectSingleNode("//div[@class='workshopItemDescription']")?.InnerHtml); Type = ItemType.Mod; if (htmlDoc.DocumentNode.SelectSingleNode("//div[@class='collectionHeader']") != null) { Type = ItemType.Collection; } if (htmlDoc.DocumentNode.SelectSingleNode("//div[@class='subscribeOption']") != null) { Type = ItemType.Other; } Image = htmlDoc.DocumentNode.Descendants("img")?.FirstOrDefault(d => d.Id == "previewImage")?.Attributes?.FirstOrDefault(x => x.Name == "src")?.Value; if (Image == null) { Image = htmlDoc.DocumentNode.Descendants("img")?.FirstOrDefault(d => d.Id == "previewImageMain")?.Attributes?.FirstOrDefault(x => x.Name == "src")?.Value; } AppId = 0; string shareclick = htmlDoc.DocumentNode.Descendants("span")?.FirstOrDefault(d => d.Id == "ShareItemBtn")?.Attributes["onclick"]?.Value; if (shareclick != null) { int startAppId = shareclick.IndexOf(", '") + 3; int endAppId = shareclick.LastIndexOf("'"); if (startAppId != -1 && endAppId != -1) { int.TryParse(shareclick.Substring(startAppId, endAppId - startAppId), out AppId); } } if (AppId != 0) { WebClient client = new WebClient(); string appData = await client.DownloadStringTaskAsync(new Uri("http://store.steampowered.com/api/appdetails?appids=" + AppId)); int index = appData.IndexOf("name"); if (index != -1) { appData = appData.Substring(index + 7); index = appData.IndexOf("\""); if (index != -1) { AppName = appData.Substring(0, index); } } } AuthorName = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='friendBlockContent']")?.InnerText?.TrimStart(); if (AuthorName.IndexOf("\r\n") != -1) { AuthorName = AuthorName.Substring(0, AuthorName.IndexOf("\r\n")); } if (AuthorName.IndexOf("\r") != -1) { AuthorName = AuthorName.Substring(0, AuthorName.IndexOf("\r")); } if (AuthorName.IndexOf("\n") != -1) { AuthorName = AuthorName.Substring(0, AuthorName.IndexOf("\n")); } AuthorUrl = htmlDoc.DocumentNode.SelectSingleNode("//a[@class='friendBlockLinkOverlay']")?.Attributes["href"]?.Value; AuthorImageUrl = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='creatorsBlock']")?.Descendants("div")?.First()?.Descendants("div")?.FirstOrDefault(x => x.HasClass("playerAvatar"))?.Descendants("img")?.First()?.Attributes["src"].Value; IsValid = true; }