CNAS取数仪器端升级
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

frmDatabaseParams.cs 58KB

4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
4ヶ月前
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  1. using CnasSynchronusClient;
  2. using CnasSynchrousModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. using System.Xml.Serialization;
  13. namespace CNAS_DBSync
  14. {
  15. public delegate void InstrumentItemDataHanlder(Dictionary<string, DataTable> dictInstrument);
  16. public partial class frmDatabaseParams : Form
  17. {
  18. public SyncInstrumentItemInfo syncInstrumentItem = new SyncInstrumentItemInfo(); //仪器信息项
  19. public Dictionary<string, DataTable> dictInstrument = new Dictionary<string, DataTable>();
  20. public InstumentCodeHanlder InstrumentDelegate; //传递仪器编码委托
  21. public InstrumentItemDataHanlder InstrumentItemData; //传递仪器项委托
  22. private string strReadExcelMode = ""; //读取Excel数据模式
  23. private string strReadFoxproMode = ""; //读取Foxpro数据模式
  24. private string strReadTxtMode = "";//读取Txt数据模式
  25. private string strReadSqliteMode = ""; //读取sqlite数据模式
  26. private string strReadAccessMode = ""; //读取Access数据模式
  27. public DataBaseInfo targetDataBaseInfo = new DataBaseInfo(); //数据库
  28. public SqlServerFormatConfig sqlServerFormat { get; set; }
  29. public frmDatabaseParams(SyncInstrumentItemInfo syncInstrumentItem)
  30. {
  31. InitializeComponent();
  32. this.syncInstrumentItem = syncInstrumentItem;
  33. //读取Excel和FoxPro的模式
  34. strReadExcelMode = FileOperation.GetFormatConfigData<ExcelFormatConfig>("ExcelFormatConfig.xml").ReadExcelFileMode;
  35. strReadFoxproMode = FileOperation.GetFormatConfigData<FoxProFormatConfig>("FoxProFormatConfig.xml").ReadFoxProFileMode;
  36. strReadTxtMode = FileOperation.GetFormatConfigData<NormalFileFormatConfig>("NormalFileFormatConfig.xml").ReadNormalFileMode;
  37. strReadSqliteMode = FileOperation.GetFormatConfigData<SqliteFormatConfig>("SqliteFormatConfig.xml").ReadSqliteFileMode;
  38. strReadAccessMode = FileOperation.GetFormatConfigData<AccessFormatConfig>("AccessFormatConfig.xml").ReadAccessFileMode;
  39. sqlServerFormat = FileOperation.GetFormatConfigData<SqlServerFormatConfig>("SqlServerFormatConfig.xml");
  40. if (GlobalCommonOperation.strStartWebApi == "1")
  41. {
  42. this.txtDBHost.Enabled = false;
  43. this.txtDBName.Enabled = false;
  44. this.txtDBUser.Enabled = false;
  45. this.txtDBPwd.Enabled = false;
  46. this.txtPort.Enabled = false;
  47. btnCNASTestLink.Enabled = false;
  48. }
  49. }
  50. private void frmDatabaseParams_Load(object sender, EventArgs e)
  51. {
  52. tabExcel.Text = strReadExcelMode == "0" ? "Excel(文件)" : "Excel(文件夹)";
  53. tabFoxPro.Text = strReadFoxproMode == "0" ? "Foxpro(文件)" : "Foxpro(文件夹)";
  54. tabTxt.Text = strReadTxtMode == "0" ? "TXT(文件)" : "TXT(文件夹)";
  55. tabSQLite.Text = strReadSqliteMode == "0" ? "Sqlite(文件)" : "Sqlite(文件夹)";
  56. tabAccess.Text = strReadAccessMode == "0" ? "Access(文件)" : "Access(文件夹)";
  57. //if(sqlServerFormat)
  58. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  59. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  60. //如果有旧值,加载旧的值
  61. switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
  62. {
  63. case DataSourceType.Excel:
  64. this.tabcDS.SelectedIndex = 0;
  65. this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  66. this.cbxExcelRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  67. this.txtRemoteExcelUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  68. this.txtRemoteExcelPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  69. break;
  70. case DataSourceType.FoxPro:
  71. this.tabcDS.SelectedIndex = 1;
  72. this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  73. this.txtFoxProUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  74. this.txtFoxProPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  75. this.cbxFoxProRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  76. this.txtRemoteFoxProUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  77. this.txtRemoteFoxProPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  78. break;
  79. case DataSourceType.Access:
  80. this.tabcDS.SelectedIndex = 2;
  81. this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  82. this.txtAccessUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  83. this.txtAceessPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  84. this.cbxAccessRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  85. this.txtAccessRemoteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  86. this.txtAccessRemotePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  87. break;
  88. case DataSourceType.SQLLite:
  89. this.tabcDS.SelectedIndex = 3;
  90. this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  91. this.txtSqliteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  92. this.txtSqlitePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  93. this.cbxSqliteRemote.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  94. this.txtSqliteRemoteUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  95. this.txtSqliteRemotePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  96. break;
  97. case DataSourceType.SQL:
  98. this.tabcDS.SelectedIndex = 4;
  99. this.txtSqlServerHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
  100. this.txtSqlServerName.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  101. this.txtSqlServerUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  102. this.txtSqlServerPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  103. //this.txtSqlServerConnect.Text = sqlServerFormat.SqlServerConnection;
  104. break;
  105. case DataSourceType.MySQL:
  106. this.tabcDS.SelectedIndex = 5;
  107. this.txtMySqlHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
  108. this.txtMySqlServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  109. this.txtMySqlUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  110. this.txtMySqlPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  111. this.txtMySqlPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
  112. break;
  113. case DataSourceType.Oracle:
  114. this.tabcDS.SelectedIndex = 6;
  115. this.txtOracleHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
  116. this.txtOracleSource.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  117. this.txtOracleUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  118. this.txtOraclePwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  119. this.txtOraclePort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
  120. break;
  121. case DataSourceType.TXT:
  122. this.tabcDS.SelectedIndex = 7;
  123. this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path;
  124. this.cbxRemoteTxt.Checked = syncInstrumentItem.SyncInstrumentDSInfo.DsPathType == PathType.Local ? false : true;
  125. this.txtRemoteTxtUserId.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser;
  126. this.txtRemoteTxtPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd;
  127. break;
  128. case DataSourceType.PostgreSQL:
  129. this.tabcDS.SelectedIndex = 8;
  130. this.txtPostgreSqlHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
  131. this.txtPostgreSqlServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  132. this.txtPostgreSqlUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  133. this.txtPostgreSqlPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  134. this.txtPostgreSqlPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
  135. break;
  136. case DataSourceType.Kingbase:
  137. this.tabcDS.SelectedIndex = 9;
  138. this.txtKingbaselHost.Text = syncInstrumentItem.SyncInstrumentDSInfo.Host;
  139. this.txtKingbaselServer.Text = syncInstrumentItem.SyncInstrumentDSInfo.ServerName;
  140. this.txtKingbaselUser.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserId;
  141. this.txtKingbaselPwd.Text = syncInstrumentItem.SyncInstrumentDSInfo.UserPwd;
  142. this.txtKingbaselPort.Text = syncInstrumentItem.SyncInstrumentDSInfo.Port;
  143. break;
  144. default:
  145. break;
  146. }
  147. //加载旧的CNAS数据库信息
  148. if (syncInstrumentItem.SyncTargetDBInfo != null)
  149. {
  150. targetDataBaseInfo = syncInstrumentItem.SyncTargetDBInfo;
  151. }
  152. else
  153. syncInstrumentItem.SyncTargetDBInfo = new DataBaseInfo();
  154. this.txtDBHost.Text = targetDataBaseInfo.DBHost;
  155. this.txtDBName.Text = targetDataBaseInfo.DBName;
  156. this.txtDBUser.Text = targetDataBaseInfo.DBUser;
  157. this.txtDBPwd.Text = targetDataBaseInfo.DBPwd;
  158. this.txtPort.Text = targetDataBaseInfo.DBPort;
  159. }
  160. private void btnOK_Click(object sender, EventArgs e)
  161. {
  162. //点击确定按钮
  163. //InstrumentData instrumentData = null;
  164. switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
  165. {
  166. case DataSourceType.Access:
  167. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtAccessPath.Text.Trim();
  168. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  169. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  170. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtAccessUser.Text.Trim();
  171. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtAceessPwd.Text.Trim();
  172. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxAccessRemote.Checked ? PathType.Remote : PathType.Local;
  173. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtAccessRemoteUser.Text.Trim();
  174. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtAccessRemotePwd.Text.Trim();
  175. break;
  176. case DataSourceType.SQLLite:
  177. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtSqlitePath.Text.Trim();
  178. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  179. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  180. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtSqliteUser.Text.Trim();
  181. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtSqlitePwd.Text.Trim();
  182. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxSqliteRemote.Checked ? PathType.Remote : PathType.Local;
  183. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtSqliteRemoteUser.Text.Trim();
  184. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtSqliteRemotePwd.Text.Trim();
  185. break;
  186. case DataSourceType.SQL:
  187. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtSqlServerHost.Text.Trim();
  188. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtSqlServerName.Text.Trim();
  189. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtSqlServerUser.Text.Trim();
  190. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
  191. break;
  192. case DataSourceType.MySQL:
  193. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtMySqlHost.Text.Trim();
  194. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtMySqlServer.Text.Trim();
  195. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtMySqlUser.Text.Trim();
  196. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtMySqlPwd.Text.Trim();
  197. syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtMySqlPort.Text.Trim();
  198. break;
  199. case DataSourceType.Oracle:
  200. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtOracleHost.Text.Trim();
  201. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtOracleSource.Text.Trim();
  202. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtOracleUserId.Text.Trim();
  203. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtOraclePwd.Text.Trim();
  204. syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtOraclePort.Text.Trim();
  205. break;
  206. case DataSourceType.FoxPro:
  207. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtFoxProFolder.Text.Trim();
  208. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  209. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  210. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtFoxProUserId.Text.Trim();
  211. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtFoxProPwd.Text.Trim();
  212. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxFoxProRemote.Checked ? PathType.Remote : PathType.Local;
  213. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteFoxProUserId.Text.Trim();
  214. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteFoxProPwd.Text.Trim();
  215. break;
  216. case DataSourceType.TXT:
  217. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtInportTxt.Text.Trim();
  218. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  219. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  220. syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
  221. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
  222. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxRemoteTxt.Checked ? PathType.Remote : PathType.Local;
  223. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteTxtUserId.Text.Trim();
  224. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteTxtPwd.Text.Trim();
  225. break;
  226. case DataSourceType.Excel:
  227. case DataSourceType.PostgreSQL:
  228. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtPostgreSqlHost.Text.Trim();
  229. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtPostgreSqlServer.Text.Trim();
  230. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtPostgreSqlUser.Text.Trim();
  231. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtPostgreSqlPwd.Text.Trim();
  232. syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtPostgreSqlPort.Text.Trim();
  233. break;
  234. case DataSourceType.Kingbase:
  235. syncInstrumentItem.SyncInstrumentDSInfo.Host = this.txtKingbaselHost.Text.Trim();
  236. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = this.txtKingbaselServer.Text.Trim();
  237. syncInstrumentItem.SyncInstrumentDSInfo.UserId = this.txtKingbaselUser.Text.Trim();
  238. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = this.txtKingbaselPwd.Text.Trim();
  239. syncInstrumentItem.SyncInstrumentDSInfo.Port = this.txtKingbaselPort.Text.Trim();
  240. break;
  241. default:
  242. syncInstrumentItem.SyncInstrumentDSInfo.Path = this.txtInportExcel.Text.Trim();
  243. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  244. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  245. syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
  246. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
  247. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = this.cbxExcelRemote.Checked ? PathType.Remote : PathType.Local;
  248. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = this.txtRemoteExcelUser.Text.Trim();
  249. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = this.txtRemoteExcelPwd.Text.Trim();
  250. break;
  251. }
  252. object[] obj = new object[] { "", "", "" };
  253. //instrumentData = InstrumentDataFact.CreateInstrumentDataSource(syncInstrumentItem.SyncInstrumentDSInfo, obj);
  254. //dictInstrument = instrumentData.GetInstrumentData();
  255. //目标库的信息
  256. if (GlobalCommonOperation.strStartWebApi != "1")
  257. {
  258. syncInstrumentItem.SyncTargetDBInfo.DBHost = this.txtDBHost.Text.Trim();
  259. syncInstrumentItem.SyncTargetDBInfo.DBName = this.txtDBName.Text.Trim();
  260. syncInstrumentItem.SyncTargetDBInfo.DBUser = this.txtDBUser.Text.Trim();
  261. syncInstrumentItem.SyncTargetDBInfo.DBPwd = this.txtDBPwd.Text.Trim();
  262. syncInstrumentItem.SyncTargetDBInfo.DBPort = this.txtPort.Text.Trim();
  263. }
  264. else
  265. syncInstrumentItem.SyncTargetDBInfo = targetDataBaseInfo;
  266. this.InstrumentDelegate(syncInstrumentItem);
  267. //this.InstrumentItemData(dictInstrument);
  268. this.Close();
  269. }
  270. private void btnOpenFileExcel_Click(object sender, EventArgs e)
  271. {
  272. if (syncInstrumentItem.Code == null) return;
  273. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  274. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  275. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Excel;
  276. if (strReadExcelMode == "0")
  277. {
  278. OpenFileDialog openFile = new OpenFileDialog
  279. {
  280. Filter = "Excel(*.xlsx)|*.xlsx|Excel(*.xls)|*.xls",
  281. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  282. Multiselect = false
  283. };
  284. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  285. this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  286. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  287. if (string.IsNullOrEmpty(fileType)) return;
  288. }
  289. else
  290. {
  291. FolderBrowserDialog dialog = new FolderBrowserDialog();
  292. dialog.Description = "请选择文件路径";
  293. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  294. this.txtInportExcel.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  295. }
  296. }
  297. private void tabcDS_Selected(object sender, TabControlEventArgs e)
  298. {
  299. //切换的时候,检查其他类型数据源是否有值,如果有值,将提示删除旧值才能配置新值
  300. if (e.TabPage == tabExcel)
  301. {
  302. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  303. if (!CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  304. {
  305. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  306. {
  307. ClearAccessControl();
  308. ClearSqliteControl();
  309. ClearSQLServerControl();
  310. ClearMySQLControl();
  311. ClearOracleControl();
  312. ClearFoxproControl();
  313. ClearTxtControl();
  314. ClearObjectValue();
  315. }
  316. else
  317. {
  318. ChangeSelectTabPageByType();
  319. return;
  320. }
  321. }
  322. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Excel;
  323. }
  324. if (e.TabPage == tabAccess)
  325. {
  326. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  327. if (!CheckExcelControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  328. {
  329. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  330. {
  331. ClearExcelControl();
  332. ClearSqliteControl();
  333. ClearSQLServerControl();
  334. ClearMySQLControl();
  335. ClearOracleControl();
  336. ClearFoxproControl();
  337. ClearTxtControl();
  338. ClearObjectValue();
  339. }
  340. else
  341. {
  342. ChangeSelectTabPageByType();
  343. return;
  344. }
  345. }
  346. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Access;
  347. }
  348. if (e.TabPage == tabSQLite)
  349. {
  350. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  351. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  352. {
  353. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  354. {
  355. ClearAccessControl();
  356. ClearExcelControl();
  357. ClearSQLServerControl();
  358. ClearMySQLControl();
  359. ClearOracleControl();
  360. ClearFoxproControl();
  361. ClearTxtControl();
  362. ClearObjectValue();
  363. }
  364. else
  365. {
  366. ChangeSelectTabPageByType();
  367. return;
  368. }
  369. }
  370. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQLLite;
  371. }
  372. if (e.TabPage == tabSQLServer)
  373. {
  374. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  375. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  376. {
  377. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  378. {
  379. ClearAccessControl();
  380. ClearExcelControl();
  381. ClearSqliteControl();
  382. ClearMySQLControl();
  383. ClearOracleControl();
  384. ClearFoxproControl();
  385. ClearTxtControl();
  386. ClearObjectValue();
  387. }
  388. else
  389. {
  390. ChangeSelectTabPageByType();
  391. return;
  392. }
  393. }
  394. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQL;
  395. }
  396. if (e.TabPage == tabMySql)
  397. {
  398. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  399. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckOracleControl() || !CheckFoxproControl() || !CheckTxtControl())
  400. {
  401. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  402. {
  403. ClearAccessControl();
  404. ClearExcelControl();
  405. ClearSqliteControl();
  406. ClearSQLServerControl();
  407. ClearOracleControl();
  408. ClearFoxproControl();
  409. ClearTxtControl();
  410. ClearObjectValue();
  411. }
  412. else
  413. {
  414. ChangeSelectTabPageByType();
  415. return;
  416. }
  417. }
  418. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.MySQL;
  419. }
  420. if (e.TabPage == tabOracle)
  421. {
  422. //检查tabAccess页面是否为空 //检查tabSQLite页面是否为空
  423. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckFoxproControl() || !CheckTxtControl())
  424. {
  425. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  426. {
  427. ClearAccessControl();
  428. ClearExcelControl();
  429. ClearSqliteControl();
  430. ClearSQLServerControl();
  431. ClearMySQLControl();
  432. ClearFoxproControl();
  433. ClearTxtControl();
  434. ClearObjectValue();
  435. }
  436. else
  437. {
  438. ChangeSelectTabPageByType();
  439. return;
  440. }
  441. }
  442. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Oracle;
  443. }
  444. if (e.TabPage == tabFoxPro)
  445. {
  446. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckTxtControl())
  447. {
  448. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  449. {
  450. ClearAccessControl();
  451. ClearExcelControl();
  452. ClearSqliteControl();
  453. ClearSQLServerControl();
  454. ClearMySQLControl();
  455. ClearOracleControl();
  456. ClearTxtControl();
  457. ClearObjectValue();
  458. }
  459. else
  460. {
  461. ChangeSelectTabPageByType();
  462. return;
  463. }
  464. }
  465. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.FoxPro;
  466. }
  467. if (e.TabPage == tabTxt)
  468. {
  469. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() || !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() || !CheckFoxproControl())
  470. {
  471. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
  472. {
  473. ClearAccessControl();
  474. ClearExcelControl();
  475. ClearSqliteControl();
  476. ClearSQLServerControl();
  477. ClearMySQLControl();
  478. ClearOracleControl();
  479. ClearFoxproControl();
  480. ClearObjectValue();
  481. }
  482. else
  483. {
  484. ChangeSelectTabPageByType();
  485. return;
  486. }
  487. }
  488. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.TXT;
  489. }
  490. if (e.TabPage == tabPostgreSql)
  491. {
  492. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() ||
  493. !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() ||
  494. !CheckFoxproControl() || !CheckTxtControl())
  495. {
  496. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示",
  497. MessageBoxButtons.OKCancel) == DialogResult.OK)
  498. {
  499. ClearAccessControl();
  500. ClearExcelControl();
  501. ClearSqliteControl();
  502. ClearSQLServerControl();
  503. ClearMySQLControl();
  504. ClearOracleControl();
  505. ClearFoxproControl();
  506. ClearTxtControl();
  507. ClearObjectValue();
  508. }
  509. else
  510. {
  511. ChangeSelectTabPageByType();
  512. return;
  513. }
  514. }
  515. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.PostgreSQL;
  516. }
  517. if (e.TabPage == tabKingbase)
  518. {
  519. if (!CheckExcelControl() || !CheckAccessControl() || !CheckSQLiteControl() ||
  520. !CheckSQLServerControl() || !CheckMySqlControl() || !CheckOracleControl() ||
  521. !CheckFoxproControl() || !CheckTxtControl() || !CheckPostgreSqlControl())
  522. {
  523. if (MessageBox.Show("其他数据源存在已保存数据,继续将删除这些值,是否继续", "提示",
  524. MessageBoxButtons.OKCancel) == DialogResult.OK)
  525. {
  526. ClearAccessControl();
  527. ClearExcelControl();
  528. ClearSqliteControl();
  529. ClearSQLServerControl();
  530. ClearMySQLControl();
  531. ClearOracleControl();
  532. ClearFoxproControl();
  533. ClearTxtControl();
  534. ClearPostgreSqlControl();
  535. ClearObjectValue();
  536. }
  537. else
  538. {
  539. ChangeSelectTabPageByType();
  540. return;
  541. }
  542. }
  543. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Kingbase;
  544. }
  545. }
  546. //根据数据源类型切换Tab页
  547. private void ChangeSelectTabPageByType()
  548. {
  549. switch (syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType)
  550. {
  551. case DataSourceType.SQLLite:
  552. tabcDS.SelectedTab = tabSQLite;
  553. break;
  554. case DataSourceType.Access:
  555. tabcDS.SelectedTab = tabAccess;
  556. break;
  557. case DataSourceType.SQL:
  558. tabcDS.SelectedTab = tabSQLServer;
  559. break;
  560. case DataSourceType.Oracle:
  561. tabcDS.SelectedTab = tabOracle;
  562. break;
  563. case DataSourceType.FoxPro:
  564. tabcDS.SelectedTab = tabFoxPro;
  565. break;
  566. case DataSourceType.TXT:
  567. tabcDS.SelectedTab = tabTxt;
  568. break;
  569. case DataSourceType.Excel:
  570. case DataSourceType.PostgreSQL:
  571. case DataSourceType.Kingbase:
  572. default:
  573. tabcDS.SelectedTab = tabExcel;
  574. break;
  575. }
  576. }
  577. private bool CheckExcelControl()
  578. {
  579. if (this.txtInportExcel.Text != "")
  580. return false;
  581. else
  582. return true;
  583. }
  584. private bool CheckAccessControl()
  585. {
  586. if (this.txtAccessPath.Text != "" || this.txtAccessUser.Text != "" || this.txtAceessPwd.Text != "")
  587. return false;
  588. else
  589. return true;
  590. }
  591. private bool CheckSQLiteControl()
  592. {
  593. if (this.txtSqlitePath.Text != "" || this.txtSqliteUser.Text != "" || this.txtSqlitePwd.Text != "")
  594. return false;
  595. else
  596. return true;
  597. }
  598. private bool CheckSQLServerControl()
  599. {
  600. if (this.txtSqlServerHost.Text.Trim() != "" || this.txtSqlServerName.Text.Trim() != "" || this.txtSqlServerPwd.Text.Trim() != "" || this.txtSqlServerUser.Text.Trim() != "")
  601. return false;
  602. else
  603. return true;
  604. }
  605. private bool CheckMySqlControl()
  606. {
  607. if (this.txtMySqlHost.Text.Trim() != "" || this.txtMySqlServer.Text.Trim() != "" || this.txtMySqlUser.Text.Trim() != "" || this.txtMySqlPwd.Text.Trim() != "" || this.txtMySqlPort.Text.Trim() != "")
  608. return false;
  609. else
  610. return true;
  611. }
  612. private bool CheckOracleControl()
  613. {
  614. if (this.txtOraclePort.Text.Trim() != "" || this.txtOraclePwd.Text.Trim() != "" || this.txtOracleHost.Text.Trim() != "" || this.txtOracleSource.Text.Trim() != "" || this.txtOracleUserId.Text.Trim() != "")
  615. return false;
  616. else
  617. return true;
  618. }
  619. private bool CheckFoxproControl()
  620. {
  621. if (this.txtFoxProFolder.Text.Trim() != "" || this.txtFoxProUserId.Text.Trim() != "" || this.txtFoxProPwd.Text.Trim() != "" || this.txtRemoteFoxProUserId.Text.Trim() != "" || this.txtRemoteFoxProPwd.Text.Trim() != "")
  622. {
  623. return false;
  624. }
  625. else
  626. return true;
  627. }
  628. private bool CheckTxtControl()
  629. {
  630. if (this.txtInportTxt.Text.Trim() != "" || this.txtRemoteTxtUserId.Text.Trim() != "" || this.txtRemoteTxtPwd.Text.Trim() != "")
  631. return false;
  632. else
  633. return true;
  634. }
  635. private void btnCNASTestLink_Click(object sender, EventArgs e)
  636. {
  637. //this.txtDBHost.Text.Trim(), this.txtDBName.Text.Trim(), this.txtDBUser.Text.Trim(), this.txtDBPwd.Text.Trim(),this.txtPort.Text.Trim()
  638. if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo()
  639. {
  640. DBHost = this.txtDBHost.Text.Trim(),
  641. DBName = this.txtDBName.Text.Trim(),
  642. DBUser = this.txtDBUser.Text.Trim(),
  643. DBPwd = this.txtDBPwd.Text.Trim(),
  644. DBPort = this.txtPort.Text.Trim()
  645. }))
  646. MessageBox.Show("连接成功!");
  647. else
  648. MessageBox.Show("连接失败!");
  649. }
  650. private void ClearExcelControl()
  651. {
  652. this.txtInportExcel.Text = "";
  653. this.txtRemoteExcelUser.Text = "";
  654. this.txtRemoteExcelPwd.Text = "";
  655. }
  656. private void ClearAccessControl()
  657. {
  658. this.txtAccessPath.Text = "";
  659. this.txtAccessUser.Text = "";
  660. this.txtAceessPwd.Text = "";
  661. this.txtAccessRemoteUser.Text = "";
  662. this.txtAccessRemotePwd.Text = "";
  663. }
  664. private void ClearSqliteControl()
  665. {
  666. this.txtSqliteUser.Text = "";
  667. this.txtSqlitePath.Text = "";
  668. this.txtSqlitePwd.Text = "";
  669. this.txtSqliteRemoteUser.Text = "";
  670. this.txtSqliteRemotePwd.Text = "";
  671. }
  672. private void ClearSQLServerControl()
  673. {
  674. this.txtSqlServerHost.Text = "";
  675. this.txtSqlServerName.Text = "";
  676. this.txtSqlServerUser.Text = "";
  677. this.txtSqlServerPwd.Text = "";
  678. }
  679. private void ClearMySQLControl()
  680. {
  681. this.txtMySqlHost.Text = "";
  682. this.txtMySqlServer.Text = "";
  683. this.txtMySqlUser.Text = "";
  684. this.txtMySqlPwd.Text = "";
  685. this.txtMySqlPort.Text = "";
  686. }
  687. private void ClearOracleControl()
  688. {
  689. this.txtOracleHost.Text = "";
  690. this.txtOracleSource.Text = "";
  691. this.txtOracleUserId.Text = "";
  692. this.txtOraclePwd.Text = "";
  693. this.txtOraclePort.Text = "";
  694. }
  695. private void ClearFoxproControl()
  696. {
  697. this.txtFoxProFolder.Text = "";
  698. this.txtFoxProUserId.Text = "";
  699. this.txtFoxProPwd.Text = "";
  700. this.txtRemoteFoxProUserId.Text = "";
  701. this.txtRemoteFoxProPwd.Text = "";
  702. }
  703. private void ClearTxtControl()
  704. {
  705. this.txtInportTxt.Text = "";
  706. this.txtRemoteTxtUserId.Text = "";
  707. this.txtRemoteTxtPwd.Text = "";
  708. }
  709. /// <summary>
  710. /// 清空对象中存储的值
  711. /// </summary>
  712. private void ClearObjectValue()
  713. {
  714. syncInstrumentItem.SyncInstrumentDSInfo.Host = "";
  715. syncInstrumentItem.SyncInstrumentDSInfo.ServerName = "";
  716. syncInstrumentItem.SyncInstrumentDSInfo.Path = "";
  717. syncInstrumentItem.SyncInstrumentDSInfo.UserId = "";
  718. syncInstrumentItem.SyncInstrumentDSInfo.UserPwd = "";
  719. syncInstrumentItem.SyncInstrumentDSInfo.Port = "";
  720. syncInstrumentItem.SyncInstrumentDSInfo.DsPathType = PathType.Local;
  721. syncInstrumentItem.SyncInstrumentDSInfo.RemoteUser = "";
  722. syncInstrumentItem.SyncInstrumentDSInfo.RemotePwd = "";
  723. }
  724. private void btnOpenFileAccess_Click(object sender, EventArgs e)
  725. {
  726. if (syncInstrumentItem.Code == null) return;
  727. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  728. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  729. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.Access;
  730. if (strReadAccessMode == "0")
  731. {
  732. OpenFileDialog openFile = new OpenFileDialog
  733. {
  734. Filter = "Microsoft Access(*.mdb)|*.mdb|Microsoft Access(*.accdb)|*.accdb",
  735. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  736. Multiselect = false
  737. };
  738. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  739. this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  740. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  741. if (string.IsNullOrEmpty(fileType)) return;
  742. }
  743. else
  744. {
  745. FolderBrowserDialog dialog = new FolderBrowserDialog();
  746. dialog.Description = "请选择文件路径";
  747. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  748. this.txtAccessPath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  749. }
  750. }
  751. private void btnOpenFileSQLite_Click(object sender, EventArgs e)
  752. {
  753. if (syncInstrumentItem.Code == null) return;
  754. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  755. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  756. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.SQLLite;
  757. if (strReadSqliteMode == "0")
  758. {
  759. OpenFileDialog openFile = new OpenFileDialog
  760. {
  761. Filter = "SQLite(*.db)|*.db",
  762. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  763. Multiselect = false
  764. };
  765. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  766. this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  767. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  768. if (string.IsNullOrEmpty(fileType)) return;
  769. }
  770. else
  771. {
  772. FolderBrowserDialog dialog = new FolderBrowserDialog();
  773. dialog.Description = "请选择文件路径";
  774. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  775. this.txtSqlitePath.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  776. }
  777. }
  778. private void btnTestSQLLink_Click(object sender, EventArgs e)
  779. {
  780. if (this.txtSqlServerHost.Text.Trim() == "" || this.txtSqlServerName.Text.Trim() == "" || this.txtSqlServerUser.Text.Trim() == "")
  781. {
  782. MessageBox.Show("请填写相关连接信息。");
  783. return;
  784. }
  785. InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  786. dbinfo.Host = this.txtSqlServerHost.Text.Trim();
  787. dbinfo.ServerName = this.txtSqlServerName.Text.Trim();
  788. dbinfo.UserId = this.txtSqlServerUser.Text.Trim();
  789. dbinfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
  790. dbinfo.Port = this.txtSqlServerPort.Text.Trim();
  791. if (new SQLServerInstrumentData(dbinfo, new object[] {
  792. "",
  793. "",
  794. ""
  795. }).TestSQLServerLink())
  796. MessageBox.Show("连接成功!");
  797. else
  798. MessageBox.Show("连接失败!");
  799. }
  800. private void cbxExcelRemote_CheckedChanged(object sender, EventArgs e)
  801. {
  802. if (!cbxExcelRemote.Checked)
  803. {
  804. this.btnOpenFileExcel.Visible = true;
  805. lblExcelRemotePwd.Visible = false;
  806. lblExcelRemoteUser.Visible = false;
  807. txtRemoteExcelUser.Visible = false;
  808. txtRemoteExcelPwd.Visible = false;
  809. }
  810. else
  811. {
  812. this.btnOpenFileExcel.Visible = false;
  813. lblExcelRemotePwd.Visible = true;
  814. lblExcelRemoteUser.Visible = true;
  815. txtRemoteExcelUser.Visible = true;
  816. txtRemoteExcelPwd.Visible = true;
  817. }
  818. }
  819. private void cbxAccessRemote_CheckedChanged(object sender, EventArgs e)
  820. {
  821. if (cbxAccessRemote.Checked)
  822. {
  823. btnOpenFileAccess.Visible = false;
  824. lblAccessRemoteUser.Visible = true;
  825. lblAccessRemotePwd.Visible = true;
  826. txtAccessRemoteUser.Visible = true;
  827. txtAccessRemotePwd.Visible = true;
  828. }
  829. else
  830. {
  831. btnOpenFileAccess.Visible = true;
  832. lblAccessRemoteUser.Visible = false;
  833. lblAccessRemotePwd.Visible = false;
  834. txtAccessRemoteUser.Visible = false;
  835. txtAccessRemotePwd.Visible = false;
  836. }
  837. }
  838. private void cbxSqliteRemote_CheckedChanged(object sender, EventArgs e)
  839. {
  840. if (cbxSqliteRemote.Checked)
  841. {
  842. btnOpenFileSQLite.Visible = false;
  843. lblSqliteRemoteUser.Visible = true;
  844. lblSqliteRemotePwd.Visible = true;
  845. txtSqliteRemoteUser.Visible = true;
  846. txtSqliteRemotePwd.Visible = true;
  847. }
  848. else
  849. {
  850. btnOpenFileSQLite.Visible = true;
  851. lblSqliteRemoteUser.Visible = false;
  852. lblSqliteRemotePwd.Visible = false;
  853. txtSqliteRemoteUser.Visible = false;
  854. txtSqliteRemotePwd.Visible = false;
  855. }
  856. }
  857. private void btnMySqlTest_Click(object sender, EventArgs e)
  858. {
  859. if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo()
  860. {
  861. DBHost = this.txtMySqlHost.Text.Trim(),
  862. DBName = this.txtMySqlServer.Text.Trim(),
  863. DBUser = this.txtMySqlUser.Text.Trim(),
  864. DBPwd = this.txtMySqlPwd.Text.Trim(),
  865. DBPort = this.txtMySqlPort.Text.Trim()
  866. }))
  867. MessageBox.Show("连接成功!");
  868. else
  869. MessageBox.Show("连接失败!");
  870. }
  871. private void btnOracleTestLink_Click(object sender, EventArgs e)
  872. {
  873. if (this.txtOracleHost.Text.Trim() == "" || this.txtOracleSource.Text.Trim() == "" || this.txtOracleUserId.Text.Trim() == "" || this.txtOraclePort.Text.Trim() == "")
  874. {
  875. MessageBox.Show("请填写相关连接信息。");
  876. return;
  877. }
  878. InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  879. dbinfo.Host = this.txtOracleHost.Text.Trim();
  880. dbinfo.ServerName = this.txtOracleSource.Text.Trim();
  881. dbinfo.UserId = this.txtOracleUserId.Text.Trim();
  882. dbinfo.UserPwd = this.txtOraclePwd.Text.Trim();
  883. dbinfo.Port = this.txtOraclePort.Text.Trim();
  884. if (new OracleInstrumentData(dbinfo, new object[] {
  885. "",
  886. "",
  887. ""
  888. }).TestSQLServerLink())
  889. MessageBox.Show("连接成功!");
  890. else
  891. MessageBox.Show("连接失败!");
  892. }
  893. private void txtFileOpenFoxPro_Click(object sender, EventArgs e)
  894. {
  895. if (syncInstrumentItem.Code == null) return;
  896. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  897. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  898. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.FoxPro;
  899. if (strReadFoxproMode == "0")
  900. {
  901. OpenFileDialog openFile = new OpenFileDialog
  902. {
  903. Filter = "Foxpro文件(*.dbf)|*.dbf",
  904. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  905. Multiselect = false
  906. };
  907. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  908. this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  909. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  910. if (string.IsNullOrEmpty(fileType)) return;
  911. }
  912. else
  913. {
  914. FolderBrowserDialog dialog = new FolderBrowserDialog();
  915. dialog.Description = "请选择文件路径";
  916. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  917. this.txtFoxProFolder.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  918. }
  919. }
  920. private void cbxFoxProRemote_CheckedChanged(object sender, EventArgs e)
  921. {
  922. if (!cbxFoxProRemote.Checked)
  923. {
  924. this.btnFileOpenFoxPro.Visible = true;
  925. lblFoxproRemoteUserId.Visible = false;
  926. lblFoxproRemotePwd.Visible = false;
  927. txtRemoteFoxProUserId.Visible = false;
  928. txtRemoteFoxProPwd.Visible = false;
  929. }
  930. else
  931. {
  932. this.btnFileOpenFoxPro.Visible = false;
  933. lblFoxproRemoteUserId.Visible = true;
  934. lblFoxproRemotePwd.Visible = true;
  935. txtRemoteFoxProUserId.Visible = true;
  936. txtRemoteFoxProPwd.Visible = true;
  937. }
  938. }
  939. private void btnOpenFileTxt_Click(object sender, EventArgs e)
  940. {
  941. if (syncInstrumentItem.Code == null) return;
  942. if (syncInstrumentItem.SyncInstrumentDSInfo == null)
  943. syncInstrumentItem.SyncInstrumentDSInfo = new InstrumentDataSourceInfo();
  944. syncInstrumentItem.SyncInstrumentDSInfo.InstrumentDataSourceType = DataSourceType.TXT;
  945. if (strReadTxtMode == "0")
  946. {
  947. OpenFileDialog openFile = new OpenFileDialog
  948. {
  949. Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*",
  950. InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
  951. Multiselect = false
  952. };
  953. if (openFile.ShowDialog() == DialogResult.Cancel) return;
  954. this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = openFile.FileName;
  955. string fileType = System.IO.Path.GetExtension(openFile.FileName);
  956. if (string.IsNullOrEmpty(fileType)) return;
  957. }
  958. else
  959. {
  960. FolderBrowserDialog dialog = new FolderBrowserDialog();
  961. dialog.Description = "请选择文件路径";
  962. if (dialog.ShowDialog() == DialogResult.Cancel) return;
  963. this.txtInportTxt.Text = syncInstrumentItem.SyncInstrumentDSInfo.Path = dialog.SelectedPath;
  964. }
  965. }
  966. private void cbxRemoteTxt_CheckedChanged(object sender, EventArgs e)
  967. {
  968. if (!cbxRemoteTxt.Checked)
  969. {
  970. this.btnOpenFileTxt.Visible = true;
  971. lblTxtRemoteUserId.Visible = false;
  972. lblTxtRemoteUserPwd.Visible = false;
  973. txtRemoteTxtUserId.Visible = false;
  974. txtRemoteTxtPwd.Visible = false;
  975. }
  976. else
  977. {
  978. this.btnOpenFileTxt.Visible = false;
  979. lblTxtRemoteUserId.Visible = true;
  980. lblTxtRemoteUserPwd.Visible = true;
  981. txtRemoteTxtUserId.Visible = true;
  982. txtRemoteTxtPwd.Visible = true;
  983. }
  984. }
  985. private void cbxTargetDBSelect_SelectedIndexChanged(object sender, EventArgs e)
  986. {
  987. if (cbxTargetDBSelect.SelectedIndex == 0)
  988. {
  989. if (GlobalCommonOperation.strStartWebApi == "1")
  990. {
  991. targetDataBaseInfo = new DataBaseInfo()
  992. {
  993. DataBaseCode = "cnas"
  994. };
  995. }
  996. else
  997. {
  998. DataBaseInfo CNASDataBase = FileOperation.GetLocalCnasDB();
  999. if (CNASDataBase != null)
  1000. {
  1001. this.txtDBHost.Text = CNASDataBase.DBHost;
  1002. this.txtDBName.Text = CNASDataBase.DBName;
  1003. this.txtDBUser.Text = CNASDataBase.DBUser;
  1004. this.txtDBPwd.Text = CNASDataBase.DBPwd;
  1005. this.txtPort.Text = CNASDataBase.DBPort;
  1006. }
  1007. }
  1008. }
  1009. else if (cbxTargetDBSelect.SelectedIndex == 1)
  1010. {
  1011. if (GlobalCommonOperation.strStartWebApi == "1")
  1012. {
  1013. targetDataBaseInfo = new DataBaseInfo()
  1014. {
  1015. DataBaseCode = "platform"
  1016. };
  1017. }
  1018. else
  1019. {
  1020. DataBaseInfo PlatDataBase = FileOperation.GetLocalPlatFormDB();
  1021. if (PlatDataBase != null)
  1022. {
  1023. this.txtDBHost.Text = PlatDataBase.DBHost;
  1024. this.txtDBName.Text = PlatDataBase.DBName;
  1025. this.txtDBUser.Text = PlatDataBase.DBUser;
  1026. this.txtDBPwd.Text = PlatDataBase.DBPwd;
  1027. this.txtPort.Text = PlatDataBase.DBPort;
  1028. }
  1029. }
  1030. }
  1031. }
  1032. private bool CheckPostgreSqlControl()
  1033. {
  1034. if (this.txtPostgreSqlHost.Text.Trim() != "" || this.txtPostgreSqlServer.Text.Trim() != "" ||
  1035. this.txtPostgreSqlUser.Text.Trim() != "" || this.txtPostgreSqlPwd.Text.Trim() != "" ||
  1036. this.txtPostgreSqlPort.Text.Trim() != "")
  1037. return false;
  1038. else
  1039. return true;
  1040. }
  1041. private void ClearPostgreSqlControl()
  1042. {
  1043. this.txtPostgreSqlHost.Text = "";
  1044. this.txtPostgreSqlServer.Text = "";
  1045. this.txtPostgreSqlUser.Text = "";
  1046. this.txtPostgreSqlPwd.Text = "";
  1047. this.txtPostgreSqlPort.Text = "";
  1048. }
  1049. private bool CheckKingbaseControl()
  1050. {
  1051. if (this.txtKingbaselHost.Text.Trim() != "" || this.txtKingbaselServer.Text.Trim() != "" ||
  1052. this.txtKingbaselUser.Text.Trim() != "" || this.txtKingbaselPwd.Text.Trim() != "" ||
  1053. this.txtKingbaselPort.Text.Trim() != "")
  1054. return false;
  1055. else
  1056. return true;
  1057. }
  1058. private void ClearKingbaseControl()
  1059. {
  1060. this.txtKingbaselHost.Text = "";
  1061. this.txtKingbaselServer.Text = "";
  1062. this.txtKingbaselUser.Text = "";
  1063. this.txtKingbaselPwd.Text = "";
  1064. this.txtKingbaselPort.Text = "";
  1065. }
  1066. private void btnKingbaselConn_Click(object sender, EventArgs e)
  1067. {
  1068. if (this.txtKingbaselHost.Text.Trim() == "" || this.txtKingbaselServer.Text.Trim() == "" ||
  1069. this.txtKingbaselUser.Text.Trim() == "" || this.txtKingbaselPort.Text.Trim() == "")
  1070. {
  1071. MessageBox.Show("请填写相关连接信息。");
  1072. return;
  1073. }
  1074. InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  1075. dbinfo.Host = this.txtKingbaselHost.Text.Trim();
  1076. dbinfo.ServerName = this.txtKingbaselServer.Text.Trim();
  1077. dbinfo.UserId = this.txtKingbaselUser.Text.Trim();
  1078. dbinfo.UserPwd = this.txtKingbaselPwd.Text.Trim();
  1079. dbinfo.Port = this.txtKingbaselPort.Text.Trim();
  1080. // 假设有KingbaseInstrumentData类来处理连接测试
  1081. if (new KingbaseServerInstrumentData(dbinfo, new object[] { "", "", "" }).TestSQLServerLink())
  1082. MessageBox.Show("连接成功!");
  1083. else
  1084. MessageBox.Show("连接失败!");
  1085. }
  1086. private void btnPostgreSqlConn_Click(object sender, EventArgs e)
  1087. {
  1088. if (this.txtPostgreSqlHost.Text.Trim() == "" || this.txtPostgreSqlServer.Text.Trim() == "" ||
  1089. this.txtPostgreSqlUser.Text.Trim() == "" || this.txtPostgreSqlPort.Text.Trim() == "")
  1090. {
  1091. MessageBox.Show("请填写相关连接信息。");
  1092. return;
  1093. }
  1094. InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  1095. dbinfo.Host = this.txtPostgreSqlHost.Text.Trim();
  1096. dbinfo.ServerName = this.txtPostgreSqlServer.Text.Trim();
  1097. dbinfo.UserId = this.txtPostgreSqlUser.Text.Trim();
  1098. dbinfo.UserPwd = this.txtPostgreSqlPwd.Text.Trim();
  1099. dbinfo.Port = this.txtPostgreSqlPort.Text.Trim();
  1100. //SQLServerInstrumentData
  1101. if (new PostgreSQLServerInstrumentData(dbinfo, new object[] {
  1102. "",
  1103. "",
  1104. ""
  1105. }).TestSQLServerLink())
  1106. MessageBox.Show("连接成功!");
  1107. else
  1108. MessageBox.Show("连接失败!");
  1109. //if (new PostgreSQLServerInstrumentData(dbinfo, new object[] { "", "", "" }).TestConnection())
  1110. // MessageBox.Show("连接成功!");
  1111. //else
  1112. // MessageBox.Show("连接失败!");
  1113. //if (this.txtSqlServerHost.Text.Trim() == "" || this.txtSqlServerName.Text.Trim() == "" || this.txtSqlServerUser.Text.Trim() == "")
  1114. //{
  1115. // MessageBox.Show("请填写相关连接信息。");
  1116. // return;
  1117. //}
  1118. //InstrumentDataSourceInfo dbinfo = new InstrumentDataSourceInfo();
  1119. //dbinfo.Host = this.txtSqlServerHost.Text.Trim();
  1120. //dbinfo.ServerName = this.txtSqlServerName.Text.Trim();
  1121. //dbinfo.UserId = this.txtSqlServerUser.Text.Trim();
  1122. //dbinfo.UserPwd = this.txtSqlServerPwd.Text.Trim();
  1123. //dbinfo.Port = this.txtSqlServerPort.Text.Trim();
  1124. //if (new SQLServerInstrumentData(dbinfo, new object[] {
  1125. // "",
  1126. // "",
  1127. // ""
  1128. //}).TestSQLServerLink())
  1129. // MessageBox.Show("连接成功!");
  1130. //else
  1131. // MessageBox.Show("连接失败!");
  1132. }
  1133. }
  1134. }