diff --git a/CNAS_DBSync/frmDatabaseParams.Designer.cs b/CNAS_DBSync/frmDatabaseParams.Designer.cs index b1a08a7..2df9813 100644 --- a/CNAS_DBSync/frmDatabaseParams.Designer.cs +++ b/CNAS_DBSync/frmDatabaseParams.Designer.cs @@ -1804,7 +1804,7 @@ // this.btnDmConn.Location = new System.Drawing.Point(167, 226); this.btnDmConn.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btnDmConn.Name = "btnDmConn"; + this.btnDmConn.Name = "txtDmPort"; this.btnDmConn.Size = new System.Drawing.Size(472, 28); this.btnDmConn.TabIndex = 68; // @@ -1822,11 +1822,12 @@ // this.button1.Location = new System.Drawing.Point(599, 272); this.button1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.button1.Name = "button1"; + this.button1.Name = "btnDmConn"; this.button1.Size = new System.Drawing.Size(118, 36); this.button1.TabIndex = 69; this.button1.Text = "测试连接"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.btnDmConn_Click); // // txtDmServer // diff --git a/CNAS_DBSync/frmDatabaseParams.cs b/CNAS_DBSync/frmDatabaseParams.cs index ebad370..bb2b180 100644 --- a/CNAS_DBSync/frmDatabaseParams.cs +++ b/CNAS_DBSync/frmDatabaseParams.cs @@ -591,6 +591,37 @@ namespace CNAS_DBSync } syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Kingbase; } + if (e.TabPage == tabDm) + { + if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || + !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || + !CheckFoxproControl() || !CheckTxtControl() || !CheckPostgreSqlControl() || + !CheckKingbaseControl()) + { + if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", + MessageBoxButtons.OKCancel) == DialogResult.OK) + { + ClearAccessControl(); + ClearExcelControl(); + ClearSqliteControl(); + ClearSQLServerControl(); + ClearMySQLControl(); + ClearOracleControl(); + ClearFoxproControl(); + ClearTxtControl(); + ClearPostgreSqlControl(); + ClearKingbaseControl(); + + ClearObjectValue(); + } + else + { + ChangeSelectTabPageByType(); + return; + } + } + syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Dm; + } } //根据数据源类型切换Tab页 @@ -1266,5 +1297,48 @@ namespace CNAS_DBSync //else // MessageBox.Show("连接失败!"); } + + private void btnDmConn_Click(object sender, EventArgs e) + { + if (this.txtDmHost.Text.Trim() == "" || this.txtDmServer.Text.Trim() == "" || + this.txtDmUser.Text.Trim() == "" || this.btnDmConn.Text.Trim() == "") + { + MessageBox.Show("请填写相关连接信息。"); + return; + } + + InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo(); + dbinfo.Host = this.txtDmHost.Text.Trim(); + dbinfo.ServerName = this.txtDmServer.Text.Trim(); + dbinfo.UserId = this.txtDmUser.Text.Trim(); + dbinfo.UserPwd = this.txtDmPwd.Text.Trim(); + dbinfo.Port = this.btnDmConn.Text.Trim(); + + if (new DmServerInstrumentData(dbinfo, new object[] { "", "", "" }).TestSQLServerLink()) + MessageBox.Show("连接成功!"); + else + MessageBox.Show("连接失败!"); + } + + private bool CheckDmControl() + { + if (this.txtDmHost.Text.Trim() != "" || this.txtDmServer.Text.Trim() != "" || + this.txtDmUser.Text.Trim() != "" || this.txtDmPwd.Text.Trim() != "" || + this.btnDmConn.Text.Trim() != "") + return false; + else + return true; + } + + private void ClearDmControl() + { + this.txtDmHost.Text = ""; + this.txtDmServer.Text = ""; + this.txtDmUser.Text = ""; + this.txtDmPwd.Text = ""; + this.btnDmConn.Text = ""; + } + + } } diff --git a/CnasSynchronusClient/InsturmentData/DmServerInstrumentData.cs b/CnasSynchronusClient/InsturmentData/DmServerInstrumentData.cs new file mode 100644 index 0000000..e05525c --- /dev/null +++ b/CnasSynchronusClient/InsturmentData/DmServerInstrumentData.cs @@ -0,0 +1,116 @@ +using CnasSynchronousCommon; +using CnasSynchronusDAL; +using CnasSynchronusIDAL; +using CnasSynchrousModel; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace CnasSynchronusClient +{ + public class DmServerInstrumentData : InstrumentData + { + public string StrHost { get; set; } + public string StrServerName { get; set; } + public string StrUser { get; set; } + public string StrPwd { get; set; } + public string strTableName { get; set; } + public string strDateColumn { get; set; } + public string strDate { get; set; } + public string StrPort { get; set; } + + public IDmDBService dmDataBaseService { get { return new DmDBService(); } } + public DmFormatConfig DmFormat { get; set; } + + public DmServerInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs) + { + try + { + DmFormat = FileOperation.GetFormatConfigData("DmFormatConfig.xml"); + + this.StrHost = dataSourceInfo.Host; + this.StrServerName = dataSourceInfo.ServerName; + this.StrUser = dataSourceInfo.UserId; + this.StrPwd = dataSourceInfo.UserPwd; + this.StrPort = dataSourceInfo.Port; + + this.strTableName = vs[0].ToString(); + this.strDateColumn = vs[1].ToString(); + this.strDate = vs[2].ToString(); + } + catch (Exception ex) + { + AppLog.Error(ex.Message); + } + } + + public override Dictionary GetInstrumentData() + { + return dmDataBaseService.GetInstrumentData(new DmOpenParams + { + StrHost = StrHost, + StrServer = StrServerName, + StrUser = StrUser, + StrPwd = StrPwd, + StrPort = StrPort + }); + } + + public override DataTable GetInstrumentDataByDate() + { + return dmDataBaseService.GetInstrumentDataByDate( + new DmOpenParams + { + StrHost = StrHost, + StrServer = StrServerName, + StrUser = StrUser, + StrPwd = StrPwd, + StrPort = StrPort, + autoSql = DmFormat.AutoSql + }, + new ConditionParams + { + TableName = strTableName, + DateColumn = strDateColumn, + DateValue = strDate + } + ); + } + + public override DataTable GetInstrumentDataStruct() + { + return dmDataBaseService.GetInstrumentDataStruct( + new DmOpenParams + { + StrHost = StrHost, + StrServer = StrServerName, + StrUser = StrUser, + StrPwd = StrPwd, + StrPort = StrPort, + autoSql = DmFormat.AutoSql + }, + new ConditionParams + { + TableName = strTableName + } + ); + } + + /// + /// 测试连接 + /// + /// + public bool TestSQLServerLink() + { + return dmDataBaseService.TestConnect( + StrHost, + StrServerName, + StrUser, + StrPwd, + StrPort + ); + } + } +} \ No newline at end of file diff --git a/CnasSynchrousModel/InstrumentDataSourceInfo.cs b/CnasSynchrousModel/InstrumentDataSourceInfo.cs index ccd7ee2..ed43996 100644 --- a/CnasSynchrousModel/InstrumentDataSourceInfo.cs +++ b/CnasSynchrousModel/InstrumentDataSourceInfo.cs @@ -20,7 +20,8 @@ namespace CnasSynchrousModel FoxPro, TXT, PostgreSQL, - Kingbase + Kingbase, + Dm } public enum PathType diff --git a/dll/CnasSynchrousModel.dll b/dll/CnasSynchrousModel.dll index b56767f..0bf5812 100644 Binary files a/dll/CnasSynchrousModel.dll and b/dll/CnasSynchrousModel.dll differ