private void btnConnectTest_Click(object sender, EventArgs e) { AppDC.DBServer = txtServer.Text.Trim(); AppDC.DBName = txtDB.Text.Trim(); AppDC.UserName = txtUserName.Text.Trim(); AppDC.Password = txtPassword.Text.Trim(); LoginDS = new SqlsvrDBSource(AppDC); if (LoginDS.Connect()) { MessageBox.Show("连接成功!"); } else { string errMsg = LoginDS.ErrorMessage; MessageBox.Show(errMsg); return; } }
public void ReadAndWriteToAzure() { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture(AzureSqlConnection, "[source].[AzureSource]"); source2Columns.InsertTestData(); TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture(AzureSqlConnection, "[dest].[AzureDestination]"); //Act DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(AzureSqlConnection, "[source].[AzureSource]"); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>(AzureSqlConnection, "[dest].[AzureDestination]"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); }
public void SimpleFlowWithBatchWrite() { //Arrange TwoColumnsTableFixture s2C = new TwoColumnsTableFixture("JsonDestBatch"); s2C.InsertTestDataSet3(); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(SqlConnection, "JsonDestBatch"); //Act JsonDestination <MySimpleRow> dest = new JsonDestination <MySimpleRow>("./ObjectWithBatchWrite.json"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Equal(File.ReadAllText("res/JsonDestination/TwoColumnsSet3.json"), File.ReadAllText("./ObjectWithBatchWrite.json")); }
public void Sql_Tablename() { TableDefinition destinationTableDefinition = new TableDefinition("test.Destination", new List <TableColumn>() { new TableColumn("Col1", "nvarchar(100)", allowNulls: false), new TableColumn("Col2", "int", allowNulls: true) }); destinationTableDefinition.CreateTable(); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>( $@"select * from (values ('Test1',1), ('Test2',2), ('Test',3)) AS MyTable(Col1,Col2)"); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>("test.Destination"); source.LinkTo(dest); source.Execute(); dest.Wait(); Assert.AreEqual(3, RowCountTask.Count("test.Destination")); }
private void ShowDataDic(DBSource dBSource, string dbname, string tbname, string html) { var tit = $"数据字典-[{dbname}].[{tbname}]"; foreach (TabPage tab in this.TabControl.TabPages) { if (tab.Text.Equals(tit)) { (tab as UC.WebTab).SetHtml(html); TabControl.SelectedTab = tab; return; } } UC.WebTab panel = new WebTab(); panel.SetHtml(html); panel.Text = tit; this.TabControl.TabPages.Add(panel); this.TabControl.SelectedTab = panel; }
public void SimpleFlowWithObject() { //Arrange TwoColumnsTableFixture s2C = new TwoColumnsTableFixture("CSVDestSimple"); s2C.InsertTestDataSet3(); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(SqlConnection, "CSVDestSimple"); //Act CSVDestination <MySimpleRow> dest = new CSVDestination <MySimpleRow>("./SimpleWithObject.csv"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Equal(File.ReadAllText("./SimpleWithObject.csv"), File.ReadAllText("res/CSVDestination/TwoColumnsSet3.csv")); }
public void AccessIntoDB() { //Arrange TableDefinition testTable = RecreateAccessTestTable(); InsertTestData(); TwoColumnsTableFixture destTable = new TwoColumnsTableFixture(SqlConnection, "dbo.AccessTargetTable"); //Act DBSource <Data> source = new DBSource <Data>(AccessOdbcConnection, "TestTable"); DBDestination <Data> dest = new DBDestination <Data>(SqlConnection, "dbo.AccessTargetTable"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert destTable.AssertTestData(); }
public void SourceMoreColumnsThanDestination(IConnectionManager connection) { //Arrange FourColumnsTableFixture source4Columns = new FourColumnsTableFixture(connection, "SourceDynamic4Cols"); source4Columns.InsertTestData(); TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture(connection, "DestinationDynamic2Cols"); //Act DBSource <ExpandoObject> source = new DBSource <ExpandoObject>(connection, "SourceDynamic4Cols"); DBDestination <ExpandoObject> dest = new DBDestination <ExpandoObject>(connection, "DestinationDynamic2Cols"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); }
public void TestTransferBetweenDBs(IConnectionManager sourceConnection, IConnectionManager destConnection) { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture(sourceConnection, "Source"); source2Columns.InsertTestData(); TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture(destConnection, "Destination"); //Act DBSource source = new DBSource(sourceConnection, "Source"); DBDestination dest = new DBDestination(destConnection, "Destination"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); }
public void DBSourceWithColumnMapping() { SqlTask.ExecuteNonQuery("Create source table", @"CREATE TABLE test.Source (Col1 nvarchar(100) null, Col2 nvarchar(100) null)"); SqlTask.ExecuteNonQuery("Insert demo data", "insert into test.Source values('Test1','Test2')"); SqlTask.ExecuteNonQuery("Insert demo data", "insert into test.Source values('Test1','Test2')"); SqlTask.ExecuteNonQuery("Insert demo data", "insert into test.Source values('Test1','Test2')"); DBSource <ColumnMapRow> source = new DBSource <ColumnMapRow>("test.Source"); CustomDestination <ColumnMapRow> dest = new CustomDestination <ColumnMapRow>( input => { Assert.AreEqual("Test1", input.Col1); Assert.AreEqual("Test2", input.B); }); source.LinkTo(dest); source.Execute(); dest.Wait(); }
public void SimpleFlow(IConnectionManager connection) { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture(connection, "DBSourceSimple"); source2Columns.InsertTestData(); TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture(connection, "DBDestinationSimple"); //Act DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(connection, "DBSourceSimple"); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>(connection, "DBDestinationSimple"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); }
public void SimpleNonGeneric() { //Arrange TwoColumnsTableFixture s2C = new TwoColumnsTableFixture("JsonDestSimpleNonGeneric"); s2C.InsertTestDataSet3(); DBSource source = new DBSource(SqlConnection, "JsonDestSimpleNonGeneric"); //Act JsonDestination dest = new JsonDestination("./SimpleNonGeneric.json"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Equal(File.ReadAllText("./SimpleNonGeneric.json"), File.ReadAllText("res/JsonDestination/TwoColumnsSet3StringArray.json")); }
private async void getStops(string traid) { Train treno = await DBSource.getTrain(traid); NomeTreno.Text = "Treno " + treno.ID; if (treno.Ferial == "Y") { Title.Text = "FERMATE - ESCLUSO DOMENICA E FESTIVI"; } if (treno.Festivo) { Title.Text = "FERMATE - SOLO DOMENICA E FESTIVI"; } if (treno.NoG == "Y") { Title.Text += " - NON GARANTITO"; } itemListView.ItemsSource = treno.ArrayOfStop; }
//private void ToggleAppBarButton(bool showPinButton) //{ // if (showPinButton) // { // this.StartPin.Label = "Agg a start"; // this.StartPin.Icon = new SymbolIcon(Symbol.Pin); // } // else // { // this.StartPin.Label = "Rim da Start"; // this.StartPin.Icon = new SymbolIcon(Symbol.UnPin); // } // this.StartPin.UpdateLayout(); //} private async void loadStations() { //ObservableCollection<TrainStop> stations = await DBSource.Stations; //foreach (TrainStop stop in stations) //{ // MapIcon icon = new MapIcon(); // icon.Title = stop.Name; // icon.NormalizedAnchorPoint = new Point(0.5, 1.0); // icon.Location = new Geopoint(new BasicGeoposition() // { // Latitude = stop.Latitude, // Longitude = stop.Longitude // }); // icon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Segnalino.png")); // Mappa.MapElements.Add(icon); //} Puspins.ItemsSource = await DBSource.getStopsPreload(); Puspins.ItemsSource = await DBSource.Stations; }
public void DB_BlockTrans_DB() { TableDefinition sourceTableDefinition = CreateSourceTable("test.Source"); TableDefinition destinationTableDefinition = CreateDestinationTable("test.Destination"); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(sourceTableDefinition); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>(destinationTableDefinition); Comparison <MySimpleRow> comp = new Comparison <MySimpleRow>( (x, y) => y.Col2 - x.Col2 ); Sort <MySimpleRow> block = new Sort <MySimpleRow>(comp); source.LinkTo(block); block.LinkTo(dest); source.Execute(); dest.Wait(); Assert.AreEqual(1, RowCountTask.Count("test.Destination", "[Key] = 1 and Col2 = 3")); Assert.AreEqual(1, RowCountTask.Count("test.Destination", "[Key] = 2 and Col2 = 2")); Assert.AreEqual(1, RowCountTask.Count("test.Destination", "[Key] = 3 and Col2 = 1")); }
public void DB_CustDest() { TableDefinition sourceTableDefinition = CreateSourceTable("test.Source"); TableDefinition destinationTableDefinition = CreateDestinationTable("test.Destination"); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>() { SourceTableDefinition = sourceTableDefinition }; CustomDestination <MySimpleRow> dest = new CustomDestination <MySimpleRow>( row => { SqlTask.ExecuteNonQuery("Insert row", $"insert into test.Destination values('{row.Value1}',{row.Value2})"); } ); source.LinkTo(dest); source.Execute(); dest.Wait(); Assert.AreEqual(3, RowCountTask.Count("test.Destination")); }
public void Table2JsonFile() { TableDefinition sourceTableDefinition = CreateSourceTable("test.Source"); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(sourceTableDefinition); List <MySimpleRow> rows = new List <MySimpleRow>(); CustomDestination <MySimpleRow> dest = new CustomDestination <MySimpleRow>( row => { rows.Add(row); } ); source.LinkTo(dest); source.Execute(); dest.Wait(); string json = JsonConvert.SerializeObject(rows, Formatting.Indented); Assert.AreEqual(json, File.ReadAllText("src/DataFlow/json_tobe.json")); }
public static bool CheckSQLConn(DBSource dbSource) { if (dbSource == null) { return(false); } try { using (MySqlConnection conn = new MySqlConnection(GetConnstringFromDBSource(dbSource, ""))) { conn.Open(); return(conn.State == ConnectionState.Open); } } catch (Exception ex) { LastException = ex; return(false); } }
public void DifferentColumnsInView(IConnectionManager connection) { //Arrange FourColumnsTableFixture s4c = new FourColumnsTableFixture(connection, "dbsource_extended"); s4c.InsertTestData(); CreateViewTask.CreateOrAlter(connection, "DBSourceViewExtended", $"SELECT {s4c.QB}Col2{s4c.QE}, {s4c.QB}Col4{s4c.QE} FROM dbsource_extended"); FourColumnsTableFixture d4c = new FourColumnsTableFixture(connection, "DBDestinationExtended", 1); //Act DBSource <MyExtendedRow> source = new DBSource <MyExtendedRow>(connection, "DBSourceViewExtended"); DBDestination <MyExtendedRow> dest = new DBDestination <MyExtendedRow>(connection, "DBDestinationExtended"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert d4c.AssertTestData(); }
public void SimpleFlow(IConnectionManager connection) { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture(connection, "dbsource_simple"); source2Columns.InsertTestData(); CreateViewTask.CreateOrAlter(connection, "DBSourceView", "SELECT * FROM dbsource_simple"); TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture(connection, "DBDestinationSimple"); //Act DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(connection, "DBSourceView"); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>(connection, "DBDestinationSimple"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); }
public void WithoutErrorLinking(IConnectionManager connection) { //Arrange CreateSourceTable(connection, "DBSourceNoErrorLinking"); TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture(connection, "DBDestinationNoErrorLinking"); //Act DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(connection, "DBSourceNoErrorLinking"); DBDestination <MySimpleRow> dest = new DBDestination <MySimpleRow>(connection, "DBDestinationNoErrorLinking"); source.LinkTo(dest); //Assert Assert.Throws <System.FormatException>(() => { source.Execute(); dest.Wait(); }); }
public void WithAdditionalNotNullCol(IConnectionManager connection) { //Arrange TwoColumnsTableFixture s2c = new TwoColumnsTableFixture(connection, "source_additionalnotnullcol"); s2c.InsertTestData(); SqlTask.ExecuteNonQuery(connection, "Create destination table", @"CREATE TABLE destination_additionalnotnullcol (col1 VARCHAR(100) NULL, col2 VARCHAR(100) NULL, col3 VARCHAR(100) NOT NULL)"); //Act DBSource source = new DBSource(connection, "source_additionalnotnullcol"); DBDestination dest = new DBDestination(connection, "destination_additionalnotnullcol"); source.LinkTo(dest); Assert.Throws <AggregateException>(() => { source.Execute(); dest.Wait(); }); }
public static DataTable ExecuteDBTable(DBSource dbSource, string connDB, string sql, params SqlParameter[] sqlParams) { using (var conn = new SqlConnection(GetConnstringFromDBSource(dbSource, connDB))) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = conn; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.CommandTimeout = 180; if (sqlParams != null) { cmd.Parameters.AddRange(sqlParams); } SqlDataAdapter ada = new SqlDataAdapter(cmd); DataTable tb = new DataTable(); ada.Fill(tb); return(tb); } } }
public void DisableHeader() { //Arrange TwoColumnsTableFixture s2c = new TwoColumnsTableFixture("CSVSourceNoHeader"); s2c.InsertTestData(); DBSource <MySimpleRow> source = new DBSource <MySimpleRow>(SqlConnection, "CSVSourceNoHeader"); //Act CSVDestination <MySimpleRow> dest = new CSVDestination <MySimpleRow>("./ConfigurationNoHeader.csv"); dest.Configuration.HasHeaderRecord = false; source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Equal(File.ReadAllText("./ConfigurationNoHeader.csv"), File.ReadAllText("res/CSVDestination/TwoColumnsNoHeader.csv")); }
public void SimpleNonGeneric() { //Arrange TwoColumnsTableFixture s2C = new TwoColumnsTableFixture("CSVDestSimpleNonGeneric"); s2C.InsertTestDataSet3(); DBSource source = new DBSource(SqlConnection, "CSVDestSimpleNonGeneric"); //Act CSVDestination dest = new CSVDestination("./SimpleNonGeneric.csv"); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert //Assert Assert.Equal(File.ReadAllText("./SimpleNonGeneric.csv"), File.ReadAllText("res/CSVDestination/TwoColumnsSet3NoHeader.csv")); }
public static List <GlobalStatusInfo> GetMysqlGlobalStatus(DBSource dbSource) { List <GlobalStatusInfo> list = new List <GlobalStatusInfo>(); var dataTable = MySQLHelper.ExecuteDBTable(dbSource, "", "show global Status;"); var dt = DateTime.Now; foreach (DataRow row in dataTable.AsEnumerable()) { GlobalStatusInfo info = new GlobalStatusInfo { Timestamp = dt, Variable_name = (string)row["Variable_name"], Val = (string)row["Value"], }; list.Add(info); } return(list); }
public void SimpleLookupFromDB(IConnectionManager connection) { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture(connection, "Source"); source2Columns.InsertTestData(); FourColumnsTableFixture dest4Columns = new FourColumnsTableFixture(connection, "Destination"); FourColumnsTableFixture lookup4Columns = new FourColumnsTableFixture(connection, "Lookup"); lookup4Columns.InsertTestData(); DBSource <MyInputDataRow> source = new DBSource <MyInputDataRow>(connection, "Source"); DBSource <MyLookupRow> lookupSource = new DBSource <MyLookupRow>(connection, "Lookup"); //Act List <MyLookupRow> LookupTableData = new List <MyLookupRow>(); Lookup <MyInputDataRow, MyOutputDataRow, MyLookupRow> lookup = new Lookup <MyInputDataRow, MyOutputDataRow, MyLookupRow>( row => { MyOutputDataRow output = new MyOutputDataRow() { Col1 = row.Col1, Col2 = row.Col2, Col3 = LookupTableData.Where(ld => ld.Key == row.Col1).Select(ld => ld.LookupValue1).FirstOrDefault(), Col4 = LookupTableData.Where(ld => ld.Key == row.Col1).Select(ld => ld.LookupValue2).FirstOrDefault(), }; return(output); } , lookupSource , LookupTableData ); DBDestination <MyOutputDataRow> dest = new DBDestination <MyOutputDataRow>(connection, "Destination"); source.LinkTo(lookup); lookup.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest4Columns.AssertTestData(); }
private void Btn_Conn_Click(object sender, EventArgs e) { DBSource = new DBSource(); try { var server = cb_servers.Text.Split(':'); DBSource.ServerName = server.First(); if (server.Length > 1) { DBSource.Port = int.Parse(server[1]); } } catch { MessageBox.Show("服务器名填写错误"); return; } DBSource.IDType = IDType.uidpwd; DBSource.DBName = cb_db.Text.ToString(); DBSource.LoginName = cb_username.Text; DBSource.LoginPassword = tb_password.Text; if (DBSource.IDType == IDType.uidpwd) { if (string.IsNullOrWhiteSpace(DBSource.LoginName)) { MessageBox.Show("请填写登陆名"); return; } } this.panel_main.Enabled = false; if (!Biz.Common.Data.OracleHelper.CheckSQLConn(DBSource)) { MessageBox.Show(Biz.Common.Data.OracleHelper.LastException.Message); this.panel_main.Enabled = true; return; } //保存一下 this.DialogResult = DialogResult.OK; }
private static void LoadColumns(Form parent, TreeNode tbNode, DBSource server) { if (server == null) { return; } List <TreeNode> treeNodes = new List <TreeNode>(); foreach (TBColumn col in Biz.Common.Data.OracleHelper.GetColumns(server, tbNode.Parent.Name, tbNode.Name)) { int imgIdx = (col.IsID && col.IsKey) ? 9 : (col.IsKey ? 4 : (col.IsID ? 10 : 5)); TreeNode newNode = new TreeNode(string.Concat(col.Name.ToLower(), "(", Common.Data.Common.OracleTypeToNetType(col.TypeName), ")"), imgIdx, imgIdx); newNode.Name = col.Name; newNode.Tag = col; treeNodes.Add(newNode); } if (parent.InvokeRequired) { parent.Invoke(new Action(() => { tbNode.Nodes.Clear(); InsertRange(tbNode, treeNodes.ToArray()); if (tbNode.Level == 3) { tbNode.Nodes.Add("INDEXS", "索引", 1, 1); tbNode.Nodes.Add("TRIGGER", "触发器", 1, 1); } tbNode.Expand(); })); } else { tbNode.Nodes.Clear(); tbNode.Nodes.AddRange(treeNodes.ToArray()); if (tbNode.Level == 3) { tbNode.Nodes.Add("INDEXS", "索引", 1, 1); tbNode.Nodes.Add("TRIGGER", "触发器", 1, 1); } tbNode.Expand(); } }
internal static Group GetSecGroupByUnitCode(DBSource dbsource, string UnitCode) { string secUserList = ""; //从组织机构里面查找文控 Server.Group gp = dbsource.GetGroupByName(UnitCode); if (gp == null) { return(null); } Server.Group resultGp = null; foreach (Server.Group g in gp.AllGroupList) { if (g.Description == "文控") { resultGp = g; break; } } return(resultGp); }
public BookDetailInfoDataProvider() { this.DataSource = new DBSource(); }
public PublisherInfoDataProvider() { this.DataSource = new DBSource(); }
public CategoryInfoDataProvider() { this.DataSource = new DBSource(); }
public ProcessRecordDataProvider() { this.DataSource = new DBSource(); }
public SupportORAgainstInfoDataProvider() { this.DataSource = new DBSource(); }
public DelayRecordDataProvider() { this.DataSource = new DBSource(); }
public SupportAndObjectionInfoDataProvider() { this.DataSource = new DBSource(); }
public AuthorInfoDataProvider() { this.DataSource = new DBSource(); }
public BorrowAndReturnRecordInfoDataProvider() { this.DataSource = new DBSource(); }
public LibraryDBWork() { this.entities=new DBSource(); }