Confirm.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using EntityDataSet;
  12. using IntelligentControlForsx.ChildForms;
  13. using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
  14. using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
  15. using Gyee_Control.Svc.Cache;
  16. using log4net;
  17. namespace Gyee_Control.View
  18. {
  19. public partial class Confirm : Form
  20. {
  21. private IList<WindturbineCmdInfo> allowInfoList;
  22. private IList<WindturbineCmdInfo> forbiddenList;
  23. private string describeString;
  24. private double? limitValue = null;//限定值(转速,功率)
  25. private string StationId = "";
  26. private ILog logger = LogManager.GetLogger("AppInfoLog");
  27. /// <summary>
  28. /// Confirm构造方法
  29. /// </summary>
  30. /// <param name="stationName">风场名</param>
  31. /// <param name="cmdInfoList">操作信息</param>
  32. /// <param name="describe">操作描述</param>
  33. public Confirm(string stationName, IList<WindturbineCmdInfo> cmdInfoList, string describe, double? limitValue = null)
  34. {
  35. try
  36. {
  37. InitializeComponent();
  38. StationId = stationName;
  39. string name = "";
  40. if (stationName == "SBQ_FDC")
  41. name = "石板泉风电场";
  42. else if (stationName == "MHS_FDC")
  43. name = "麻黄山风电场";
  44. else if (stationName == "NSS_FDC")
  45. name = "牛首山风电场";
  46. else if (stationName == "XS_FDC")
  47. name = "香山风电场";
  48. this.groupBox1.Text = name + " ---- " + this.groupBox1.Text;
  49. this.groupBox2.Text = name + " ---- " + this.groupBox2.Text;
  50. describeString = describe;
  51. //获取要控制的风机数据
  52. CmdInfoScreenSvc screenSvc = CmdInfoScreenSvc.GetCmdInfoScreenSvc();
  53. DataTable allowTable;//可操作风机
  54. DataTable forbiddenTable;//不可操作风机DataTable
  55. //筛选出可以进行操作的风机
  56. allowInfoList = screenSvc.GetAllowInfo(cmdInfoList, out allowTable, out forbiddenList, out forbiddenTable);
  57. this.limitValue = limitValue;
  58. this.gvAllow.DataSource = allowTable;
  59. this.gvAllow.ClearSelection();
  60. this.gvForbidden.DataSource = forbiddenTable;
  61. if (this.gvForbidden.Columns.Count > 0)
  62. {
  63. this.gvForbidden.Columns[0].FillWeight = 20;
  64. this.gvForbidden.Columns[1].FillWeight = 90;
  65. this.gvForbidden.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  66. }
  67. this.gvForbidden.ClearSelection();
  68. if (this.gvAllow.Rows.Count == 0)
  69. {
  70. this.btnConfirm.Enabled = false;
  71. }
  72. else
  73. {
  74. this.btnConfirm.Enabled = true;
  75. }
  76. }
  77. catch (Exception ex)
  78. {
  79. Console.WriteLine(ex);
  80. }
  81. }
  82. private void gvAllow_DataError(object sender, DataGridViewDataErrorEventArgs e)
  83. {
  84. }
  85. private void gvForbidden_DataError(object sender, DataGridViewDataErrorEventArgs e)
  86. {
  87. }
  88. private void btnConfirm_Click(object sender, EventArgs e)
  89. {
  90. try
  91. {
  92. user userData = null;
  93. FingerCheck2 check = new FingerCheck2();
  94. check.ShowDialog();
  95. userData = FingerCheck2.checkSuccessUser;
  96. //userData = new user();
  97. //userData.id = 1;
  98. //userData.user_name = "wanghs";
  99. //userData.name = "wanghs";
  100. if (userData != null)
  101. {
  102. if (limitValue.HasValue)
  103. TaskQueueSvc.QueueAdd(allowInfoList.Select(s => s.WindturbineId).ToList(), StationId, allowInfoList[0].CmdType, userData, limitValue);
  104. else
  105. TaskQueueSvc.QueueAdd(allowInfoList.Select(s => s.WindturbineId).ToList(), StationId, allowInfoList[0].CmdType, userData);
  106. }
  107. this.Close();
  108. }
  109. catch (Exception ex)
  110. {
  111. }
  112. }
  113. private void btnCancel_Click(object sender, EventArgs e)
  114. {
  115. this.Close();
  116. }
  117. }
  118. }