public static void ExportMySQL() { if (!CMOptions.ModuleEnabled || !CMOptions.MySQLEnabled || !CMOptions.MySQLInfo.IsValid()) { if (_Connection != null) { _Connection.Dispose(); _Connection = null; } return; } if (_Connection != null && !_Connection.IsDisposed) { return; } CMOptions.ToConsole("Updating MySQL database..."); VitaNexCore.TryCatch( () => { _Connection = new MySQLConnection(CMOptions.MySQLInfo); _Connection.ConnectAsync(0, true, () => { var a = new Action(UpdateMySQL); a.BeginInvoke( r => { a.EndInvoke(r); UpdateMySQL(); }, null); }); }, x => { if (_Connection != null) { _Connection.Dispose(); _Connection = null; } CMOptions.ToConsole(x); }); }
public void Dispose() { if (_cachedConnection != null) { _cachedConnection.Dispose(); _cachedConnection = null; } }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
static void Main(string[] args) { #region MySQLConnection // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs // the idea is to test MySQL as we have LINQ to SQL also running in chrome now //var mysqld = @"C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\mysqld.exe"; //// --standalone --console //var mysqldp = Process.Start(mysqld, " --standalone --console"); // Additional information: WaitForInputIdle failed. This could be because the process does not have a graphical interface. //mysqldp.WaitForInputIdle(); Thread.Sleep(3000); // the safe way to hint we need to talk PHP dialect QueryExpressionBuilder.Dialect = QueryExpressionBuilderDialect.MySQL; QueryExpressionBuilder.WithConnection = y => { var DataSource = "file:xApplicationPerformance.xlsx.sqlite"; var cc0 = new MySQLConnection( new System.Data.MySQL.MySQLConnectionStringBuilder { UserID = "tssl", Server = "192.168.1.211", // password is useless if client cert is to be used Password = "******", SslMode = MySQLSslMode.Required, // private key CertificateFile = @"X:\Monese\network\certs\local_devsql1\local_sql_client.pfx", //ConnectionTimeout = 3000 }.ToString() //new MySQLConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString() ); // Additional information: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'asus7' (using password: NO) // Additional information: Unable to connect to any of the specified MySQL hosts. cc0.Open(); #region use db { var a = Assembly.GetExecutingAssembly().GetName(); // SkipUntilIfAny ??? var QDataSource = a.Name + ":" + DataSource.SkipUntilIfAny("file:").TakeUntilIfAny(".xlsx.sqlite"); // QDataSource.Length = 76 var QLengthb = QDataSource.Length; // Database 64 cc0.CreateCommand("CREATE DATABASE IF NOT EXISTS `" + QDataSource + "`").ExecuteScalar(); cc0.CreateCommand("use `" + QDataSource + "`").ExecuteScalar(); } #endregion y(cc0); cc0.Dispose(); }; #endregion new PerformanceResourceTimingData2ApplicationPerformance().Delete(); new PerformanceResourceTimingData2ApplicationPerformance().Insert( new PerformanceResourceTimingData2ApplicationPerformanceRow { connectEnd = 9, connectStart = 5, Tag = "first insert" }, new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, connectEnd = 111, Tag = "middle insert" }, new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, connectEnd = 11, Tag = "Last insert, selected by group by" } ); // https://code.google.com/p/chromium/issues/detail?id=369239&can=5&colspec=ID%20Pri%20M%20Iteration%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified var f = ( from x in new PerformanceResourceTimingData2ApplicationPerformance() //orderby x.Key ascending // MYSQL and SQLITE seem to behave differently? in reverse actually! orderby x.connectEnd descending // { f = { c = 3, Tag = first insert } } //orderby x.Key ascending // { f = { c = 3, Tag = Last insert, selected by group by } } // { f = { c = 3, Tag = first insert } } group x by x.connectStart into gg select new { c = gg.Count(), // need orderby x.Key descending ! gg.Last().Tag } ).FirstOrDefault(); System.Console.WriteLine( new { f } ); //mysqldp.CloseMainWindow(); Debugger.Break(); }
static void Main(string[] args) { // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs #region MySQLConnection // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs // the idea is to test MySQL as we have LINQ to SQL also running in chrome now //var mysqld = @"C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\mysqld.exe"; var mysqld = @"X:\util\xampp-win32-1.8.3-5-VC11\xampp\mysql\bin\mysqld.exe"; // --standalone --console var mysqldp = Process.Start(mysqld, " --standalone --console"); // C:\util\xampp\mysql\bin\mysqld.exe --defaults-file=C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\my.ini mysql // already running as a service? //151019 12:23:06 InnoDB: Operating system error number 32 in a file operation. //InnoDB: The error means that another program is using InnoDB's files. //InnoDB: This might be a backup or antivirus software or another instance //InnoDB: of MySQL. Please close it to get rid of this error. // Additional information: WaitForInputIdle failed. This could be because the process does not have a graphical interface. //mysqldp.WaitForInputIdle(); Thread.Sleep(3000); // the safe way to hint we need to talk PHP dialect QueryExpressionBuilder.Dialect = QueryExpressionBuilderDialect.MySQL; QueryExpressionBuilder.WithConnection = y => { var DataSource = "file:xApplicationPerformance.xlsx.sqlite"; var cc0 = new MySQLConnection( new System.Data.MySQL.MySQLConnectionStringBuilder { UserID = "root", Server = "127.0.0.1", //SslMode = MySQLSslMode.VerifyFull //ConnectionTimeout = 3000 }.ToString() //new MySQLConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString() ); // Additional information: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'asus7' (using password: NO) // Additional information: Unable to connect to any of the specified MySQL hosts. cc0.Open(); // Additional information: Authentication to host '127.0.0.1' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: NO) // https://www.apachefriends.org/download.html #region use db { var a = Assembly.GetExecutingAssembly().GetName(); // SkipUntilIfAny ??? var QDataSource = a.Name + ":" + DataSource.SkipUntilIfAny("file:").TakeUntilIfAny(".xlsx.sqlite"); // QDataSource.Length = 76 var QLengthb = QDataSource.Length; // Database 64 cc0.CreateCommand("CREATE DATABASE IF NOT EXISTS `" + QDataSource + "`").ExecuteNonQuery(); cc0.CreateCommand("use `" + QDataSource + "`").ExecuteNonQuery(); } #endregion y(cc0); cc0.Dispose(); }; #endregion var n = new PerformanceResourceTimingData2ApplicationPerformance(); var rid = n.Insert( new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, connectEnd = 13, EventTime = DateTime.Now.AddDays(-0), z = new XElement("goo", "foo") } ); // { LastInsertRowId = 2 } var c = new PerformanceResourceTimingData2ApplicationPerformance().Count(); Console.WriteLine(new { c, rid }); Debugger.Break(); // + $exception {"Process has exited, so the requested information is not available."} System.Exception {System.InvalidOperationException} mysqldp.CloseMainWindow(); }
static void Main(string[] args) { #region MySQLConnection // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs // the idea is to test MySQL as we have LINQ to SQL also running in chrome now var mysqld = @"C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\mysqld.exe"; // --standalone --console var mysqldp = Process.Start(mysqld, " --standalone --console"); // Additional information: WaitForInputIdle failed. This could be because the process does not have a graphical interface. //mysqldp.WaitForInputIdle(); Thread.Sleep(3000); // the safe way to hint we need to talk PHP dialect QueryExpressionBuilder.Dialect = QueryExpressionBuilderDialect.MySQL; QueryExpressionBuilder.WithConnection = y => { var DataSource = "file:xApplicationPerformance.xlsx.sqlite"; var cc0 = new MySQLConnection( new System.Data.MySQL.MySQLConnectionStringBuilder { UserID = "root", Server = "127.0.0.1", //SslMode = MySQLSslMode.VerifyFull //ConnectionTimeout = 3000 }.ToString() //new MySQLConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString() ); // Additional information: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'asus7' (using password: NO) // Additional information: Unable to connect to any of the specified MySQL hosts. cc0.Open(); #region use db { var a = Assembly.GetExecutingAssembly().GetName(); // SkipUntilIfAny ??? var QDataSource = a.Name + ":" + DataSource.SkipUntilIfAny("file:").TakeUntilIfAny(".xlsx.sqlite"); // QDataSource.Length = 76 var QLengthb = QDataSource.Length; // Database 64 cc0.CreateCommand("CREATE DATABASE IF NOT EXISTS `" + QDataSource + "`").ExecuteScalar(); cc0.CreateCommand("use `" + QDataSource + "`").ExecuteScalar(); } #endregion y(cc0); cc0.Dispose(); }; #endregion new PerformanceResourceTimingData2ApplicationPerformance().Delete(); new PerformanceResourceTimingData2ApplicationPerformance().Insert( new PerformanceResourceTimingData2ApplicationPerformanceRow { connectEnd = 9, connectStart = 5, Tag = "first insert" }, new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, connectEnd = 111, Tag = "middle insert" }, new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, connectEnd = 11, Tag = "Last insert, selected by group by" } ); // https://code.google.com/p/chromium/issues/detail?id=369239&can=5&colspec=ID%20Pri%20M%20Iteration%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified var f = ( from x in new PerformanceResourceTimingData2ApplicationPerformance() //orderby x.Key ascending // MYSQL and SQLITE seem to behave differently? in reverse actually! orderby x.connectEnd ascending // { f = { c = 3, Tag = first insert } } group x by x.connectStart into gg select new { c = gg.Count(), // need orderby x.Key descending ! gg.Last().Tag } ).FirstOrDefault(); System.Console.WriteLine( new { f } ); mysqldp.CloseMainWindow(); Debugger.Break(); }
static void Main(string[] args) { // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs // the idea is to test MySQL as we have LINQ to SQL also running in chrome now var mysqld = @"C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\mysqld.exe"; // --standalone --console var mysqldp = Process.Start(mysqld, " --standalone --console"); // Additional information: WaitForInputIdle failed. This could be because the process does not have a graphical interface. //mysqldp.WaitForInputIdle(); Thread.Sleep(500); #region MySQLConnection // the safe way to hint we need to talk PHP dialect QueryExpressionBuilder.Dialect = QueryExpressionBuilderDialect.MySQL; QueryExpressionBuilder.WithConnection = y => { var DataSource = "file:xApplicationPerformance.xlsx.sqlite"; var cc0 = new MySQLConnection( new System.Data.MySQL.MySQLConnectionStringBuilder { UserID = "root", Server = "127.0.0.1", }.ToString() //new MySQLConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString() ); // Additional information: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'asus7' (using password: NO) // Additional information: Unable to connect to any of the specified MySQL hosts. cc0.Open(); #region use db { var a = Assembly.GetExecutingAssembly().GetName(); // SkipUntilIfAny ??? var QDataSource = a.Name + ":" + DataSource.SkipUntilIfAny("file:").TakeUntilIfAny(".xlsx.sqlite"); // QDataSource.Length = 76 var QLengthb = QDataSource.Length; // Database 64 cc0.CreateCommand("CREATE DATABASE IF NOT EXISTS `" + QDataSource + "`").ExecuteScalar(); cc0.CreateCommand("use `" + QDataSource + "`").ExecuteScalar(); } #endregion y(cc0); cc0.Dispose(); }; #endregion //'TestXMySQL.PerformanceResourceTimingData2ApplicationPerformanceRow' cannot be used for delegate parameter of type 'System.Object' // ThreadLocal SynchronizationContext aware ConnectionPool? var n = new PerformanceResourceTimingData2ApplicationPerformance(); //n.Create(); // wont return? jsc broke xMySQL async? no there was an sql error //var count = n.CountAsync(cc0).Result; var count = n.Count(); // ScriptCoreLib.Async n.Insert( new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, connectEnd = 13, EventTime = DateTime.Now.AddDays(-0) } // if you do not wait you wont get the id damn it ); // should be based on QueryExpressionBuilder.Dialect, and wait for the last async? //var id = cc0.GetLastInsertRowId(); // http://stackoverflow.com/questions/5440168/c-sharp-mysql-there-is-already-an-open-datareader-associated-with-this-connectio var q = from x in new PerformanceResourceTimingData2ApplicationPerformance() orderby x.Timestamp descending select new { x.Key, x.connectStart, x.connectEnd, x.Timestamp }; //var f = q.FirstOrDefaultAsync().Result; var f = q.FirstOrDefault(); Console.WriteLine(new { f }); //new PerformanceResourceTimingData2ApplicationPerformance().Where(x => x.Key == f.Key).Delete(); //new PerformanceResourceTimingData2ApplicationPerformance().Delete(x => x.Key == f.Key); new PerformanceResourceTimingData2ApplicationPerformance().Delete(f.Key); mysqldp.CloseMainWindow(); Debugger.Break(); }
static void Main(string[] args) { // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs #region MySQLConnection // the idea is to test MySQL as we have LINQ to SQL also running in chrome now var mysqld = @"C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\mysqld.exe"; // --standalone --console var mysqldp = Process.Start(mysqld, " --standalone --console"); // Additional information: WaitForInputIdle failed. This could be because the process does not have a graphical interface. //mysqldp.WaitForInputIdle(); Thread.Sleep(5500); // the safe way to hint we need to talk PHP dialect QueryExpressionBuilder.Dialect = QueryExpressionBuilderDialect.MySQL; QueryExpressionBuilder.WithConnection = y => { var DataSource = "file:xApplicationPerformance.xlsx.sqlite"; var cc0 = new MySQLConnection( new System.Data.MySQL.MySQLConnectionStringBuilder { UserID = "root", Server = "127.0.0.1", }.ToString() //new MySQLConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString() ); // Additional information: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'asus7' (using password: NO) // Additional information: Unable to connect to any of the specified MySQL hosts. var st = Stopwatch.StartNew(); while (true) { try { Thread.Sleep(300); cc0.Open(); break; } catch { if (st.ElapsedMilliseconds > 6000) { // give up throw; } } } #region use db { var a = Assembly.GetExecutingAssembly().GetName(); // SkipUntilIfAny ??? var QDataSource = a.Name + ":" + DataSource.SkipUntilIfAny("file:").TakeUntilIfAny(".xlsx.sqlite"); // QDataSource.Length = 76 var QLengthb = QDataSource.Length; // Database 64 cc0.CreateCommand("CREATE DATABASE IF NOT EXISTS `" + QDataSource + "`").ExecuteScalar(); cc0.CreateCommand("use `" + QDataSource + "`").ExecuteScalar(); } #endregion y(cc0); cc0.Dispose(); }; #endregion new PerformanceResourceTimingData2ApplicationPerformance().Insert( new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, Tag = "first insert" } ); new PerformanceResourceTimingData2ApplicationResourcePerformance().Insert( new PerformanceResourceTimingData2ApplicationResourcePerformanceRow { connectStart = 5, Tag = "first insert" } ); // Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== `y`.`connectStart` var q = ( from x in new PerformanceResourceTimingData2ApplicationPerformance() join y in new PerformanceResourceTimingData2ApplicationResourcePerformance() on x.connectStart equals y.connectStart select new { field1 = x.connectStart, field2 = y.connectStart, field3 = y.connectStart, } ); var f = q.FirstOrDefault(); Console.WriteLine(new { f }); // { f = { field1 = 5, field2 = 5, field3 = 5 } } mysqldp.CloseMainWindow(); Debugger.Break(); }
static void Main(string[] args) { // X:\jsc.svn\examples\javascript\LINQ\test\TestSelectGroupByAndConstant\TestSelectGroupByAndConstant\ApplicationWebService.cs #region MySQLConnection // the idea is to test MySQL as we have LINQ to SQL also running in chrome now var mysqld = @"C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\mysqld.exe"; // --standalone --console var mysqldp = Process.Start(mysqld, " --standalone --console"); // Additional information: WaitForInputIdle failed. This could be because the process does not have a graphical interface. //mysqldp.WaitForInputIdle(); Thread.Sleep(5500); // the safe way to hint we need to talk PHP dialect QueryExpressionBuilder.Dialect = QueryExpressionBuilderDialect.MySQL; QueryExpressionBuilder.WithConnection = y => { var DataSource = "file:xApplicationPerformance.xlsx.sqlite"; var cc0 = new MySQLConnection( new System.Data.MySQL.MySQLConnectionStringBuilder { UserID = "root", Server = "127.0.0.1", }.ToString() //new MySQLConnectionStringBuilder { DataSource = "file:PerformanceResourceTimingData2.xlsx.sqlite" }.ToString() ); // Additional information: Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'asus7' (using password: NO) // Additional information: Unable to connect to any of the specified MySQL hosts. var st = Stopwatch.StartNew(); while (true) try { Thread.Sleep(300); cc0.Open(); break; } catch { if (st.ElapsedMilliseconds > 6000) // give up throw; } #region use db { var a = Assembly.GetExecutingAssembly().GetName(); // SkipUntilIfAny ??? var QDataSource = a.Name + ":" + DataSource.SkipUntilIfAny("file:").TakeUntilIfAny(".xlsx.sqlite"); // QDataSource.Length = 76 var QLengthb = QDataSource.Length; // Database 64 cc0.CreateCommand("CREATE DATABASE IF NOT EXISTS `" + QDataSource + "`").ExecuteScalar(); cc0.CreateCommand("use `" + QDataSource + "`").ExecuteScalar(); } #endregion y(cc0); cc0.Dispose(); }; #endregion new PerformanceResourceTimingData2ApplicationPerformance().Insert( new PerformanceResourceTimingData2ApplicationPerformanceRow { connectStart = 5, Tag = "first insert" } ); new PerformanceResourceTimingData2ApplicationResourcePerformance().Insert( new PerformanceResourceTimingData2ApplicationResourcePerformanceRow { connectStart = 5, Tag = "first insert" } ); // Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== `y`.`connectStart` var q = ( from x in new PerformanceResourceTimingData2ApplicationPerformance() join y in new PerformanceResourceTimingData2ApplicationResourcePerformance() on x.connectStart equals y.connectStart select new { field1 = x.connectStart, field2 = y.connectStart, field3 = y.connectStart, } ); var f = q.FirstOrDefault(); Console.WriteLine(new { f }); // { f = { field1 = 5, field2 = 5, field3 = 5 } } mysqldp.CloseMainWindow(); Debugger.Break(); }