using System;
using System.Collections.Generic;
using System.Windows.Forms;
using EntityDataSet;
using GDNXFD.Data;
using IntelligentControlForsx.ChildForms;
using IntelligentControlForsx.Service;
using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
using CommonMethod = IntelligentControlForsx.Common.CommonMethod;
namespace IntelligentControlForsx
{
public partial class AlarmItem : UserControl
{
//报警确认功能暂时挂起
public event EventHandler AlarmConfirmClick;
private AlertServiceClient asc = null;
//1为停机,2为复位
private int stopOrRest = 0;
public AlarmItem()
{
InitializeComponent();
}
private AlertSnap alertSnap;
public AlertSnap getAlertSnap()
{
return alertSnap;
}
public void setAlertSnap(AlertSnap value)
{
alertSnap = value;
if (alertSnap != null)
{
lblTime.Text = alertSnap.LastUpdateTime.Value.ToString("yyy-MM-dd HH:mm:ss");
lblThingId.Text = alertSnap.ObjectName;
lblAlarmText.Text = alertSnap.AlertText;
btnConfirm.Visible = true;
if (alertSnap.CategoryName == "自定义")
{
btnSend.Text = "停机";
stopOrRest = 1;
}
else if(alertSnap.CategoryName=="风机")
{
btnSend.Text = "复位";
stopOrRest = 2;
}
}
else
{
lblTime.Text = "";
lblThingId.Text = "";
lblAlarmText.Text = "";
btnConfirm.Visible = false;
// this.BackColor = Color.White;
}
}
//生成缺陷单方法
private void btnConfirm_Click(object sender, EventArgs e)
{
if (alertSnap != null)
{
AlarmConfirmClick(alertSnap.Id, e);
MessageBox.Show("缺陷单已生成");
}
}
///
/// 发送命令方法,忽略(确认)、复位、停机
///
///
///
private void btnSend_Click(object sender, EventArgs e)
{
user userData = null;
try
{
FingerCheck2 check = new FingerCheck2();
check.ShowDialog();
userData = FingerCheck2.checkSuccessUser;
}
catch (Exception ex)
{
}
if (userData == null)
{
return;
}
IList sendList = new List();
sendList.Add(alertSnap.ObjectId);
if (stopOrRest != 0)
{
if(stopOrRest==1)
TaskQueueSvc.QueueAdd(sendList, alertSnap.StationId, CmdType.Stop, userData);
else if(stopOrRest==2)
TaskQueueSvc.QueueAdd(sendList, alertSnap.StationId, CmdType.Reset, userData);
}
//报警信息操作方法
if (asc == null)
asc = AlertServiceClientFactory.CreateAlertServiceClient();
asc.ConfirmAlert(alertSnap.Id);
MessageBox.Show(btnSend.Text+"操作已完成");
//IList lst = asc.GetAlertSnaps();
//ClientCache.Instance.AlertSnaps = lst;
//MediaManager.Instance.UpdateAlertMediaStatus();
}
private void lblTime_DoubleClick(object sender, EventArgs e)
{
PageToWindturbineInfo();
}
private void lblThingId_DoubleClick(object sender, EventArgs e)
{
PageToWindturbineInfo();
}
private void lblAlarmText_DoubleClick(object sender, EventArgs e)
{
PageToWindturbineInfo();
}
private void PageToWindturbineInfo()
{
string windturbineId = alertSnap.WindturbineId;
string powerStationId = alertSnap.StationId;
NavService.Instance.NavForWindturbine("pictureBoxParamters", windturbineId, powerStationId);
}
}
}