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