MatrixForm_SendCMD_Backup.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using GDNXFD.Data;
  11. using IntelligentControlForsx.Template;
  12. using IntelligentControlForsx.Service;
  13. using IntelligentControlForsx.MyControls;
  14. using EntityDataSet;
  15. using WisdomClient.data;
  16. using WisdomClient;
  17. using log4net;
  18. using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
  19. using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
  20. using CommonMethod = IntelligentControlForsx.Common.CommonMethod;
  21. /*
  22. * matrixForm窗体 的备份 2020/7/3
  23. *
  24. *此界面用来做备份.当前并不需要做控制功能 所以先将matrixForm窗体的控制去掉
  25. *
  26. *
  27. */
  28. namespace IntelligentControlForsx.ChildForms
  29. {
  30. public partial class MatrixForm_SendCMD_Backup : TemplateForm
  31. {
  32. private ILog logger = LogManager.GetLogger("AppInfoLog");
  33. private bool isPageChange = false; //标记矩阵页面是否被切换
  34. #region 构造方法及界面初始化
  35. public MatrixForm_SendCMD_Backup()
  36. {
  37. // ControlStyles.UserPaint |
  38. this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);//开启双缓冲
  39. InitializeComponent();
  40. //stationId = NavService.Instance.StationId;
  41. this.pnlStations.Controls.Clear();
  42. stationId = "0";
  43. InitMatrixPanel();
  44. }
  45. private void MatrixForm_Load(object sender, EventArgs e)
  46. {
  47. RefreshMatrixPanel();
  48. }
  49. private void InitMatrixPanel()
  50. {
  51. this.SuspendLayout();
  52. this.pnlStations.Controls.Clear();
  53. IList<windpowerstation> lstStation = CacheService.Instance.GetFDCList();
  54. foreach (var st in lstStation)
  55. {
  56. MatrixStation ctrlStation = new MatrixStation();
  57. ctrlStation.StationId = st.ID;
  58. ctrlStation.StationName = st.NAME;
  59. ctrlStation.CntAll = st.QUANTITY.GetValueOrDefault();
  60. ctrlStation.ContextMenuStrip1 = this.cMenuControl;
  61. ctrlStation.InitTablePanel();
  62. ctrlStation.Dock = DockStyle.Top;
  63. ctrlStation.Name = "ctrl" + st.ID;
  64. this.pnlStations.Controls.Add(ctrlStation);
  65. ///////////////////////////////////////////////////
  66. //MatrixStation2 ctrlStation2 = new MatrixStation2();
  67. //ctrlStation2.StationId = st.ID;
  68. //ctrlStation2.StationId = st.ID;
  69. //ctrlStation2.StationName = st.NAME;
  70. //ctrlStation2.CntAll = st.QUANTITY.GetValueOrDefault();
  71. //ctrlStation2.ContextMenuStrip1 = this.cMenuControl;
  72. //ctrlStation2.InitTablePanel();
  73. //ctrlStation2.Dock = DockStyle.Top;
  74. //ctrlStation2.Name = "ctrl2" + st.ID;
  75. //ctrlStation2.Hide();
  76. //this.pnlStations.Controls.Add(ctrlStation2);
  77. ///////////////////////////////////////////////////
  78. }
  79. this.Refresh();
  80. this.ResumeLayout();
  81. }
  82. #endregion
  83. #region 场站变换
  84. private string stationId="0";
  85. [Browsable(true), Category("Data")]
  86. public String StationId
  87. {
  88. get
  89. {
  90. return stationId;
  91. }
  92. set
  93. {
  94. stationId = value;
  95. RefreshMatrixPanel();
  96. }
  97. }
  98. private void RefreshMatrixPanel()
  99. {
  100. if (stationId == "all" || stationId == "0" || stationId == "-1")
  101. {
  102. foreach (var ctrl in this.pnlStations.Controls)
  103. {
  104. if (ctrl is MatrixStation)
  105. {
  106. ((MatrixStation)ctrl).Active();
  107. }
  108. }
  109. }
  110. else
  111. {
  112. foreach (var ctrl in this.pnlStations.Controls)
  113. {
  114. if (ctrl is MatrixStation2)
  115. {
  116. if (((MatrixStation2)ctrl).StationId == stationId)
  117. ((MatrixStation2)ctrl).Active();
  118. else
  119. ((MatrixStation2)ctrl).DeActive();
  120. }
  121. else if (ctrl is MatrixStation)
  122. {
  123. ((MatrixStation)ctrl).DeActive();
  124. }
  125. }
  126. }
  127. }
  128. #endregion
  129. private string formMode = "matrix"; //matrix -- 显示矩阵 popup -- 显示弹窗(智慧启停)
  130. public string FormMode
  131. {
  132. get
  133. {
  134. return formMode;
  135. }
  136. set
  137. {
  138. formMode = value;
  139. }
  140. }
  141. public override void Active()
  142. {
  143. stationId = NavService.Instance.StationId;
  144. if (!isPageChange)
  145. {
  146. if (stationId.Length > 3)
  147. {
  148. this.matrixPopup1.StationId = stationId;
  149. }
  150. if ("matrix".Equals(formMode))
  151. {
  152. this.matrixTop1.Active();
  153. RefreshMatrixPanel();
  154. this.matrixPopup1.DeActive();
  155. }
  156. else
  157. {
  158. this.matrixTop1.DeActive();
  159. foreach (var ctrl in this.pnlStations.Controls)
  160. {
  161. if (ctrl is MatrixStation)
  162. {
  163. ((MatrixStation)ctrl).DeActive();
  164. }
  165. }
  166. this.matrixPopup1.Active();
  167. }
  168. }
  169. else
  170. {
  171. this.matrixTop1.Active();
  172. foreach (var ctrl in this.pnlStations.Controls)
  173. {
  174. if (ctrl is MatrixStation)
  175. {
  176. ((MatrixStation)ctrl).Active();
  177. }
  178. if (ctrl is MatrixStation2)
  179. {
  180. ((MatrixStation2)ctrl).DeActive();
  181. }
  182. }
  183. this.matrixPopup1.Active();
  184. }
  185. this.Show();
  186. }
  187. public override void DeActive()
  188. {
  189. isPageChange = true;
  190. this.Hide();
  191. this.matrixTop1.DeActive();
  192. foreach (var ctrl in this.pnlStations.Controls)
  193. {
  194. if (ctrl is MatrixStation)
  195. {
  196. ((MatrixStation)ctrl).DeActive();
  197. }
  198. if (ctrl is MatrixStation2)
  199. {
  200. ((MatrixStation2)ctrl).DeActive();
  201. }
  202. }
  203. this.matrixPopup1.DeActive();
  204. }
  205. public override void SelectedStationChanged(string stationId)
  206. {
  207. isPageChange = false;
  208. //MessageBox.Show(stationId);
  209. this.stationId = stationId;
  210. Active();
  211. }
  212. private void btnShowPopup_Click(object sender, EventArgs e)
  213. {
  214. this.matrixPopup1.Visible = true;
  215. this.matrixPopup1.BringToFront();
  216. formMode = "popup";
  217. Active();
  218. }
  219. private void cMenuControl_Opening(object sender, CancelEventArgs e)
  220. {
  221. MatrixBlock md = (sender as ContextMenuStrip).SourceControl as MatrixBlock;
  222. if (md != null)
  223. {
  224. this.cMenuControl.Tag = md;
  225. this.cMenuControl.Enabled = true;
  226. string windturbineId = CommonMethod.GetLongWindturbineId(md.DeviceId);
  227. bool isHung = false;
  228. isHung = md.IsLock;
  229. if (!isHung)
  230. {
  231. if (md.StationId.Equals("SBQ_FDC") || md.StationId.Equals("XS_FDC") ||
  232. md.StationId.Equals("NSS_FDC") || md.StationId.Equals("MHS_FDC"))
  233. {
  234. this.menuReset.Enabled = false;
  235. this.menuMaintain.Enabled = false;
  236. this.menuCancelMaintain.Enabled = false;
  237. this.menuStartUp.Enabled = false;
  238. this.menuShutDown.Enabled = false;
  239. this.menuUnLock.Enabled = false;
  240. this.menuLock.Enabled = true;
  241. int st = Convert.ToInt32(md.Status);
  242. switch (st)
  243. {
  244. case 0:
  245. this.menuShutDown.Enabled = false;
  246. this.menuStartUp.Enabled = false;
  247. this.menuMaintain.Enabled = false;
  248. this.menuCancelMaintain.Enabled = false;
  249. this.menuReset.Enabled = false;
  250. break;
  251. case 1:
  252. this.menuShutDown.Enabled = true;
  253. this.menuStartUp.Enabled = false;
  254. this.menuMaintain.Enabled = false;
  255. this.menuCancelMaintain.Enabled = false;
  256. this.menuReset.Enabled = false;
  257. break;
  258. case 2:
  259. this.menuShutDown.Enabled = false;
  260. this.menuStartUp.Enabled = true;
  261. this.menuMaintain.Enabled = true;
  262. this.menuCancelMaintain.Enabled = false;
  263. this.menuReset.Enabled = false;
  264. break;
  265. case 3:
  266. this.menuShutDown.Enabled = true;
  267. this.menuStartUp.Enabled = false;
  268. this.menuMaintain.Enabled = false;
  269. this.menuCancelMaintain.Enabled = false;
  270. this.menuReset.Enabled = false;
  271. break;
  272. case 4:
  273. this.menuShutDown.Enabled = true;
  274. this.menuStartUp.Enabled = false;
  275. this.menuMaintain.Enabled = false;
  276. this.menuCancelMaintain.Enabled = false;
  277. this.menuReset.Enabled = false;
  278. break;
  279. case 5:
  280. this.menuShutDown.Enabled = false;
  281. this.menuStartUp.Enabled = false;
  282. this.menuMaintain.Enabled = false;
  283. this.menuCancelMaintain.Enabled = false;
  284. this.menuReset.Enabled = true;
  285. break;
  286. case 6:
  287. this.menuShutDown.Enabled = false;
  288. this.menuStartUp.Enabled = false;
  289. this.menuMaintain.Enabled = false;
  290. this.menuCancelMaintain.Enabled = true;
  291. this.menuReset.Enabled = false;
  292. break;
  293. case 7:
  294. this.menuShutDown.Enabled = false;
  295. this.menuStartUp.Enabled = false;
  296. this.menuMaintain.Enabled = false;
  297. this.menuCancelMaintain.Enabled = false;
  298. this.menuReset.Enabled = false;
  299. break;
  300. }
  301. if (md.DeviceModel.Equals("UP105-2000-S"))
  302. {
  303. switch (st)
  304. {
  305. case 0:
  306. this.menuShutDown.Enabled = false;
  307. this.menuStartUp.Enabled = false;
  308. this.menuMaintain.Enabled = false;
  309. this.menuCancelMaintain.Enabled = false;
  310. this.menuReset.Enabled = false;
  311. break;
  312. case 1:
  313. this.menuShutDown.Enabled = true;
  314. this.menuStartUp.Enabled = false;
  315. this.menuMaintain.Enabled = false;
  316. this.menuCancelMaintain.Enabled = false;
  317. this.menuReset.Enabled = false;
  318. break;
  319. case 2:
  320. this.menuShutDown.Enabled = false;
  321. this.menuStartUp.Enabled = true;
  322. this.menuMaintain.Enabled = false;
  323. this.menuCancelMaintain.Enabled = false;
  324. this.menuReset.Enabled = false;
  325. break;
  326. case 3:
  327. this.menuShutDown.Enabled = true;
  328. this.menuStartUp.Enabled = false;
  329. this.menuMaintain.Enabled = false;
  330. this.menuCancelMaintain.Enabled = false;
  331. this.menuReset.Enabled = false;
  332. break;
  333. case 4:
  334. this.menuShutDown.Enabled = true;
  335. this.menuStartUp.Enabled = false;
  336. this.menuMaintain.Enabled = false;
  337. this.menuCancelMaintain.Enabled = false;
  338. this.menuReset.Enabled = false;
  339. break;
  340. case 5:
  341. this.menuShutDown.Enabled = false;
  342. this.menuStartUp.Enabled = false;
  343. this.menuMaintain.Enabled = false;
  344. this.menuCancelMaintain.Enabled = false;
  345. this.menuReset.Enabled = true;
  346. break;
  347. case 6:
  348. this.menuShutDown.Enabled = false;
  349. this.menuStartUp.Enabled = false;
  350. this.menuMaintain.Enabled = false;
  351. this.menuCancelMaintain.Enabled = false;
  352. this.menuReset.Enabled = false;
  353. break;
  354. case 7:
  355. this.menuShutDown.Enabled = false;
  356. this.menuStartUp.Enabled = false;
  357. this.menuMaintain.Enabled = false;
  358. this.menuCancelMaintain.Enabled = false;
  359. this.menuReset.Enabled = false;
  360. break;
  361. }
  362. }
  363. }
  364. else
  365. {
  366. this.cMenuControl.Enabled = false;
  367. }
  368. }
  369. else
  370. {
  371. this.menuShutDown.Enabled = false;
  372. this.menuStartUp.Enabled = false;
  373. this.menuMaintain.Enabled = false;
  374. this.menuCancelMaintain.Enabled = false;
  375. this.menuReset.Enabled = false;
  376. this.menuUnLock.Enabled = true;
  377. this.menuLock.Enabled = false;
  378. }
  379. //MessageBox.Show(md.DeviceModel + "," + md.StationId);
  380. //e.Cancel = true;
  381. }
  382. //string whichcontrol_name = (sender as ContextMenuStrip).SourceControl.Name;
  383. }
  384. private void menuStartUp_Click(object sender, EventArgs e)
  385. {
  386. string deviceId = "";
  387. string powerStationId = "";
  388. if (this.cMenuControl.Tag is MatrixBlock)
  389. {
  390. MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
  391. deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
  392. powerStationId = device2.StationId;
  393. }
  394. bool isBusy = IsBusy(deviceId);
  395. if (isBusy)
  396. {
  397. MessageBox.Show("风机操作过频繁!");
  398. return;
  399. }
  400. try
  401. {
  402. user userData = null;
  403. FingerCheck2 check = new FingerCheck2();
  404. check.ShowDialog();
  405. userData = FingerCheck2.checkSuccessUser;
  406. if (userData != null)
  407. {
  408. if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
  409. sendCommand(deviceId, powerStationId, CmdType.Start, userData);
  410. }
  411. }
  412. catch (Exception ex)
  413. {
  414. logger.Error(ex);
  415. }
  416. }
  417. private void menuShutDown_Click(object sender, EventArgs e)
  418. {
  419. string deviceId = "";
  420. string powerStationId = "";
  421. if (this.cMenuControl.Tag is MatrixBlock)
  422. {
  423. MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
  424. deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
  425. powerStationId = device2.StationId;
  426. }
  427. bool isBusy = IsBusy(deviceId);
  428. if (isBusy)
  429. {
  430. MessageBox.Show("风机操作过频繁!");
  431. return;
  432. }
  433. try
  434. {
  435. user userData = null;
  436. FingerCheck2 check = new FingerCheck2();
  437. check.ShowDialog();
  438. userData = FingerCheck2.checkSuccessUser;
  439. if (userData != null)
  440. {
  441. if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
  442. sendCommand(deviceId, powerStationId, CmdType.Stop, userData);
  443. }
  444. }
  445. catch (Exception ex)
  446. {
  447. logger.Error(ex);
  448. }
  449. }
  450. private void menuReset_Click(object sender, EventArgs e)
  451. {
  452. string deviceId = "";
  453. string powerStationId = "";
  454. if (this.cMenuControl.Tag is MatrixBlock)
  455. {
  456. MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
  457. deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
  458. powerStationId = device2.StationId;
  459. }
  460. bool isBusy = IsBusy(deviceId);
  461. if (isBusy)
  462. {
  463. MessageBox.Show("风机操作过频繁!");
  464. return;
  465. }
  466. try
  467. {
  468. user userData = null;
  469. FingerCheck2 check = new FingerCheck2();
  470. check.ShowDialog();
  471. userData = FingerCheck2.checkSuccessUser;
  472. if (userData != null)
  473. {
  474. if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
  475. sendCommand(deviceId, powerStationId, CmdType.Reset, userData);
  476. }
  477. }
  478. catch (Exception ex)
  479. {
  480. logger.Error(ex);
  481. }
  482. }
  483. private void menuMaintain_Click(object sender, EventArgs e)
  484. {
  485. string deviceId = "";
  486. string powerStationId = "";
  487. if (this.cMenuControl.Tag is MatrixBlock)
  488. {
  489. MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
  490. deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
  491. powerStationId = device2.StationId;
  492. }
  493. bool isBusy = IsBusy(deviceId);
  494. if (isBusy)
  495. {
  496. MessageBox.Show("风机操作过频繁!");
  497. return;
  498. }
  499. try
  500. {
  501. user userData = null;
  502. FingerCheck2 check = new FingerCheck2();
  503. check.ShowDialog();
  504. userData = FingerCheck2.checkSuccessUser;
  505. if (userData != null)
  506. {
  507. if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
  508. sendCommand(deviceId, powerStationId, CmdType.Maintain, userData);
  509. }
  510. }
  511. catch (Exception ex)
  512. {
  513. logger.Error(ex);
  514. }
  515. }
  516. private void menuCancelMaintain_Click(object sender, EventArgs e)
  517. {
  518. string deviceId = "";
  519. string powerStationId = "";
  520. if (this.cMenuControl.Tag is MatrixBlock)
  521. {
  522. MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
  523. deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
  524. powerStationId = device2.StationId;
  525. }
  526. bool isBusy = IsBusy(deviceId);
  527. if (isBusy)
  528. {
  529. MessageBox.Show("风机操作过频繁!");
  530. return;
  531. }
  532. try
  533. {
  534. user userData = null;
  535. FingerCheck2 check = new FingerCheck2();
  536. check.ShowDialog();
  537. userData = FingerCheck2.checkSuccessUser;
  538. if (userData != null)
  539. {
  540. if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
  541. sendCommand(deviceId, powerStationId, CmdType.UnMaintain, userData);
  542. }
  543. }
  544. catch (Exception ex)
  545. {
  546. logger.Error(ex);
  547. }
  548. }
  549. private void sendCommand(string wtId, string windPowerStationId, CmdType cmdType, user userData)
  550. {
  551. IList<string> windturbineIdList = new List<string>();
  552. windturbineIdList.Add(wtId);
  553. TaskQueueSvc.QueueAdd(windturbineIdList, windPowerStationId, cmdType, userData);
  554. }
  555. private void menuUnLock_Click(object sender, EventArgs e)
  556. {
  557. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  558. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  559. string powerStationId = device3.StationId;
  560. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  561. {
  562. view_tspoint point =
  563. ctx.view_tspoint.Where(
  564. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  565. .FirstOrDefault();
  566. if (point != null)
  567. {
  568. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.UnLock);
  569. if (isSuccess)
  570. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  571. else
  572. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  573. }
  574. else
  575. {
  576. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  577. }
  578. }
  579. }
  580. /// <summary>
  581. /// 场内受累检修
  582. /// </summary>
  583. /// <param name="sender"></param>
  584. /// <param name="e"></param>
  585. private void menuStationCheckLock_Click(object sender, EventArgs e)
  586. {
  587. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  588. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  589. string powerStationId = device3.StationId;
  590. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  591. {
  592. view_tspoint point =
  593. ctx.view_tspoint.Where(
  594. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  595. .FirstOrDefault();
  596. if (point != null)
  597. {
  598. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationCheckLock);
  599. if (isSuccess)
  600. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  601. else
  602. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  603. }
  604. else
  605. {
  606. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  607. }
  608. }
  609. }
  610. /// <summary>
  611. /// 场内受累故障
  612. /// </summary>
  613. /// <param name="sender"></param>
  614. /// <param name="e"></param>
  615. private void menuStationFaultLock_Click(object sender, EventArgs e)
  616. {
  617. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  618. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  619. string powerStationId = device3.StationId;
  620. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  621. {
  622. view_tspoint point =
  623. ctx.view_tspoint.Where(
  624. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  625. .FirstOrDefault();
  626. if (point != null)
  627. {
  628. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationFaulLockt);
  629. if (isSuccess)
  630. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  631. else
  632. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  633. }
  634. else
  635. {
  636. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  637. }
  638. }
  639. }
  640. /// <summary>
  641. /// 场外受累电网
  642. /// </summary>
  643. /// <param name="sender"></param>
  644. /// <param name="e"></param>
  645. private void menuStationPowerLineLock_Click(object sender, EventArgs e)
  646. {
  647. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  648. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  649. string powerStationId = device3.StationId;
  650. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  651. {
  652. view_tspoint point =
  653. ctx.view_tspoint.Where(
  654. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  655. .FirstOrDefault();
  656. if (point != null)
  657. {
  658. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationPowerLineLock);
  659. if (isSuccess)
  660. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  661. else
  662. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  663. }
  664. else
  665. {
  666. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  667. }
  668. }
  669. }
  670. /// <summary>
  671. /// 故障维修
  672. /// </summary>
  673. /// <param name="sender"></param>
  674. /// <param name="e"></param>
  675. private void menuFaultLock_Click(object sender, EventArgs e)
  676. {
  677. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  678. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  679. string powerStationId = device3.StationId;
  680. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  681. {
  682. view_tspoint point =
  683. ctx.view_tspoint.Where(
  684. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  685. .FirstOrDefault();
  686. if (point != null)
  687. {
  688. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.FaultLock);
  689. if (isSuccess)
  690. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  691. else
  692. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  693. }
  694. else
  695. {
  696. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  697. }
  698. }
  699. }
  700. /// <summary>
  701. /// 检修
  702. /// </summary>
  703. /// <param name="sender"></param>
  704. /// <param name="e"></param>
  705. private void menuCheckLock_Click(object sender, EventArgs e)
  706. {
  707. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  708. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  709. string powerStationId = device3.StationId;
  710. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  711. {
  712. view_tspoint point =
  713. ctx.view_tspoint.Where(
  714. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  715. .FirstOrDefault();
  716. if (point != null)
  717. {
  718. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.CheckLock);
  719. if (isSuccess)
  720. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  721. else
  722. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  723. }
  724. else
  725. {
  726. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  727. }
  728. }
  729. }
  730. /// <summary>
  731. /// 场外受累天气
  732. /// </summary>
  733. /// <param name="sender"></param>
  734. /// <param name="e"></param>
  735. private void menuStationWeatherLock_Click(object sender, EventArgs e)
  736. {
  737. MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
  738. string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
  739. string powerStationId = device3.StationId;
  740. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  741. {
  742. view_tspoint point =
  743. ctx.view_tspoint.Where(
  744. s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
  745. .FirstOrDefault();
  746. if (point != null)
  747. {
  748. bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationWeatherLock);
  749. if (isSuccess)
  750. MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
  751. else
  752. MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
  753. }
  754. else
  755. {
  756. MessageBox.Show("未找到相关挂牌点,请联系管理员!");
  757. }
  758. }
  759. }
  760. /// <summary>
  761. /// 挂牌方法
  762. /// </summary>
  763. /// <param name="pStationId">场站Id</param>
  764. /// <param name="windturbineId">风机Id</param>
  765. /// <param name="tagName">挂牌测点</param>
  766. /// <param name="type">挂牌类型</param>
  767. /// <returns></returns>
  768. private bool WindturbineLock(string pStationId, string windturbineId, string tagName, HungType type)
  769. {
  770. bool isSuccess = false;
  771. try
  772. {
  773. user userData = null;
  774. FingerCheck2 check = new FingerCheck2();
  775. check.ShowDialog();
  776. userData = FingerCheck2.checkSuccessUser;
  777. if (userData != null)
  778. {
  779. TsPointData tData = new TsPointData();
  780. tData.tagName = tagName;
  781. TsData t = new TsData();
  782. t.doubleValue = (int)type;
  783. DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
  784. TimeSpan sp = DateTime.Now.Subtract(dtStart);
  785. long time = long.Parse(sp.Ticks.ToString().Substring(0, sp.Ticks.ToString().Length - 4));
  786. t.ts = time;
  787. tData.tsData = t;
  788. RestfulClient.writeLatest(tData);
  789. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  790. {
  791. #region 写入操作日志
  792. control_log logData = new control_log();
  793. logData.windturbine_id = windturbineId;
  794. logData.station_id = pStationId;
  795. logData.control_user_id = userData.id;
  796. logData.send_control_time = DateTime.Now;
  797. logData.control_type = (int)CmdType.UnHangLock;
  798. logData.is_send_control_success = true;
  799. ctx.Entry(logData).State = EntityState.Added;
  800. int count = ctx.SaveChanges();
  801. if (count > 0)
  802. isSuccess = true;
  803. #endregion
  804. }
  805. }
  806. }
  807. catch (Exception ex)
  808. {
  809. logger.Error(ex);
  810. }
  811. return isSuccess;
  812. }
  813. private bool IsBusy(string windturbineId)
  814. {
  815. if (TaskQueueSvc.dicTask.ContainsKey(windturbineId))
  816. return true;
  817. else
  818. return false;
  819. }
  820. //protected override CreateParams CreateParams
  821. //{
  822. // get
  823. // {
  824. // CreateParams cp = base.CreateParams;
  825. // cp.ExStyle |= 0x02000000;
  826. // return cp;
  827. // }
  828. //}
  829. }
  830. }