protected override void WndProc(ref Message m) { if (m.Msg == ConstInfor.FORMMESSAGE && (int)m.WParam == ConstInfor.CLOSEMSGPARAM) { PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.LeaveReferParam); CommonCollection.personOpers.Add(curpersonoper); } base.WndProc(ref m); }
private void ReferParamSetWin_Load(object sender, EventArgs e) { //記錄当前人员进入Node参数设置界面的操作 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.EnterReferParam); CommonCollection.personOpers.Add(curpersonoper); string strrefermsg = ""; string strid = mrefer.ID[0].ToString("X2") + mrefer.ID[1].ToString("X2"); string strname = CommonBoxOperation.GetRouterName(strid); rstlb.Visible = false; if (null == strname || "".Equals(strname)) { strrefermsg = strid; } else { strrefermsg = strname + "(" + strid + ")"; } refermsgtxt.Text = strrefermsg; eqpttypetxt.Text = ConstInfor.GetDevType(NodeType.ReferNode, mrefer.type); vertxt.Text = ((byte)(mrefer.Version >> 24)).ToString("D2") + ((byte)(mrefer.Version >> 16)).ToString("D2") + ((byte)(mrefer.Version >> 8)).ToString("D2") + ((byte)(mrefer.Version)).ToString("X2"); /*读取参数信息 */ //读取信号阀值 referparam mrfpm = null; mrfpm = ReadReferParam(mrefer, frm.MyUdpClient, referparm.Sgthreshold); if (null == mrfpm) { sthdlb.Text = "read error"; } else { sthdlb.Text = "read ok"; sthdtxt.Text = mrfpm.Sgthreshold + ""; } //读取信号强度系数 mrfpm = ReadReferParam(mrefer, frm.MyUdpClient, referparm.Sgstrengthfac); if (null == mrfpm) { ssfaclb.Text = "read error"; } else { ssfaclb.Text = "read ok"; ssfactxt.Text = string.Format("{0:F2}", (double)mrfpm.Sgstrengthfac / 100); } }
/// <summary> /// 查找按钮,用于查找Tag和设备讯息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchBtn_Click(object sender, EventArgs e) { String StrIDorName = TagIDorNameTB.Text.ToUpper(); if ("".Equals(StrIDorName)) { MessageBox.Show("設備的ID或名稱不能為空!"); return; } if (tagrb.Checked) { #region 查找Tag设备 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchTag); CommonCollection.personOpers.Add(curpersonoper); TagPack MyTag = null; MyTag = SysParam.GetPackTag(StrIDorName); if (null == MyTag) { MyTag = SysParam.GetPackTag_Name(StrIDorName); } if (null == MyTag) { MessageBox.Show("查詢" + StrIDorName + "的Tag設備不存在!"); return; } Area curarea = CommonBoxOperation.GetAreaFromRouterID(MyTag.RD_New[0].ToString("X2") + MyTag.RD_New[1].ToString("X2")); if (null == curarea) { MessageBox.Show("對不起,卡片所在的區域不存在!"); return; } try { SysParam.isTracking = true; MyAllRegInfoWin = new AllRegInfoWin(frm, SpeceilAlarm.PersonHelp, MyTag.TD[0].ToString("X2") + MyTag.TD[1].ToString("X2")); MyAllRegInfoWin.ShowDialog(); } catch (Exception ex) { FileOperation.WriteLog("搜索Tag設備出現異常!異常原因:" + ex.ToString()); } finally { this.Close(); } #endregion } else if (rfrb.Checked) { #region 查找Refer设备 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchRefer); CommonCollection.personOpers.Add(curpersonoper); string strareaid = ""; BasicRouter mrt = null; foreach (KeyValuePair <string, Area> marea in CommonCollection.Areas) { if (null == marea.Value) { continue; } marea.Value.AreaRouter.TryGetValue(StrIDorName, out mrt); if (mrt != null) { strareaid = marea.Key; break; } foreach (KeyValuePair <string, BasicRouter> router in marea.Value.AreaRouter) { if (null == router.Value) { continue; } if (StrIDorName.Equals(router.Value.Name)) { mrt = router.Value; break; } } if (null != mrt) { strareaid = marea.Key; break; } } if (null == strareaid || "".Equals(strareaid)) { MessageBox.Show("查詢" + StrIDorName + @"的參考點設備不存在!"); return; } RegInfoWin myregwin = new RegInfoWin(frm, strareaid); myregwin.ShowDialog(); this.Close(); #endregion } else if (ndrb.Checked) { #region 查找Node设备 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchNode); CommonCollection.personOpers.Add(curpersonoper); string strareaid = ""; BasicNode mnd = null; foreach (KeyValuePair <string, Area> marea in CommonCollection.Areas) { if (null == marea.Value) { continue; } marea.Value.AreaNode.TryGetValue(StrIDorName, out mnd); if (mnd != null) { strareaid = marea.Key; break; } foreach (KeyValuePair <string, BasicNode> node in marea.Value.AreaNode) { if (null == node.Value) { continue; } if (StrIDorName.Equals(node.Value.Name)) { mnd = node.Value; break; } } if (null != mnd) { strareaid = marea.Key; break; } } if (null == strareaid || "".Equals(strareaid)) { MessageBox.Show("查詢" + StrIDorName + @"的數據節點設備不存在!"); return; } RegInfoWin myregwin = new RegInfoWin(frm, strareaid); myregwin.ShowDialog(); this.Close(); #endregion } }
/// <summary> // 开始验证密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Enter_Btn_Click(object sender, EventArgs e) { string UserName = UserName_TB.Text.Trim(); string Pass = Pass_TB.Text.Trim(); if ("".Equals(UserName)) { MessageBox.Show("對不起,用戶名不能為空!"); return; } if (logoutcb.Checked) { mainfrm.mexittype = ExitType.LogOut; } else { mainfrm.mexittype = ExitType.AppExit; } Person mperson = GetUser(UserName, Pass); if (mainfrm.CurPerson == null) { //说明此时是用户登录操作 if (ConstInfor.dmatekname.ToUpper().Equals(UserName.ToUpper()) && ConstInfor.dmatekpsw.ToUpper().Equals(Pass.ToUpper())) { //登陆时发现输入的账号及密码时dmatek和dmatek1234时,说明是本公司的人员 byte[] dmatekid = new byte[2]; dmatekid[0] = 0xFF; dmatekid[1] = 0xFF; mperson = new Person(dmatekid, ConstInfor.dmatekname, ConstInfor.dmatekpsw, 1); } mainfrm.CurPerson = mperson; if (null != mainfrm.CurPerson) { mainfrm.Text = "人員定位系統V11.2.18 (當前用戶: " + mainfrm.CurPerson.Name + ")"; PersonOperation curpersonoper = new PersonOperation(mainfrm.CurPerson.ID, OperType.LoginIn); CommonCollection.personOpers.Add(curpersonoper); } } if (!VerifyUserMsg(mperson, UserName, Pass)) { if (--count > 0) { MessageBox.Show("用戶名或密碼不正確!"); return; } else {//超过3次密码都输入错误时,退出应用 MessageBox.Show("對不起,用戶名或密碼錯誤,退出登錄/驗證窗體..."); this.DialogResult = DialogResult.Cancel; this.Close(); if (curopertype == OperType.OpenForm) { mainfrm.Close(); } return; } } this.DialogResult = DialogResult.OK; //此时记录下操作 if (curopertype == OperType.OpenForm || curopertype == OperType.CloseForm) { PersonOperation curpersonoper = null; if (curopertype == OperType.CloseForm) { if (mainfrm.mexittype == ExitType.AppExit) { curpersonoper = new PersonOperation(mainfrm.CurPerson.ID, OperType.CloseForm); } else if (mainfrm.mexittype == ExitType.LogOut) { curpersonoper = new PersonOperation(mainfrm.CurPerson.ID, OperType.LoginOut); } } else if (curopertype == OperType.OpenForm) { curpersonoper = new PersonOperation(mainfrm.CurPerson.ID, OperType.OpenForm); } if (null != curpersonoper) { CommonCollection.personOpers.Add(curpersonoper); } } this.Close(); }
/// <summary> /// 清除警告资讯 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClearAlarmTagsBtn_Click(object sender, EventArgs e) { OperType curOperType = OperType.UnKnown; switch (CurSpeceilAlarm) { case SpeceilAlarm.PersonHelp: curOperType = OperType.DelePersonHelpAlarm; break; case SpeceilAlarm.AreaControl: curOperType = OperType.DeleAreaAdminAlarm; break; case SpeceilAlarm.Resid: curOperType = OperType.DelePersonStopAlarm; break; } if (frm.CurPerson == null) { if (MessageBox.Show("對不起,你還沒有登錄,不能清除已經處理的警告訊息,請問是否需要登陸?") == System.Windows.Forms.DialogResult.OK) { EnterPassWin MyEnterPassWin = new EnterPassWin(frm, curOperType); if (DialogResult.OK != MyEnterPassWin.ShowDialog()) { return; } } else { return; } } if (PersonAlarmListView.CheckedItems.Count <= 0) { MessageBox.Show("請先選擇處理的项!"); return; } PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, curOperType); CommonCollection.personOpers.Add(curpersonoper); string StrIndex = ""; int index = -1; foreach (ListViewItem item in PersonAlarmListView.CheckedItems) { StrIndex = item.Name; try { index = Convert.ToInt32(StrIndex); }catch (Exception) { index = -1; continue; } if (index >= 0) { try { if (CommonCollection.WarmInfors[index].isHandler) { CommonCollection.WarmInfors[index].isClear = true; } }catch (Exception) { } } } string StrDir = FileOperation.WarmMsg; string StrFileName = StrDir + "\\" + FileOperation.WarmName; List <WarmInfo> listbox = null; if (File.Exists(StrFileName)) { listbox = FileOperation.GetWarmData(StrFileName); } //清除掉警报讯息集合中需要清理的项 for (int i = 0; i < CommonCollection.WarmInfors.Count; i++) { if (CommonCollection.WarmInfors[i].isClear) { //需要先存起来这样方便警告讯息的查找 if (null != listbox) { listbox.Add(CommonCollection.WarmInfors[i]); } CommonCollection.WarmInfors.Remove(CommonCollection.WarmInfors[i]); i--; } } //完成清理警告讯息后,再将警报讯息保存起来,方便查看 if (null != listbox) { FileOperation.SaveWarmData(listbox, StrFileName); } //清除掉列表项,这样就能保证每次序列号不会出错 PersonAlarmListView.Items.Clear(); DrawIMG.DrawMainCenter(frm.MainCenter_G); frm.MainCenter_Panel_Paint(null, null); }
/// <summary> /// 处理警告资讯 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandlerAlarmBtn_Click(object sender, EventArgs e) { OperType curOperType = OperType.UnKnown; switch (CurSpeceilAlarm) { case SpeceilAlarm.PersonHelp: curOperType = OperType.HandlePersonHelpAlarm; break; case SpeceilAlarm.AreaControl: curOperType = OperType.HandleAreaAdminAlarm; break; case SpeceilAlarm.Resid: curOperType = OperType.HandlePersonStopAlarm; break; } if (frm.CurPerson == null) { if (MessageBox.Show("對不起,你還沒有登錄,不能處理警報訊息,請問是否需要登陸?", "提醒", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { EnterPassWin MyEnterPassWin = new EnterPassWin(frm, curOperType); if (DialogResult.OK != MyEnterPassWin.ShowDialog()) { return; } } else { return; } } if (PersonAlarmListView.CheckedItems.Count <= 0) { MessageBox.Show("請先選擇處理的项!"); return; } PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, curOperType); CommonCollection.personOpers.Add(curpersonoper); int index = -1; foreach (ListViewItem item in PersonAlarmListView.CheckedItems) { string StrIndex = item.Name; try { index = Convert.ToInt32(StrIndex); }catch (Exception) { index = -1; continue; } if (index >= 0) { try { if (!CommonCollection.WarmInfors[index].isHandler) { CommonCollection.WarmInfors[index].isHandler = true; CommonCollection.WarmInfors[index].ClearAlarmTime = DateTime.Now; } }catch (Exception) { } } } }