Form1.cs 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  1. using CarMeterSystem.OptionCls;
  2. using com.hnshituo.core.webapp.vo;
  3. using Common;
  4. using iCore.Rtdb.RtdbTable;
  5. using MeterConditionLibrary;
  6. using MeterModelLibrary;
  7. using MeterModuleLibrary.uc;
  8. using MeterPlugInLibrary;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Diagnostics;
  14. using System.Drawing;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Net.NetworkInformation;
  18. using System.Windows.Forms;
  19. using SystemOffLine;
  20. namespace CarMeterSystem
  21. {
  22. public partial class Form1 : Form
  23. {
  24. public Form1()
  25. {
  26. InitializeComponent();
  27. }
  28. private Log l = Log.GetInstance();
  29. private Print printClass = new Print();//打印
  30. //内存表
  31. private MemoryTableDataSocket MemoClass = new MemoryTableDataSocket("");
  32. //实时表数据采集
  33. private DataCollectionControl collection = new DataCollectionControl();
  34. //图片控制器含图片压缩及上传curl
  35. private ImageCurlControl imageCurlControl = new ImageCurlControl();
  36. //与监控界面对接的表
  37. private MeterWorkMonitorService meterWorkMonitor = new MeterWorkMonitorService();
  38. //零点报警表
  39. private meterworkzeroalarmservice zeroAlarmService = new meterworkzeroalarmservice();
  40. //车号修正
  41. private CarNoModfiy modfiy = new CarNoModfiy();
  42. //一码通接口调用
  43. private HttpRequest httpRequest = new HttpRequest();
  44. /// <summary>
  45. /// 这个是保存前一次采集中的车号信息
  46. /// </summary>
  47. private string preCarNo = "";
  48. //验证对射
  49. private validParkStatus valid = new validParkStatus();
  50. //语音播报
  51. private VoicePlay vicPlayClass = new VoicePlay();
  52. private LED_Control led_controler = null;
  53. //监控表操作
  54. private MeterMonitorWeightService monitorWeightService = new MeterMonitorWeightService();
  55. private MeterWorkScheduledHelpService meterWorkScheduledHelpService = new MeterWorkScheduledHelpService();
  56. //验证校秤数据
  57. private validCalibration vCalib = new validCalibration();
  58. private MeterWorkCarActualFirstService workCarActualFirstService = new MeterWorkCarActualFirstService(); //一次计量数据
  59. //查询当前是否校秤
  60. private bool bRelation = true;
  61. /// <summary>
  62. /// 欢迎界面
  63. /// </summary>
  64. private frmWelcome_Jisco frmWelcome = new frmWelcome_Jisco();//欢迎
  65. /// <summary>
  66. /// 计量页
  67. /// </summary>
  68. private frmOneYardToEnd fcc = null;
  69. /// <summary>
  70. /// 基础数据载入
  71. /// </summary>
  72. private BaseDbCls bd = new BaseDbCls();
  73. //扫码修正车号标识
  74. private bool codeFlag = false;
  75. private List<ucBusinessType> lu = new List<ucBusinessType>();
  76. private bool isVoiceDownCar = false;//车上人员请下车播放一次
  77. private bool isShowFrmWelcome = false; //是否显示欢迎界面;在这个测试界面,不显示欢迎界面
  78. private bool isOpened = false;//是否已经打开了扫码计量界面
  79. private SerialPortES sweepCodeClass = new SerialPortES();
  80. private SerialPortES sweepCodeClass2 = new SerialPortES();
  81. private void Form1_Load(object sender, EventArgs e)
  82. {
  83. //*
  84. try
  85. {
  86. //CollectModel temp = new CollectModel();
  87. //temp.weight = 501;
  88. //PbCache.collect = temp;
  89. //frmMatMsgInfo frmMatMsgInfo = new frmMatMsgInfo();
  90. //frmMatMsgInfo.Show();
  91. // 计量页
  92. fcc = new frmOneYardToEnd();
  93. timer1.Start();
  94. //2021年6月21日 杨秀东添加
  95. if (isShowFrmWelcome)
  96. {
  97. frmWelcome.Show();
  98. frmWelcome.Visible = true;
  99. }
  100. LoginCls lg = new LoginCls();
  101. if (lg.LoginIn())
  102. {
  103. //if (SystemUpdate(false))
  104. //{
  105. // return;
  106. //}
  107. // 加载并验证基本配置
  108. if (bd.setBaseDb() && bd.getBaseDb())
  109. {
  110. if (!string.IsNullOrEmpty(PbCache.sportInfo.ledIp))
  111. {
  112. led_controler = new LED_Control(PbCache.sportInfo.ledIp);
  113. }
  114. //调用该方法时已赋值
  115. RESTfulResult<List<MeterWorkMonitor>> rm = meterWorkMonitor.doQueryOneWf(new MeterWorkMonitor { validFlag = "1", pointNo = PbCache.sportInfo.baseSpotNo });
  116. if (!rm.Succeed)
  117. {
  118. l.WriteLog(1, "载入监控表数据异常");
  119. return;
  120. }
  121. else if (rm.Data != null && rm.Data.Count > 0)
  122. {
  123. if (string.IsNullOrEmpty(PbCache.collect_no))
  124. {
  125. PbCache.collect_no = rm.Data[0].collectionCode;
  126. MemoClass = new MemoryTableDataSocket(PbCache.collect_no);
  127. }
  128. }
  129. else
  130. {
  131. //l.WriteLog(1, "为配置监控数据");
  132. //return;
  133. }
  134. //若未校秤的话,也不允许计量
  135. //载入界面业务按钮
  136. if (PbCache.businessType != null && PbCache.businessType.Count > 0)
  137. {
  138. foreach (ComBaseInfo info in PbCache.businessType)
  139. {
  140. ucBusinessType uc = new ucBusinessType();
  141. switch (info.baseCode)
  142. {
  143. case "001006003":
  144. uc.setControl(info.baseName, info.memo, info.baseCode);
  145. break;
  146. case "001006001":
  147. case "001006002":
  148. uc.setControl(info.baseName, info.memo, info.baseCode);
  149. break;
  150. default:
  151. uc.setControl(info.baseName, info.memo, info.baseCode);
  152. break;
  153. }
  154. uc.Dock = DockStyle.Top;
  155. //uc.setControl("","","",);
  156. uc.ucEvent += new EventHandler(ucEvents);
  157. lu.Add(uc);
  158. panel7.Controls.Add(uc);
  159. }
  160. }
  161. //开启基础进程
  162. l.WriteLog(0, "系统登录成功");
  163. collection.EventDataCollectionArgs += new EventDataCollection(EventData);//数据采集
  164. collection.Start(PbCache.sportInfo.baseSpotNo, PbCache.sportInfo.baseSpotName);
  165. imageCurlControl.Start(); //图片采集线程
  166. //新扫码线程
  167. if (AppConfigCache._comPara?.Split(new char[] { ',' })?.Length == 5)
  168. {
  169. sweepCodeClass.StartThreadSweep(AppConfigCache._comPara); //扫码线程
  170. }
  171. if (AppConfigCache._comPara2?.Split(new char[] { ',' })?.Length == 5)
  172. {
  173. sweepCodeClass2.StartThreadSweep(AppConfigCache._comPara2); //扫码线程
  174. }
  175. }
  176. else
  177. {
  178. l.WriteLog(0, "系统登录失败");
  179. }
  180. }
  181. else
  182. {
  183. l.WriteLog(0, "按IP地址找不到计量点信息,系统登录失败");
  184. }
  185. }
  186. catch (Exception ex)
  187. {
  188. l.WriteLog(0, "系统加载失败:" + ex.Message);
  189. }
  190. //*/
  191. }
  192. #region
  193. //*
  194. /// <summary>
  195. /// 委托的方式调用控件的点击事件
  196. /// </summary>
  197. /// <param name="sender"></param>
  198. /// <param name="e"></param>
  199. public void ucEvents(object sender, EventArgs e)
  200. {
  201. Control control = (Control)sender;
  202. ucBusinessType um = control.Parent.Parent as ucBusinessType;
  203. try
  204. {
  205. switch (control.Name)
  206. {
  207. case "btnContext":
  208. case "btnPurchase":
  209. {
  210. PbCache.bussinessTypeName = um._bussiness == null ? "" : um._bussiness;
  211. PbCache.bussinessTypeCode = um._code;
  212. switch (um._code)
  213. {
  214. case "001006003":
  215. frmInternalTransport frm = new frmInternalTransport();
  216. frm.ShowDialog();
  217. break;
  218. /*
  219. case "001006001":
  220. case "001006002":
  221. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  222. frmCar.ShowDialog();
  223. break;
  224. //*/
  225. default:
  226. frmCarSalePurchase frmCar = new frmCarSalePurchase();
  227. frmCar.ShowDialog();
  228. break;
  229. }
  230. };
  231. break;
  232. default: break;
  233. }
  234. }
  235. catch (Exception ex)
  236. {
  237. //MessageBox.Show("操作异常:" + ex.Message);
  238. }
  239. }
  240. //*/
  241. #endregion
  242. #region
  243. private void setWelecomeVis(bool visb)
  244. {
  245. /*
  246. if (frmWelcome.InvokeRequired)
  247. {
  248. Action<bool> action = new Action<bool>(setWelecomeVis);
  249. Invoke(action, new object[] { visb });
  250. }
  251. else
  252. {
  253. if (frmWelcome.Visible != visb)
  254. {
  255. frmWelcome.Visible = visb;
  256. frmWelcome.setLogin();
  257. }
  258. }
  259. //*/
  260. }
  261. #endregion
  262. private int iCount = 0, iHodeTime = 0;
  263. private bool flagCarMonit = false;//车号修正
  264. private bool bEditCar = false; //手动修正车号
  265. private bool isOpenMeter = false; //是否已打开计量界面,若已经打开则这里关于超量程及红外的语音将停止播报
  266. private string firstCode = "";//上次扫码的信息
  267. private string ledTxt = "";
  268. private bool isLedWrite = false;//是否写入一次LED
  269. private string sPreNo = ""; //记录重量曲线变化
  270. private int preWgt = 0;//前一次重量,用于重量曲线
  271. private string sCarNo = "";
  272. private int iCountPark = 0;
  273. private string editCarNo = "";
  274. private bool isResFlag = true;
  275. private string RFIDCarNo = "";
  276. private string isWriteRFID = AppConfigCache.isWriteRFID;
  277. //EventData实例化
  278. RESTfulResult<string> rmsEventDataLastTime = new RESTfulResult<string>();
  279. RESTfulResult<List<MeterWorkMonitor>> rmUpdateEventDataMonitor = new RESTfulResult<List<MeterWorkMonitor>>();
  280. MeterWorkMonitor updateEventDataMonitor = new MeterWorkMonitor();
  281. MeterMonitorWeight meterMonitorWeightEventData1 = new MeterMonitorWeight();
  282. MeterMonitorWeight meterMonitorWeightEventData2 = new MeterMonitorWeight();
  283. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  284. PbModelDbService<List<PbModelDb>> pbpRFIDEventData = new PbModelDbService<List<PbModelDb>>();
  285. RESTfulResult<List<PbModelDb>> rmTRFIDEventData = new RESTfulResult<List<PbModelDb>>();
  286. RESTfulResult<string> rmsmwUpdateEventData = new RESTfulResult<string>();
  287. MeterWorkScheduledHelp meterWorkScheduledHelp1 = new MeterWorkScheduledHelp();
  288. MeterWorkScheduledHelp meterWorkScheduledHelpRFID = new MeterWorkScheduledHelp();
  289. RESTfulResult<string> rmsdoUpdateWfEventData = new RESTfulResult<string>();
  290. RESTfulResult<string> rmssEventData = new RESTfulResult<string>();
  291. MeterWorkMonitor meterWorkMonitorEventDataI = new MeterWorkMonitor();
  292. MeterWorkCarActualFirstService mwcfs = new MeterWorkCarActualFirstService();
  293. RESTfulResult<string> rmsSweepCodeClass = new RESTfulResult<string>();
  294. frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  295. /// <summary>
  296. /// 数据采集
  297. /// </summary>
  298. /// <param name="o"></param>
  299. /// <param name="e"></param>
  300. private void EventData(object o, DataCollectionArgs e)
  301. {
  302. if (!timer1.Enabled)
  303. {
  304. timer1.Enabled = true;
  305. l.WriteLog(32, "定时器重启(timer1_Tick:frmMain),车号:" + PbCache.resultCarNo + "||" + (PbCache.collect == null ? "" : PbCache.collect.carno));
  306. }
  307. #region
  308. //num++;
  309. //e.carno = "湘G88888";
  310. //if (num < 20)
  311. //{
  312. // e.weight = 23580;
  313. // e.weightStatus = 1;
  314. //}
  315. //else if (num < 26)
  316. //{
  317. // e.weight = 23580;
  318. // e.weightStatus = 0;
  319. //}
  320. //else if (num < 39)
  321. //{
  322. // e.weight = 23580;
  323. // e.weightStatus = 0;
  324. //}
  325. //else if (num < 45)
  326. //{
  327. // e.weight = 15000;
  328. // e.weightStatus = 1;
  329. //}
  330. //else
  331. //{
  332. // e.weight = 400;
  333. //}
  334. #endregion
  335. //这里每隔0.5秒执行一次
  336. try
  337. {
  338. if (e.carno == "nown")
  339. {
  340. e.carno = "";
  341. }
  342. #region 扫码信息
  343. //if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  344. //{
  345. // if (string.IsNullOrEmpty(PbCache.strCode))
  346. // {
  347. // codeFlag = false;
  348. // firstCode = "";
  349. // PbCache.strCode = "";
  350. // l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  351. // }
  352. //}
  353. //else
  354. //{
  355. // codeFlag = true;
  356. // frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  357. // Hashtable hashTable = new Hashtable();
  358. // hashTable.Add("message", sweepCodeClass.StrCode);
  359. // rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
  360. // if (rmsSweepCodeClass.Code == "0")
  361. // {
  362. // PbCache.collect.carno = rmsSweepCodeClass.Data;
  363. // PbCache.strCode = rmsSweepCodeClass.Data;
  364. // }
  365. // if (rmsSweepCodeClass.Code == "1")
  366. // {
  367. // vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
  368. // frmOneYardToEnd.setMsgInfo("车号二维码已过期");
  369. // }
  370. // if (rmsSweepCodeClass.Code == "2")
  371. // {
  372. // vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  373. // frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  374. // }
  375. // if (rmsSweepCodeClass.Code == "9")
  376. // {
  377. // vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  378. // frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  379. // }
  380. // l.WriteLog(12, "测试扫码值" + rmsSweepCodeClass.Data);
  381. //}
  382. // 司机扫码为空,取工控机二维码
  383. if (PbCache.sportInfo.scanRequireValid == "1")
  384. {
  385. if (PbCache.monitor.isValidScan == "0")
  386. {
  387. if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  388. {
  389. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  390. {
  391. if (string.IsNullOrEmpty(PbCache.strCode))
  392. {
  393. codeFlag = false;
  394. firstCode = "";
  395. PbCache.strCode = "";
  396. //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  397. }
  398. }
  399. else
  400. {
  401. if (sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
  402. {
  403. DecodeQRCodeYMT(sweepCodeClass.StrCode);
  404. }
  405. else
  406. {
  407. DecodeQRCode(sweepCodeClass.StrCode);
  408. }
  409. }
  410. }
  411. else
  412. {
  413. if (sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
  414. {
  415. DecodeQRCodeYMT(sweepCodeClass2.StrCode);
  416. }
  417. else
  418. {
  419. DecodeQRCode(sweepCodeClass2.StrCode);
  420. }
  421. }
  422. }
  423. }
  424. else
  425. {
  426. if (string.IsNullOrEmpty(sweepCodeClass2.StrCode))
  427. {
  428. if (string.IsNullOrEmpty(sweepCodeClass.StrCode))
  429. {
  430. if (string.IsNullOrEmpty(PbCache.strCode))
  431. {
  432. codeFlag = false;
  433. firstCode = "";
  434. PbCache.strCode = "";
  435. //l.WriteLog(12, "主线程扫码值为空时清空;sweepCodeClass.StrCode值为" + sweepCodeClass.StrCode + " ;PbCache.strCode值为:" + PbCache.strCode);
  436. }
  437. }
  438. else
  439. {
  440. if (sweepCodeClass.StrCode.Substring(0, 3) == "TWB")
  441. {
  442. DecodeQRCodeYMT(sweepCodeClass.StrCode);
  443. }
  444. else
  445. {
  446. DecodeQRCode(sweepCodeClass.StrCode);
  447. }
  448. }
  449. }
  450. else
  451. {
  452. if (sweepCodeClass2.StrCode.Substring(0, 3) == "TWB")
  453. {
  454. DecodeQRCodeYMT(sweepCodeClass2.StrCode);
  455. }
  456. else
  457. {
  458. DecodeQRCode(sweepCodeClass2.StrCode);
  459. }
  460. }
  461. }
  462. #endregion
  463. #region 秤上无车10分钟获取一次基础数据
  464. if (iCount < 1200)
  465. {
  466. iCount++;
  467. }
  468. else
  469. {
  470. try
  471. {
  472. //秤上没有车时,每隔10分钟获取一次基础数据
  473. if (e.weight < 500)
  474. {
  475. if (bd.setBaseDb())
  476. {
  477. l.WriteLog(0, "十分钟获取基础数据成功");
  478. }
  479. else
  480. {
  481. l.WriteLog(0, "十分钟获取基础数据失败");
  482. }
  483. iCount = 0;
  484. }
  485. }
  486. catch (Exception ex)
  487. {
  488. l.WriteLog(0, "十分钟获取基础数据失败:" + ex.Message);
  489. iCount = 0;
  490. }
  491. }
  492. #endregion
  493. #region 每10秒写入一次当前时间
  494. if (iCount % 20 == 0)
  495. {
  496. //更新在线时间
  497. rmsEventDataLastTime = meterWorkMonitor.doUpdateWfBySpotNo(new MeterWorkMonitor { pointNo = PbCache.sportInfo.baseSpotNo });
  498. if (!rmsEventDataLastTime.Succeed)
  499. {
  500. l.WriteLog(0, "frmMain.EventData异常:写入时间异常,原因:" + rmsEventDataLastTime.ResultMessage);
  501. }
  502. }
  503. #endregion
  504. #region
  505. //一旦界面锁定则不采集数据
  506. PbCache.collect.pointid = PbCache.sportInfo.baseSpotNo;
  507. PbCache.collect.parkStatus = e.parkStatus;
  508. PbCache.collect.datetime = e.datetime;
  509. PbCache.collect.licType = e.licType;
  510. if (testFlag)
  511. {
  512. sCarNo = testCarNo;
  513. //PbCache.collect.carno = testCarNo;
  514. PbCache.collect.weight = testWgt;
  515. PbCache.collect.weightStatus = 0;
  516. PbCache.monitorResult.valid_park_status = true;
  517. PbCache.collect.parkStatus = 0;
  518. if (PbCache.collect.weight > e.weight)
  519. e.weight = PbCache.collect.weight;
  520. PbCache.strCode = testPlanNo;
  521. e.carno = testCarNo;
  522. //PbCache.strQRCode = testCode;
  523. }
  524. else
  525. {
  526. PbCache.collect.weight = e.weight;
  527. PbCache.collect.weightStatus = e.weightStatus;
  528. }
  529. if (PbCache.collect != null && PbCache.collect.weightStatus == 0)
  530. {
  531. if (string.IsNullOrEmpty(PbCache.resultWgt))
  532. {
  533. PbCache.resultWgt = e.weight + "";
  534. }
  535. if (!string.IsNullOrEmpty(PbCache.resultWgt) && e.weight > Convert.ToInt32(PbCache.resultWgt))
  536. {
  537. PbCache.resultWgt = e.weight + "";
  538. }
  539. if (!string.IsNullOrEmpty(e.carno) && PbCache.resultCarNo != e.carno)
  540. {
  541. PbCache.resultCarNo = e.carno + "";
  542. l.WriteLog(28, "车号賦值跟蹤:PbCache.resultCarNo" + PbCache.resultCarNo + "||e.carno" + e.carno);
  543. }
  544. }
  545. //*/
  546. // 更新监控表
  547. //doLive();
  548. //重量大于500的情况下
  549. if (e.weight > 500)
  550. {
  551. isResFlag = true;
  552. if (PbCache.dtStartTime == null)
  553. PbCache.dtStartTime = DateTime.Now;
  554. isLedWrite = true;
  555. PbCache.strState = "0";
  556. #region 车上人员请下车
  557. try
  558. {
  559. //界面未锁定的情况下,有车号,如果重量稳定了,停车线验证通过,未超量程的情况下,则按钮可用
  560. if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno) && PbCache.collect.weightStatus == 0 && PbCache.monitorResult.valid_park_status && PbCache.collect.weight < PbCache.range.upperRange)
  561. {
  562. if (!isVoiceDownCar)
  563. {
  564. isVoiceDownCar = true;
  565. vicPlayClass.GetVoicePlay("车上人员请下车", PbCache.collect.carno);
  566. }
  567. }
  568. }
  569. catch { }
  570. #endregion
  571. setWelecomeVis(false);
  572. //每隔1秒刷一次计量实时监控表数据值
  573. if (iCount % 2 == 0)
  574. {
  575. //调用该方法时已赋值
  576. updateEventDataMonitor.validFlag = "1";
  577. updateEventDataMonitor.pointNo = PbCache.sportInfo.baseSpotNo;
  578. rmUpdateEventDataMonitor = meterWorkMonitor.doQueryOneWf(updateEventDataMonitor);
  579. if (!rmUpdateEventDataMonitor.Succeed)
  580. {
  581. l.WriteLog(0, "frmMain.EventData异常419:" + rmUpdateEventDataMonitor.ResultMessage);
  582. }
  583. else
  584. {
  585. if (rmUpdateEventDataMonitor.Data != null && rmUpdateEventDataMonitor.Data.Count > 0)
  586. {
  587. PbCache.monitor = rmUpdateEventDataMonitor.Data[0];
  588. if (string.IsNullOrEmpty(PbCache.collect_no))
  589. {
  590. PbCache.collect_no = rmUpdateEventDataMonitor.Data[0].collectionCode;
  591. }
  592. if (ledTxt != rmUpdateEventDataMonitor.Data[0].ledWriter && rmUpdateEventDataMonitor.Data[0].ledWriter != "")
  593. {
  594. //调用LED信息写入******************************
  595. ledTxt = rmUpdateEventDataMonitor.Data[0].ledWriter;
  596. }
  597. if (string.IsNullOrEmpty(ledTxt))
  598. {
  599. ledTxt = "欢迎使用酒钢汽车衡智能计量系统!";
  600. }
  601. }
  602. }
  603. #region 2021-03-29
  604. #region 摄像头当前采集的车号与上次采集的不一样且当前未勾选不验证,且当前车号未进行手动修正的情况下
  605. if (preCarNo != e.carno && PbCache.monitor != null && PbCache.monitor.validCarno != "0" && !bEditCar)
  606. {
  607. flagCarMonit = false;
  608. }
  609. preCarNo = e.carno;
  610. #endregion
  611. if (!flagCarMonit)
  612. {
  613. sCarNo = e.carno;
  614. }
  615. //*
  616. //有车号,且重量稳定的情况下,只修正一次车号
  617. if (!string.IsNullOrEmpty(e.carno) && e.weightStatus == 0 && !flagCarMonit && PbCache.monitor != null && PbCache.monitor.carMonitor == "1" && PbCache.monitor.carMonitorLvl > 0)
  618. {
  619. flagCarMonit = true;
  620. string methods = "";
  621. for (int i = 0; i <= PbCache.monitor.carMonitorLvl; i++)
  622. {
  623. methods += "CarNoTrustCorrect" + i + ",";
  624. }
  625. editCarNo = modfiy.CarNoCorrect(e.carno, methods.Substring(0, methods.Length - 1));
  626. sCarNo = editCarNo;
  627. //mwUpdate
  628. }
  629. //勾选了不验证车号的情况
  630. if (PbCache.monitor.validCarno == "0")
  631. {
  632. flagCarMonit = true;
  633. }
  634. #endregion
  635. #region 每隔1秒写入一次重量曲线
  636. try
  637. {
  638. if (preWgt != e.weight)
  639. {
  640. preWgt = e.weight;
  641. sPreNo = PbCache.sportInfo.baseSpotNo + DateTime.Now.ToString("yyyyMMddHHmmssfff");
  642. meterMonitorWeightEventData1.weightNo = sPreNo;
  643. meterMonitorWeightEventData1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  644. meterMonitorWeightEventData1.baseSpotName = PbCache.sportInfo.baseSpotName;
  645. meterMonitorWeightEventData1.collectWeight = e.weight + "";
  646. meterMonitorWeightEventData1.collectStartTime = PbCache.dtStartTime.Value;
  647. meterMonitorWeightEventData1.collectEndTime = DateTime.Now;
  648. meterMonitorWeightEventData1.spotTypeNo = "001002001";
  649. meterMonitorWeightEventData1.spotTypeName = "汽车衡";
  650. meterMonitorWeightEventData1.actualFirstNo = PbCache.actualFirstNo;
  651. monitorWeightService.doAddWf(meterMonitorWeightEventData1);
  652. }
  653. else
  654. {
  655. if (!string.IsNullOrEmpty(sPreNo))
  656. {
  657. meterMonitorWeightEventData2.weightNo = sPreNo;
  658. meterMonitorWeightEventData2.collectEndTime = DateTime.Now;
  659. monitorWeightService.doUpdateWf(meterMonitorWeightEventData2);
  660. }
  661. }
  662. }
  663. catch { }
  664. #endregion
  665. #region 停留超时
  666. iHodeTime++;
  667. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  668. mwUpdate.editCar = editCarNo;
  669. if (PbCache.holdTime != null && PbCache.holdTime.Count > 0)
  670. {
  671. if (PbCache.holdTime[0].retentionTime != null)
  672. {
  673. if (PbCache.holdTime[0].retentionTime.Value < iHodeTime)
  674. {
  675. l.WriteLog(33, "iHodeTime:" + iHodeTime + ",PbCache.holdTime[0].retentionTime.Value:" + PbCache.holdTime[0].retentionTime.Value + ",mwUpdate.stopOverTime:" + mwUpdate.stopOverTime);
  676. PbCache.isOvertimeAlarm = true; //是否超时报警
  677. mwUpdate.stopOverTime = "1"; //写入一次停留超时
  678. //mwUpdate.isHelp = "1";//派位
  679. //mwUpdate.isTakeOver = "1";
  680. iHodeTime = 99999;//不再增长避免超出
  681. }
  682. }
  683. }
  684. #endregion
  685. #region RFID识别车号信息
  686. mwUpdate.rfidCar = "";
  687. mwUpdate.photoCar = e.vdioCarNos;
  688. mwUpdate.scanCar = "";
  689. if (testFlag)
  690. {
  691. mwUpdate.scanCar = PbCache.collect.carno;
  692. }
  693. //mwUpdate.photoCar = PbCache.collect.carno;
  694. if (!string.IsNullOrEmpty(e.RfidNos))
  695. {
  696. string sqls = @"SELECT RFID_ID id,CAR_NO text FROM METER_BASE_RFID_INFO where RFID_CODE = '" + e.RfidNos + "'";
  697. rmTRFIDEventData = pbpRFIDEventData.executeSqlDataWf(sqls);
  698. if (rmTRFIDEventData.Data == null || rmTRFIDEventData.Data.Count == 0)
  699. { }
  700. else
  701. {
  702. mwUpdate.rfidCar = rmTRFIDEventData.Data[0].text;
  703. sCarNo = rmTRFIDEventData.Data[0].text;
  704. RFIDCarNo = rmTRFIDEventData.Data[0].text;
  705. }
  706. }
  707. #endregion
  708. #region 计量员修改的车号信息
  709. if (PbCache.monitor != null && !string.IsNullOrEmpty(PbCache.monitor.setCar))
  710. {
  711. sCarNo = PbCache.monitor.setCar;
  712. bEditCar = true;
  713. flagCarMonit = true;
  714. codeFlag = false;
  715. sweepCodeClass.StrCode = "";
  716. sweepCodeClass2.StrCode = "";
  717. }
  718. #endregion
  719. #region 重量信息
  720. if (!PbCache.isLockFrm)
  721. {
  722. mwUpdate.wgt = e.weight;
  723. }
  724. else
  725. {
  726. mwUpdate.wgt = Convert.ToInt32(PbCache.lockWgt);
  727. }
  728. #endregion
  729. #region 写入一次监控表,将重量/车号停留超时等信息写入
  730. mwUpdate.msgInfo = PbCache.ResultMessage;
  731. mwUpdate.weightStatus = PbCache.collect.weightStatus;
  732. //另外初始化一次监控数据
  733. rmsmwUpdateEventData = meterWorkMonitor.doUpdateWf(mwUpdate);
  734. if (!rmsmwUpdateEventData.Succeed)
  735. {
  736. l.WriteLog(0, "frmMain.EventData异常583:写入信息异常" + mwUpdate);
  737. }
  738. #endregion
  739. //验证对射
  740. valid.ValidMethod();
  741. if (!isOpenMeter)
  742. {
  743. //if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  744. if (PbCache.range != null && PbCache.range.upperRange < e.weight)
  745. {
  746. //超量程
  747. vicPlayClass.GetVoicePlay("已超量程", e.carno);
  748. //return;
  749. }
  750. else if (e.weightStatus == 0)
  751. {
  752. if (!PbCache.monitorResult.valid_park_status)
  753. {
  754. iCountPark++;
  755. if (iCountPark > 9)
  756. {
  757. //重量稳定,且对射验证不合格
  758. vicPlayClass.GetVoicePlay("您的车辆未停到位", e.carno);
  759. //return;
  760. iCountPark = 0; //2021年7月27日5s播一次,然后重新在播
  761. }
  762. }
  763. else
  764. {
  765. iCountPark = 0;
  766. }
  767. }
  768. }
  769. if (!lu[0].bcEnable)
  770. {
  771. foreach (ucBusinessType uc in lu)
  772. {
  773. uc.setControlEnable(true);
  774. }
  775. }
  776. if ((sweepCodeClass.StrCode == "" || sweepCodeClass2.StrCode == "") && !codeFlag)
  777. {
  778. PbCache.collect.carno = sCarNo;
  779. }
  780. }
  781. PbCache.collect.carno = sCarNo;
  782. //写入LED信息
  783. //if (PbCache.sportInfo != null && PbCache.ledInfo != PbCache.OldLedInfo)
  784. //{
  785. // PbCache.OldLedInfo = PbCache.ledInfo;
  786. // if (PbCache.monitor != null && PbCache.monitor.ledKeep == "0")
  787. // {
  788. // //led_controler.setOneLineMsg(PbCache.sportInfo.ledIp, PbCache.ledInfo);
  789. // }
  790. //}
  791. }
  792. else
  793. {
  794. isOpened = false; //下次上秤直接打开主界面
  795. if (e.weight > 10 && e.weight < 500)
  796. {
  797. //重量小于500,大于10
  798. MeterWorkMonitor mwUpdate = new MeterWorkMonitor();
  799. mwUpdate.pointNo = PbCache.sportInfo.baseSpotNo;
  800. mwUpdate.wgt = e.weight;
  801. rmsdoUpdateWfEventData = meterWorkMonitor.doUpdateWf(mwUpdate);
  802. }
  803. if (e.weight > 0 && e.weight < 200)
  804. {
  805. doOperateLive();
  806. }
  807. if (e.weight == 0)
  808. {
  809. PbCache.isZeroAlarm = false;
  810. }
  811. editCarNo = "";
  812. firstCode = ""; //历史的扫码枪的值
  813. preCarNo = "";
  814. sCarNo = "";
  815. sPreNo = "";
  816. preWgt = 0;
  817. //不等于空的时候说明写过一次日志了
  818. if (!testFlag)
  819. {
  820. isResFlag = false;
  821. meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  822. meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
  823. meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
  824. meterWorkScheduledHelp1.helpContent = "车号:" + (string.IsNullOrEmpty(PbCache.collect.carno) ? (string.IsNullOrEmpty(PbCache.resultCarNo) ? "未识别" : PbCache.resultCarNo) : PbCache.collect.carno) + ";重量:" + (PbCache.lockWgt == 0 ? PbCache.resultWgt : PbCache.lockWgt + "") + ";提示信息:" + PbCache.resultMsgAll;
  825. meterWorkScheduledHelp1.warmType = "5";
  826. meterWorkScheduledHelp1.warmTypeName = "计量提示跟踪";
  827. meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
  828. l.WriteLog(28, "车号:" + (string.IsNullOrEmpty(PbCache.collect.carno) ? (string.IsNullOrEmpty(PbCache.resultCarNo) ? "未识别" : PbCache.resultCarNo) : PbCache.collect.carno) + ";重量:" + (PbCache.lockWgt == 0 ? PbCache.resultWgt : PbCache.lockWgt + "") + ";提示信息:" + PbCache.resultMsgAll);
  829. }
  830. //不等于空的时候说明写过一次日志了
  831. if (!string.IsNullOrEmpty(RFIDCarNo) && isWriteRFID == "1")
  832. {
  833. meterWorkScheduledHelp1.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  834. meterWorkScheduledHelp1.baseSpotName = PbCache.sportInfo.baseSpotName;
  835. meterWorkScheduledHelp1.carNo = string.IsNullOrEmpty(PbCache.collect.carno) ? PbCache.resultCarNo : PbCache.collect.carno;
  836. meterWorkScheduledHelp1.helpContent = RFIDCarNo;
  837. meterWorkScheduledHelp1.warmType = "7";
  838. meterWorkScheduledHelp1.warmTypeName = "RFID识别率";
  839. meterWorkScheduledHelpService.add(meterWorkScheduledHelp1);
  840. RFIDCarNo = "";
  841. }
  842. PbCache.isOvertimeAlarm = false; //是否超时报警
  843. PbCache.strCode = "";
  844. PbCache.strState = "";
  845. PbCache.ResultMessage = "";
  846. PbCache.resultMsgAll = "";
  847. PbCache.resultCarNo = "";
  848. PbCache.resultWgt = "";
  849. bEditCar = false;
  850. isVoiceDownCar = false;
  851. flagCarMonit = false;
  852. iHodeTime = 0;
  853. isOpenMeter = false;
  854. PbCache.isLockFrm = false;
  855. PbCache.dtStartTime = null;
  856. PbCache.voiceOver = true;
  857. if (PbCache.collect != null && !string.IsNullOrEmpty(PbCache.collect.carno))
  858. {
  859. PbCache.collect.carno = "";
  860. }
  861. setWelecomeVis(true);
  862. if (lu[0].bcEnable)
  863. {
  864. foreach (ucBusinessType uc in lu)
  865. {
  866. uc.setControlEnable(false);
  867. }
  868. }
  869. meterWorkMonitorEventDataI.pointNo = PbCache.sportInfo.baseSpotNo;
  870. meterWorkMonitorEventDataI.validWgt = "1";
  871. meterWorkMonitorEventDataI.validCarno = "1";
  872. meterWorkMonitorEventDataI.validTareTime = "1";
  873. meterWorkMonitorEventDataI.validMatTime = "1";
  874. meterWorkMonitorEventDataI.validTimeInterval = "1";
  875. meterWorkMonitorEventDataI.validParkStatus = "1";
  876. meterWorkMonitorEventDataI.validExceedWgt = "1";
  877. meterWorkMonitorEventDataI.validPredictionDiff = "1";
  878. meterWorkMonitorEventDataI.validLianda = "1";
  879. meterWorkMonitorEventDataI.validMatClick = "1";
  880. meterWorkMonitorEventDataI.setCar = "";
  881. meterWorkMonitorEventDataI.isValidScan = "1";
  882. meterWorkMonitorEventDataI.rfidCar = "";
  883. meterWorkMonitorEventDataI.photoCar = "";
  884. meterWorkMonitorEventDataI.scanCar = "";
  885. meterWorkMonitorEventDataI.editCar = "";
  886. meterWorkMonitorEventDataI.zeroState = "0";
  887. meterWorkMonitorEventDataI.carErr = "0";
  888. meterWorkMonitorEventDataI.ferroalloyResult = "0";
  889. meterWorkMonitorEventDataI.wgtErr = "0";
  890. meterWorkMonitorEventDataI.stopOverTime = "0";
  891. meterWorkMonitorEventDataI.msgInfo = "";
  892. meterWorkMonitorEventDataI.ledWriter = "";
  893. meterWorkMonitorEventDataI.isOverWgt = "";
  894. meterWorkMonitorEventDataI.isHelp = "0";
  895. meterWorkMonitorEventDataI.wgt = e.weight;
  896. // 终端机,DVR,MOXA,PLC状态监控
  897. // 20220928 by BourneCao
  898. bool DVR_Online = PingIp(PbCache.sportInfo.videoIp);
  899. meterWorkMonitorEventDataI.dvrState = DVR_Online == true ? "0" : "1";
  900. bool Power_Online = PingIp(PbCache.sportInfo.controlIp);
  901. meterWorkMonitorEventDataI.powerState = Power_Online == true ? "0" : "1";
  902. bool MOXA_Online = PingIp(PbCache.sportInfo.moxaIp);
  903. meterWorkMonitorEventDataI.moxaState = MOXA_Online == true ? "0" : "1";
  904. bool PLC_Online = PingIp(PbCache.sportInfo.plcIp);
  905. meterWorkMonitorEventDataI.plcState = PLC_Online == true ? "0" : "1";
  906. //*
  907. //另外初始化一次监控数据
  908. RESTfulResult<string> rmssEventData = meterWorkMonitor.doUpdateWf(meterWorkMonitorEventDataI);
  909. if (!rmssEventData.Succeed)
  910. {
  911. l.WriteLog(0, "frmMain.EventData异常754:写入信息异常");
  912. }
  913. //*/
  914. //LED写入
  915. if (isLedWrite)
  916. {
  917. isLedWrite = false;
  918. }
  919. }
  920. #endregion
  921. }
  922. catch (Exception ex)
  923. {
  924. l.WriteLog(0, "frmMain.EventData异常:" + ex.Message);
  925. }
  926. }
  927. private void DecodeQRCodeYMT(string strCode)
  928. {
  929. try
  930. {
  931. string test = strCode.Substring(0, 3);
  932. codeFlag = true;
  933. string token = httpRequest.GetToken();
  934. string carNo = httpRequest.getCarNo(strCode,token);
  935. PbCache.collect.carno = carNo;
  936. PbCache.strCode = carNo;
  937. }
  938. catch (Exception e)
  939. {
  940. }
  941. }
  942. private void DecodeQRCode(string strCode)
  943. {
  944. codeFlag = true;
  945. //frmOneYardToEnd frmOneYardToEnd = new frmOneYardToEnd();
  946. Hashtable hashTable = new Hashtable();
  947. hashTable.Add("message", strCode);
  948. rmsSweepCodeClass = mwcfs.DecryptionForWfTest(hashTable);
  949. if (rmsSweepCodeClass.Code == "0")
  950. {
  951. PbCache.collect.carno = rmsSweepCodeClass.Data;
  952. PbCache.strCode = rmsSweepCodeClass.Data;
  953. }
  954. if (rmsSweepCodeClass.Code == "1")
  955. {
  956. vicPlayClass.GetVoicePlay("车号二维码已过期", PbCache.collect.carno);
  957. frmOneYardToEnd.setMsgInfo("车号二维码已过期");
  958. }
  959. if (rmsSweepCodeClass.Code == "2")
  960. {
  961. vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  962. frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  963. }
  964. if (rmsSweepCodeClass.Code == "9")
  965. {
  966. vicPlayClass.GetVoicePlay("不是有效车号二维码", PbCache.collect.carno);
  967. frmOneYardToEnd.setMsgInfo("不是有效车号二维码");
  968. }
  969. l.WriteLog(12, "测试扫码值" + rmsSweepCodeClass.Data);
  970. }
  971. private delegate void ShowBtnTare(bool flag);//定义委托 期限皮重按钮
  972. private int testWgt = 1000;
  973. private string testCarNo = "", testPlanNo = "";
  974. private bool testFlag = false;
  975. /// <summary>
  976. /// 截图测试
  977. /// </summary>
  978. /// <param name="sender"></param>
  979. /// <param name="e"></param>
  980. private void button2_Click(object sender, EventArgs e)
  981. {
  982. CameraShotCls cameraShot = new CameraShotCls();
  983. //cameraShot.CapMethod("1");
  984. _ = Invoke(new Action(() => { cameraShot.CapMethod("15"); }));
  985. }
  986. //测试打印
  987. private string strFirstNo = "";
  988. private void btnTestPrint_Click(object sender, EventArgs e)
  989. {
  990. Print1(txtPlanNo.Text);
  991. }
  992. //弹窗
  993. private static FrmMessage FrmMess(string strMess, string strBtnSaveInfo)
  994. {
  995. FrmMessage frmMessage = new FrmMessage();
  996. frmMessage.StartPosition = FormStartPosition.Manual;
  997. frmMessage.Location = new Point(350, 450);
  998. frmMessage.ShowMessage = strMess;
  999. frmMessage.BtnSaveText = strBtnSaveInfo;
  1000. frmMessage.BtnCancelText = "取消";
  1001. return frmMessage;
  1002. }
  1003. private class PrintCls
  1004. {
  1005. public int printNum { get; set; }
  1006. public MeterWorkCarActual printDb { get; set; }
  1007. public int iType { get; set; } //0毛 1 皮 2净
  1008. public string qrCode { get; set; }
  1009. }
  1010. private PrintCls printData = new PrintCls();
  1011. private void Print1(string firstNo)
  1012. {
  1013. try
  1014. {
  1015. //lg.WriteLog(1, "打印开始");
  1016. #region 获取打印信息,若需要打印则调用打印操作
  1017. List<PrintCls> prrintC = new List<PrintCls>();
  1018. string sql = @"select actual_no actualNo,
  1019. prediction_no predictionNo,
  1020. car_no carNo,
  1021. matter_no matterNo,
  1022. matter_name matterName,
  1023. gross_weight grossWeight,
  1024. gross_time grossTime,
  1025. tare_weight tareWeight,
  1026. tare_time tareTime,
  1027. net_weight netWeight,
  1028. net_Time netTime,
  1029. 'x' meterTypeNo,
  1030. meter_type_name meterTypeName,
  1031. spec_name specName,
  1032. forwarding_unit_name forwardingUnitName,
  1033. receiving_uint_name receivingUintName,
  1034. load_point_name loadPointName,
  1035. add_weight addWeight,
  1036. '1' uploadFlag --1结净数据 0一次表数据
  1037. from meter_work_car_actual where actual_first1_no = '" + firstNo + @"' or actual_first2_no='" + firstNo + @"'
  1038. union all
  1039. select t.actual_first_no actualNo,
  1040. t.prediction_no predictionNo,
  1041. t.car_no carNo,
  1042. t.matter_no matterNo,
  1043. t.matter_name matterName,
  1044. t.meter_weight grossWeight,
  1045. t.create_time grossTime,
  1046. 0 tareWeight,
  1047. t.create_time tareTime,
  1048. 0 netWeight,
  1049. null netTime,
  1050. t.weight_type meterTypeNo, --0毛重 否则皮重
  1051. t.meter_type_name meterTypeName,
  1052. t.spec_name specName,
  1053. t.forwarding_unit_name forwardingUnitName,
  1054. t.receiving_uint_name receivingUintName,
  1055. t.load_point_name loadPointName,
  1056. t.add_weight addWeight,
  1057. '0' uploadFlag
  1058. from METER_WORK_CAR_ACTUAL_FIRST t
  1059. where t.actual_first_no = '" + firstNo + "' or t.actual_first_no = (select max(actual_first2_no) from meter_work_car_actual where actual_first1_no='" + firstNo + "')";
  1060. //查下如果有毛重或者结净数据,则可进入打印判断
  1061. PbModelDbService<List<MeterWorkCarActual>> pbModelDbService = new PbModelDbService<List<MeterWorkCarActual>>();
  1062. RESTfulResult<List<MeterWorkCarActual>> rm = pbModelDbService.executeSqlDataWf(sql);
  1063. //lg.WriteLog(1, "打印第一个sql:" + sql);
  1064. if (rm.Succeed)
  1065. {
  1066. if (rm.Data != null && rm.Data.Count > 0)
  1067. {
  1068. //2021年6月26日 对一车联运的进行处理;用一次计量编号查二次计量数据,
  1069. sql = @"select t3.actual_no actualNo, t3.prediction_no predictionNo, t3.car_no carNo, t3.matter_no matterNo, t3.matter_name matterName,
  1070. t3.gross_weight grossWeight, t3.gross_time grossTime, t3.tare_weight tareWeight, t3.tare_time tareTime, t3.net_weight netWeight,
  1071. t3.net_Time netTime, 'x' meterTypeNo, t3.meter_type_name meterTypeName, t3.spec_name specName,
  1072. t3.forwarding_unit_name forwardingUnitName, t3.receiving_uint_name receivingUintName, t3.load_point_name loadPointName,
  1073. t3.add_weight addWeight, '1' uploadFlag from meter_work_car_actual_first t2
  1074. left join meter_work_car_actual t3 on t2.actual_first_no = t3.actual_first1_no
  1075. where t2.prediction_combination in (select t.prediction_combination
  1076. from meter_work_car_actual_first t
  1077. where t3.value_flag = '0' and t.actual_first_no = '" + firstNo + @"' and
  1078. instr(t.prediction_combination, '20') > 0) order by t3.net_time desc";
  1079. RESTfulResult<List<MeterWorkCarActual>> rmLy = pbModelDbService.executeSqlDataWf(sql);
  1080. if (rmLy.Succeed && rmLy.Data != null && rmLy.Data.Count == 1)
  1081. {
  1082. rm.Data = rmLy.Data; //一车联运,将毛重替换为净重数据
  1083. }
  1084. //若有毛重或者净重,找到对应数据的物料信息,若有,那么去找打印配置信息数据
  1085. List<MeterWorkCarActual> mwa = rm.Data.Where(s => !string.IsNullOrEmpty(s.matterNo) && (s.meterTypeNo == "x" || s.meterTypeNo == "0")).ToList();
  1086. if (mwa != null && mwa.Count > 0 && !string.IsNullOrEmpty(mwa[0].matterNo))
  1087. {
  1088. sql = @"select BASE_SPOT_NO baseSpotNo,
  1089. load_point_no loadPointNo,
  1090. matter_no matterNo,
  1091. METER_TYPE_NO meterTypeNo,
  1092. weight_type_name weightTypeName,
  1093. PRINT_NUM printNum
  1094. from METER_BASE_BILL_PRINT
  1095. where matter_no = '" + mwa[0].matterNo + @"'
  1096. and nvl(BASE_SPOT_NO, '" + PbCache.sportInfo.baseSpotNo + @"') = '" + PbCache.sportInfo.baseSpotNo + @"'
  1097. and nvl(load_point_no, '" + (mwa[0].loadPointNo == null ? "1" : mwa[0].loadPointNo) + @"') = '" + (mwa[0].loadPointNo == null ? "1" : mwa[0].loadPointNo) + @"'";
  1098. //lg.WriteLog(1, "打印第二个sql:" + sql); and nvl(METER_TYPE_NO, '" + PbCache.bussinessTypeCode + @"') = '" + PbCache.bussinessTypeCode + @"'
  1099. //and nvl(METER_TYPE_NO, '') = ''
  1100. PbModelDbService<List<MeterBaseBillPrint>> pbPrintService = new PbModelDbService<List<MeterBaseBillPrint>>();
  1101. RESTfulResult<List<MeterBaseBillPrint>> rmPint = pbPrintService.executeSqlDataWf(sql);
  1102. if (rmPint.Succeed)
  1103. {
  1104. if (rmPint.Data != null && rmPint.Data.Count > 0)
  1105. {
  1106. //若有净重信息:1毛重时间晚于皮重时间,则打印毛、皮、净重,2毛重早于皮重,打印皮、净
  1107. //若只有毛重信息则打印毛重
  1108. List<MeterBaseBillPrint> lGrossprint = rmPint.Data.Where(s => s.weightTypeName.Contains("毛")).ToList();
  1109. List<MeterBaseBillPrint> lTarePrint = rmPint.Data.Where(s => s.weightTypeName.Contains("皮")).ToList();
  1110. List<MeterBaseBillPrint> lNetprint = rmPint.Data.Where(s => s.weightTypeName.Contains("净")).ToList();
  1111. List<MeterWorkCarActual> mwaChild = mwa.Where(s => s.meterTypeNo == "x").ToList();
  1112. if (mwaChild != null && mwaChild.Count > 0) //若有净重信息
  1113. {
  1114. if (lTarePrint != null && lTarePrint.Count > 0)
  1115. {
  1116. //获取非毛,非净重信息如果没有则用的期限皮,此时不打,否则则打印
  1117. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo != "x" && s.meterTypeNo != "0").FirstOrDefault();
  1118. if (mwca != null)
  1119. {
  1120. PrintCls cls = new PrintCls();
  1121. cls.printNum = (int)(lTarePrint[0].printNum == null ? 0 : lTarePrint[0].printNum.Value);
  1122. cls.iType = 1;//皮重
  1123. cls.printDb = mwca;
  1124. prrintC.Add(cls);
  1125. }
  1126. }
  1127. if (lGrossprint != null && lGrossprint.Count > 0)
  1128. {
  1129. //获取毛重信息
  1130. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "0").FirstOrDefault();
  1131. if (mwca != null)
  1132. {
  1133. PrintCls cls = new PrintCls();
  1134. cls.printNum = (int)(lGrossprint[0].printNum == null ? 0 : lGrossprint[0].printNum.Value);
  1135. cls.iType = 0;//毛重
  1136. cls.printDb = mwca;
  1137. prrintC.Add(cls);
  1138. }
  1139. }
  1140. if (lNetprint != null && lNetprint.Count > 0)
  1141. {
  1142. //获取净重信息
  1143. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "x").FirstOrDefault();
  1144. if (mwca != null)
  1145. {
  1146. PrintCls cls = new PrintCls();
  1147. cls.printNum = (int)(lNetprint[0].printNum == null ? 0 : lNetprint[0].printNum.Value);
  1148. cls.iType = 2;//净重
  1149. cls.printDb = mwca;
  1150. prrintC.Add(cls);
  1151. }
  1152. }
  1153. }
  1154. else //只有毛重信息则打印毛重
  1155. {
  1156. if (lGrossprint != null && lGrossprint.Count > 0)
  1157. {
  1158. //获取毛重信息
  1159. MeterWorkCarActual mwca = rm.Data.Where(s => s.meterTypeNo == "0").FirstOrDefault();
  1160. if (mwca != null)
  1161. {
  1162. PrintCls cls = new PrintCls();
  1163. cls.printNum = (int)(lGrossprint[0].printNum == null ? 0 : lGrossprint[0].printNum.Value);
  1164. cls.iType = 0;//毛重
  1165. cls.printDb = mwca;
  1166. prrintC.Add(cls);
  1167. }
  1168. }
  1169. }
  1170. if (prrintC != null && prrintC.Count > 0)
  1171. {
  1172. FrmMessage frmMessage = FrmMess("是否打印第【1】张票据!", "打印");
  1173. if (frmMessage.ShowDialog(this) == DialogResult.OK)
  1174. {
  1175. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】是否打印选择了【是】");
  1176. l.WriteLog(15, PbCache.lockCarNo + "是否打印选择了【是】");
  1177. strFirstNo = firstNo;
  1178. //printDocument1.PrinterSettings.PrinterName = PbCache.sportInfo.printerName;//strPntSvrName;
  1179. System.Drawing.Printing.PaperSize customSize1 = new System.Drawing.Printing.PaperSize("TestPaper", 398, 433); //101mm*110mm,换算成英寸
  1180. printDocument1.DefaultPageSettings.PaperSize = customSize1;//将自定义的Papersize赋给PrintDocument
  1181. System.Drawing.Printing.Margins marginss = new System.Drawing.Printing.Margins(0, 0, 0, 0);
  1182. printDocument1.DefaultPageSettings.Margins = marginss;
  1183. printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
  1184. foreach (PrintCls db in prrintC)
  1185. {
  1186. switch (db.printDb.meterTypeNo)
  1187. {
  1188. case "0": //毛
  1189. db.qrCode = db.printDb.actualNo + "," + db.printDb.grossWeight + "," + "1";
  1190. break;
  1191. case "x": //净
  1192. db.qrCode = db.printDb.actualNo + "," + db.printDb.netWeight + "," + "2";
  1193. break;
  1194. default: //皮
  1195. db.qrCode = db.printDb.actualNo + "," + db.printDb.grossWeight + "," + "1";
  1196. break;
  1197. }
  1198. RESTfulResult<string> rQRCode = workCarActualFirstService.doQRCodeWf(db.qrCode);
  1199. db.qrCode = rQRCode.Data;
  1200. for (int i = 0; i < db.printNum; i++)
  1201. {
  1202. if (i == 0)
  1203. {
  1204. printData = db;
  1205. printDocument1.Print();
  1206. l.WriteLog(10, "当前第" + (i + 1) + "次打印:" + printData.iType + " 车号:" + db.printDb.carNo + ",二维码:" + db.qrCode);
  1207. }
  1208. else
  1209. {
  1210. FrmMessage frmMessageContinue = FrmMess("已打印【" + i + "】张,是否继续打印第【" + (i + 1) + "】张票据!", "打印");
  1211. if (frmMessageContinue.ShowDialog(this) == DialogResult.OK)
  1212. {
  1213. printData = db;
  1214. printDocument1.Print();
  1215. l.WriteLog(10, "当前第" + (i + 1) + "次打印:" + printData.iType + " 车号:" + db.printDb.carNo + ",二维码:" + db.qrCode);
  1216. }
  1217. else
  1218. {
  1219. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】第" + i + "次是否打印,选择了【否】");
  1220. }
  1221. }
  1222. //printData = db;
  1223. //printDocument1.Print();
  1224. //lg.WriteLog(11, "当前打印:" + printData.iType + " 车号:" + db.printDb.carNo);
  1225. }
  1226. }
  1227. }
  1228. else
  1229. {
  1230. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】是否打印选择了【否】");
  1231. l.WriteLog(15, PbCache.lockCarNo + "是否打印选择了【否】");
  1232. }
  1233. }
  1234. }
  1235. }
  1236. else
  1237. {
  1238. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】获取打印配置数据信息异常sql:【" + sql + "】");
  1239. }
  1240. }
  1241. }
  1242. }
  1243. else
  1244. {
  1245. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】获取计量数据信息异常sql:【" + sql + "】");
  1246. }
  1247. #endregion 获取打印信息,若需要打印则调用打印操作
  1248. }
  1249. catch (Exception ex)
  1250. {
  1251. l.WriteLog(10, "车号【" + PbCache.lockCarNo + "】打印异常" + ex);
  1252. }
  1253. }
  1254. private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
  1255. {
  1256. try
  1257. {
  1258. if (printData != null && printData.printDb != null)
  1259. {
  1260. printClass.PrintAllPage(e, printData.printDb, printData.qrCode);
  1261. /*
  1262. //结净打印
  1263. if (printData.iType == 2)
  1264. {
  1265. printClass.PrintPage(e, printData.printDb, PbCache.strQRCode);
  1266. }
  1267. else //非结净打印
  1268. {
  1269. printClass.PrintWgtPage(e, printData.printDb, PbCache.strQRCode);
  1270. }
  1271. //*/
  1272. }
  1273. }
  1274. catch (Exception ex)
  1275. {
  1276. l.WriteLog(11, "打印异常" + ex);
  1277. }
  1278. }
  1279. /// <summary>
  1280. /// 重量大于500,直接打开主界面
  1281. /// </summary>
  1282. /// <param name="sender"></param>
  1283. /// <param name="e"></param>
  1284. private void timer1_Tick(object sender, EventArgs e)
  1285. {
  1286. //timer1.Stop();
  1287. try
  1288. {
  1289. if (!isOpened && PbCache.collect?.weight > 500)
  1290. {
  1291. PbCache.bussinessTypeName = "";
  1292. PbCache.bussinessTypeCode = "";
  1293. if (fcc.Visible == false)
  1294. {
  1295. fcc.Visible = true;
  1296. fcc.init();
  1297. }
  1298. }
  1299. timer1.Interval = 1000;
  1300. }
  1301. catch (Exception ee)
  1302. {
  1303. //GlobalInstanceController.Instance.LastCallMessage = ee.Message;
  1304. timer1.Interval = 1000;
  1305. }
  1306. //timer1.Start();
  1307. }
  1308. /// <summary>
  1309. /// 操作Live表的数据:零点报警
  1310. /// </summary>
  1311. private void doOperateLive()
  1312. {
  1313. if (PbCache.collect_no == null)
  1314. {
  1315. return;
  1316. }
  1317. List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
  1318. if (ll != null)
  1319. {
  1320. foreach (LiveData lv in ll)
  1321. {
  1322. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  1323. {
  1324. case "StaticStatus"://车辆检测 "0、东西方向激光均无报警;否则报警
  1325. break;
  1326. case "SwitchLight"://PLC红绿灯控制模式状态 "PLC有三种控制模式:1、自动、2、远控;3、检修
  1327. break;
  1328. case "LightWest"://红绿灯:1、为绿灯;2、为红灯;"
  1329. break;
  1330. case "ZeroWeightStatus": //0、其它,1、零点报警,红绿灯变红,
  1331. if (((lv.Value ?? "0") + "").Equals("1"))
  1332. {
  1333. doInsertZeroAlarm();
  1334. PbCache.isZeroAlarm = true;
  1335. }
  1336. else
  1337. {
  1338. PbCache.isZeroAlarm = false;
  1339. }
  1340. break;
  1341. }
  1342. }
  1343. }
  1344. }
  1345. /// <summary>
  1346. /// 操作Live表的数据:零点报警
  1347. /// </summary>
  1348. private void doLive()
  1349. {
  1350. if (PbCache.collect_no == null)
  1351. {
  1352. return;
  1353. }
  1354. List<LiveData> ll = MemoClass.getWarnInfo(PbCache.collect_no);
  1355. MeterWorkMonitor mwm = new MeterWorkMonitor();
  1356. mwm.pointNo = PbCache.sportInfo.baseSpotNo;
  1357. mwm.redGreenLightState = "0";
  1358. if (ll != null)
  1359. {
  1360. foreach (LiveData lv in ll)
  1361. {
  1362. switch (lv.Tagname.Replace(PbCache.collect_no, ""))
  1363. {
  1364. case "PowerStatus":
  1365. mwm.powerState = lv.Value.ToString();
  1366. break;
  1367. case "PlcWatchDog":
  1368. if (int.Parse(lv.Value.ToString()) >= 0 && int.Parse(lv.Value.ToString()) <= 0)
  1369. {
  1370. mwm.plcState = 0.ToString();
  1371. }
  1372. break;
  1373. case "InfraredWest":
  1374. if (lv.Value.ToString() == "2")
  1375. {
  1376. mwm.leftInfraredRayState = "0";
  1377. }
  1378. else
  1379. {
  1380. mwm.leftInfraredRayState = lv.Value.ToString();
  1381. }
  1382. break;
  1383. case "InfraredEast":
  1384. if (lv.Value.ToString() == "2")
  1385. {
  1386. mwm.rightInfraredRayState = "0";
  1387. }
  1388. else
  1389. {
  1390. mwm.rightInfraredRayState = lv.Value.ToString();
  1391. }
  1392. break;
  1393. case "AmplifierState":
  1394. mwm.amplifierState = lv.Value.ToString();
  1395. break;
  1396. case "LampState":
  1397. if (lv.Value.ToString() == "2")
  1398. {
  1399. mwm.lampState = "0";
  1400. }
  1401. else
  1402. {
  1403. mwm.lampState = lv.Value.ToString();
  1404. }
  1405. break;
  1406. case "InfraredLeft":
  1407. if (lv.Value.ToString() == "2")
  1408. {
  1409. mwm.frontInfraredRayState = "0";
  1410. }
  1411. else
  1412. {
  1413. mwm.frontInfraredRayState = lv.Value.ToString();
  1414. }
  1415. break;
  1416. case "InfraredRight":
  1417. if (lv.Value.ToString() == "2")
  1418. {
  1419. mwm.rearInfraredRayState = "0";
  1420. }
  1421. else
  1422. {
  1423. mwm.rearInfraredRayState = lv.Value.ToString();
  1424. }
  1425. break;
  1426. case "ZeroWeightStatus":
  1427. mwm.zeroState = lv.Value.ToString();
  1428. break;
  1429. case "RfidState":
  1430. mwm.rfidState = lv.Value.ToString();
  1431. if (((lv.Value ?? "0") + "").Equals("1"))
  1432. {
  1433. doInsertZeroAlarm();
  1434. PbCache.isZeroAlarm = true;
  1435. }
  1436. else
  1437. {
  1438. PbCache.isZeroAlarm = false;
  1439. }
  1440. break;
  1441. }
  1442. }
  1443. }
  1444. RESTfulResult<string> rms = meterWorkMonitor.doUpdateWf(mwm);
  1445. }
  1446. /// <summary>
  1447. /// 新增零点报警的数据
  1448. /// </summary>
  1449. private void doInsertZeroAlarm()
  1450. {
  1451. if (!PbCache.isZeroAlarm)
  1452. {
  1453. PbCache.isZeroAlarm = true;
  1454. MeterWorkZeroAlarm workZeroAlarm = new MeterWorkZeroAlarm();
  1455. workZeroAlarm.zeroWeight = PbCache.collect.weight;
  1456. workZeroAlarm.spotTypeNo = PbCache.sportInfo.spotTypeNo;
  1457. workZeroAlarm.spotTypeName = PbCache.sportInfo.spotTypeName;
  1458. workZeroAlarm.baseSpotNo = PbCache.sportInfo.baseSpotNo;
  1459. workZeroAlarm.baseSpotName = PbCache.sportInfo.baseSpotName;
  1460. workZeroAlarm.scalePointNo = PbCache.collect_no;
  1461. workZeroAlarm.createManNo = PbCache.sportInfo.baseSpotNo;
  1462. workZeroAlarm.createManName = PbCache.sportInfo.baseSpotName;
  1463. RESTfulResult<String> rms = zeroAlarmService.doInsertZeroAlarm(workZeroAlarm);
  1464. if (rms.Succeed)
  1465. {
  1466. l.WriteLog(20, "新增成功:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight);
  1467. }
  1468. else
  1469. {
  1470. l.WriteLog(20, "操作失败:" + workZeroAlarm.baseSpotName + ":" + workZeroAlarm.zeroWeight + rms.Data + rms.Message);
  1471. }
  1472. }
  1473. }
  1474. private void button3_Click(object sender, EventArgs e)
  1475. {
  1476. string limsResult = "";
  1477. JGLimsInterface gLimsInterface = new JGLimsInterface();
  1478. }
  1479. /// <summary>
  1480. /// 查询重量信息,显示在界面上面
  1481. /// </summary>
  1482. /// <param name="sender"></param>
  1483. /// <param name="e"></param>
  1484. private void button4_Click(object sender, EventArgs e)
  1485. {
  1486. try
  1487. {
  1488. string sqls = @"select '毛重:' || t.gross_weight / 1000 || ' T / 皮重:' || t.tare_weight / 1000 || ' T / 净重:' || t.net_weight / 1000 || ' T ' as text
  1489. from meter_work_car_actual t where t.value_flag = '0' and T.Prediction_No = '" + txtPlanNo.Text + @"'";
  1490. PbModelDbService<List<PbModelDb>> pbRelation = new PbModelDbService<List<PbModelDb>>();
  1491. RESTfulResult<List<PbModelDb>> rmRelation = pbRelation.executeSqlDataWf(sqls);
  1492. if (rmRelation.Succeed && rmRelation.Data != null && rmRelation.Data.Count > 0)
  1493. {
  1494. MessageBox.Show(rmRelation.Data[0].text);
  1495. }
  1496. else
  1497. {
  1498. MessageBox.Show("空");
  1499. }
  1500. }
  1501. catch (Exception ex)
  1502. {
  1503. }
  1504. }
  1505. private void button1_Click(object sender, EventArgs e)
  1506. {
  1507. isOpened = false;
  1508. testFlag = true;
  1509. PbCache.isTest= true;
  1510. testWgt = (int)numericUpDown1.Value;
  1511. //CollectModel model = new CollectModel();
  1512. //model.weight = testWgt;
  1513. //PbCache.collect = model;
  1514. testCarNo = textBox1.Text.Trim();
  1515. testPlanNo = txtPlanNo.Text.Trim();
  1516. }
  1517. private void Form1_FormClosing(object sender, FormClosingEventArgs e)
  1518. {
  1519. collection.Stop();
  1520. imageCurlControl.Stop();
  1521. sweepCodeClass.CloseThread();
  1522. sweepCodeClass2.CloseThread();
  1523. timer1.Stop();
  1524. timer1.Dispose();
  1525. }
  1526. private bool SystemUpdate(bool isMessage)
  1527. {
  1528. ReleaseList releaseList = new ReleaseList(Application.StartupPath + @"\" + GlobalVariable.Instance.ReleaseFileName);
  1529. DownloadTools dt = new DownloadTools();
  1530. try
  1531. {
  1532. bool isDownload = dt.IsDownloadFile(GlobalVariable.Instance.LocalPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ReleaseFileName);
  1533. if (!isDownload)
  1534. {
  1535. if (isMessage) MessageBox.Show("无法连接到远程主机!", Application.ProductName);
  1536. return false;
  1537. }
  1538. }
  1539. catch (Exception e)
  1540. {
  1541. MessageBox.Show(e.Message);
  1542. }
  1543. bool flag = this.CheckUpdate(releaseList);
  1544. if (flag)
  1545. {
  1546. MessageBox.Show("有新版本,现在更新");
  1547. string t = dt.DownloadFile(Application.StartupPath, GlobalVariable.Instance.ReleaseURL, GlobalVariable.Instance.ApplicationUpdater);
  1548. this.Close();
  1549. Application.Exit();
  1550. GC.Collect();
  1551. Process.Start(Application.StartupPath + @"\" + GlobalVariable.Instance.ApplicationUpdater);
  1552. return true;
  1553. }
  1554. else
  1555. {
  1556. if (isMessage) MessageBox.Show("你的系统已经是最新版本,不需要更新!", Application.ProductName);
  1557. return false;
  1558. }
  1559. }
  1560. private bool CheckUpdate(ReleaseList localRelease)
  1561. {
  1562. try
  1563. {
  1564. string fileNameAll = Application.StartupPath + "\\" + GlobalVariable.Instance.LocalPath + "\\" + GlobalVariable.Instance.ReleaseFileName;
  1565. ReleaseList remoteRelease = new ReleaseList(fileNameAll);
  1566. return (((localRelease != null) && (remoteRelease != null)) && localRelease.ReleaseDate.CompareTo(remoteRelease.ReleaseDate) < 0);
  1567. }
  1568. catch (Exception exception)
  1569. {
  1570. MessageBox.Show(exception.Message);
  1571. }
  1572. return false;
  1573. }
  1574. #region PING IP
  1575. /// <summary>
  1576. /// ping ip,测试能否ping通
  1577. /// </summary>
  1578. /// <param name="strIP">IP地址</param>
  1579. /// <returns></returns>
  1580. private bool PingIp(string strIP)
  1581. {
  1582. bool bRet = false;
  1583. try
  1584. {
  1585. Ping pingSend = new Ping();
  1586. PingReply reply = pingSend.Send(strIP, 1000);
  1587. if (reply.Status == IPStatus.Success)
  1588. bRet = true;
  1589. }
  1590. catch (Exception)
  1591. {
  1592. bRet = false;
  1593. }
  1594. return bRet;
  1595. }
  1596. #endregion
  1597. }
  1598. }