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

frmDatabaseParams.cs 62KB

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