Exemplo n.º 1
0
        private string CombinationalLogicCode(string AreaCode, string number)
        {
            string builder = "";

            number = GetNuberToString(number);
            // 63301080000000314010401
            string level              = "6";
            string ResourceType       = "0314";
            string ResourceTypeNumber = "01";


            // 子类型
            string Subtype   = "04";
            string logicCode = level + AreaCode + ResourceType + ResourceTypeNumber + Subtype + number;

            if (logicCode.Length != 23 && LogicalData.LogicalCode.Length == 23)
            {
                logicCode = LogicalData.LogicalCode;
            }
            logicCode = GetLogicalCodel(logicCode);

            if (logicCode.Length == 23)
            {
                if (!UpdateLogicalCode(LogicalData.srvID, logicCode))
                {
                    ServerForm.SetManager("更改逻辑编码失败", System.Drawing.Color.Red);
                }
                return(logicCode);
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 组合逻辑码
        /// </summary>

        public string GetLogicalAndAddDataBase()
        {
            string logicalCode = GetGBCode();

            int number = GetGBCodeCount(LogicalData.srvAreaID, null);

            if (number > 99)
            {
                ServerForm.SetManager("资源已满,查看是否要进行变更", System.Drawing.Color.Red);
            }
            return(CombinationalLogicCode(logicalCode, number.ToString()));
        }
Exemplo n.º 3
0
        public string AddPostQueue(string address, string FileName)
        {
            if (!string.IsNullOrEmpty(address) && !string.IsNullOrEmpty(FileName))
            {
                PostModel postInfo = new PostModel();
                postInfo.Address  = address;
                postInfo.FileName = FileName;
                Queueinterface <PostModel> .SendQueue.Enqueue(postInfo);

                ServerForm.SetManager("队列添加成功:" + postInfo.FileName, Color.Green);
                return("1");
            }
            else
            {
                ServerForm.SetManager("队列添加失败:" + FileName, Color.Red);
                return("2");
            }
        }
Exemplo n.º 4
0
 private void PostSend(PostModel postModel)
 {
     try
     {
         string result = HttpSendFile.UploadFilesByPost(postModel.Address, postModel.FileName);
         if (result != "0")
         {
             ServerForm.SetManager("发送成功:" + postModel.FileName, Color.Green);
         }
         else
         {
             ServerForm.SetManager("发送失败" + postModel.FileName, Color.Red);
         }
     }
     catch (Exception ex)
     {
         ServerForm.SetManager("发送失败" + postModel.FileName + "失败原因:" + ex.Message, Color.Red);
         Log.Instance.LogWrite("发送队列异常:" + ex.ToString());
     }
 }
        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>
        /// <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);
        }