|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358 |
- using CnasSynchronusClient;
- using CnasSynchrousModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Xml.Serialization;
-
- namespace CNAS_DBSync
- {
- public delegate void InstrumentItemDataHanlder(Dictionary<string, DataTable> dictInstrument);
-
- public partial class frmDatabaseParams : Form
- {
- public SyncInstrumentItemInfo syncInstrumentItem = new SyncInstrumentItemInfo(); //仪器信息项
- public Dictionary<string, DataTable> dictInstrument = new Dictionary<string, DataTable>();
- public InstumentCodeHanlder InstrumentDelegate; //传递仪器编码委托
- public InstrumentItemDataHanlder InstrumentItemData; //传递仪器项委托
- private string strReadExcelMode = ""; //读取Excel数据模式
- private string strReadFoxproMode = ""; //读取Foxpro数据模式
- private string strReadTxtMode = "";//读取Txt数据模式
- private string strReadSqliteMode = ""; //读取sqlite数据模式
- private string strReadAccessMode = ""; //读取Access数据模式
- public DataBaseInfo targetDataBaseInfo = new DataBaseInfo(); //数据库
-
- public SqlServerFormatConfig sqlServerFormat { get; set; }
-
- public frmDatabaseParams(SyncInstrumentItemInfo syncInstrumentItem)
- {
- InitializeComponent();
- this.syncInstrumentItem = syncInstrumentItem;
-
- //读取Excel和FoxPro的模式
- strReadExcelMode = FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml").ReadExcelFileMode;
- strReadFoxproMode = FileOperation.GetFormatConfigData<FoxProFormatConfig>("FoxProFormatConfig.xml").ReadFoxProFileMode;
- strReadTxtMode = FileOperation.GetFormatConfigData<NormalFileFormatConfig>("NormalFileFormatConfig.xml").ReadNormalFileMode;
- strReadSqliteMode = FileOperation.GetFormatConfigData<SqliteFormatConfig>("SqliteFormatConfig.xml").ReadSqliteFileMode;
- strReadAccessMode = FileOperation.GetFormatConfigData<AccessFormatConfig>("AccessFormatConfig.xml").ReadAccessFileMode;
-
- sqlServerFormat = FileOperation.GetFormatConfigData<SqlServerFormatConfig>("SqlServerFormatConfig.xml");
-
- if (GlobalCommonOperation.strStartWebApi == "1")
- {
- this.txtDBHost.Enabled = false;
- this.txtDBName.Enabled = false;
- this.txtDBUser.Enabled = false;
- this.txtDBPwd.Enabled = false;
- this.txtPort.Enabled = false;
- btnCNASTestLink.Enabled = false;
- }
- }
-
- private void frmDatabaseParams_Load(object sender, EventArgs e)
- {
- tabExcel.Text = strReadExcelMode == "0" ? "Excel(文件)" : "Excel(文件夹)";
- tabFoxPro.Text = strReadFoxproMode == "0" ? "Foxpro(文件)" : "Foxpro(文件夹)";
- tabTxt.Text = strReadTxtMode == "0" ? "TXT(文件)" : "TXT(文件夹)";
- tabSQLite.Text = strReadSqliteMode == "0" ? "Sqlite(文件)" : "Sqlite(文件夹)";
- tabAccess.Text = strReadAccessMode == "0" ? "Access(文件)" : "Access(文件夹)";
-
- //if(sqlServerFormat)
-
- if (syncInstrumentItem.SyncInstrumentDSInfo == null)
- syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
-
- //如果有旧值,加载旧的值
- switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
- {
- case DataSourceType.Excel:
- this.tabcDS.SelectedIndex = 0;
- this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
-
- this.cbxExcelRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
- this.txtRemoteExcelUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
- this.txtRemoteExcelPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
- break;
- case DataSourceType.FoxPro:
- this.tabcDS.SelectedIndex = 1;
- this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
- this.txtFoxProUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtFoxProPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
-
- this.cbxFoxProRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
- this.txtRemoteFoxProUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
- this.txtRemoteFoxProPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
- break;
- case DataSourceType.Access:
- this.tabcDS.SelectedIndex = 2;
- this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
- this.txtAccessUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtAceessPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
-
- this.cbxAccessRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
- this.txtAccessRemoteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
- this.txtAccessRemotePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
- break;
- case DataSourceType.SQLLite:
- this.tabcDS.SelectedIndex = 3;
- this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
- this.txtSqliteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtSqlitePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
-
- this.cbxSqliteRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
- this.txtSqliteRemoteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
- this.txtSqliteRemotePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
- break;
- case DataSourceType.SQL:
- this.tabcDS.SelectedIndex = 4;
- this.txtSqlServerHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
- this.txtSqlServerName.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
- this.txtSqlServerUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtSqlServerPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
-
- //this.txtSqlServerConnect.Text = sqlServerFormat.SqlServerConnection;
- break;
- case DataSourceType.MySQL:
- this.tabcDS.SelectedIndex = 5;
- this.txtMySqlHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
- this.txtMySqlServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
- this.txtMySqlUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtMySqlPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
- this.txtMySqlPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
- break;
- case DataSourceType.Oracle:
- this.tabcDS.SelectedIndex = 6;
-
- this.txtOracleHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
- this.txtOracleSource.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
- this.txtOracleUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtOraclePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
- this.txtOraclePort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
- break;
- case DataSourceType.TXT:
- this.tabcDS.SelectedIndex = 7;
- this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
-
- this.cbxRemoteTxt.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
- this.txtRemoteTxtUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
- this.txtRemoteTxtPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
- break;
- case DataSourceType.PostgreSQL:
- this.tabcDS.SelectedIndex = 8;
- this.txtPostgreSqlHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
- this.txtPostgreSqlServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
- this.txtPostgreSqlUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtPostgreSqlPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
- this.txtPostgreSqlPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
- break;
- case DataSourceType.Kingbase:
- this.tabcDS.SelectedIndex = 9;
- this.txtKingbaselHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
- this.txtKingbaselServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
- this.txtKingbaselUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtKingbaselPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
- this.txtKingbaselPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
- break;
- case DataSourceType.Dm:
- this.tabcDS.SelectedIndex = 10;
- this.txtDmHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
- this.txtDmServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
- this.txtDmUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
- this.txtDmPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
- this.txtDmPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
- break;
- default:
- break;
- }
-
- //加载旧的CNAS数据库信息
- if (syncInstrumentItem.SyncTargetDBInfo != null)
- {
- targetDataBaseInfo = syncInstrumentItem.SyncTargetDBInfo;
- }
- else
- syncInstrumentItem.SyncTargetDBInfo = new DataBaseInfo();
-
- this.txtDBHost.Text = targetDataBaseInfo.DBHost;
- this.txtDBName.Text = targetDataBaseInfo.DBName;
- this.txtDBUser.Text = targetDataBaseInfo.DBUser;
- this.txtDBPwd.Text = targetDataBaseInfo.DBPwd;
- this.txtPort.Text = targetDataBaseInfo.DBPort;
-
-
- }
-
- private void btnOK_Click(object sender, EventArgs e)
- {
- //点击确定按钮
- //InstrumentData instrumentData = null;
-
- switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
- {
- case DataSourceType.Access:
- syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtAccessPath.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtAccessUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtAceessPwd.Text.Trim();
-
- syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxAccessRemote.Checked ? PathType.Remote : PathType.Local;
- syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtAccessRemoteUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtAccessRemotePwd.Text.Trim();
- break;
- case DataSourceType.SQLLite:
- syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtSqlitePath.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtSqliteUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtSqlitePwd.Text.Trim();
-
- syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxSqliteRemote.Checked ? PathType.Remote : PathType.Local;
- syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtSqliteRemoteUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtSqliteRemotePwd.Text.Trim();
- break;
- case DataSourceType.SQL:
- syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtSqlServerHost.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtSqlServerName.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtSqlServerUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
- break;
- case DataSourceType.MySQL:
- syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtMySqlHost.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtMySqlServer.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtMySqlUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtMySqlPwd.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtMySqlPort.Text.Trim();
- break;
- case DataSourceType.Oracle:
- syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtOracleHost.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtOracleSource.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtOracleUserId.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtOraclePwd.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtOraclePort.Text.Trim();
- break;
- case DataSourceType.FoxPro:
- syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtFoxProFolder.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtFoxProUserId.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtFoxProPwd.Text.Trim();
-
- syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxFoxProRemote.Checked ? PathType.Remote : PathType.Local;
- syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteFoxProUserId.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteFoxProPwd.Text.Trim();
- break;
- case DataSourceType.TXT:
- syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtInportTxt.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
-
- syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxRemoteTxt.Checked ? PathType.Remote : PathType.Local;
- syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteTxtUserId.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteTxtPwd.Text.Trim();
- break;
- case DataSourceType.Excel:
- case DataSourceType.PostgreSQL:
- syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtPostgreSqlHost.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtPostgreSqlServer.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtPostgreSqlUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtPostgreSqlPwd.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtPostgreSqlPort.Text.Trim();
- break;
- case DataSourceType.Kingbase:
- syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtKingbaselHost.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtKingbaselServer.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtKingbaselUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtKingbaselPwd.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtKingbaselPort.Text.Trim();
- break;
- case DataSourceType.Dm:
- syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtDmHost.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtDmServer.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtDmUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtDmPwd.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtDmPort.Text.Trim();
- break;
- default:
- syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtInportExcel.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
-
- syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxExcelRemote.Checked ? PathType.Remote : PathType.Local;
- syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteExcelUser.Text.Trim();
- syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteExcelPwd.Text.Trim();
- break;
- }
- object[] obj = new object[] { "", "", "" };
- //instrumentData = InstrumentDataFact.CreateInstrumentDataSource(syncInstrumentItem.SyncInstrumentDSInfo, obj);
- //dictInstrument = instrumentData.GetInstrumentData();
-
- //目标库的信息
- if (GlobalCommonOperation.strStartWebApi != "1")
- {
- syncInstrumentItem.SyncTargetDBInfo.DBHost = this.txtDBHost.Text.Trim();
- syncInstrumentItem.SyncTargetDBInfo.DBName = this.txtDBName.Text.Trim();
- syncInstrumentItem.SyncTargetDBInfo.DBUser = this.txtDBUser.Text.Trim();
- syncInstrumentItem.SyncTargetDBInfo.DBPwd = this.txtDBPwd.Text.Trim();
- syncInstrumentItem.SyncTargetDBInfo.DBPort = this.txtPort.Text.Trim();
- }
- else
- syncInstrumentItem.SyncTargetDBInfo = targetDataBaseInfo;
-
- this.InstrumentDelegate(syncInstrumentItem);
- //this.InstrumentItemData(dictInstrument);
-
- this.Close();
- }
-
- private void btnOpenFileExcel_Click(object sender, EventArgs e)
- {
- if (syncInstrumentItem.Code == null) return;
-
- if (syncInstrumentItem.SyncInstrumentDSInfo == null)
- syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
-
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Excel;
-
- if (strReadExcelMode == "0")
- {
- OpenFileDialog openFile = new OpenFileDialog
- {
- Filter = "Excel(*.xlsx)|*.xlsx|Excel(*.xls)|*.xls",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
- Multiselect = false
- };
-
- if (openFile.ShowDialog() == DialogResult.Cancel) return;
- this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
- string fileType = System.IO.Path.GetExtension(openFile.FileName);
- if (string.IsNullOrEmpty(fileType)) return;
- }
- else
- {
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "请选择文件路径";
-
- if (dialog.ShowDialog() == DialogResult.Cancel) return;
- this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
- }
- }
-
- private void tabcDS_Selected(object sender, TabControlEventArgs e)
- {
- //切换的时候,检查其他类型数据源是否有值,如果有值,将提示删除旧值才能配置新值
- if (e.TabPage == tabExcel)
- {
- //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
- if (!CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Excel;
- }
- if (e.TabPage == tabAccess)
- {
- //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
- if (!CheckExcelControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Access;
- }
- if (e.TabPage == tabSQLite)
- {
- //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQLLite;
- }
- if (e.TabPage == tabSQLServer)
- {
- //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQL;
- }
- if (e.TabPage == tabMySql)
- {
- //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.MySQL;
- }
- if (e.TabPage == tabOracle)
- {
- //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Oracle;
- }
- if (e.TabPage == tabFoxPro)
- {
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.FoxPro;
- }
- if (e.TabPage == tabTxt)
- {
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.TXT;
- }
- if (e.TabPage == tabPostgreSql)
- {
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() ||
- !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() ||
- !CheckFoxproControl() || !CheckTxtControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示",
- MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.PostgreSQL;
- }
- if (e.TabPage == tabKingbase)
- {
- if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() ||
- !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() ||
- !CheckFoxproControl() || !CheckTxtControl() || !CheckPostgreSqlControl())
- {
- if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示",
- MessageBoxButtons.OKCancel) == DialogResult.OK)
- {
- ClearAccessControl();
- ClearExcelControl();
- ClearSqliteControl();
- ClearSQLServerControl();
- ClearMySQLControl();
- ClearOracleControl();
- ClearFoxproControl();
- ClearTxtControl();
- ClearPostgreSqlControl();
-
- ClearObjectValue();
- }
- else
- {
- ChangeSelectTabPageByType();
- return;
- }
- }
- 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页
- private void ChangeSelectTabPageByType()
- {
- switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
- {
- case DataSourceType.SQLLite:
- tabcDS.SelectedTab = tabSQLite;
- break;
- case DataSourceType.Access:
- tabcDS.SelectedTab = tabAccess;
- break;
- case DataSourceType.SQL:
- tabcDS.SelectedTab = tabSQLServer;
- break;
- case DataSourceType.Oracle:
- tabcDS.SelectedTab = tabOracle;
- break;
- case DataSourceType.FoxPro:
- tabcDS.SelectedTab = tabFoxPro;
- break;
- case DataSourceType.TXT:
- tabcDS.SelectedTab = tabTxt;
- break;
- case DataSourceType.Excel:
- case DataSourceType.PostgreSQL:
- case DataSourceType.Kingbase:
- default:
- tabcDS.SelectedTab = tabExcel;
- break;
- }
- }
-
-
- private bool CheckExcelControl()
- {
- if (this.txtInportExcel.Text != "")
- return false;
- else
- return true;
- }
-
- private bool CheckAccessControl()
- {
- if (this.txtAccessPath.Text != "" || this.txtAccessUser.Text != "" || this.txtAceessPwd.Text != "")
- return false;
- else
- return true;
- }
-
- private bool CheckSQLiteControl()
- {
- if (this.txtSqlitePath.Text != "" || this.txtSqliteUser.Text != "" || this.txtSqlitePwd.Text != "")
- return false;
- else
- return true;
- }
- private bool CheckSQLServerControl()
- {
- if (this.txtSqlServerHost.Text.Trim() != "" || this.txtSqlServerName.Text.Trim() != "" || this.txtSqlServerPwd.Text.Trim() != "" || this.txtSqlServerUser.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private bool CheckMySqlControl()
- {
- if (this.txtMySqlHost.Text.Trim() != "" || this.txtMySqlServer.Text.Trim() != "" || this.txtMySqlUser.Text.Trim() != "" || this.txtMySqlPwd.Text.Trim() != "" || this.txtMySqlPort.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private bool CheckOracleControl()
- {
- if (this.txtOraclePort.Text.Trim() != "" || this.txtOraclePwd.Text.Trim() != "" || this.txtOracleHost.Text.Trim() != "" || this.txtOracleSource.Text.Trim() != "" || this.txtOracleUserId.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private bool CheckFoxproControl()
- {
- if (this.txtFoxProFolder.Text.Trim() != "" || this.txtFoxProUserId.Text.Trim() != "" || this.txtFoxProPwd.Text.Trim() != "" || this.txtRemoteFoxProUserId.Text.Trim() != "" || this.txtRemoteFoxProPwd.Text.Trim() != "")
- {
- return false;
- }
- else
- return true;
- }
-
- private bool CheckTxtControl()
- {
- if (this.txtInportTxt.Text.Trim() != "" || this.txtRemoteTxtUserId.Text.Trim() != "" || this.txtRemoteTxtPwd.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private void btnCNASTestLink_Click(object sender, EventArgs e)
- {
- //this.txtDBHost.Text.Trim(), this.txtDBName.Text.Trim(), this.txtDBUser.Text.Trim(), this.txtDBPwd.Text.Trim(),this.txtPort.Text.Trim()
- if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo()
- {
- DBHost = this.txtDBHost.Text.Trim(),
- DBName = this.txtDBName.Text.Trim(),
- DBUser = this.txtDBUser.Text.Trim(),
- DBPwd = this.txtDBPwd.Text.Trim(),
- DBPort = this.txtPort.Text.Trim()
- }))
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
- }
-
- private void ClearExcelControl()
- {
- this.txtInportExcel.Text = "";
- this.txtRemoteExcelUser.Text = "";
- this.txtRemoteExcelPwd.Text = "";
- }
-
- private void ClearAccessControl()
- {
- this.txtAccessPath.Text = "";
- this.txtAccessUser.Text = "";
- this.txtAceessPwd.Text = "";
- this.txtAccessRemoteUser.Text = "";
- this.txtAccessRemotePwd.Text = "";
- }
-
- private void ClearSqliteControl()
- {
- this.txtSqliteUser.Text = "";
- this.txtSqlitePath.Text = "";
- this.txtSqlitePwd.Text = "";
- this.txtSqliteRemoteUser.Text = "";
- this.txtSqliteRemotePwd.Text = "";
- }
-
- private void ClearSQLServerControl()
- {
- this.txtSqlServerHost.Text = "";
- this.txtSqlServerName.Text = "";
- this.txtSqlServerUser.Text = "";
- this.txtSqlServerPwd.Text = "";
- }
-
- private void ClearMySQLControl()
- {
- this.txtMySqlHost.Text = "";
- this.txtMySqlServer.Text = "";
- this.txtMySqlUser.Text = "";
- this.txtMySqlPwd.Text = "";
- this.txtMySqlPort.Text = "";
- }
-
- private void ClearOracleControl()
- {
- this.txtOracleHost.Text = "";
- this.txtOracleSource.Text = "";
- this.txtOracleUserId.Text = "";
- this.txtOraclePwd.Text = "";
- this.txtOraclePort.Text = "";
- }
-
- private void ClearFoxproControl()
- {
- this.txtFoxProFolder.Text = "";
- this.txtFoxProUserId.Text = "";
- this.txtFoxProPwd.Text = "";
- this.txtRemoteFoxProUserId.Text = "";
- this.txtRemoteFoxProPwd.Text = "";
- }
-
- private void ClearTxtControl()
- {
- this.txtInportTxt.Text = "";
- this.txtRemoteTxtUserId.Text = "";
- this.txtRemoteTxtPwd.Text = "";
- }
- /// <summary>
- /// 清空对象中存储的值
- /// </summary>
- private void ClearObjectValue()
- {
- syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
- syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
- syncInstrumentItem.SyncInstrumentDSInfo.Path = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
- syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
- syncInstrumentItem.SyncInstrumentDSInfo.Port = "";
-
- syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = PathType.Local;
- syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = "";
- syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = "";
- }
-
- private void btnOpenFileAccess_Click(object sender, EventArgs e)
- {
- if (syncInstrumentItem.Code == null) return;
-
- if (syncInstrumentItem.SyncInstrumentDSInfo == null)
- syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
-
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Access;
-
- if (strReadAccessMode == "0")
- {
- OpenFileDialog openFile = new OpenFileDialog
- {
- Filter = "Microsoft Access(*.mdb)|*.mdb|Microsoft Access(*.accdb)|*.accdb",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
- Multiselect = false
- };
-
- if (openFile.ShowDialog() == DialogResult.Cancel) return;
- this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
- string fileType = System.IO.Path.GetExtension(openFile.FileName);
- if (string.IsNullOrEmpty(fileType)) return;
- }
- else
- {
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "请选择文件路径";
-
- if (dialog.ShowDialog() == DialogResult.Cancel) return;
- this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
- }
- }
-
- private void btnOpenFileSQLite_Click(object sender, EventArgs e)
- {
- if (syncInstrumentItem.Code == null) return;
-
- if (syncInstrumentItem.SyncInstrumentDSInfo == null)
- syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
-
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQLLite;
-
- if (strReadSqliteMode == "0")
- {
- OpenFileDialog openFile = new OpenFileDialog
- {
- Filter = "SQLite(*.db)|*.db",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
- Multiselect = false
- };
-
- if (openFile.ShowDialog() == DialogResult.Cancel) return;
- this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
- string fileType = System.IO.Path.GetExtension(openFile.FileName);
- if (string.IsNullOrEmpty(fileType)) return;
- }
- else
- {
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "请选择文件路径";
-
- if (dialog.ShowDialog() == DialogResult.Cancel) return;
- this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
- }
- }
-
- private void btnTestSQLLink_Click(object sender, EventArgs e)
- {
- if (this.txtSqlServerHost.Text.Trim() == "" || this.txtSqlServerName.Text.Trim() == "" || this.txtSqlServerUser.Text.Trim() == "")
- {
- MessageBox.Show("请填写相关连接信息。");
- return;
- }
-
- InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
- dbinfo.Host = this.txtSqlServerHost.Text.Trim();
- dbinfo.ServerName = this.txtSqlServerName.Text.Trim();
- dbinfo.UserId = this.txtSqlServerUser.Text.Trim();
- dbinfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
- dbinfo.Port = this.txtSqlServerPort.Text.Trim();
- if (new SQLServerInstrumentData(dbinfo, new object[] {
- "",
- "",
- ""
- }).TestSQLServerLink())
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
- }
-
- private void cbxExcelRemote_CheckedChanged(object sender, EventArgs e)
- {
- if (!cbxExcelRemote.Checked)
- {
- this.btnOpenFileExcel.Visible = true;
-
- lblExcelRemotePwd.Visible = false;
- lblExcelRemoteUser.Visible = false;
- txtRemoteExcelUser.Visible = false;
- txtRemoteExcelPwd.Visible = false;
- }
- else
- {
- this.btnOpenFileExcel.Visible = false;
-
- lblExcelRemotePwd.Visible = true;
- lblExcelRemoteUser.Visible = true;
- txtRemoteExcelUser.Visible = true;
- txtRemoteExcelPwd.Visible = true;
- }
- }
-
- private void cbxAccessRemote_CheckedChanged(object sender, EventArgs e)
- {
- if (cbxAccessRemote.Checked)
- {
- btnOpenFileAccess.Visible = false;
-
- lblAccessRemoteUser.Visible = true;
- lblAccessRemotePwd.Visible = true;
- txtAccessRemoteUser.Visible = true;
- txtAccessRemotePwd.Visible = true;
- }
- else
- {
- btnOpenFileAccess.Visible = true;
-
- lblAccessRemoteUser.Visible = false;
- lblAccessRemotePwd.Visible = false;
- txtAccessRemoteUser.Visible = false;
- txtAccessRemotePwd.Visible = false;
- }
- }
-
- private void cbxSqliteRemote_CheckedChanged(object sender, EventArgs e)
- {
- if (cbxSqliteRemote.Checked)
- {
- btnOpenFileSQLite.Visible = false;
-
- lblSqliteRemoteUser.Visible = true;
- lblSqliteRemotePwd.Visible = true;
- txtSqliteRemoteUser.Visible = true;
- txtSqliteRemotePwd.Visible = true;
- }
- else
- {
- btnOpenFileSQLite.Visible = true;
-
- lblSqliteRemoteUser.Visible = false;
- lblSqliteRemotePwd.Visible = false;
- txtSqliteRemoteUser.Visible = false;
- txtSqliteRemotePwd.Visible = false;
- }
- }
-
- private void btnMySqlTest_Click(object sender, EventArgs e)
- {
-
- if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo()
- {
- DBHost = this.txtMySqlHost.Text.Trim(),
- DBName = this.txtMySqlServer.Text.Trim(),
- DBUser = this.txtMySqlUser.Text.Trim(),
- DBPwd = this.txtMySqlPwd.Text.Trim(),
- DBPort = this.txtMySqlPort.Text.Trim()
- }))
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
- }
-
- private void btnOracleTestLink_Click(object sender, EventArgs e)
- {
- if (this.txtOracleHost.Text.Trim() == "" || this.txtOracleSource.Text.Trim() == "" || this.txtOracleUserId.Text.Trim() == "" || this.txtOraclePort.Text.Trim() == "")
- {
- MessageBox.Show("请填写相关连接信息。");
- return;
- }
-
- InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
- dbinfo.Host = this.txtOracleHost.Text.Trim();
- dbinfo.ServerName = this.txtOracleSource.Text.Trim();
- dbinfo.UserId = this.txtOracleUserId.Text.Trim();
- dbinfo.UserPwd = this.txtOraclePwd.Text.Trim();
- dbinfo.Port = this.txtOraclePort.Text.Trim();
- if (new OracleInstrumentData(dbinfo, new object[] {
- "",
- "",
- ""
- }).TestSQLServerLink())
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
- }
-
- private void txtFileOpenFoxPro_Click(object sender, EventArgs e)
- {
- if (syncInstrumentItem.Code == null) return;
-
- if (syncInstrumentItem.SyncInstrumentDSInfo == null)
- syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
-
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.FoxPro;
-
- if (strReadFoxproMode == "0")
- {
- OpenFileDialog openFile = new OpenFileDialog
- {
- Filter = "Foxpro文件(*.dbf)|*.dbf",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
- Multiselect = false
- };
-
- if (openFile.ShowDialog() == DialogResult.Cancel) return;
- this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
- string fileType = System.IO.Path.GetExtension(openFile.FileName);
- if (string.IsNullOrEmpty(fileType)) return;
- }
- else
- {
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "请选择文件路径";
-
- if (dialog.ShowDialog() == DialogResult.Cancel) return;
- this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
- }
- }
-
- private void cbxFoxProRemote_CheckedChanged(object sender, EventArgs e)
- {
- if (!cbxFoxProRemote.Checked)
- {
- this.btnFileOpenFoxPro.Visible = true;
-
- lblFoxproRemoteUserId.Visible = false;
- lblFoxproRemotePwd.Visible = false;
- txtRemoteFoxProUserId.Visible = false;
- txtRemoteFoxProPwd.Visible = false;
- }
- else
- {
- this.btnFileOpenFoxPro.Visible = false;
-
- lblFoxproRemoteUserId.Visible = true;
- lblFoxproRemotePwd.Visible = true;
- txtRemoteFoxProUserId.Visible = true;
- txtRemoteFoxProPwd.Visible = true;
- }
- }
-
- private void btnOpenFileTxt_Click(object sender, EventArgs e)
- {
- if (syncInstrumentItem.Code == null) return;
-
- if (syncInstrumentItem.SyncInstrumentDSInfo == null)
- syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
-
- syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.TXT;
-
- if (strReadTxtMode == "0")
- {
- OpenFileDialog openFile = new OpenFileDialog
- {
- Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*",
- InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
- Multiselect = false
- };
-
- if (openFile.ShowDialog() == DialogResult.Cancel) return;
- this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
- string fileType = System.IO.Path.GetExtension(openFile.FileName);
- if (string.IsNullOrEmpty(fileType)) return;
- }
- else
- {
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- dialog.Description = "请选择文件路径";
-
- if (dialog.ShowDialog() == DialogResult.Cancel) return;
- this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
- }
- }
-
- private void cbxRemoteTxt_CheckedChanged(object sender, EventArgs e)
- {
- if (!cbxRemoteTxt.Checked)
- {
- this.btnOpenFileTxt.Visible = true;
-
- lblTxtRemoteUserId.Visible = false;
- lblTxtRemoteUserPwd.Visible = false;
- txtRemoteTxtUserId.Visible = false;
- txtRemoteTxtPwd.Visible = false;
- }
- else
- {
- this.btnOpenFileTxt.Visible = false;
-
- lblTxtRemoteUserId.Visible = true;
- lblTxtRemoteUserPwd.Visible = true;
- txtRemoteTxtUserId.Visible = true;
- txtRemoteTxtPwd.Visible = true;
- }
- }
-
- private void cbxTargetDBSelect_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (cbxTargetDBSelect.SelectedIndex == 0)
- {
- if (GlobalCommonOperation.strStartWebApi == "1")
- {
- targetDataBaseInfo = new DataBaseInfo()
- {
- DataBaseCode = "cnas"
- };
- }
- else
- {
- DataBaseInfo CNASDataBase = FileOperation.GetLocalCnasDB();
- if (CNASDataBase != null)
- {
- this.txtDBHost.Text = CNASDataBase.DBHost;
- this.txtDBName.Text = CNASDataBase.DBName;
- this.txtDBUser.Text = CNASDataBase.DBUser;
- this.txtDBPwd.Text = CNASDataBase.DBPwd;
- this.txtPort.Text = CNASDataBase.DBPort;
- }
- }
- }
- else if (cbxTargetDBSelect.SelectedIndex == 1)
- {
- if (GlobalCommonOperation.strStartWebApi == "1")
- {
- targetDataBaseInfo = new DataBaseInfo()
- {
- DataBaseCode = "platform"
- };
- }
- else
- {
- DataBaseInfo PlatDataBase = FileOperation.GetLocalPlatFormDB();
- if (PlatDataBase != null)
- {
- this.txtDBHost.Text = PlatDataBase.DBHost;
- this.txtDBName.Text = PlatDataBase.DBName;
- this.txtDBUser.Text = PlatDataBase.DBUser;
- this.txtDBPwd.Text = PlatDataBase.DBPwd;
- this.txtPort.Text = PlatDataBase.DBPort;
- }
- }
- }
- }
-
-
-
- private bool CheckPostgreSqlControl()
- {
- if (this.txtPostgreSqlHost.Text.Trim() != "" || this.txtPostgreSqlServer.Text.Trim() != "" ||
- this.txtPostgreSqlUser.Text.Trim() != "" || this.txtPostgreSqlPwd.Text.Trim() != "" ||
- this.txtPostgreSqlPort.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private void ClearPostgreSqlControl()
- {
- this.txtPostgreSqlHost.Text = "";
- this.txtPostgreSqlServer.Text = "";
- this.txtPostgreSqlUser.Text = "";
- this.txtPostgreSqlPwd.Text = "";
- this.txtPostgreSqlPort.Text = "";
- }
-
- private bool CheckKingbaseControl()
- {
- if (this.txtKingbaselHost.Text.Trim() != "" || this.txtKingbaselServer.Text.Trim() != "" ||
- this.txtKingbaselUser.Text.Trim() != "" || this.txtKingbaselPwd.Text.Trim() != "" ||
- this.txtKingbaselPort.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private void ClearKingbaseControl()
- {
- this.txtKingbaselHost.Text = "";
- this.txtKingbaselServer.Text = "";
- this.txtKingbaselUser.Text = "";
- this.txtKingbaselPwd.Text = "";
- this.txtKingbaselPort.Text = "";
- }
-
- private void btnKingbaselConn_Click(object sender, EventArgs e)
- {
- if (this.txtKingbaselHost.Text.Trim() == "" || this.txtKingbaselServer.Text.Trim() == "" ||
- this.txtKingbaselUser.Text.Trim() == "" || this.txtKingbaselPort.Text.Trim() == "")
- {
- MessageBox.Show("请填写相关连接信息。");
- return;
- }
-
- InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
- dbinfo.Host = this.txtKingbaselHost.Text.Trim();
- dbinfo.ServerName = this.txtKingbaselServer.Text.Trim();
- dbinfo.UserId = this.txtKingbaselUser.Text.Trim();
- dbinfo.UserPwd = this.txtKingbaselPwd.Text.Trim();
- dbinfo.Port = this.txtKingbaselPort.Text.Trim();
-
- // 假设有KingbaseInstrumentData类来处理连接测试
- if (new KingbaseServerInstrumentData(dbinfo, new object[] { "", "", "" }).TestSQLServerLink())
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
- }
-
-
- private void btnPostgreSqlConn_Click(object sender, EventArgs e)
- {
- if (this.txtPostgreSqlHost.Text.Trim() == "" || this.txtPostgreSqlServer.Text.Trim() == "" ||
- this.txtPostgreSqlUser.Text.Trim() == "" || this.txtPostgreSqlPort.Text.Trim() == "")
- {
- MessageBox.Show("请填写相关连接信息。");
- return;
- }
-
- InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
- dbinfo.Host = this.txtPostgreSqlHost.Text.Trim();
- dbinfo.ServerName = this.txtPostgreSqlServer.Text.Trim();
- dbinfo.UserId = this.txtPostgreSqlUser.Text.Trim();
- dbinfo.UserPwd = this.txtPostgreSqlPwd.Text.Trim();
- dbinfo.Port = this.txtPostgreSqlPort.Text.Trim();
- //SQLServerInstrumentData
- if (new PostgreSQLServerInstrumentData(dbinfo, new object[] {
- "",
- "",
- ""
- }).TestSQLServerLink())
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
-
-
-
-
-
-
-
- //if (new PostgreSQLServerInstrumentData(dbinfo, new object[] { "", "", "" }).TestConnection())
- // MessageBox.Show("连接成功!");
- //else
- // MessageBox.Show("连接失败!");
-
-
- //if (this.txtSqlServerHost.Text.Trim() == "" || this.txtSqlServerName.Text.Trim() == "" || this.txtSqlServerUser.Text.Trim() == "")
- //{
- // MessageBox.Show("请填写相关连接信息。");
- // return;
- //}
-
- //InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
- //dbinfo.Host = this.txtSqlServerHost.Text.Trim();
- //dbinfo.ServerName = this.txtSqlServerName.Text.Trim();
- //dbinfo.UserId = this.txtSqlServerUser.Text.Trim();
- //dbinfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
- //dbinfo.Port = this.txtSqlServerPort.Text.Trim();
- //if (new SQLServerInstrumentData(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.txtDmPort.Text.Trim() != "")
- return false;
- else
- return true;
- }
-
- private void ClearDmControl()
- {
- this.txtDmHost.Text = "";
- this.txtDmServer.Text = "";
- this.txtDmUser.Text = "";
- this.txtDmPwd.Text = "";
- this.txtDmPort.Text = "";
- }
-
- private void btnDmConn_Click(object sender, EventArgs e)
- {
- if (this.txtDmHost.Text.Trim() == "" || this.txtDmServer.Text.Trim() == "" ||
- this.txtDmUser.Text.Trim() == "" || this.txtDmPort.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.txtDmPort.Text.Trim();
-
- if (new DmServerInstrumentData(dbinfo, new object[] { "", "", "" }).TestSQLServerLink())
- MessageBox.Show("连接成功!");
- else
- MessageBox.Show("连接失败!");
- }
- }
- }
|