Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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)
                    {
                    }
                }
            }
        }