Esempio n. 1
0
 public static void GetSMSHandle()
 {
     Task.Run(() =>
     {
         while (true)
         {
             if (CDMASMS.queue.Count > 0)
             {
                 int num    = CDMASMS.queue.Dequeue();
                 string sms = CDMASMS.ReadMsgByIndex(num);
                 if (sms != null)
                 {
                     string[] str = sms.Split(';');
                     wellCurrentStateInfo.Report_Time = DateTime.ParseExact(str[1].Trim(), "yyyyMMddHHmmss", CultureInfo.CurrentCulture).ToString("yyyy/MM/dd HH:mm:ss");
                     SMSAnalysis.MsgResult(str[2].Trim());
                     if (SMSAnalysis.isInvalid == true)
                     {
                         Process.GetCurrentProcess().CloseMainWindow();
                         return;
                     }
                     if (SMSAnalysis.isInvalid == false)
                     {
                         Process.GetCurrentProcess().CloseMainWindow();
                         return;
                     }
                     else
                     {
                         wellInfo = wellInfoService.GetWellInfoByPhone(str[0].Trim());
                         if (wellInfo.WellCurrentStateInfo.Well_State_ID == 6)
                         {
                             LogHelper.WriteLog("人井维护。ID:" + wellInfo.Terminal_ID);
                             return;
                         }
                         else
                         {
                             ShowMessageForm.ShowForm();
                             //人井打开
                             if (SMSAnalysis.IsOpen)
                             {
                                 wellCurrentStateInfo.Well_State_ID = 2;
                                 UpdateWellCurrentState();
                                 UpdateAlarmInfo();
                                 if (getSMSDelegate != null)
                                 {
                                     getSMSDelegate();
                                 }
                             }
                             else//人井关闭
                             {
                                 //终端低电量报警
                                 if (SMSAnalysis.IsElectricityAlarm)
                                 {
                                     wellCurrentStateInfo.Well_State_ID = 3;
                                     UpdateWellCurrentState();
                                     UpdateAlarmInfo();
                                     if (getSMSDelegate != null)
                                     {
                                         getSMSDelegate();
                                     }
                                 }
                                 //烟感报警
                                 if (SMSAnalysis.IsSmokeAlarm)
                                 {
                                     wellCurrentStateInfo.Well_State_ID = 4;
                                     UpdateWellCurrentState();
                                     UpdateAlarmInfo();
                                     if (getSMSDelegate != null)
                                     {
                                         getSMSDelegate();
                                     }
                                 }
                                 //烟感电量报警
                                 if (SMSAnalysis.IsSmoke_PowerAlarm)
                                 {
                                     wellCurrentStateInfo.Well_State_ID = 5;
                                     UpdateWellCurrentState();
                                     UpdateAlarmInfo();
                                     if (getSMSDelegate != null)
                                     {
                                         getSMSDelegate();
                                     }
                                 }
                                 else
                                 {
                                     wellCurrentStateInfo.Well_State_ID = 1;
                                     UpdateWellCurrentState();
                                 }
                             }
                             InsertSystemLogInfo();
                             UpdateMap(wellInfo.Terminal_ID);
                             UpdateReportNum();
                         }
                     }
                 }
                 CDMASMS.DeleteMsgByIndex(num);
             }
             else
             {
                 Thread.Sleep(3000);
             }
         }
     });
 }
Esempio n. 2
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            if (txtTerminal_ID.Text.Trim() == "")
            {
                UMessageBox.Show("请填写人井编号。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtLongitude.Text.Trim() == "" && txtLatitude.Text.Trim() == "")
            {
                UMessageBox.Show("请填写经度纬度。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtTerminal_Phone.Text.Trim() == "")
            {
                UMessageBox.Show("请填写终端手机号。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (cbOperator.SelectedIndex == -1)
            {
                UMessageBox.Show("请选择值班人员。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (tbReportInterval.Text.Trim() == "" && !isNumber(tbReportInterval.Text.Trim()))
            {
                UMessageBox.Show("请填写上报时间间隔。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            this.DialogResult       = DialogResult.OK;
            terminal_ID             = wellInfo.Terminal_ID = txtTerminal_ID.Text.Trim();
            wellInfo.Name           = txtName.Text.Trim();
            wellInfo.Longitude      = txtLongitude.Text.Trim();
            wellInfo.Latitude       = txtLatitude.Text.Trim();
            wellInfo.Place          = txtPlace.Text.Trim();
            wellInfo.Terminal_Phone = txtTerminal_Phone.Text.Trim();
            wellInfo.Operator_ID    = (int)cbOperator.SelectedValue;
            reportInterval          = int.Parse(tbReportInterval.Text.Trim());

            if (_isInsert)
            {
                if (wellInfoService.GetWellInfoByTerminal_ID(txtTerminal_ID.Text.Trim()) == null && wellInfoService.GetWellInfoByPhone(txtTerminal_Phone.Text.Trim()) == null)
                {
                    wellInfoService.InsertWellInfo(wellInfo);
                    wellStateService.InsertWellCurrentStateInfo(wellInfo.Terminal_ID, (int)cbState.SelectedValue);
                    wellInfoService.InsertReportInfo(wellInfo.Terminal_ID, reportInterval);

                    userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "添加人井。", CommonClass.UserName, null, null);
                }
                else
                {
                    UMessageBox.Show("当前人井已存在。", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                wellInfoService.UpdateWellInfo(wellInfo);
                wellStateService.UpdateWellCurrentStateInfo((int)cbState.SelectedValue, wellInfo.Terminal_ID);
                wellInfoService.UpdateReportInterval(reportInterval, wellInfo.Terminal_ID);

                userLogHelper.InsertUserLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), "更新人井信息。", CommonClass.UserName, null, null);
            }
            UMessageBox.Show(this.Text + "成功!", "人井监控管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }