123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using GDNXFD.Data;
- using IntelligentControlForsx.Template;
- using IntelligentControlForsx.Service;
- using IntelligentControlForsx.MyControls;
- using EntityDataSet;
- using WisdomClient.data;
- using WisdomClient;
- using log4net;
- using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
- using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
- using CommonMethod = IntelligentControlForsx.Common.CommonMethod;
- namespace IntelligentControlForsx.ChildForms
- {
- public partial class MatrixForm : TemplateForm
- {
- private ILog logger = LogManager.GetLogger("AppInfoLog");
- private bool isPageChange = false; //标记矩阵页面是否被切换
- #region 构造方法及界面初始化
- public MatrixForm()
- {
- // ControlStyles.UserPaint |
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);//开启双缓冲
- InitializeComponent();
- //stationId = NavService.Instance.StationId;
- this.pnlStations.Controls.Clear();
- stationId = "0";
- InitMatrixPanel();
- }
- private void MatrixForm_Load(object sender, EventArgs e)
- {
- RefreshMatrixPanel();
- }
- private void InitMatrixPanel()
- {
- this.SuspendLayout();
- this.pnlStations.Controls.Clear();
- IList<windpowerstation> lstStation = CacheService.Instance.GetFDCList();
- foreach (var st in lstStation)
- {
- MatrixStation ctrlStation = new MatrixStation();
- ctrlStation.StationId = st.ID;
- ctrlStation.StationName = st.NAME;
- ctrlStation.CntAll = st.QUANTITY.GetValueOrDefault();
- ctrlStation.ContextMenuStrip1 = this.cMenuControl;
- ctrlStation.InitTablePanel();
- ctrlStation.Dock = DockStyle.Top;
- ctrlStation.Name = "ctrl" + st.ID;
- this.pnlStations.Controls.Add(ctrlStation);
- ///////////////////////////////////////////////////
- //MatrixStation2 ctrlStation2 = new MatrixStation2();
- //ctrlStation2.StationId = st.ID;
- //ctrlStation2.StationId = st.ID;
- //ctrlStation2.StationName = st.NAME;
- //ctrlStation2.CntAll = st.QUANTITY.GetValueOrDefault();
- //ctrlStation2.ContextMenuStrip1 = this.cMenuControl;
- //ctrlStation2.InitTablePanel();
- //ctrlStation2.Dock = DockStyle.Top;
- //ctrlStation2.Name = "ctrl2" + st.ID;
- //ctrlStation2.Hide();
- //this.pnlStations.Controls.Add(ctrlStation2);
- ///////////////////////////////////////////////////
- }
- this.Refresh();
- this.ResumeLayout();
- }
- #endregion
- #region 场站变换
- private string stationId="0";
- [Browsable(true), Category("Data")]
- public String StationId
- {
- get
- {
- return stationId;
- }
- set
- {
- stationId = value;
- RefreshMatrixPanel();
- }
- }
- private void RefreshMatrixPanel()
- {
- if (stationId == "all" || stationId == "0" || stationId == "-1")
- {
- foreach (var ctrl in this.pnlStations.Controls)
- {
- if (ctrl is MatrixStation)
- {
- ((MatrixStation)ctrl).Active();
- }
- }
- }
- else
- {
- foreach (var ctrl in this.pnlStations.Controls)
- {
- if (ctrl is MatrixStation2)
- {
- if (((MatrixStation2)ctrl).StationId == stationId)
- ((MatrixStation2)ctrl).Active();
- else
- ((MatrixStation2)ctrl).DeActive();
- }
- else if (ctrl is MatrixStation)
- {
- ((MatrixStation)ctrl).DeActive();
- }
- }
- }
- }
- #endregion
- private string formMode = "matrix"; //matrix -- 显示矩阵 popup -- 显示弹窗(智慧启停)
- public string FormMode
- {
- get
- {
- return formMode;
- }
- set
- {
- formMode = value;
- }
- }
- public override void Active()
- {
- stationId = NavService.Instance.StationId;
- if (!isPageChange)
- {
- if (stationId.Length > 3)
- {
- this.matrixPopup1.StationId = stationId;
- }
- if ("matrix".Equals(formMode))
- {
- this.matrixTop1.Active();
- RefreshMatrixPanel();
- this.matrixPopup1.DeActive();
- }
- else
- {
- this.matrixTop1.DeActive();
- foreach (var ctrl in this.pnlStations.Controls)
- {
- if (ctrl is MatrixStation)
- {
- ((MatrixStation)ctrl).DeActive();
- }
- }
- this.matrixPopup1.Active();
- }
-
- }
- else
- {
- this.matrixTop1.Active();
- foreach (var ctrl in this.pnlStations.Controls)
- {
- if (ctrl is MatrixStation)
- {
- ((MatrixStation)ctrl).Active();
- }
- if (ctrl is MatrixStation2)
- {
- ((MatrixStation2)ctrl).DeActive();
- }
- }
- this.matrixPopup1.Active();
- }
-
- this.Show();
- }
- public override void DeActive()
- {
- isPageChange = true;
- this.Hide();
- this.matrixTop1.DeActive();
- foreach (var ctrl in this.pnlStations.Controls)
- {
- if (ctrl is MatrixStation)
- {
- ((MatrixStation)ctrl).DeActive();
- }
- if (ctrl is MatrixStation2)
- {
- ((MatrixStation2)ctrl).DeActive();
- }
- }
- this.matrixPopup1.DeActive();
- }
- public override void SelectedStationChanged(string stationId)
- {
- isPageChange = false;
- //MessageBox.Show(stationId);
- this.stationId = stationId;
- Active();
- }
- private void btnShowPopup_Click(object sender, EventArgs e)
- {
- this.matrixPopup1.Visible = true;
- this.matrixPopup1.BringToFront();
- formMode = "popup";
- Active();
- }
- private void cMenuControl_Opening(object sender, CancelEventArgs e)
- {
- MatrixBlock md = (sender as ContextMenuStrip).SourceControl as MatrixBlock;
- if (md != null)
- {
- this.cMenuControl.Tag = md;
- this.cMenuControl.Enabled = true;
- string windturbineId = CommonMethod.GetLongWindturbineId(md.DeviceId);
- bool isHung = false;
- isHung = md.IsLock;
- if (!isHung)
- {
- if (md.StationId.Equals("SBQ_FDC") || md.StationId.Equals("XS_FDC") ||
- md.StationId.Equals("NSS_FDC") || md.StationId.Equals("MHS_FDC"))
- {
- this.menuReset.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuShutDown.Enabled = false;
- this.menuUnLock.Enabled = false;
- this.menuLock.Enabled = true;
- int st = Convert.ToInt32(md.Status);
- switch (st)
- {
- case 0:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 1:
- this.menuShutDown.Enabled = true;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 2:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = true;
- this.menuMaintain.Enabled = true;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 3:
- this.menuShutDown.Enabled = true;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 4:
- this.menuShutDown.Enabled = true;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 5:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = true;
- break;
- case 6:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = true;
- this.menuReset.Enabled = false;
- break;
- case 7:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- }
- if (md.DeviceModel.Equals("UP105-2000-S"))
- {
- switch (st)
- {
- case 0:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 1:
- this.menuShutDown.Enabled = true;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 2:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = true;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 3:
- this.menuShutDown.Enabled = true;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 4:
- this.menuShutDown.Enabled = true;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 5:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = true;
- break;
- case 6:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- case 7:
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- break;
- }
- }
- }
- else
- {
- this.cMenuControl.Enabled = false;
- }
- }
- else
- {
- this.menuShutDown.Enabled = false;
- this.menuStartUp.Enabled = false;
- this.menuMaintain.Enabled = false;
- this.menuCancelMaintain.Enabled = false;
- this.menuReset.Enabled = false;
- this.menuUnLock.Enabled = true;
- this.menuLock.Enabled = false;
- }
- //MessageBox.Show(md.DeviceModel + "," + md.StationId);
- //e.Cancel = true;
- }
- //string whichcontrol_name = (sender as ContextMenuStrip).SourceControl.Name;
- }
- private void menuStartUp_Click(object sender, EventArgs e)
- {
- string deviceId = "";
- string powerStationId = "";
- if (this.cMenuControl.Tag is MatrixBlock)
- {
- MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
- deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
- powerStationId = device2.StationId;
- }
- bool isBusy = IsBusy(deviceId);
- if (isBusy)
- {
- MessageBox.Show("风机操作过频繁!");
- return;
- }
- try
- {
- user userData = null;
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- if (userData != null)
- {
- if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
- sendCommand(deviceId, powerStationId, CmdType.Start, userData);
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- }
- private void menuShutDown_Click(object sender, EventArgs e)
- {
- string deviceId = "";
- string powerStationId = "";
- if (this.cMenuControl.Tag is MatrixBlock)
- {
- MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
- deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
- powerStationId = device2.StationId;
- }
- bool isBusy = IsBusy(deviceId);
- if (isBusy)
- {
- MessageBox.Show("风机操作过频繁!");
- return;
- }
- try
- {
- user userData = null;
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- if (userData != null)
- {
- if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
- sendCommand(deviceId, powerStationId, CmdType.Stop, userData);
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- }
- private void menuReset_Click(object sender, EventArgs e)
- {
- string deviceId = "";
- string powerStationId = "";
- if (this.cMenuControl.Tag is MatrixBlock)
- {
- MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
- deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
- powerStationId = device2.StationId;
- }
- bool isBusy = IsBusy(deviceId);
- if (isBusy)
- {
- MessageBox.Show("风机操作过频繁!");
- return;
- }
- try
- {
- user userData = null;
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- if (userData != null)
- {
- if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
- sendCommand(deviceId, powerStationId, CmdType.Reset, userData);
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- }
- private void menuMaintain_Click(object sender, EventArgs e)
- {
- string deviceId = "";
- string powerStationId = "";
- if (this.cMenuControl.Tag is MatrixBlock)
- {
- MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
- deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
- powerStationId = device2.StationId;
- }
- bool isBusy = IsBusy(deviceId);
- if (isBusy)
- {
- MessageBox.Show("风机操作过频繁!");
- return;
- }
- try
- {
- user userData = null;
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- if (userData != null)
- {
- if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
- sendCommand(deviceId, powerStationId, CmdType.Maintain, userData);
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- }
- private void menuCancelMaintain_Click(object sender, EventArgs e)
- {
- string deviceId = "";
- string powerStationId = "";
- if (this.cMenuControl.Tag is MatrixBlock)
- {
- MatrixBlock device2 = (MatrixBlock)this.cMenuControl.Tag;
- deviceId = CommonMethod.GetLongWindturbineId(device2.DeviceId);
- powerStationId = device2.StationId;
- }
- bool isBusy = IsBusy(deviceId);
- if (isBusy)
- {
- MessageBox.Show("风机操作过频繁!");
- return;
- }
- try
- {
- user userData = null;
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- if (userData != null)
- {
- if (String.IsNullOrWhiteSpace(deviceId) == false && String.IsNullOrWhiteSpace(powerStationId) == false)
- sendCommand(deviceId, powerStationId, CmdType.UnMaintain, userData);
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- }
- private void sendCommand(string wtId, string windPowerStationId, CmdType cmdType, user userData)
- {
- IList<string> windturbineIdList = new List<string>();
- windturbineIdList.Add(wtId);
- TaskQueueSvc.QueueAdd(windturbineIdList, windPowerStationId, cmdType, userData);
- }
- private void menuUnLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.UnLock);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 场内受累检修
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void menuStationCheckLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationCheckLock);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 场内受累故障
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void menuStationFaultLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationFaulLockt);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 场外受累电网
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void menuStationPowerLineLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationPowerLineLock);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 故障维修
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void menuFaultLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.FaultLock);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 检修
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void menuCheckLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.CheckLock);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 场外受累天气
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void menuStationWeatherLock_Click(object sender, EventArgs e)
- {
- MatrixBlock device3 = (MatrixBlock)this.cMenuControl.Tag;
- string windturbineId = CommonMethod.GetLongWindturbineId(device3.DeviceId);
- string powerStationId = device3.StationId;
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- view_tspoint point =
- ctx.view_tspoint.Where(
- s => s.thing_id == windturbineId && s.thing_type == "windturbine" && s.uniform_code == "XDSL")
- .FirstOrDefault();
- if (point != null)
- {
- bool isSuccess = WindturbineLock(powerStationId, windturbineId, point.id, HungType.StationWeatherLock);
- if (isSuccess)
- MessageBox.Show("风机:" + windturbineId + "挂牌成功!");
- else
- MessageBox.Show("风机:" + windturbineId + "挂牌成功失败,请重试!");
- }
- else
- {
- MessageBox.Show("未找到相关挂牌点,请联系管理员!");
- }
- }
- }
- /// <summary>
- /// 挂牌方法
- /// </summary>
- /// <param name="pStationId">场站Id</param>
- /// <param name="windturbineId">风机Id</param>
- /// <param name="tagName">挂牌测点</param>
- /// <param name="type">挂牌类型</param>
- /// <returns></returns>
- private bool WindturbineLock(string pStationId, string windturbineId, string tagName, HungType type)
- {
- bool isSuccess = false;
- try
- {
- user userData = null;
- FingerCheck2 check = new FingerCheck2();
- check.ShowDialog();
- userData = FingerCheck2.checkSuccessUser;
- if (userData != null)
- {
- TsPointData tData = new TsPointData();
- tData.tagName = tagName;
- TsData t = new TsData();
- t.doubleValue = (int)type;
- DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
- TimeSpan sp = DateTime.Now.Subtract(dtStart);
- long time = long.Parse(sp.Ticks.ToString().Substring(0, sp.Ticks.ToString().Length - 4));
- t.ts = time;
- tData.tsData = t;
- RestfulClient.writeLatest(tData);
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- #region 写入操作日志
- control_log logData = new control_log();
- logData.windturbine_id = windturbineId;
- logData.station_id = pStationId;
- logData.control_user_id = userData.id;
- logData.send_control_time = DateTime.Now;
- logData.control_type = (int)CmdType.UnHangLock;
- logData.is_send_control_success = true;
- ctx.Entry(logData).State = EntityState.Added;
- int count = ctx.SaveChanges();
- if (count > 0)
- isSuccess = true;
- #endregion
- }
- }
- }
- catch (Exception ex)
- {
- logger.Error(ex);
- }
- return isSuccess;
- }
- private bool IsBusy(string windturbineId)
- {
- if (TaskQueueSvc.dicTask.ContainsKey(windturbineId))
- return true;
- else
- return false;
- }
- //protected override CreateParams CreateParams
- //{
- // get
- // {
- // CreateParams cp = base.CreateParams;
- // cp.ExStyle |= 0x02000000;
- // return cp;
- // }
- //}
- }
- }
|