public static void UpdateDatabase(PostMain post) { try { using (System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\jmcbr\\Source\\Repos\\subanalyzer\\SubAnalyzer\\SubAnalyzer\\subanalyzer.mdf;Integrated Security=True;Connect Timeout=30")) { System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); var query = String.Format("INSERT INTO [PostMain] (Title, UserName, TitleLink, PostId, PostDate) VALUES('{0}', '{1}', '{2}', '{3}', '{4}')", post.Title, post.UserName, post.TitleLink, post.PostId, post.PostDate ); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; cmd.Connection = sqlConnection; sqlConnection.Open(); cmd.ExecuteNonQuery(); sqlConnection.Close(); } } catch (Exception e) { throw; } }
private static unsafe IntPtr VirtualMachine__RunFunctionHook(VirtualMachine *virtualMachine, string functionName, int a3, int a4, int a5, int a6) { IntPtr num = IntPtr.Zero; try { string str = functionName; if (str == "config") { PreConfig?.Invoke(); num = VirtualMachine__RunFunction(virtualMachine, functionName, a3, a4, a5, a6); PostConfig?.Invoke(); } else { if (str == "main") { PreMain?.Invoke(); num = VirtualMachine__RunFunction(virtualMachine, functionName, a3, a4, a5, a6); PostMain?.Invoke(); } else { num = VirtualMachine__RunFunction(virtualMachine, functionName, a3, a4, a5, a6); } } } catch (Exception ex) { Trace.WriteLine($"Unhandled Exception in {nameof(Script)}.{nameof(VirtualMachine__RunFunctionHook)}!"); Trace.WriteLine(ex.ToString()); } return(num); }
public static string Test2(string url, int count, string after) { try { var webGet = new HtmlWeb(); var document = webGet.Load(url); var postList = document.DocumentNode.SelectNodes("//div[@id='siteTable']/div[contains(@class, 'thing')]"); var skipId = ""; foreach (HtmlNode post in postList) { var topMatter = post.SelectSingleNode(".//div[contains(@class, 'entry')]").SelectSingleNode(".//div[contains(@class, 'top-matter')]"); var unVoted = post.SelectSingleNode(".//div[contains(@class, 'unvoted')]"); var score = unVoted.SelectSingleNode(".//div[contains(@class, 'unvoted')]").InnerText; var tagLine = topMatter.SelectSingleNode(".//p[contains(@class, 'tagline')]"); var titleContent = topMatter.SelectSingleNode(".//p[@class='title']").SelectSingleNode(".//a[contains(@class, 'title')]"); var postTitle = titleContent.InnerText; var titleLink = titleContent.Attributes["href"].Value; var userName = tagLine.SelectSingleNode(".//a[contains(@class, 'author')]").InnerText; var postId = post.Id.Split('_')[2]; DateTime postTime = Convert.ToDateTime(tagLine.SelectSingleNode(".//time").Attributes["datetime"].Value); var newPost = new PostMain() { Title = postTitle.Replace("\"", "'").Replace("'", "''"), UserName = userName, TitleLink = titleLink, PostId = postId, PostDate = postTime }; DatabaseService.UpdateDatabase(newPost); skipId = postId; } return(skipId); } catch (Exception e) { return("Nope"); } }