Form1.cs 81 KB

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