void DoTask() { Global.Report.WriteAppLog(string.Format("Task scheduler:{0} id = {1} starting", Schema.Name, SchemaId)); try { System.Data.SqlClient.SqlConnectionStringBuilder sqlConnBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(); sqlConnBuilder.DataSource = string.Format("127.0.0.1:{0}", Global.Setting.Config.TcpPort); sqlConnBuilder.UserID = Schema.UserName.Trim(); sqlConnBuilder.Password = Hubble.Framework.Security.DesEncryption.Decrypt(new byte[] { 0x14, 0x0A, 0x0C, 0x0E, 0x0A, 0x11, 0x42, 0x58 }, Schema.Password); sqlConnBuilder.InitialCatalog = Schema.Database.Trim(); using (Hubble.SQLClient.HubbleAsyncConnection conn = new Hubble.SQLClient.HubbleAsyncConnection(sqlConnBuilder.ConnectionString)) { conn.Open(); Hubble.SQLClient.HubbleCommand cmd = new Hubble.SQLClient.HubbleCommand(Schema.Sql, conn); cmd.CommandTimeout = 3600 * 24 * 365 * 10; cmd.ExecuteNonQuery(); } } catch (ServerException e) { Global.Report.WriteErrorLog(string.Format("Run task scheduler:{0} id = {1} fail, task hasn't finished. \r\nException:{2} \r\n:Stack:{3}", Schema.Name, SchemaId, e.Message, e.InnerStackTrace)); } catch (Exception e) { Global.Report.WriteErrorLog(string.Format("Run task scheduler:{0} id = {1} fail, task hasn't finished", Schema.Name, SchemaId), e); } lock (this) { _Thread = null; } Global.Report.WriteAppLog(string.Format("Task scheduler:{0} id = {1} finished", Schema.Name, SchemaId)); }
private void buttonTest_Click(object sender, EventArgs e) { try { System.Data.SqlClient.SqlConnectionStringBuilder sqlConnBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder(); sqlConnBuilder.DataSource = QueryAnalyzer.GlobalSetting.DataAccess.ServerName; sqlConnBuilder.UserID = textBoxUserName.Text.Trim(); sqlConnBuilder.Password = textBoxPassword.Text.Trim(); sqlConnBuilder.InitialCatalog = textBoxDatabase.Text.Trim(); using (Hubble.SQLClient.HubbleConnection conn = new Hubble.SQLClient.HubbleConnection(sqlConnBuilder.ConnectionString)) { conn.Open(); Hubble.SQLClient.HubbleCommand cmd = new Hubble.SQLClient.HubbleCommand(textBoxSql.Text, conn); cmd.ExecuteNonQuery(); } MessageBox.Show("Execute sql successful.", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }