123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- using EntityDataSet;
- using GDNXFD.Data;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using IntelligentControlForsx.ChildForms;
- using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
- using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
- using IntelligentControlForsx.Service;
- namespace IntelligentControlForsx
- {
- public partial class FrmAlarmByObject : Form
- {
- [DllImport("user32.dll")]
- public static extern bool ReleaseCapture();
- [DllImport("user32.dll")]
- public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
- public const int WM_SYSCOMMAND = 0x0112;
- public const int SC_MOVE = 0xF010;
- public const int HTCAPTION = 0x0002;
- private bool isLoadding = false;
- private bool isReady = false;
- private string objectId;
- private AlertServiceClient asc = null;
- private BindingList<AlertSnap> bindings;
- public FrmAlarmByObject(string objectId)
- {
- InitializeComponent();
- this.dgvAlarm.AutoGenerateColumns = false;
- this.dgvAlarm.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- this.dgvAlarm.DefaultCellStyle = dataGridViewCellStyle1;
- this.objectId = objectId;
- this.TopMost = true;
- //isReady = true;
- //LoadData();
- }
- private void dgvAlarm_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- // MessageBox.Show(e.ColumnIndex + "");
- //MessageBox.Show("单元格的内容是:" + dgvAlarm.Rows[e.RowIndex].Cells[e.ColumnIndex+1].Value.ToString());
- if (e.ColumnIndex == 6)
- {
- string snapId = dgvAlarm.Rows[e.RowIndex].Cells[7].Value.ToString();
- MessageBox.Show(snapId);
- }
- string windturbineId = dgvAlarm.Rows[e.RowIndex].Cells["Column_WindturbineId"].Value.ToString();
- string alertSnapIds = dgvAlarm.Rows[e.RowIndex].Cells["Column8"].Value.ToString().Trim();
- long alertSnapId;
- long.TryParse(alertSnapIds, out alertSnapId);
- if (dgvAlarm.Columns[e.ColumnIndex].Name == "Column_Confirm" && e.RowIndex >= 0)
- {
- //报警信息操作方法
- if (asc == null)
- asc = AlertServiceClientFactory.CreateAlertServiceClient();
- if (alertSnapId > 0)
- asc.ConfirmAlert(alertSnapId);
- MessageBox.Show("确认操作" + alertSnapId);
- }
- if (dgvAlarm.Columns[e.ColumnIndex].Name == "Column_Control" && e.RowIndex >= 0)
- {
- if (!string.IsNullOrEmpty(windturbineId))
- {
- if (windturbineId.Contains("SG01_") || windturbineId.Contains("MG01_") ||
- windturbineId.Contains("QG01_") || windturbineId.Contains("XG01_") ||
- windturbineId.Contains("NG01_"))
- {
- user userData = null;
- try
- {
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- }
- catch (Exception ex)
- {
- }
- if (userData == null)
- {
- return;
- }
- IList<string> sendList = new List<string>();
- sendList.Add("windturbineId");
- string controlTypeString = dgvAlarm.Rows[e.RowIndex].Cells["Column_Control"].Value.ToString().Trim();
- string stationId = "";
- if (windturbineId.Contains("SG01_"))
- stationId = "SBQ_FDC";
- if (windturbineId.Contains("MG01_"))
- stationId = "MHS_FDC";
- if (windturbineId.Contains("NG01_"))
- stationId = "NSS_FDC";
- if (windturbineId.Contains("XG01_"))
- stationId = "XS_FDC";
- if (windturbineId.Contains("QG01_"))
- stationId = "QS_FDC";
- if (controlTypeString == "复位")
- TaskQueueSvc.QueueAdd(sendList, stationId, CmdType.Reset, userData);
- else if (controlTypeString == "停机")
- TaskQueueSvc.QueueAdd(sendList, stationId, CmdType.Stop, userData);
- //报警信息操作方法
- if (asc == null)
- asc = AlertServiceClientFactory.CreateAlertServiceClient();
- if (alertSnapId > 0)
- asc.ConfirmAlert(alertSnapId);
- MessageBox.Show(controlTypeString + "操作已完成");
- }
- }
- }
- }
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Hide();
- }
- private void btnMax_Click(object sender, EventArgs e)
- {
- if (this.WindowState == FormWindowState.Maximized)
- this.WindowState = FormWindowState.Normal;
- else
- this.WindowState = FormWindowState.Maximized;
- }
- private void panel1_MouseDown(object sender, MouseEventArgs e)
- {
- ReleaseCapture();
- SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
- }
- private void FrmAlarmByObject_Load(object sender, EventArgs e)
- {
- IList<AlertSnap> lstSnap = ClientCache.Instance.AlarmGroups[objectId].SnapList;
- bindings = new BindingList<AlertSnap>(lstSnap);
- this.dgvAlarm.DataSource = bindings;
- if (!objectId.Contains("SG01_") && !objectId.Contains("MG01_") && !
- objectId.Contains("QG01_") && !objectId.Contains("XG01_") && !
- objectId.Contains("NG01_"))
- {
- btnReset.Enabled = false;
- btnStop.Enabled = false;
- }
- else
- {
- btnReset.Enabled = true;
- btnStop.Enabled = true;
- }
- }
- public void ShowData(string objectId)
- {
- this.objectId = objectId;
- try
- {
- IList<AlertSnap> lstSnap = ClientCache.Instance.AlarmGroups[objectId].SnapList;//.AlertSnaps.Where(s => s.ObjectId == this.objectId).ToList();
- if (lstSnap == null || lstSnap.Count == 0)
- return;
- bindings = new BindingList<AlertSnap>(lstSnap);
- this.dgvAlarm.DataSource = bindings;
- if (this.dgvAlarm.RowCount > 1)
- this.Show();
- }
- catch { }
- if (!objectId.EndsWith("风机"))
- //.Contains("SG01_") && !objectId.Contains("MG01_") && !
- // objectId.Contains("QG01_") && !objectId.Contains("XG01_") && !
- // objectId.Contains("NG01_"))
- {
- btnReset.Enabled = false;
- btnStop.Enabled = false;
- }
- else
- {
- btnReset.Enabled = true;
- btnStop.Enabled = true;
- }
-
- }
- private void LoadData()
- {
- try
- {
- IList<AlertSnap> lstSnap = ClientCache.Instance.AlarmGroups[objectId].SnapList;//.AlertSnaps.Where(s => s.ObjectId == this.objectId).ToList();
- bindings = new BindingList<AlertSnap>(lstSnap);
- this.dgvAlarm.DataSource = bindings;
- }
- catch { }
- }
- private void btnStop_Click(object sender, EventArgs e)
- {
- string info = SubmitMethod(2);
- MessageBox.Show(info);
- this.Hide();
- }
- private void btnConfirm_Click(object sender, EventArgs e)
- {
- string info = SubmitMethod(3);
- MessageBox.Show(info);
- this.Hide();
- }
- private void btnReset_Click(object sender, EventArgs e)
- {
- string info = SubmitMethod(1);
- MessageBox.Show(info);
- this.Hide();
- }
- private void btnSend_Click(object sender, EventArgs e)
- {
- string info = SubmitMethod(4);
- MessageBox.Show(info);
- this.Hide();
- }
- public string SubmitMethod(int type)
- {
- string info = "";
- user userData = null;
- try
- {
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- }
- catch (Exception ex)
- {
- return "获取用户失败";
- }
- if (userData == null)
- {
- return "找不到用户";
- }
- string objectId = "";
- if (bindings.Count > 0)
- objectId = bindings[0].ObjectId.Trim();
- if (string.IsNullOrEmpty(objectId))
- return "获取设备编号失败";
- string stationId = "";
- if (objectId.Contains("SG01_"))
- stationId = "SBQ_FDC";
- else if (objectId.Contains("MG01_"))
- stationId = "MHS_FDC";
- else if (objectId.Contains("XG01_"))
- stationId = "XS_FDC";
- else if (objectId.Contains("MN01_"))
- stationId = "NSS_FDC";
- else if (objectId.Contains("QG01_"))
- stationId = "QS_FDC";
- IList<string> windturbineIdList = new List<string>();
- windturbineIdList.Add(objectId);
- //复位
- if (type == 1)
- {
- TaskQueueSvc.QueueAdd(windturbineIdList, stationId, CmdType.Reset, userData);
- info = "复位命令已下达";
- }
- //停机
- else if (type == 2)
- {
- TaskQueueSvc.QueueAdd(windturbineIdList, stationId, CmdType.Stop, userData);
- info = "停机命令已下达";
- }
- //确认
- else if (type == 3)
- {
- info = "已确认";
- }
- //缺陷单
- else if (type == 4)
- {
- info = "缺陷单已发送";
- }
- else
- {
- return "未知操作";
- }
- if (asc == null)
- asc = AlertServiceClientFactory.CreateAlertServiceClient();
- for (int i = 0; i < bindings.Count; i++)
- {
- long alertSnapId = bindings[i].Id;
- if (alertSnapId > 0)
- asc.ConfirmAlert(alertSnapId);
- }
- return info;
- }
- private void dgvAlarm_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex > -1)
- {
- try
- {
- string objectId = dgvAlarm.Rows[e.RowIndex].Cells["Column_WindturbineId"].Value.ToString();
- if (objectId.IndexOf("01") > 0)
- {
- NavService.Instance.NavForWindturbine("pictureBoxParamters", objectId, getStationId2(objectId));
- }
- }
- catch { }
- }
-
- }
- private string getStationId2(string wtId)
- {
- if (wtId.StartsWith("MG"))
- return "MHS_FDC";
- if (wtId.StartsWith("NG"))
- return "NSS_FDC";
- if (wtId.StartsWith("SG"))
- return "SBQ_FDC";
- if (wtId.StartsWith("XG"))
- return "XS_FDC";
- if (wtId.StartsWith("QG"))
- return "QS_FDC";
- return "SBQ_FDC";
- }
- }
- }
|