protected override string InsertTsCmdStore(string TsCmd_ValueID, string m_AreaCode, string Content, string sDateTime, string sEndDateTime) { try { string sqlstr = ""; if (!string.IsNullOrEmpty(AudioModel.PlayingContent)) { sqlstr = "insert into TsCmdStore(TsCmd_Type, TsCmd_Mode, TsCmd_UserID, TsCmd_ValueID, TsCmd_Params, TsCmd_Date,TsCmd_ExcuteTime,TsCmd_SaveTime, TsCmd_Status,TsCmd_EndTime,TsCmd_Note,Ebm_ID,AreaCode,MsgTitle,TsCmd_PlayCount)" + "values('播放视频', '区域', '" + SingletonInfo.GetInstance().TsCmd_UserID + "','" + TsCmd_ValueID + "', '1~" + AudioModel.PlayingContent + "~0~1200~192~0~1~1', " + "'" + sDateTime + "'" + ",'" + sDateTime + "','" + sDateTime + "', 0,'" + sEndDateTime + "'," + "'-1'" + "," + AudioModel.EBMID + "," + AudioModel.AeraCodeReal + ",'" + AudioModel.MsgTitleNew + "','20'" + ")"; } else { sqlstr = "insert into TsCmdStore(TsCmd_Type, TsCmd_Mode, TsCmd_UserID, TsCmd_ValueID, TsCmd_Params, TsCmd_Date,TsCmd_ExcuteTime,TsCmd_SaveTime, TsCmd_Status,TsCmd_EndTime,TsCmd_Note,Ebm_ID,AreaCode,MsgTitle,TsCmd_PlayCount)" + "values('文本播放', '区域', '" + SingletonInfo.GetInstance().TsCmd_UserID + "','" + TsCmd_ValueID + "', '" + AudioModel.PlayingContent + "~向上移动~10~12~0', " + "'" + sDateTime + "'" + ",'" + sDateTime + "','" + sDateTime + "', 0,'" + sEndDateTime + "'," + "'-1'" + "," + AudioModel.EBMID + "," + AudioModel.AeraCodeReal + ",'" + AudioModel.MsgTitleNew + "','20'" + ")"; } string TsCmdStoreID = mainForm.dba.UpdateDbBySQLRetID(sqlstr).ToString(); if (Convert.ToInt32(TsCmdStoreID) > 0) { return(TsCmdStoreID); } } catch (Exception ex) { throw new Exception("插入TsCmdStore失败:" + ex.Message); } return(null); }
private bool UpdateState() { bool flag = false; XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); string MediaSql = ""; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; List <Device> lDev = new List <Device>(); try { lDev = GetEBRDTStateFromDataBase("Full"); frdStateName = "10" + SingletonInfo.GetInstance().CurrentResourcecode + BBSHelper.GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(SingletonInfo.GetInstance().SendTarAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } catch (Exception ex) { throw new Exception("终端状态变更:" + ex.Message); } return(flag); }
private void GetSQLData() { DataTable dt = new DataTable(); string sql = "select * from recordlist"; SingletonInfo.GetInstance().DataBase.FromSql(sql, out dt); if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { RecordDetail pp = new RecordDetail(); pp.AreaCode = item["AreaCode"].ToString(); pp.DealFlag = Convert.ToInt32(item["DealFlag"].ToString()); pp.EventType = item["EventType"].ToString(); pp.MediumType = item["MediumType"].ToString(); pp.MsgEndTime = item["MsgEndTime"].ToString(); pp.MsgStartTime = item["MsgStartTime"].ToString(); pp.RecordId = item["RecordId"].ToString(); pp.SavePath = item["SavePath"].ToString(); pp.Severity = item["Severity"].ToString(); pp.SourceTar = item["SourceTar"].ToString(); pp.SourceTarPath = item["SourceTarPath"].ToString(); pp.TextContent = item["TextContent"].ToString(); pp.MsgTitle = item["MsgTitle"].ToString(); pp.SenderCode = item["SenderCode"].ToString(); pp.SenderName = item["SenderName"].ToString(); pp.SendTime = item["SendTime"].ToString(); SetDataGridviewControlPropertyValue(this.skinDataGridView_Main, pp); SingletonInfo.GetInstance().RecordDetailList.Add(pp); } } }
public virtual AudioModel PlayReady(int type, string MQIns) { try { if (MoreTime()) { PlayStateInterface.Untreated(AudioModel.XmlFilaPath, "未处理", "0"); } else { bool res = false; string MQInstruction = MQIns; string AreaString = CombinationArea(); ///获取TsCmd_ValueID string TsCmd_ValueID = GetTmcValue(AreaString); if (!string.IsNullOrEmpty(TsCmd_ValueID)) { string result = InsertTsCmdStore(TsCmd_ValueID, AreaString, MQInstruction, AudioModel.PlayingTime.ToString(), AudioModel.PlayEndTime.ToString()); SingletonInfo.GetInstance().DicTsCmd_ID.Add(AreaString, result); if (!string.IsNullOrEmpty(result)) { Thread thread; string uuid = Guid.NewGuid().ToString("N"); thread = new Thread(delegate() { AudioPlay(type, MQInstruction, result, TsCmd_ValueID); } ); SingletonInfo.GetInstance().DicPlayingThread[AudioModel.AeraCodeReal].Add(thread); // th.Add(uuid,thread); thread.IsBackground = true; thread.Start(); while (true) { Thread.Sleep(1000); if (thread.ThreadState == ThreadState.Stopped) { thread.Abort(); // th.Remove(uuid); SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); break; } } } } } } catch (Exception ex) { return(AudioModel); } return(null); }
/// <summary> /// 数据解析 /// </summary> public void DealStatus() { while (isRun) { try { if (!beforeAnalysisQueue.IsEmpty) { EquipmentSource data; beforeAnalysisQueue.TryDequeue(out data); //拿出数据 string dadada = ""; for (int i = 0; i < data.RawData.Length; i++) { dadada += " " + data.RawData[i].ToString("X2"); } if (SingletonInfo.GetInstance().ProtocolCode == "1") { //处理国标情况 20180913新增 if (data != null && data.RawData != null && data.RawData.Length > 0) { var dataNew = HandlerQueue_NationalStandard(data); //解析数据 if (dataNew != null) { afterAnalysisQueue_NS.Enqueue(dataNew); //放入已解析队列 // clientsConn.AddOrUpdate(dataNew.PhysicalAddressFormat, data.ConnId, (key, value) => { return value = data.ConnId; }); autoEvent.Set(); //通知saveThread } } } else { //处理广西情况 if (data != null && data.RawData != null && data.RawData.Length > 0) { var dataNew = HandlerQueue(data); //解析数据 if (dataNew != null) { afterAnalysisQueue.Enqueue(dataNew); //放入已解析队列 // clientsConn.AddOrUpdate(dataNew.PhysicalAddressFormat, data.ConnId, (key, value) => { return value = data.ConnId; }); autoEvent.Set(); //通知saveThread } } } } Thread.Sleep(50); } catch (Exception ex) { log.Error("数据解析异常-" + beforeAnalysisQueue.Count, ex); continue; } } }
private void skinDataGridView_Main_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { switch (e.ColumnIndex) { case 0: MessageShowDlg = new MessageShowForm { label1 = { Text = @"确认处理?" } }; MessageShowDlg.ShowDialog(); if (MessageShowDlg.IsSure) { DataGridViewRow dgvR = skinDataGridView_Main.Rows[e.RowIndex]; dgvR.DefaultCellStyle.BackColor = Color.FromArgb(40, 36, 36); RecordDetail selectone = (RecordDetail)dgvR.Tag; selectone.DealFlag = 1; //更新数据库 SingletonInfo.GetInstance().DataBase.UpdateRecorde(selectone); dgvR.Cells[0].Value = "已处理"; dgvR.Cells[0].ReadOnly = true; } break; case 2: DataGridViewRow dgvRS = skinDataGridView_Main.Rows[e.RowIndex]; RecordDetail selected = (RecordDetail)dgvRS.Tag; EBMDetailShowDlg = new EBMDetailShowForm(selected); EBMDetailShowDlg.ShowDialog(); break; case 9: MessageShowDlg = new MessageShowForm { label1 = { Text = @"打开链接?" } }; MessageShowDlg.ShowDialog(); if (MessageShowDlg.IsSure) { DataGridViewRow dgvR = skinDataGridView_Main.Rows[e.RowIndex]; RecordDetail selectone = (RecordDetail)dgvR.Tag; string path = Path.GetDirectoryName(selectone.SavePath); System.Diagnostics.Process.Start(path); } break; } } catch (Exception) { throw; } }
private void btnSet_Click(object sender, EventArgs e) { if (!Regex.IsMatch(this.textTcpPort.Text.Trim(), "^([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$")) { MessageBox.Show("端口号应为0到65535的数字,请重新填写", "提示"); } else if (!Regex.IsMatch(this.textUdpPort.Text.Trim(), "^([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$")) { MessageBox.Show("端口号应为0到65535的数字,请重新填写", "提示"); } else if (this.textTcpPort.Text.Trim() == this.textUdpPort.Text.Trim()) { MessageBox.Show("端口号不能重复,请重新填写", "提示"); } else if (!Regex.IsMatch(this.textMQPort.Text.Trim(), "^([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$")) { MessageBox.Show("端口号应为0到65535的数字,请重新填写", "提示"); this.textMQPort.Focus(); } else if (!Regex.IsMatch(this.txtMQServer.Text, "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")) { MessageBox.Show("请输入合法IP", "提示"); this.txtMQServer.Focus(); } else if (!this.PingIp()) { MessageBox.Show("MQ服务器连接失败,网络不通", "提示"); this.txtMQServer.Focus(); } else { if (FormMain.DataBase == null) { FormMain.DataBase = new DBHelper(); } FormMain.DataBase.SetConnectString(this.txtServer.Text.Trim(), this.txtDbuser.Text.Trim(), this.txtDbPass.Text.Trim(), this.txtDb.Text.Trim()); this.ini.WriteValue("LocalHost", "LoaclIP", this.cbBoxIP.Text.Trim()); this.ini.WriteValue("LocalHost", "TCPLocalPort", this.textTcpPort.Text.Trim()); this.ini.WriteValue("LocalHost", "UDPLocalPort", this.textUdpPort.Text.Trim()); this.ini.WriteValue("Database", "ServerName", this.txtServer.Text.Trim()); this.ini.WriteValue("Database", "DataBase", this.txtDb.Text.Trim()); this.ini.WriteValue("Database", "LogID", this.txtDbuser.Text.Trim()); this.ini.WriteValue("Database", "LogPass", this.txtDbPass.Text.Trim()); this.ini.WriteValue("MQ", "MQIP", this.txtMQServer.Text.Trim()); this.ini.WriteValue("MQ", "MQPORT", this.textMQPort.Text.Trim()); this.ini.WriteValue("MQ", "TopicName", this.txtTopiName.Text.Trim()); this.ini.WriteValue("ProtocolType", "type", this.cmb_protocoltype.SelectedValue.ToString()); SingletonInfo.GetInstance().ProtocolCode = cmb_protocoltype.SelectedValue.ToString(); base.DialogResult = DialogResult.OK; } }
/// <summary> /// 播发状态反馈 20181213 /// </summary> /// <param name="ebdsr"></param> /// <param name="BrdStateDesc"></param> /// <param name="BrdStateCode"></param> /// <returns></returns> private bool sendEBMStateResponse(EBD ebdsr, string BrdStateCode) { //*反馈 #region 先删除解压缩包中的文件 bool flag = false; foreach (string xmlfiledel in Directory.GetFileSystemEntries(ServerForm.sEBMStateResponsePath)) { if (File.Exists(xmlfiledel)) { FileInfo fi = new FileInfo(xmlfiledel); if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1) { fi.Attributes = FileAttributes.Normal; } File.Delete(xmlfiledel);//直接删除其中的文件 } } #endregion End XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); //rHeart.SourceAreaCode = ServerForm. strSourceAreaCode; //rHeart.SourceType = ServerForm.strSourceType; //rHeart.SourceName = ServerForm.strSourceName; //rHeart.SourceID = ServerForm.strSourceID; //rHeart.sHBRONO = SingletonInfo.GetInstance().CurrentResourcecode; string frdStateName = "10" + SingletonInfo.GetInstance().CurrentResourcecode + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.EBMStateRequestResponse(ebdsr, frdStateName, BrdStateCode); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sEBMStateResponsePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sEBMStateResponsePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sEBMStateResponsePath, ServerForm.sSendTarPath, frdStateName);// "HB000000000001");//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\EBDT_" + frdStateName + ".tar"; try { string result = HttpSendFile.UploadFilesByPost(SingletonInfo.GetInstance().SendTarAddress, sHeartBeatTarName); if (result != "0") { return(true); } } catch (Exception w) { Log.Instance.LogWrite("应急消息播发状态反馈发送平台错误:" + w.Message); } return(flag); }
/// <summary> /// 输出数据到数据库 /// </summary> public void SaveEqStatus() { DataTable dt = null; DataTable dtNew = null; DataTable dtNa = null; if (SingletonInfo.GetInstance().ProtocolCode == "1") { //国标情况 lock (dtsrvStatus_national.Rows.SyncRoot) //多线程环境下锁住DataTable中的Rows集合同时也锁住了Columns集合 { if (dtsrvStatus_national.Rows.Count > 0) { dtNa = dtsrvStatus_national.Copy(); dtsrvStatus_national.Rows.Clear(); } } if (db != null && dtNa != null) { db.BulkEquipmentDetailNation(dtNa); } } else { //图南情况 lock (dtStatus.Rows.SyncRoot) { if (dtStatus.Rows.Count > 0) { dt = dtStatus.Copy(); dtStatus.Rows.Clear(); } } lock (dtStatusNew.Rows.SyncRoot) //多线程环境下锁住DataTable中的Rows集合同时也锁住了Columns集合 { if (dtStatusNew.Rows.Count > 0) { dtNew = dtStatusNew.Copy(); dtStatusNew.Rows.Clear(); } } if (db != null && dt != null && dtNew != null) { var status = db.UpdateSrvEquipmentStatusBatch(dt); db.BulkEquipmentDetail(dt); db.BulkNewEquipmentDetail(dtNew); // log.Info("数据库存储结束-" + status); } } }
private void ShowData(object obj) { RecordDetail dd = (RecordDetail)obj; SetDataGridviewControlPropertyValue(this.skinDataGridView_Main, dd); int UnhandledMsgCount = 0; UnhandledMsgCount = SingletonInfo.GetInstance().RecordDetailList.FindAll(s => s.DealFlag == 0).Count; this.Invoke(new Action(() => { taskbarNotifier3.Show(dd, UnhandledMsgCount); })); }
/// <summary> /// 播放 /// </summary> /// <returns></returns> public bool AudioPlay(int type, string ParamValue, string TsCmd_ID, string TsCmd_ValueID, string EBMInfoID) { try { ServerForm.SetManager("EBM开始时间: " + AudioModel.PlayingTime + "===>EBM结束时间: " + AudioModel.PlayEndTime, Color.Green); ServerForm.SetManager("播放开始时间: " + AudioModel.PlayingTime + "===>播放结束时间: " + AudioModel.PlayEndTime, Color.Green); ServerForm.SetManager("等待播放" + AudioModel.PlayingContent, Color.Green); EBD ebd = GetEBD(AudioModel.XmlFilaPath); string AreaString = CombinationArea(); #region 未播放 if (DateTime.Compare(AudioModel.PlayingTime, DateTime.Now) > 0) { AudioPlayState = AudioMessage.AudioPlayState.NotPlay; lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.NotBroadcast; } string strSql = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "1", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSql); Task.Factory.StartNew(() => { PlayStateInterface.NotPlay(TsCmd_ID, AudioModel.XmlFilaPath, "1"); ServerForm.SetManager("反馈未播放状态", Color.Green); }); } #endregion 未播放代码 //播放中 #region 播放中 while (true) { DateTime current = DateTime.Now; Thread.Sleep(1000); if (DateTime.Compare(current, AudioModel.PlayingTime) > 0)//当前时间大于播放开始时间 { ServerForm.SetManager("播放开始:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Color.Green); lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.Playback; } AudioPlayState = AudioMessage.AudioPlayState.Playing; // MqSendOrder sendOrder = new MqSendOrder(); bool result = SendMQ.MqSendOrder.sendOrder.SendMq(ebd, type, ParamValue, TsCmd_ID, TsCmd_ValueID); string strSql = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "2", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSql); Task.Factory.StartNew(() => { PlayStateInterface.Playing(TsCmd_ID, AudioModel.XmlFilaPath, "2", "播发中"); ServerForm.SetManager("反馈播发中状态", Color.Green); }); ServerForm.SetManager("播放中的反馈已发送", Color.Green); break; } } #endregion 播放中代码 //播放完成 #region 播放完 ServerForm.SetManager("进入等待播放完成流程", Color.Green); while (true) { Thread.Sleep(1000); // ServerForm.SetManager("未到结束时间在播放过程中:"+tmp.ToString(), Color.Green); if (DateTime.Compare(DateTime.Now, AudioModel.PlayEndTime) < 0)//结束时间大于当前时间 { string MediaSql = "select TsCmd_ID,TsCmd_ExCute from TsCmdStore where TsCmd_ID='" + TsCmd_ID + "'"; // MediaSql = "select top(1)TsCmd_ID,TsCmd_XmlFile from TsCmdStore where TsCmd_ValueID = '" + ebd.EBMStateRequest.EBM.EBMID + "' order by TsCmd_Date desc"; DataTable dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia != null && dtMedia.Rows.Count > 0) { if (dtMedia.Rows[0]["TsCmd_ExCute"].ToString().Contains("播放完毕")) { string strSql = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "3", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSql); ServerForm.SetManager("播放结束", Color.Green); lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.PlayOut; } AudioPlayState = AudioMessage.AudioPlayState.PlayingOver; Task.Factory.StartNew(() => { PlayStateInterface.PlayOver(TsCmd_ID, AudioModel.XmlFilaPath, "3", "开机/运行中"); ServerForm.SetManager("反馈播放完成状态", Color.Green); }); if (SingletonInfo.GetInstance().DicTsCmd_ID.ContainsKey(AreaString)) { SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); } if (SingletonInfo.GetInstance().DicPlayingThread.ContainsKey(AudioModel.AeraCodeReal)) { SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); // MessageBox.Show("文件播放完了->删除" + AudioModel.AeraCodeReal + "的字典值"); } break; } } } else { lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.PlayOut; } ServerForm.SetManager("播放结束", Color.Green); Task.Factory.StartNew(() => { PlayStateInterface.PlayOver(TsCmd_ID, AudioModel.XmlFilaPath, "3", "开机/运行中"); ServerForm.SetManager("反馈播放完成状态", Color.Green); }); string strSqlupdateEBMInfo = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "3", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSqlupdateEBMInfo); //没播放完 但是文件时间到了 string strSql = ""; if (type == 1) { strSql = string.Format("update PLAYRECORD set PR_REC_STATUS = '{0}' where PR_SourceID='{1}'", "删除", TsCmd_ID); mainForm.dba.UpdateDbBySQL(strSql); string strSqlTsCmdStore = string.Format("update TsCmdStore set TsCmd_ExCute = '{0}' where TsCmd_ID='{1}'", "播放完毕", TsCmd_ID); mainForm.dba.UpdateDbBySQL(strSqlTsCmdStore); } else if (type == 2) { strSql = string.Format("update PLAYRECORD set PR_REC_STATUS = '{0}' ", "删除"); mainForm.dba.UpdateDbBySQL(strSql); } if (SingletonInfo.GetInstance().DicTsCmd_ID.ContainsKey(AreaString)) { SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); } if (SingletonInfo.GetInstance().DicPlayingThread.ContainsKey(AudioModel.AeraCodeReal)) { SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); // MessageBox.Show("播放时间到了->删除"+ AudioModel.AeraCodeReal+"的字典值"); } break; } } #endregion 播放完代码 GC.Collect(); return(true); } catch (Exception ex) { AudioPlayState = AudioMessage.AudioPlayState.error; // MessageBox.Show(ex.Message + ex.StackTrace); } return(false); }
public virtual AudioModel PlayReady(int type, string MQIns, string EBMInfoID) { try { if (MoreTime()) { //已经过了播放时间 不处理 PlayStateInterface.Untreated(AudioModel.XmlFilaPath, "0"); } else { bool res = false; string MQInstruction = MQIns; string AreaString = CombinationArea(); ///获取TsCmd_ValueID string TsCmd_ValueID = ""; //if (type == 2)//好坑 现场又坑我一把 20181219 //{ // TsCmd_ValueID = GetTmcValue(AreaString); //} //else //{ // TsCmd_ValueID = AreaString;//注意此处的TsCmd_ValueID为12位的区域码 20181212与刘工一起核查 //} TsCmd_ValueID = GetTmcValue(AreaString); if (!string.IsNullOrEmpty(TsCmd_ValueID)) { string result = InsertTsCmdStore(TsCmd_ValueID, AreaString, MQInstruction, AudioModel.PlayingTime.ToString(), AudioModel.PlayEndTime.ToString()); if (SingletonInfo.GetInstance().DicTsCmd_ID.ContainsKey(AreaString)) { SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); } SingletonInfo.GetInstance().DicTsCmd_ID.Add(AreaString, result); if (!string.IsNullOrEmpty(result)) { Thread thread; string uuid = Guid.NewGuid().ToString("N"); thread = new Thread(delegate() { AudioPlay(type, MQInstruction, result, TsCmd_ValueID, EBMInfoID); } ); SingletonInfo.GetInstance().DicPlayingThread[AudioModel.AeraCodeReal].Add(thread); thread.IsBackground = true; thread.Start(); while (true) { Thread.Sleep(200); if (thread.ThreadState == ThreadState.Stopped) { thread.Abort(); GC.Collect(); if (SingletonInfo.GetInstance().DicPlayingThread.ContainsKey(AudioModel.AeraCodeReal)) { SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); ServerForm.SetManager("播放过程线程stopped,DicPlayingThread中的字典被清理", Color.Green); } break; } } } } } } catch (Exception ex) { // MessageBox.Show("DicPlayingThread.count:"+SingletonInfo.GetInstance().DicPlayingThread.Count.ToString() + ","+ ex.Message+ex.StackTrace);// 测试注释 // return AudioModel; } return(null); }
/// <summary> /// 从数据库获取终端状态信息 /// </summary> /// <param name="datatype"></param> /// <returns></returns> private List <Device> GetEBRDTStateFromDataBase(string datatype) { List <Device> ListDevicetmp = new List <Device>(); if (datatype == "Incremental") { #region 增量 string MediaSql = "select a.SRV_PHYSICAL_CODE,a.SRV_LOGICAL_CODE_GB,a.SRV_RMT_STATUS,b.powersupplystatus from SRV a inner join Srv_Status b on a.SRV_PHYSICAL_CODE = b.srv_physical_code"; DataTable dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia.Rows.Count > 0) { List <IncrementalEBRDTState> Listtmp = new List <IncrementalEBRDTState>(); foreach (DataRow item in dtMedia.Rows) { IncrementalEBRDTState pp = new IncrementalEBRDTState(); pp.powersupplystatus = item["powersupplystatus"].ToString(); pp.SRV_LOGICAL_CODE_GB = item["SRV_LOGICAL_CODE_GB"].ToString(); pp.SRV_PHYSICAL_CODE = item["SRV_PHYSICAL_CODE"].ToString(); pp.SRV_RMT_STATUS = item["SRV_RMT_STATUS"].ToString(); Listtmp.Add(pp); } if (!CheckList(Listtmp, SingletonInfo.GetInstance().ListIncrementalEBRDTState)) { foreach (IncrementalEBRDTState item in Listtmp) { IncrementalEBRDTState selectone = SingletonInfo.GetInstance().ListIncrementalEBRDTState.Find(c => c.SRV_PHYSICAL_CODE.Equals(item.SRV_PHYSICAL_CODE)); if (selectone != null) { if (!selectone.Equals(item)) { selectone = item; Device pp = new Device(); pp.EBRID = item.SRV_LOGICAL_CODE_GB; if (item.SRV_RMT_STATUS == "离线") { pp.StateCode = "3"; } else { string statustmp = item.powersupplystatus; if (statustmp.Contains("广播")) { pp.StateCode = "5"; } if (statustmp.Contains("关机")) { pp.StateCode = "2"; } if (statustmp.Contains("开机")) { pp.StateCode = "1"; } } ListDevicetmp.Add(pp); } } else { //说明是新增的终端 Device pp = new Device(); pp.EBRID = item.SRV_LOGICAL_CODE_GB; string statustmp = item.powersupplystatus; if (statustmp.Contains("广播")) { pp.StateCode = "5"; } if (statustmp.Contains("关机")) { pp.StateCode = "2"; } if (statustmp.Contains("开机")) { pp.StateCode = "1"; } ListDevicetmp.Add(pp); SingletonInfo.GetInstance().ListIncrementalEBRDTState.Add(item); } } } else { // MessageBox.Show("终端状态没有发生变化"); } } #endregion } else { #region 全量 //全量终端信息 包括没有回传功能的设备 string MediaSql1 = "select SRV_PHYSICAL_CODE,SRV_LOGICAL_CODE_GB,SRV_RMT_STATUS,SRV_RMT_SWITCH from SRV"; string MediaSql2 = "select srv_physical_code,powersupplystatus from Srv_Status"; DataTable dtMedia1 = mainForm.dba.getQueryInfoBySQL(MediaSql1); DataTable dtMedia2 = mainForm.dba.getQueryInfoBySQL(MediaSql2); foreach (DataRow item1 in dtMedia1.Rows) { if (item1["SRV_RMT_SWITCH"].ToString() == "启用") { //带回传功能的终端 DataRow[] drsingle = dtMedia2.Select(string.Format("srv_physical_code={0}", item1["SRV_PHYSICAL_CODE"])); if (drsingle.Length > 0) { foreach (DataRow item2 in dtMedia2.Rows) { if (item2["srv_physical_code"].ToString() == item1["SRV_PHYSICAL_CODE"].ToString()) { Device pp = new Device(); pp.EBRID = item1["SRV_LOGICAL_CODE_GB"].ToString(); if (item1["SRV_RMT_STATUS"].ToString() == "离线") { pp.StateCode = "3"; } else { string statustmp = item2["powersupplystatus"].ToString(); if (statustmp.Contains("广播")) { pp.StateCode = "5"; } if (statustmp.Contains("关机")) { pp.StateCode = "2"; } if (statustmp.Contains("开机")) { pp.StateCode = "1"; } } ListDevicetmp.Add(pp); } } } else { //有回传功能但数据没回传回来 Device pp = new Device(); pp.EBRID = item1["SRV_LOGICAL_CODE_GB"].ToString(); pp.StateCode = "3"; ListDevicetmp.Add(pp); } } else { //不带回传功能的终端 Device pp = new Device(); pp.EBRID = item1["SRV_LOGICAL_CODE_GB"].ToString(); pp.StateCode = "1";//没有回传,不知道具体状态,先强制赋值 20190111 ListDevicetmp.Add(pp); } } #endregion } return(ListDevicetmp); }
private bool UpdateState(string TimingTerminalState) { bool flag = false; XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); rHeart.SourceAreaCode = ServerForm.strSourceAreaCode; rHeart.SourceType = ServerForm.strSourceType; rHeart.SourceName = ServerForm.strSourceName; rHeart.SourceID = ServerForm.strSourceID; rHeart.sHBRONO = SingletonInfo.GetInstance().CurrentResourcecode; string MediaSql = ""; string strSRV_ID = ""; string strSRV_CODE = ""; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; List <Device> lDev = new List <Device>(); try { MediaSql = "select SRV.SRV_ID,SRV.SRV_CODE,SRV_GOOGLE,SRV_PHYSICAL_CODE,srv_detail,SRV_LOGICAL_CODE_GB,SRV_MFT_DATE,updateDate,SRV_RMT_STATUS FROM SRV left join Srvtype on SRV.DeviceTypeId= Srvtype .srv_id where Srvtype.srv_id=1"; DataTable dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia != null && dtMedia.Rows.Count > 0) { if (dtMedia.Rows.Count > 100) { int mod = dtMedia.Rows.Count / 100 + 1; for (int i = 0; i < mod; i++) { for (int idtM = 0; idtM < dtMedia.Rows.Count; idtM++) { Device DV = new Device(); DV.SRV_ID = dtMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); DV.DeviceID = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE_GB"].ToString();//修改于20180819 把资源码换成23位 DV.DeviceName = dtMedia.Rows[idtM][4].ToString(); DV.Latitude = dtMedia.Rows[idtM][2].ToString().Split(',')[0]; DV.Longitude = dtMedia.Rows[idtM][2].ToString().Split(',')[1]; DV.Srv_Mft_Date = dtMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtMedia.Rows[idtM]["updateDate"].ToString(); DV.DeviceState = TimingTerminalState; lDev.Add(DV); } frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(SingletonInfo.GetInstance().SendTarAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } } else { for (int idtM = 0; idtM < dtMedia.Rows.Count; idtM++) { Device DV = new Device(); DV.SRV_ID = dtMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); DV.DeviceID = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE_GB"].ToString(); DV.DeviceName = dtMedia.Rows[idtM][4].ToString(); DV.Latitude = dtMedia.Rows[idtM][2].ToString().Split(',')[0]; DV.Longitude = dtMedia.Rows[idtM][2].ToString().Split(',')[1]; DV.Srv_Mft_Date = dtMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtMedia.Rows[idtM]["updateDate"].ToString(); DV.DeviceState = TimingTerminalState; lDev.Add(DV); } Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(SingletonInfo.GetInstance().SendTarAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } } else { Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(SingletonInfo.GetInstance().SendTarAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } } catch (Exception ex) { throw new Exception("终端状态变更:" + ex.Message); } return(flag); }
//public MonitorPlatformMessage Serializable(string Msg) //{ // MonitorPlatformMessage tmp = new MonitorPlatformMessage(); // string[] msgItem = Msg.Split('|'); // if (msgItem.Length > 0) // { // tmp.FILENAME = msgItem[0].Split('~')[1].Split('.')[0]; // tmp.SRVPHYSICALCODE = msgItem[1].Split('~')[1]; // byte[] startIndex = new byte[4]; // if (msgItem[2].Split('~')[1].Length > 0) // { // for (int i = 0; i < msgItem[2].Split('~')[1].Length / 2; i++) // { // startIndex[i] = (byte)Convert.ToInt32(msgItem[2].Split('~')[1].Substring(2 * i, 2), 16); // } // } // tmp.PACKSTARTINDEX = startIndex; // } // return tmp; //} public void Serialize(string Msg) { if (Msg.Contains("UPGRADE")) { UpdateCode tmp = new UpdateCode(); string[] msgItem = Msg.Split('|'); if (msgItem.Length > 0) { foreach (var item in msgItem) { switch (item.Split('~')[0]) { case "PACKETTYPE": tmp.PACKETTYPE = item.Split('~')[1]; break; case "NEWVERSION": tmp.NEWVERSION = item.Split('~')[1]; break; case "OLDVERSION": tmp.OLDVERSION = item.Split('~')[1]; break; case "UPGRADEMODE": tmp.UPGRADEMODE = item.Split('~')[1]; break; case "HTTPURL": tmp.HTTPURL = item.Split('~')[1]; break; case "LIST": string[] str = item.Split('~')[1].Split('&'); tmp.LIST = new List <string>(); foreach (var code in str) { tmp.LIST.Add(code); } break; } } SendbackDetail sendbackDetail = new SendbackDetail(); sendbackDetail.tag = Equipment.OnlineUpdate; sendbackDetail.Extras = tmp; DataDealHelper.MyEvent(sendbackDetail); } } else if (Msg.Contains("TRANSFER")) { TransferCode tmp = new TransferCode(); string[] msgItem = Msg.Split('|'); if (msgItem.Length > 0) { foreach (var item in msgItem) { switch (item.Split('~')[0]) { case "PACKETTYPE": tmp.PACKETTYPE = item.Split('~')[1]; break; case "FILENAME": tmp.FILENAME = item.Split('~')[1]; break; case "SRVPHYSICALCODE": tmp.SRVPHYSICALCODE = item.Split('~')[1]; break; case "PACKSTARTINDEX": byte[] startIndex = new byte[4]; if (item.Split('~')[1].Length > 0) { for (int i = 0; i < item.Split('~')[1].Length / 2; i++) { startIndex[i] = (byte)Convert.ToInt32(item.Split('~')[1].Substring(2 * i, 2), 16); } } tmp.PACKSTARTINDEX = startIndex; break; case "AUDIOREBACKSERVERIP": tmp.AUDIOREBACKSERVERIP = item.Split('~')[1]; break; case "AUDIOREBACKPORT": tmp.AUDIOREBACKPORT = Convert.ToInt32(item.Split('~')[1]); break; } } if (tmp.AUDIOREBACKSERVERIP != null && tmp.AUDIOREBACKPORT != null) { string name = Dns.GetHostName(); IPAddress[] ipadrlist = Dns.GetHostAddresses(name); foreach (var item in ipadrlist) { if (item.ToString() == tmp.AUDIOREBACKSERVERIP) { OpenReceiveTool(tmp.AUDIOREBACKSERVERIP, Convert.ToInt32(tmp.AUDIOREBACKPORT)); } } } tmp.Audio_reback_mode = 1;//1 UDP;2 TCP;3串口;其它值预留 现暂时默认设置为udp 20180129 SendbackDetail sendbackDetail = new SendbackDetail(); sendbackDetail.tag = Equipment.FileName; sendbackDetail.Extras = tmp; DataDealHelper.MyEvent(sendbackDetail); } } else if (Msg.Contains("TTS")) { TTSC tmp = new TTSC(); string[] msgItem = Msg.Split('|'); if (msgItem.Length > 0) { foreach (var item in msgItem) { switch (item.Split('~')[0]) { case "PACKETTYPE": tmp.PACKETTYPE = item.Split('~')[1]; break; case "TsCmd_Params": tmp.TsCmd_Params = item.Split('~')[1]; break; case "TsCmd_Mode": tmp.TsCmd_Mode = item.Split('~')[1]; break; case "TsCmd_ValueID": tmp.DeviceIdList = new List <int>(); if (tmp.TsCmd_Mode == "区域") { string strAreaId = item.Split('~')[1]; string[] ids = strAreaId.Split(','); List <int> tt = new List <int>(); for (int i = 0; i < ids.Length; i++) { tt.Add(Convert.ToInt32(ids[i])); } tmp.DeviceIdList = db.AeraCode2DeviceID(tt); } else { string strDeviceID = item.Split('~')[1]; string[] ids = strDeviceID.Split(','); foreach (var id in ids) { tmp.DeviceIdList.Add(Convert.ToInt32(id)); } } break; case "TsCmd_PlayCount": tmp.TsCmd_PlayCount = Convert.ToInt32(item.Split('~')[1]); break; } } tmp.FileID = (SingletonInfo.GetInstance().FileID + 1).ToString("X").PadLeft(4, '0'); SingletonInfo.GetInstance().FileID += 1; SendbackDetail sendbackDetail = new SendbackDetail(); sendbackDetail.tag = Equipment.TTS; sendbackDetail.Extras = tmp; log.Error("收到文本转语音MQ指令"); DataDealHelper.MyEvent(sendbackDetail); } } }
public string GetSequenceCodes() { SingletonInfo.GetInstance().SequenceCodes += 1; return(SingletonInfo.GetInstance().SequenceCodes.ToString().PadLeft(16, '0')); }
/// <summary> /// 播放 /// </summary> /// <returns></returns> public bool AudioPlay(int type, string ParamValue, string TsCmd_ID, string TsCmd_ValueID) { try { HttpServerFrom.SetManager("EBM开始时间: " + AudioModel.PlayingTime + "===>EBM结束时间: " + AudioModel.PlayEndTime, Color.Green); HttpServerFrom.SetManager("播放开始时间: " + AudioModel.PlayingTime + "===>播放结束时间: " + AudioModel.PlayEndTime, Color.Green); HttpServerFrom.SetManager("等待播放" + AudioModel.PlayingContent, Color.Green); EBD ebd = GetEBD(AudioModel.XmlFilaPath); string AreaString = CombinationArea(); ///未播放 AudioPlayState = AudioMessage.AudioPlayState.NotPlay; lock (HttpServerFrom.PlayBackObject) { HttpServerFrom.PlayBack = HttpServerFrom.PlaybackStateType.NotBroadcast; } #region 未播放 PlayStateInterface.NotPlay(TsCmd_ID, AudioModel.XmlFilaPath, "未播放", "1"); #endregion 未播放代码 //播放中 #region 播放中 while (true) { DateTime current = DateTime.Now; Thread.Sleep(500); if (DateTime.Compare(current, AudioModel.PlayingTime) > 0) { HttpServerFrom.SetManager("播放开始", Color.Green); lock (HttpServerFrom.PlayBackObject) { HttpServerFrom.PlayBack = HttpServerFrom.PlaybackStateType.Playback; } AudioPlayState = AudioMessage.AudioPlayState.Playing; bool result = SendMQ.MqSendOrder.sendOrder.SendMq(ebd, type, ParamValue, TsCmd_ID, TsCmd_ValueID); PlayStateInterface.Playing(TsCmd_ID, AudioModel.XmlFilaPath, "播放中", "2", "播发中"); break; } } #endregion 播放中代码 //播放完成 #region 播放完 while (true) { Thread.Sleep(500); if (DateTime.Compare(DateTime.Now, AudioModel.PlayEndTime) < 0)//结束时间大于当前时间 { string MediaSql = "select TsCmd_ID,TsCmd_ExCute from TsCmdStore where TsCmd_ID='" + TsCmd_ID + "'"; DataTable dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia.Rows[0]["TsCmd_ExCute"].ToString().Contains("播放完毕")) { HttpServerFrom.SetManager("播放结束", Color.Green); lock (HttpServerFrom.PlayBackObject) { HttpServerFrom.PlayBack = HttpServerFrom.PlaybackStateType.PlayOut; } AudioPlayState = AudioMessage.AudioPlayState.PlayingOver; PlayStateInterface.PlayOver(TsCmd_ID, AudioModel.XmlFilaPath, "播放完成", "3", "开机/运行中"); SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); break; } } else { lock (HttpServerFrom.PlayBackObject) { HttpServerFrom.PlayBack = HttpServerFrom.PlaybackStateType.PlayOut; } HttpServerFrom.SetManager("播放结束", Color.Green); //没播放完 但是文件时间到了 string strSql = ""; if (type == 1) { strSql = string.Format("update PLAYRECORD set PR_REC_STATUS = '{0}' where PR_SourceID='{1}'", "删除", TsCmd_ID); mainForm.dba.UpdateDbBySQL(strSql); string strSqlTsCmdStore = string.Format("update TsCmdStore set TsCmd_ExCute = '{0}' where TsCmd_ID='{1}'", "播放完毕", TsCmd_ID); mainForm.dba.UpdateDbBySQL(strSqlTsCmdStore); } else if (type == 2) { strSql = string.Format("update PLAYRECORD set PR_REC_STATUS = '{0}' ", "删除"); mainForm.dba.UpdateDbBySQL(strSql); } SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); break; } } #endregion 播放完代码 GC.Collect(); return(true); } catch (Exception ex) { AudioPlayState = AudioMessage.AudioPlayState.error; Log.Instance.LogWrite(ex.Message); } return(false); }
private void skinDataGridView_Record_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { switch (e.ColumnIndex) { case 0: MessageShowDlg = new MessageShowForm { label1 = { Text = @"确认处理?" } }; MessageShowDlg.ShowDialog(); if (MessageShowDlg.IsSure) { DataGridViewRow dgvR = skinDataGridView_Record.Rows[e.RowIndex]; RecordDetail selectone = (RecordDetail)dgvR.Tag; selectone.DealFlag = 1; //更新数据库 SingletonInfo.GetInstance().DataBase.UpdateRecorde(selectone); dgvR.Cells[0].Value = "已处理"; dgvR.Cells[0].ReadOnly = true; //通知到主显示表skinDataGridView_Main this.Invoke(new Action(() => { foreach (DataGridViewRow item in skinDataGridView_Main.Rows) { if (item.Cells[1].Value.ToString() == selectone.RecordId) { item.Tag = selectone; item.Cells[0].Value = "已处理"; } } })); } break; case 2: DataGridViewRow dgvRS = skinDataGridView_Record.Rows[e.RowIndex]; RecordDetail selected = (RecordDetail)dgvRS.Tag; EBMDetailShowDlg = new EBMDetailShowForm(selected); EBMDetailShowDlg.ShowDialog(); break; case 9: MessageShowDlg = new MessageShowForm { label1 = { Text = @"打开链接?" } }; MessageShowDlg.ShowDialog(); if (MessageShowDlg.IsSure) { DataGridViewRow dgvR = skinDataGridView_Record.Rows[e.RowIndex]; RecordDetail selectone = (RecordDetail)dgvR.Tag; string path = Path.GetDirectoryName(selectone.SavePath); System.Diagnostics.Process.Start(path); } break; } } catch (Exception) { throw; } }
private void btn_Search_Click(object sender, EventArgs e) { try { List <RecordDetail> FindedList = new List <RecordDetail>(); switch (cmb_SearchType.SelectedIndex) { case 0: //消息媒体 int MediumType = Convert.ToInt32(cmb_MediumType.SelectedValue); switch (MediumType) { case 1: //mp3 FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.MediumType == "mp3").ToList(); break; case 2: //文本 FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.MediumType == "文本").ToList(); break; } break; case 1: //开始时间 foreach (RecordDetail item in SingletonInfo.GetInstance().RecordDetailList) { DateTime starttime = Convert.ToDateTime(item.MsgStartTime); if (DateTime.Compare(starttime, dateTimePicker1.Value) > 0 && DateTime.Compare(starttime, dateTimePicker2.Value) < 0) { FindedList.Add(item); } } break; case 2: //事件类型码 FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.EventType == txt_EventType.Text.Trim()).ToList(); break; case 3: //事件级别 int Severity = Convert.ToInt32(cmb_Severity.SelectedValue); switch (Severity) { case 0: FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.Severity == "0").ToList(); break; case 1: FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.Severity == "1").ToList(); break; case 2: FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.Severity == "2").ToList(); break; case 3: FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.Severity == "3").ToList(); break; case 4: FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.Severity == "4").ToList(); break; } break; case 4: //区域码 FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.AreaCode == txt_AreaCode.Text.Trim()).ToList(); break; case 5: //文本关键字 foreach (RecordDetail item in SingletonInfo.GetInstance().RecordDetailList) { if (!string.IsNullOrEmpty(item.TextContent)) { if (item.TextContent.Contains(txt_TextContent.Text.Trim())) { FindedList.Add(item); } } } break; case 6: // 消息处理未处理 int MessageStatus = Convert.ToInt32(cmb_MessageStatus.SelectedValue); switch (MessageStatus) { case 1: //已处理 FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.DealFlag == 1).ToList(); break; case 2: //未处理 FindedList = SingletonInfo.GetInstance().RecordDetailList.Where(x => x.DealFlag == 0).ToList(); break; } break; } ShowSelectRecord(FindedList); } catch (Exception) { throw; } }
public static string GetEquipmentValueString(Equipment eq, object value) { try { switch (eq) { case Equipment.Open: case Equipment.Close: case Equipment.BitOperationOpen: case Equipment.BitOperationClose: case Equipment.BitOperationUn: case Equipment.ByteOpAddition: case Equipment.ByteOpSubtraction: case Equipment.UShortOpAddition: case Equipment.UShortOpSubtraction: case Equipment.SingleOpAddition: case Equipment.SingleOpSubtraction: break; case Equipment.FMFreList: //byte var freList = (byte[])value; string[] sbFre = new string[freList[0]]; for (int i = 0; i < freList[0]; i++) { //sbFre[i] = ("频率" + freList[i * 3 + 1].ToString() + ":" + (ushort)(freList[i * 3 + 3] | freList[i * 3 + 2] << 8) * 10 + "KHz"); //if (SingletonInfo.GetInstance().factorycode == "1" && SingletonInfo.GetInstance().TerminalType == true && SingletonInfo.GetInstance().Version == "2.0") //{ // //按条件判断解析方式 当厂家代码为01 终端表 02/03 版本2.0 采用以下解析方式 // sbFre[i] = ((freList[i * 3 + 3] << 8 | freList[i * 3 + 2]) * 10).ToString();//按照陈良及段强的建议修改 20171128 //} //else //{ // sbFre[i] = ((freList[i * 3 + 3] | freList[i * 3 + 2] << 8) * 10).ToString(); //} 测试注释20171203 // sbFre[i] = ((freList[i * 3 + 3] | freList[i * 3 + 2] << 8) * 10).ToString(); sbFre[i] = ((freList[i * 3 + 3] << 8 | freList[i * 3 + 2]) * 10).ToString();//按照陈良及段强的建议修改 20171128 } return(string.Join(",", sbFre)); case Equipment.FMSignalStrength: //byte var signalStrengthList = (byte[])value; string[] sbSignal = new string[signalStrengthList[0]]; for (int i = 0; i < signalStrengthList[0]; i++) { //sbSignal[i] = ("强度" + signalStrengthList[i * 2 + 1].ToString() + ":" + Convert.ToString(signalStrengthList[i * 2 + 2], 10) + "dB"); sbSignal[i] = Convert.ToString(signalStrengthList[i * 2 + 2], 10); } return(string.Join(",", sbSignal)); case Equipment.PlayType: //byte var bitPlayType = Convert.ToString((byte)value, 2).PadLeft(8, '0'); var highPlayType = Convert.ToByte(bitPlayType.Substring(0, 4), 2); var lowPlayType = Convert.ToByte(bitPlayType.Substring(4, 4), 2); StringBuilder outStrPlayType = new StringBuilder(); switch (highPlayType) { case 1: outStrPlayType.Append("省"); break; case 2: outStrPlayType.Append("市"); break; case 3: outStrPlayType.Append("县"); break; case 4: outStrPlayType.Append("乡"); break; case 5: outStrPlayType.Append("村"); break; } switch (lowPlayType) { case 1: outStrPlayType.Append("一级(特别重大)"); break; case 2: outStrPlayType.Append("二级(重大)"); break; case 3: outStrPlayType.Append("三级(较大)"); break; case 4: outStrPlayType.Append("四级(一般)"); break; } return(outStrPlayType.ToString()); case Equipment.Versions: //byte var versions = value as byte[]; return(string.Format("{0}.{1} {2}.{3}", Convert.ToString(versions[1], 16), Convert.ToString(versions[0], 16).PadLeft(2, '0'), Convert.ToString(versions[3], 16), Convert.ToString(versions[2], 16).PadLeft(2, '0'))); // 测试注释 20171203 //return string.Format("{0}.{1} {2}.{3}", Convert.ToString(versions[0], 16), Convert.ToString(versions[1], 16), // Convert.ToString(versions[2], 16), Convert.ToString(versions[3], 16)); case Equipment.DigitalTVRadioFrequencyMode: //byte return((byte)value == 0 ? "DTMB" : "DVB-C"); case Equipment.DigitalTVRadioFrequencyFre: //Uint16 return(value.ToString()); case Equipment.QAMType: //byte return(EnumHelper.GetEnumDescription((QAMEnum)((byte)value))); case Equipment.BroadcastVolume: //byte case Equipment.BroadcastTimeout: //byte (秒) case Equipment.CurrentModeSignalQuality: //byte case Equipment.CurrentModeSignalStrength: //byte (dB) return(value.ToString()); case Equipment.RemoteControlCenterIPAddress: //IP return(((byte[])value).ToArrayString(".")); case Equipment.RemoteControlCenterPort: //Uint16 return(value.ToString()); case Equipment.AudioServerIPAddress: //IP return(((byte[])value).ToArrayString(".")); case Equipment.AudioServerPort: //Uint16 return(value.ToString()); case Equipment.CallWay: //byte return(EnumHelper.GetEnumDescription((CallWayEnum)((byte)value))); case Equipment.FileName: //byte[] return(Encoding.ASCII.GetString((byte[])value)); case Equipment.RecordingDuration: //Uint32 case Equipment.PacksTotalNumber: //Uint32 case Equipment.RebackFileType: //byte case Equipment.PackStartIndex: //Uint32 case Equipment.LastPacksNuber: //Uint32 return(value.ToString()); case Equipment.LogicalAddress: //byte case Equipment.PhysicalAddress: //byte return(((byte[])value).ToNumberArrayString("", 16)); case Equipment.BroadcastState: //byte switch ((byte)value) { case 0x81: return("播放上级日常广播"); case 0x82: return("播放上级应急广播"); case 0x83: return("本地插播"); case 0x84: return("播放本地流程广播"); case 0x00: return("待机"); default: return("待机"); } case Equipment.TerminalType: //byte string terminaltypestr = EnumHelper.GetEnumDescription((TerminalTypeEnum)((byte)value)); if (terminaltypestr == "3" || terminaltypestr == "2") { SingletonInfo.GetInstance().TerminalType = true; } return(terminaltypestr); case Equipment.Longitude: //Float case Equipment.Latitude: //Float return(((float)value).ToString("f7")); case Equipment.RebackMode: //byte return((byte)value == 1 ? "GPRS" : "IP 网络"); case Equipment.NetworkMode: //byte return((byte)value == 1 ? "局域网" : "跨路由"); case Equipment.Voltage220: //Float (V) case Equipment.Voltage24: //Float (V) case Equipment.Voltage12: //Float (V) case Equipment.AmplifierElectricCurrent: //Float (A) return(((float)value).ToString("f2")); case Equipment.LocalHost: //IP case Equipment.SubnetMask: //IP case Equipment.DefaultGateway: //IP return(((byte[])value).ToArrayString(".")); case Equipment.AudioReback: //byte[] return(string.Empty); case Equipment.AudioRebackProtocol: //byte return(EnumHelper.GetEnumDescription((AudioRebackProtocol)((byte)value))); case Equipment.RecordingCategory: //byte return(EnumHelper.GetEnumDescription((RecordingCategory)((byte)value))); case Equipment.StartPackageNumber: //uint return(value.ToString()); case Equipment.terminal2serverhandshake: return(value.ToString()); } return(value.ToString()); } catch { return(null); } }
/// <summary> /// 数据存储到内存 /// </summary> public void SaveStatus() { EquipmentDetail detail; NSEquipmentDetail detail_NS; while (this.isRun) { try { if (SingletonInfo.GetInstance().ProtocolCode == "2") { #region 处理图南协议的 if (!this.afterAnalysisQueue.IsEmpty) { this.afterAnalysisQueue.TryDequeue(out detail); if (detail != null && !IsHeartBeat(detail)) { if (detail.FileName != null && detail.FileName.Length > 0 && Enum.IsDefined(typeof(RecordingCategory), detail.RecordingCategory)) { ThreadPool.QueueUserWorkItem(delegate { if (this.db != null) { this.db.InsertOrUpdateAudioRecorde(detail); } }); } else { string[] fmFreList = detail.FMFreListFormat.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries); string[] fmSigStrength = detail.FMSignalStrengthFormat.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries); lock (this.dtStatus.Rows.SyncRoot) { DataRow[] rows2 = this.dtStatus.Select("srv_physical_code='" + detail.PhysicalAddressFormat + "'"); if (rows2 != null && rows2.Length > 0) { DataRow[] array = rows2; foreach (DataRow item2 in array) { for (int j = this.dtStatus.Rows.Count - 1; j >= 0; j--) { if (this.dtStatus.Rows[j]["srv_physical_code"] == item2["srv_physical_code"]) { this.dtStatus.Rows[j].Delete(); } } this.dtStatus.AcceptChanges(); } } this.dtStatus.Rows.Add(0, detail.PhysicalAddressFormat, (detail.BroadcastStateFormat == "待机") ? "关机" : "开机", detail.Voltage220Format, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, (fmFreList.Length > 0) ? fmFreList[0] : "0", (fmSigStrength.Length > 0) ? fmSigStrength[0] : "0", (fmFreList.Length > 1) ? fmFreList[1] : "0", (fmSigStrength.Length > 1) ? fmSigStrength[1] : "0", DBNull.Value, DBNull.Value, detail.LogicalAddressFormat, detail.PhysicalAddressFormat, DBNull.Value, DBNull.Value, DBNull.Value, detail.SrvTime); } lock (this.dtStatusNew.Rows.SyncRoot) { DataRow[] rows = this.dtStatusNew.Select("srv_physical_code='" + detail.PhysicalAddressFormat + "'"); if (rows != null && rows.Length > 0) { DataRow[] array2 = rows; foreach (DataRow item in array2) { for (int i = this.dtStatusNew.Rows.Count - 1; i >= 0; i--) { if (this.dtStatusNew.Rows[i]["srv_physical_code"] == item["srv_physical_code"]) { this.dtStatusNew.Rows[i].Delete(); } } this.dtStatusNew.AcceptChanges(); } } this.dtStatusNew.Rows.Add(0, detail.PhysicalAddressFormat, detail.BroadcastStateFormat, detail.Voltage220Format, (fmFreList.Length > 0) ? fmFreList[0] : "0", (fmSigStrength.Length > 0) ? fmSigStrength[0] : "0", (fmFreList.Length > 1) ? fmFreList[1] : "0", (fmSigStrength.Length > 1) ? fmSigStrength[1] : "0", detail.LogicalAddressFormat, detail.PhysicalAddressFormat, detail.SrvTime, detail.PlayTypeFormat, detail.VersionsFormat, detail.DigitalTVRadioFrequencyModeFormat, detail.DigitalTVRadioFrequencyFreFormat, detail.BroadcastVolumeFormat, detail.CurrentModeSignalQualityFormat, detail.CurrentModeSignalStrengthFormat, detail.RemoteControlCenterIPAddressFormat, detail.RemoteControlCenterPortFormat, detail.AudioServerIPAddressFormat, detail.AudioServerPortFormat, detail.CallWayFormat, detail.FileNameFormat, detail.RecordingDurationFormat, detail.PacksTotalNumberFormat, detail.RebackFileTypeFormat, detail.PackStartIndexFormat, detail.LastPacksNuberFormat, detail.TerminalTypeFormat, detail.LongitudeFormat, detail.LatitudeFormat, detail.RebackModeFormat, detail.NetworkModeFormat, detail.Voltage24Format, detail.Voltage12Format, detail.AmplifierElectricCurrentFormat, detail.LocalHostFormat, detail.SubnetMaskFormat, detail.DefaultGatewayFormat, detail.FactoryName); int count = this.dtStatusNew.Rows.Count; this.SaveEqStatus(); } } } } else { this.autoEvent.WaitOne(); } #endregion } else { //处理国标协议 if (!this.afterAnalysisQueue_NS.IsEmpty) { this.afterAnalysisQueue_NS.TryDequeue(out detail_NS); if (detail_NS != null) { if (string.IsNullOrEmpty(detail_NS.ResourceCode)) { db.UpdateSrvEquipmentStatusBatch_Nation(detail_NS); } else { lock (this.dtsrvStatus_national.Rows.SyncRoot) { DataRow[] rows2 = this.dtsrvStatus_national.Select("srv_physical_code='" + detail_NS.srv_physical_code + "'"); if (rows2 != null && rows2.Length > 0) { DataRow[] array = rows2; foreach (DataRow item2 in array) { for (int j = this.dtsrvStatus_national.Rows.Count - 1; j >= 0; j--) { if (this.dtsrvStatus_national.Rows[j]["srv_physical_code"] == item2["srv_physical_code"]) { this.dtsrvStatus_national.Rows[j].Delete(); } } this.dtsrvStatus_national.AcceptChanges(); } } this.dtsrvStatus_national.Rows.Add(detail_NS.ResourceCode, detail_NS.TerminalVolume, detail_NS.TerminalAddressInfo, detail_NS.RebackInfo, detail_NS.srv_physical_code, detail_NS.WorkStatus, detail_NS.FaultCode, detail_NS.DeviceTypeCode, detail_NS.HardwareVersionNum, detail_NS.SoftwareVersionNum, detail_NS.FMStatus, detail_NS.DVBCStatus, detail_NS.DTMBStatus, detail_NS.DVBC_FreqInfo, detail_NS.DTMB_FreqInfo, detail_NS.FM_FreqScanList, detail_NS.FM_CurrentFreqInfo, detail_NS.FM_KeepOrderInfo); this.SaveEqStatus(); } } } } else { this.autoEvent.WaitOne(); } } } catch (Exception ex) { // DataDealHelper.log.Error("数据缓存异常-" + this.afterAnalysisQueue.Count, ex); } } }