private void LaunchArrows(Dictionary <string, string> msg) { #if _debug DateTime time = DateTime.Now; #endif UserDataSetTableAdapters.ArrowTableAdapter ad = new UserDataSetTableAdapters.ArrowTableAdapter(); UserDataSet.ArrowDataTable dt = ad.GetData( "select * from [Arrow] where [Name] = @Name or [Name] like @Names", new Dictionary <string, object> { { "@Name", msg["Name"] }, { "@Names", msg["Name"] + ".%" } } ); // this method is slower than above //var dt = ad.GetData(); //var row = (from r in dt // where r.Name == msg[dt.NameColumn.ColumnName] // select r).First(); if (dt.Count == 1) { LaunchArrow(dt[0], msg["Arg"]); } else { foreach (var row in dt) { LaunchArrow(row); } } ad.Update(dt); #if _debug Console.WriteLine(msg["Name"]); Console.WriteLine(msg["Arg"]); Console.WriteLine("time: " + DateTime.Now.Subtract(time).TotalMilliseconds + "\r\n"); #endif }
public static void CheckAndFix() { UserDataSetTableAdapters.ArrowTableAdapter da = new UserDataSetTableAdapters.ArrowTableAdapter(); da.Adapter.SelectCommand = da.Connection.CreateCommand(); da.Adapter.SelectCommand.CommandText = @"create table if not exists Arrow ( Name varchar(50) NOT NULL, Cmd text NOT NULL, Arg varchar(500), Tag varchar(500), HotKey varchar(500), Count int NOT NULL DEFAULT 0, Enabled tinyint NOT NULL DEFAULT 0, Encrypted tinyint NOT NULL DEFAULT 0, Timestamp datetime NOT NULL, GUID char(50) NOT NULL, PRIMARY KEY (Name) );"; da.Connection.Open(); da.Adapter.SelectCommand.ExecuteNonQuery(); da.Connection.Close(); }
private void LaunchArrows(Dictionary<string, string> msg) { #if _debug DateTime time = DateTime.Now; #endif UserDataSetTableAdapters.ArrowTableAdapter ad = new UserDataSetTableAdapters.ArrowTableAdapter(); UserDataSet.ArrowDataTable dt = ad.GetData( "select * from [Arrow] where [Name] = @Name or [Name] like @Names", new Dictionary<string, object> { { "@Name", msg["Name"] }, { "@Names", msg["Name"] + ".%" } } ); // this method is slower than above //var dt = ad.GetData(); //var row = (from r in dt // where r.Name == msg[dt.NameColumn.ColumnName] // select r).First(); if (dt.Count == 1) { LaunchArrow(dt[0], msg["Arg"]); } else { foreach (var row in dt) { LaunchArrow(row); } } ad.Update(dt); #if _debug Console.WriteLine(msg["Name"]); Console.WriteLine(msg["Arg"]); Console.WriteLine("time: " + DateTime.Now.Subtract(time).TotalMilliseconds + "\r\n"); #endif }