Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PutEquipmentDetail(int id, EquipmentDetail equipmentDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != equipmentDetail.Id)
            {
                return(BadRequest());
            }

            db.Entry(equipmentDetail).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EquipmentDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public EquipmentDetail ShowEquipment(int equipmentId)
        {
            var form = new EquipmentDetail();

            form.ShowObject(equipmentId);
            return(form);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新或插入录音记录
 /// </summary>
 /// <param name="detail"></param>
 public void InsertOrUpdateAudioRecorde(EquipmentDetail detail)
 {
     if (detail != null)
     {
         string sql = "select filename from Srv_AudioRecorde where filename='" + detail.FileNameFormat + "'";
         try
         {
             SqlCommand cmd = new SqlCommand(sql, this.conn);
             if (this.conn.State != ConnectionState.Open)
             {
                 this.conn.Open();
             }
             object rowCount   = cmd.ExecuteScalar();
             string sqlUpdate2 = "";
             sqlUpdate2 = (cmd.CommandText = ((rowCount == null) ? string.Format("insert into Srv_AudioRecorde (recordingcategory,rebackfiletype,recording_duration,packs_totalnumber,srv_time,srv_physical_code,filename) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", detail.RecordingCategoryFormat, detail.RebackFileTypeFormat, detail.RecordingDurationFormat, detail.PacksTotalNumberFormat, detail.SrvTime, detail.PhysicalAddressFormat, detail.FileNameFormat) : string.Format("update Srv_AudioRecorde set recordingcategory='{0}', rebackfiletype='{1}', recording_duration='{2}', packs_totalnumber='{3}', srv_time='{4}' where filename='{5}'", detail.RecordingCategoryFormat, detail.RebackFileTypeFormat, detail.RecordingDurationFormat, detail.PacksTotalNumberFormat, detail.SrvTime, detail.FileNameFormat)));
             cmd.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             DBHelper.log.Error("更新或插入录音记录异常", ex);
         }
         finally
         {
             this.conn.Close();
         }
     }
 }
        /// <summary>
        /// 判断是否是心跳包  心跳包不入数据库   新增于20180302
        /// </summary>
        /// <param name="detail"></param>
        /// <returns></returns>
        public bool IsHeartBeat(EquipmentDetail detail)
        {
            bool flag = false;

            if (detail.AmplifierElectricCurrentFormat == "" && detail.AudioReback == null && detail.AudioRebackFormat == "" && detail.AudioRebackProtocolFormat == "" && detail.AudioServerIPAddress == null && detail.AudioServerIPAddressFormat == "" && detail.AudioServerPortFormat == "" && detail.BroadcastStateFormat == "" && detail.BroadcastTimeoutFormat == "" && detail.BroadcastVolumeFormat == "" && detail.CallWayFormat == "" && detail.CurrentModeSignalQualityFormat == "" && detail.CurrentModeSignalStrengthFormat == "" && detail.DefaultGateway == null && detail.DefaultGatewayFormat == "" && detail.DigitalTVRadioFrequencyFreFormat == "" && detail.DigitalTVRadioFrequencyModeFormat == "" && detail.FileName == null && detail.FileNameFormat == "" && detail.FileNameFormat == "" && detail.FMFreList == null && detail.FMFreListFormat == "" && detail.FMSignalStrength == null && detail.FMSignalStrengthFormat == "" && detail.IPAddressTmp == null && detail.LastPacksNuberFormat == "" && detail.LatitudeFormat == "" && detail.LocalHost == null && detail.LocalHostFormat == "" && detail.LogicalAddressFormat == "" && detail.LongitudeFormat == "" && detail.NetworkModeFormat == "" && detail.PackStartIndexFormat == "" && detail.PacksTotalNumberFormat == "" && detail.PlayTypeFormat == "" && detail.QAMTypeFormat == "" && detail.RebackFileTypeFormat == "" && detail.RebackModeFormat == "" && detail.RecordingCategoryFormat == "" && detail.RecordingDurationFormat == "" && detail.RemoteControlCenterIPAddress == null && detail.RemoteControlCenterIPAddressFormat == "" && detail.RemoteControlCenterPortFormat == "" && detail.RemotePortTmpFormat == "" && detail.StartPackageNumberFormat == "" && detail.SubnetMask == null && detail.SubnetMaskFormat == "" && detail.Versions == null && detail.VersionsFormat == "" && detail.Voltage12Format == "" && detail.Voltage220Format == "" && detail.Voltage24Format == "")
            {
                flag = true;
            }

            return(flag);
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> GetEquipmentDetail(int id)
        {
            EquipmentDetail equipmentDetail = await db.EquipmentDetail.FindAsync(id);

            if (equipmentDetail == null)
            {
                return(NotFound());
            }

            return(Ok(equipmentDetail));
        }
        public async Task <IActionResult> PostEquipmentDetail([FromBody] EquipmentDetail equipmentDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Details.Add(equipmentDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEquipmentDetail", new { id = equipmentDetail.Id }, equipmentDetail));
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> PostEquipmentDetail(EquipmentDetail equipmentDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.EquipmentDetail.Add(equipmentDetail);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = equipmentDetail.Id }, equipmentDetail));
        }
Ejemplo n.º 8
0
        public async Task <IHttpActionResult> DeleteEquipmentDetail(int id)
        {
            EquipmentDetail equipmentDetail = await db.EquipmentDetail.FindAsync(id);

            if (equipmentDetail == null)
            {
                return(NotFound());
            }

            db.EquipmentDetail.Remove(equipmentDetail);
            await db.SaveChangesAsync();

            return(Ok(equipmentDetail));
        }
Ejemplo n.º 9
0
        public string PostEquipmentDetailDomainService(EquipmentDetail equipmentDetail)
        {
            if (equipmentDetail.Equipments.Marca == "HP")
            {
                return("No se puede ingresar la marca HP");
            }

            if (equipmentDetail.Tipo == "Dañado")
            {
                return("No se puede ingresar equipo de tipo Dañado");
            }

            return(null);
        }
        public async Task <IActionResult> PutEquipmentDetail([FromRoute] int id, [FromBody] EquipmentDetail equipmentDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != equipmentDetail.Id)
            {
                return(BadRequest());
            }

            _context.Entry(equipmentDetail).State = EntityState.Modified;

            return(NoContent());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 更新或插入录音记录
        /// </summary>
        /// <param name="detail"></param>
        public void InsertOrUpdateAudioRecorde(EquipmentDetail detail)
        {
            if (detail == null)
            {
                return;
            }

            string sql = "select filename from Srv_AudioRecorde where filename='" + detail.FileNameFormat + "'";

            try
            {
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                var    rowCount  = cmd.ExecuteScalar();
                string sqlUpdate = "";
                if (rowCount != null)
                {
                    sqlUpdate = string.Format("update Srv_AudioRecorde set recordingcategory='{0}', rebackfiletype='{1}', " +
                                              "recording_duration='{2}', packs_totalnumber='{3}', srv_time='{4}' where filename='{5}'",
                                              detail.RecordingCategoryFormat, detail.RebackFileTypeFormat, detail.RecordingDurationFormat,
                                              detail.PacksTotalNumberFormat, detail.SrvTime, detail.FileNameFormat);
                }
                else
                {
                    sqlUpdate = string.Format("insert into Srv_AudioRecorde " +
                                              "(recordingcategory,rebackfiletype,recording_duration,packs_totalnumber,srv_time,srv_physical_code,filename) " +
                                              "values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}')",
                                              detail.RecordingCategoryFormat, detail.RebackFileTypeFormat, detail.RecordingDurationFormat,
                                              detail.PacksTotalNumberFormat, detail.SrvTime, detail.PhysicalAddressFormat, detail.FileNameFormat);
                }
                cmd.CommandText = sqlUpdate;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                log.Error("更新或插入录音记录异常", ex);
            }
            finally { conn.Close(); }
        }
Ejemplo n.º 12
0
 public IEnumerable <EquipmentDetail> GetAllEquipment()
 {
     try
     {
         EquipmentDetail objOutPut = new EquipmentDetail();
         _repo = new EquipmentRepo();
         var lst = _repo.GetAllEquipment();
         if (lst != null)
         {
             return(lst.ToList());
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 解析终端设备工作状态
        /// </summary>
        /// <param name="data"></param>
        /// <returns>设备状态</returns>
        private EquipmentDetail HandlerQueue(EquipmentSource datare)
        {
            byte[] data = datare.RawData;
            if (data.Length < 13)
            {
                return(null);
            }

            EquipmentDetail equipmentDetail = new EquipmentDetail();

            try
            {
                equipmentDetail.IPAddressTmpFormat = datare.RemoteIPTmp;
                equipmentDetail.RemotePortTmp      = (ushort)datare.RemotePortTmp;
                log.Info("开始解析数据-" + data.Length);
                equipmentDetail.SrvTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                FeaturesCode fc;
                string       outMsg; //返回的错误信息,正确解析则返回空
                var          detail = EquipmentHelper.HandleData(data, out fc, out outMsg);

                if (detail != null && string.IsNullOrWhiteSpace(outMsg) && detail.ContainsKey(Equipment.PhysicalAddress))
                {
                    var msgType = Convert.ToChar(data[0]);
                    if (msgType == '&')
                    {
                        //帧头占12字节
                        equipmentDetail.HeaderData = data.Take(12).ToArray();
                    }
                    else if (msgType == '%')
                    {
                        //帧头占18字节
                        equipmentDetail.HeaderData = data.Take(18).ToArray();
                    }
                    byte[] address = detail[Equipment.PhysicalAddress];//每个包必须有物理码

                    string pp = "";
                    for (int i = 0; i < address.Length; i++)
                    {
                        pp += address[i].ToString("X2");// bytes[i].ToString("X2").PadLeft(2, '0');
                    }


                    clientsConn.AddOrUpdate(pp, datare.ConnId, (key, value) => { return(value = datare.ConnId); });

                    clientsHeadData.AddOrUpdate(pp, equipmentDetail.HeaderData, (key, value) => { return(value = equipmentDetail.HeaderData); });
                    #region 解析EquipmentDetail
                    foreach (var key in detail.Keys)
                    {
                        if (key.ToString() == "RemoteControlCenterIPAddress")
                        {
                            int ppr = 0;
                            int ffp = 1;
                            int fs  = ppr + ffp;
                            Console.Write("");
                        }
                        var proInfo = typeof(EquipmentDetail).GetProperty(key.ToString());
                        if (null != proInfo)
                        {
                            var eqValue = EquipmentHelper.GetEquipmentValue(key, detail[key], equipmentDetail);
                            proInfo.SetValue(equipmentDetail, eqValue, null);
                            typeof(EquipmentDetail).GetProperty(key.ToString() + "Format").SetValue(equipmentDetail,
                                                                                                    EquipmentHelper.GetEquipmentValueString(key, eqValue), null);
                        }
                    }
                    #endregion

                    var dataHeader = EquipmentHelper.HandleHeader(EquipmentHelper.GetFrameHeader(data));
                    if (dataHeader != null)
                    {
                        equipmentDetail.FactoryName = dataHeader[FrameHeaderEnum.FactoryNumber];
                    }
                }
                else
                {
                    equipmentDetail = null;
                }
            }
            catch (Exception ex)
            {
                log.Error("设备详细信息解析异常", ex);
                equipmentDetail = null;
            }
            return(equipmentDetail);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 终端和服务器握手  应答发送
        /// </summary>
        /// <param name="data"></param>
        private void SendDataResponse(object data)
        {
            SendbackDetail SendObject = (SendbackDetail)data;

            switch ((Equipment)SendObject.tag)
            {
            case Equipment.terminal2serverhandshake:
            {
                EquipmentDetail ob = SendObject.Rebackdata;
                byte[]          SendCommandShakehandsList = new byte[21] {
                    38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                };

                for (int m = 0; m < 9; m++)
                {
                    SendCommandShakehandsList[1 + m] = ob.HeaderData[1 + m];
                }
                SendCommandShakehandsList[10] = ob.HeaderData[16];
                string datatmp2 = "10040041030102";        //20180125应朱红彪需求 数据长度的大小端转换 高低位换位置  以后对外对接可能存在问题
                string crcdata  = "10040041030102";
                datatmp2 += HexHelper.crc16(crcdata);      //算CRC
                byte[] byteArray = new byte[datatmp2.Length / 2];
                for (int l = 0; l < byteArray.Length; l++)
                {
                    SendCommandShakehandsList[12 + l] = (byte)Convert.ToInt32(datatmp2.Substring(l * 2, 2).ToString(), 16);
                }
                string physicalAddress = ob.PhysicalAddressFormat;
                IntPtr connId          = default(IntPtr);

                if (physicalAddress != null)
                {
                    if (this.dataHelper.Clients.TryGetValue(physicalAddress, out connId))
                    {
                        byte[] bytes2 = SendCommandShakehandsList;
                        this.netServer.Send(connId, bytes2, bytes2.Length);

                        //日志打印  20180305
                        log.Info("握手应答指令已发送");
                    }
                }
                break;
            }

            case Equipment.OnlineUpdate:    //在线升级指令下发
                UpdateCode uc = (UpdateCode)SendObject.Extras;
                if (uc.LIST.Count > 0)
                {
                    foreach (var item in uc.LIST)
                    {
                        if (Encoding.Default.GetBytes(uc.HTTPURL).Length < 128)    //url长度小于128字节
                        {
                            byte[] HeaderData = new byte[] { };

                            if (!this.dataHelper.ClientHD.TryGetValue(item, out HeaderData))
                            {
                                break;
                            }

                            string      codestr  = uc.UPGRADEMODE + "," + item + "," + uc.OLDVERSION + "," + uc.NEWVERSION + "," + uc.HTTPURL;
                            byte[]      DataList = Encoding.Default.GetBytes(codestr);//字符串转ASCII
                            List <byte> SendCommandListUpdate = new List <byte>();
                            SendCommandListUpdate.Add(38);

                            for (int k = 0; k < 9; k++)
                            {
                                SendCommandListUpdate.Add(HeaderData[1 + k]);    //9位资源码
                            }

                            SendCommandListUpdate.Add(HeaderData[16]);    //协议版本号

                            //补全整个发送帧
                            for (int i = 0; i < 6 + 2 + DataList.Length + 1; i++)
                            {
                                SendCommandListUpdate.Add(0);
                            }

                            byte[] sendcommand = SendCommandListUpdate.ToArray();

                            string datalenth = (DataList.Length + 3).ToString("x").PadLeft(4, '0');

                            sendcommand[12] = (byte)Convert.ToInt32("10", 16);
                            sendcommand[13] = (byte)Convert.ToInt32(datalenth.Substring(2, 2), 16);
                            sendcommand[14] = (byte)Convert.ToInt32(datalenth.Substring(0, 2), 16);
                            sendcommand[15] = (byte)Convert.ToInt32("42", 16);
                            sendcommand[16] = 3;
                            sendcommand[17] = (byte)DataList.Length;

                            for (int l = 0; l < DataList.Length; l++)
                            {
                                sendcommand[18 + l] = DataList[l];
                            }
                            sendcommand = HexHelper.crc16(sendcommand, 12);
                            IntPtr connIdFile = default(IntPtr);
                            if (this.dataHelper.Clients.TryGetValue(item, out connIdFile))
                            {
                                byte[] bytes = sendcommand;


                                var           str    = DateTime.Now.ToString();
                                var           encode = Encoding.UTF8;
                                StringBuilder ret    = new StringBuilder();
                                foreach (byte b in bytes)
                                {
                                    //{0:X2} 大写
                                    ret.AppendFormat("{0:x2}", b);
                                }
                                string hex = ret.ToString();



                                this.netServer.Send(connIdFile, bytes, bytes.Length);

                                //日志打印  20180305
                                log.Info("在线升级指令已发送:" + ret);
                            }
                        }
                    }
                }

                break;

            case Equipment.FileName:    //文件调取

                //根据物理码找到 曾经有过的连接 和包头

                //  TransferCode select = (TransferCode)SendObject.DataEntity;
                TransferCode select       = (TransferCode)SendObject.Extras;
                byte[]       HeadDataFile = new byte[] { };

                if (!this.dataHelper.ClientHD.TryGetValue(select.SRVPHYSICALCODE, out HeadDataFile))
                {
                    break;
                }
                List <byte> SendCommandFilesList2 = new List <byte>();
                SendCommandFilesList2.Add(38);

                for (int k = 0; k < 9; k++)
                {
                    SendCommandFilesList2.Add(HeadDataFile[1 + k]); //9位资源码
                }
                SendCommandFilesList2.Add(HeadDataFile[16]);        //协议版本号

                SendCommandFilesList2.Add(0);                       //预留字段
                //补全整个发送帧
                for (int i = 0; i < 55; i++)
                {
                    SendCommandFilesList2.Add(0);
                }


                byte[] sendcommandFile = SendCommandFilesList2.ToArray();
                sendcommandFile[12] = (byte)Convert.ToInt32("10", 16);

                string datalenthFile = (50).ToString("x").PadLeft(4, '0');
                sendcommandFile[12] = (byte)Convert.ToInt32("03", 16);
                sendcommandFile[13] = (byte)Convert.ToInt32(datalenthFile.Substring(2, 2), 16);
                sendcommandFile[14] = (byte)Convert.ToInt32(datalenthFile.Substring(0, 2), 16);
                sendcommandFile[15] = (byte)Convert.ToInt32("17", 16);
                sendcommandFile[16] = (byte)Convert.ToInt32("03", 16);
                sendcommandFile[17] = (byte)24;
                string pp2    = select.FILENAME.Substring(0, 15);
                byte[] array2 = Encoding.ASCII.GetBytes(pp2);
                for (int i = 0; i < array2.Length; i++)
                {    //默认长度为15
                    sendcommandFile[18 + i] = array2[i];
                }
                string pp    = select.FILENAME.Substring(15, 18);
                byte[] array = new byte[pp.Length / 2];
                for (int j = 0; j < pp.Length / 2; j++)
                {
                    //默认长度为9
                    array[j] = Convert.ToByte(pp.Substring(2 * j, 2).ToString(), 16);
                }

                for (int i = 0; i < 9; i++)
                {
                    sendcommandFile[33 + i] = array[i];
                }

                sendcommandFile[42] = (byte)Convert.ToInt32("21", 16);
                sendcommandFile[43] = (byte)Convert.ToInt32("03", 16);
                sendcommandFile[44] = (byte)4;
                for (int i = 0; i < 4; i++)
                {
                    sendcommandFile[45 + i] = select.PACKSTARTINDEX[i];
                }

                sendcommandFile[49] = (byte)Convert.ToInt32("39", 16);
                sendcommandFile[50] = (byte)Convert.ToInt32("03", 16);
                sendcommandFile[51] = (byte)1;
                sendcommandFile[52] = (byte)select.Audio_reback_mode;

                sendcommandFile[53] = (byte)Convert.ToInt32("14", 16);
                sendcommandFile[54] = (byte)Convert.ToInt32("03", 16);
                sendcommandFile[55] = (byte)4;

                for (int i = 0; i < 4; i++)
                {
                    sendcommandFile[56 + i] = (byte)(Convert.ToInt32(select.AUDIOREBACKSERVERIP.Split('.')[i]));
                }

                sendcommandFile[60] = (byte)Convert.ToInt32("15", 16);
                sendcommandFile[61] = (byte)Convert.ToInt32("03", 16);
                sendcommandFile[62] = (byte)2;
                string porttmp = select.AUDIOREBACKPORT.ToString("x").PadLeft(4, '0');
                sendcommandFile[63] = (byte)Convert.ToInt32(porttmp.Substring(2, 2), 16);
                sendcommandFile[64] = (byte)Convert.ToInt32(porttmp.Substring(0, 2), 16);

                sendcommandFile = HexHelper.crc16(sendcommandFile, 12);



                IntPtr connIdFiletransfer = default(IntPtr);
                if (this.dataHelper.Clients.TryGetValue(select.SRVPHYSICALCODE, out connIdFiletransfer))
                {
                    byte[] bytes = sendcommandFile;

                    string dadada = "";
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        dadada += bytes[i].ToString("X2");
                    }

                    this.netServer.Send(connIdFiletransfer, bytes, bytes.Length);
                    //日志打印  20180305
                    log.Info("录音文件调取指令已发送");
                }

                break;

            case Equipment.TTS:    //文本转语音
                log.Info("文本转语音指令进行组装发送阶段");
                TTSC ttsc = (TTSC)SendObject.Extras;

                string tmp1 = "";
                foreach (int item1 in ttsc.DeviceIdList)
                {
                    tmp1 += " " + item1.ToString();
                }
                log.Info("文本转语音指令设备ID" + tmp1);

                List <string> PhysicalList = dataHelper.DecId2Physical(ttsc.DeviceIdList);

                string tmp = "";

                foreach (string item in PhysicalList)
                {
                    tmp += " " + item;
                }
                log.Info("文本转语音指令物理码" + tmp);
                byte[] TextList = Encoding.Default.GetBytes(ttsc.TsCmd_Params);    //字符串转ASCII

                foreach (var phycode in PhysicalList)
                {
                    if (TextList.Length <= (255 - 6) * 5)    //一个UDP包能发完  终端接收缓冲区为1024字节 实际最多一帧4段发完
                    {
                        List <byte> SendCommandListTTS = new List <byte>();
                        SendCommandListTTS.Add(38);
                        byte[] HeaderData = new byte[] { };

                        if (dataHelper.ClientHD == null)
                        {
                            log.Info("文本转语音指令数据头为空");
                            //终端未上报  建立连接
                            return;
                        }
                        if (!this.dataHelper.ClientHD.TryGetValue(phycode, out HeaderData))
                        {
                            //终端未上报  建立连接
                            log.Info("文本转语音指令的物理码搜不到数据头,当前物理码:" + phycode.ToString());
                            continue;
                        }

                        for (int k = 0; k < 9; k++)
                        {
                            SendCommandListTTS.Add(HeaderData[1 + k]);
                        }
                        SendCommandListTTS.Add(HeaderData[16]);    //协议版本号


                        int count = TextList.Length / 249 + 1;    //段数  文本通过几段发送

                        switch (count)
                        {
                        case 1:
                            //补充完整发送数据
                            for (int i = 0; i < 6 + 2 + TextList.Length + 1 + 6; i++)
                            {
                                SendCommandListTTS.Add(0);
                            }

                            byte[] sendcommand = SendCommandListTTS.ToArray();

                            string datalenth = (TextList.Length + 6 + 3).ToString("x").PadLeft(4, '0');

                            sendcommand[12] = (byte)Convert.ToInt32("10", 16);
                            sendcommand[13] = (byte)Convert.ToInt32(datalenth.Substring(2, 2), 16);
                            sendcommand[14] = (byte)Convert.ToInt32(datalenth.Substring(0, 2), 16);
                            sendcommand[15] = (byte)Convert.ToInt32("44", 16);
                            sendcommand[16] = (byte)Convert.ToInt32("03", 16);
                            sendcommand[17] = (byte)(TextList.Length + 6);

                            sendcommand[18] = (byte)0;
                            sendcommand[19] = (byte)ttsc.TsCmd_PlayCount;


                            sendcommand[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommand[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommand[22] = (byte)1;        //分段序号
                            sendcommand[23] = (byte)1;        //总段数


                            for (int l = 0; l < TextList.Length; l++)
                            {
                                sendcommand[24 + l] = TextList[l];
                            }
                            sendcommand = HexHelper.crc16(sendcommand, 12);
                            IntPtr connIdFile = default(IntPtr);
                            if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFile))
                            {
                                byte[] bytes = sendcommand;
                                this.netServer.Send(connIdFile, bytes, bytes.Length);
                                //日志打印  20180305
                                log.Info("文本转语音指令已发送");
                            }
                            break;

                        case 2:

                            for (int i = 0; i < TextList.Length + 24; i++)
                            {
                                SendCommandListTTS.Add(0);
                            }

                            byte[] sendcommandSection2 = SendCommandListTTS.ToArray();

                            string datalenthSection2 = (TextList.Length + 18).ToString("x").PadLeft(4, '0');

                            sendcommandSection2[12] = (byte)Convert.ToInt32("10", 16);
                            sendcommandSection2[13] = (byte)Convert.ToInt32(datalenthSection2.Substring(2, 2), 16);
                            sendcommandSection2[14] = (byte)Convert.ToInt32(datalenthSection2.Substring(0, 2), 16);


                            #region 数据段1
                            sendcommandSection2[15] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection2[16] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection2[17] = (byte)255;
                            sendcommandSection2[18] = (byte)0;
                            sendcommandSection2[19] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection2[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection2[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection2[22] = (byte)1;        //分段序号
                            sendcommandSection2[23] = (byte)2;        //总段数
                            for (int l = 0; l < 249; l++)
                            {
                                sendcommandSection2[24 + l] = TextList[l];
                            }
                            #endregion

                            #region 数据段2
                            sendcommandSection2[273] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection2[274] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection2[275] = (byte)(TextList.Length - 249 + 6);
                            sendcommandSection2[276] = (byte)0;
                            sendcommandSection2[277] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection2[278] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection2[279] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection2[280] = (byte)2;        //分段序号
                            sendcommandSection2[281] = (byte)2;        //总段数

                            for (int l = 0; l < TextList.Length - 249; l++)
                            {
                                sendcommandSection2[282 + l] = TextList[249 + l];
                            }
                            #endregion

                            sendcommandSection2 = HexHelper.crc16(sendcommandSection2, 12);
                            IntPtr connIdFileTTS2 = default(IntPtr);
                            if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFileTTS2))
                            {
                                byte[] bytes = sendcommandSection2;
                                this.netServer.Send(connIdFileTTS2, bytes, bytes.Length);
                                //日志打印  20180305
                                log.Info("文本转语音指令已发送");
                            }
                            break;

                        case 3:

                            for (int i = 0; i < TextList.Length + 33; i++)
                            {
                                SendCommandListTTS.Add(0);
                            }

                            byte[] sendcommandSection3 = SendCommandListTTS.ToArray();

                            string datalenthSection3 = (TextList.Length + 27).ToString("x").PadLeft(4, '0');

                            sendcommandSection3[12] = (byte)Convert.ToInt32("10", 16);
                            sendcommandSection3[13] = (byte)Convert.ToInt32(datalenthSection3.Substring(2, 2), 16);
                            sendcommandSection3[14] = (byte)Convert.ToInt32(datalenthSection3.Substring(0, 2), 16);

                            #region 数据段1
                            sendcommandSection3[15] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection3[16] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection3[17] = (byte)255;
                            sendcommandSection3[18] = (byte)0;
                            sendcommandSection3[19] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection3[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection3[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection3[22] = (byte)1;        //分段序号
                            sendcommandSection3[23] = (byte)3;        //总段数
                            for (int l = 0; l < 249; l++)
                            {
                                sendcommandSection3[24 + l] = TextList[l];
                            }
                            #endregion

                            #region 数据段2
                            sendcommandSection3[273] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection3[274] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection3[275] = (byte)255;
                            sendcommandSection3[276] = (byte)0;
                            sendcommandSection3[277] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection3[278] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection3[279] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection3[280] = (byte)2;        //分段序号
                            sendcommandSection3[281] = (byte)3;        //总段数

                            for (int l = 0; l < 249; l++)
                            {
                                sendcommandSection3[282 + l] = TextList[249 + l];
                            }
                            #endregion

                            #region 数据段3
                            sendcommandSection3[531] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection3[532] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection3[533] = (byte)(TextList.Length - 249 * 2 + 6);
                            sendcommandSection3[534] = (byte)0;
                            sendcommandSection3[535] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection3[536] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection3[537] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection3[538] = (byte)3;        //分段序号
                            sendcommandSection3[539] = (byte)3;        //总段数

                            for (int l = 0; l < TextList.Length - 249 * 2; l++)
                            {
                                sendcommandSection3[540 + l] = TextList[498 + l];
                            }
                            #endregion

                            sendcommandSection3 = HexHelper.crc16(sendcommandSection3, 12);
                            IntPtr connIdFileTTS3 = default(IntPtr);
                            if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFileTTS3))
                            {
                                byte[] bytes = sendcommandSection3;
                                this.netServer.Send(connIdFileTTS3, bytes, bytes.Length);
                                //日志打印  20180305
                                log.Info("文本转语音指令已发送");
                            }
                            break;

                        case 4:

                            for (int i = 0; i < TextList.Length + 42; i++)
                            {
                                SendCommandListTTS.Add(0);
                            }

                            byte[] sendcommandSection4 = SendCommandListTTS.ToArray();

                            string datalenthSection4 = (TextList.Length + 36).ToString("x").PadLeft(4, '0');

                            sendcommandSection4[12] = (byte)Convert.ToInt32("10", 16);
                            sendcommandSection4[13] = (byte)Convert.ToInt32(datalenthSection4.Substring(2, 2), 16);
                            sendcommandSection4[14] = (byte)Convert.ToInt32(datalenthSection4.Substring(0, 2), 16);

                            #region 数据段1
                            sendcommandSection4[15] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection4[16] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection4[17] = (byte)255;
                            sendcommandSection4[18] = (byte)0;
                            sendcommandSection4[19] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection4[20] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection4[21] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection4[22] = (byte)1;        //分段序号
                            sendcommandSection4[23] = (byte)4;        //总段数
                            for (int l = 0; l < 249; l++)
                            {
                                sendcommandSection4[24 + l] = TextList[l];
                            }
                            #endregion

                            #region 数据段2
                            sendcommandSection4[273] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection4[274] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection4[275] = (byte)255;
                            sendcommandSection4[276] = (byte)0;
                            sendcommandSection4[277] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection4[278] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection4[279] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection4[280] = (byte)2;        //分段序号
                            sendcommandSection4[281] = (byte)4;        //总段数

                            for (int l = 0; l < 249; l++)
                            {
                                sendcommandSection4[282 + l] = TextList[249 + l];
                            }
                            #endregion

                            #region 数据段3
                            sendcommandSection4[531] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection4[532] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection4[533] = (byte)255;
                            sendcommandSection4[534] = (byte)0;
                            sendcommandSection4[535] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection4[536] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection4[537] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection4[538] = (byte)3;        //分段序号
                            sendcommandSection4[539] = (byte)4;        //总段数

                            for (int l = 0; l < 249; l++)
                            {
                                sendcommandSection4[540 + l] = TextList[498 + l];
                            }
                            #endregion

                            #region 数据段4
                            sendcommandSection4[789] = (byte)Convert.ToInt32("44", 16);
                            sendcommandSection4[790] = (byte)Convert.ToInt32("03", 16);
                            sendcommandSection4[791] = (byte)(TextList.Length - 249 * 3 + 6);
                            sendcommandSection4[792] = (byte)0;
                            sendcommandSection4[793] = (byte)ttsc.TsCmd_PlayCount;
                            sendcommandSection4[794] = (byte)Convert.ToInt32(ttsc.FileID.Substring(0, 2), 16);
                            sendcommandSection4[795] = (byte)Convert.ToInt32(ttsc.FileID.Substring(2, 2), 16);
                            sendcommandSection4[796] = (byte)4;        //分段序号
                            sendcommandSection4[797] = (byte)4;        //总段数

                            for (int l = 0; l < TextList.Length - 249 * 3; l++)
                            {
                                sendcommandSection4[798 + l] = TextList[747 + l];
                            }
                            #endregion

                            sendcommandSection4 = HexHelper.crc16(sendcommandSection4, 12);
                            IntPtr connIdFileTTS4 = default(IntPtr);
                            if (this.dataHelper.Clients.TryGetValue(phycode, out connIdFileTTS4))
                            {
                                byte[] bytes = sendcommandSection4;
                                this.netServer.Send(connIdFileTTS4, bytes, bytes.Length);
                                //日志打印  20180305
                                log.Info("文本转语音指令已发送");
                            }

                            break;

                        case 5:
                            break;
                        }
                    }
                    else
                    {
                        //需分包发送  目前暂无这么大的数据
                    }
                }
                break;
            }
        }
        public static object GetEquipmentValue(Equipment eq, byte[] eqData, EquipmentDetail ob)
        {
            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

                    return(eqData);


                case Equipment.FMSignalStrength:    //byte
                    return(eqData);

                case Equipment.PlayType:    //byte
                    return(eqData[0]);

                case Equipment.Versions:    //byte
                    return(eqData);

                case Equipment.DigitalTVRadioFrequencyMode:    //byte
                    return(eqData[0]);

                case Equipment.DigitalTVRadioFrequencyFre:    //Uint16
                    // string DTVRFre ="" ;


                    //if (SingletonInfo.GetInstance().factorycode == "1" && SingletonInfo.GetInstance().TerminalType == true && SingletonInfo.GetInstance().Version == "2.0")
                    //{
                    //    DTVRFre = eqData[2].ToString() + eqData[1].ToString() + eqData[0].ToString();   //疑问  是否需要转16进制    20171128
                    //}
                    //else
                    //{
                    //    DTVRFre = eqData.ToNumberArrayString("", 16);
                    //}   测试注释  20171203
                    // var DTVRFre = eqData.ToNumberArrayString("", 16);


                    var DTVRFre = (Convert.ToInt32(eqData[2].ToString("X2") + eqData[1].ToString("X2")) / 10).ToString();
                    return(uint.Parse(DTVRFre));

                case Equipment.QAMType:                   //byte
                case Equipment.BroadcastVolume:           //byte
                case Equipment.BroadcastTimeout:          //byte
                case Equipment.CurrentModeSignalQuality:  //byte
                case Equipment.CurrentModeSignalStrength: //byte
                    return(eqData[0]);

                case Equipment.RemoteControlCenterIPAddress:    //IP
                    return(eqData);

                case Equipment.RemoteControlCenterPort:    //Uint16
                    return(BitConverter.ToUInt16(eqData, 0));

                case Equipment.AudioServerIPAddress:    //IP
                    return(eqData);

                case Equipment.AudioServerPort:    //Uint16
                    return(BitConverter.ToUInt16(eqData, 0));

                case Equipment.CallWay:    //byte
                    return(eqData[0]);

                case Equipment.FileName:    //byte[]
                    return(eqData);

                case Equipment.RecordingDuration:   //Uint32
                case Equipment.PacksTotalNumber:    //Uint32
                    return(BitConverter.ToUInt32(eqData, 0));

                case Equipment.RebackFileType:    //byte
                    return(eqData[0]);

                case Equipment.PackStartIndex:    //Uint32
                case Equipment.LastPacksNuber:    //Uint32
                    return(BitConverter.ToUInt32(eqData, 0));

                case Equipment.LogicalAddress:    //byte
                case Equipment.PhysicalAddress:   //byte
                    //        Task.Factory.StartNew(delegate
                    //{
                    //    string phycode = eqData.ToNumberArrayString("", 16);
                    //    if (SingletonInfo.GetInstance().MonitorPlatformMessageList.Any())//判断非空
                    //    {
                    //        MonitorPlatformMessage monitorPlatformMessage = SingletonInfo.GetInstance().MonitorPlatformMessageList.Find((MonitorPlatformMessage tmp) => tmp.SRVPHYSICALCODE == phycode);
                    //        if (monitorPlatformMessage != null)
                    //        {
                    //            SendbackDetail sendbackDetail = new SendbackDetail();
                    //            sendbackDetail.tag = Equipment.PhysicalAddress;
                    //            sendbackDetail.DataEntity = monitorPlatformMessage;
                    //            sendbackDetail.Rebackdata = ob;
                    //            EquipmentHelper.MyEvent(sendbackDetail);
                    //        }
                    //    }
                    //});
                    return(eqData);

                case Equipment.BroadcastState:  //byte
                case Equipment.TerminalType:    //byte
                    return(eqData[0]);

                case Equipment.Longitude:   //Float
                case Equipment.Latitude:    //Float
                    return(BitConverter.ToSingle(eqData, 0));

                case Equipment.RebackMode:    //byte
                case Equipment.NetworkMode:   //byte
                    return(eqData[0]);

                case Equipment.Voltage220:               //Float
                case Equipment.Voltage24:                //Float
                case Equipment.Voltage12:                //Float
                case Equipment.AmplifierElectricCurrent: //Float
                    return(BitConverter.ToSingle(eqData, 0));

                case Equipment.LocalHost:      //IP
                case Equipment.SubnetMask:     //IP
                case Equipment.DefaultGateway: //IP
                    return(eqData);

                case Equipment.AudioReback:    //byte[]
                    return(eqData);

                case Equipment.AudioRebackProtocol:  //byte
                case Equipment.RecordingCategory:    //byte
                    return(eqData[0]);

                case Equipment.StartPackageNumber:    //uint
                    return(BitConverter.ToUInt32(eqData, 0));

                case Equipment.terminal2serverhandshake:    //uint

                    Task.Factory.StartNew(delegate
                    {
                        SendbackDetail sendbackDetail2 = new SendbackDetail();
                        sendbackDetail2.tag            = Equipment.terminal2serverhandshake;
                        sendbackDetail2.Rebackdata     = ob;
                        EquipmentHelper.MyEvent(sendbackDetail2);
                    });
                    return(eqData[0]);
                }
                return(eqData);
            }
            catch
            {
                return(null);
            }
        }