Ejemplo n.º 1
0
        public bool UpdateSrvEquipmentStatusBatch_Nation(NSEquipmentDetail selectone)
        {
            SqlDataAdapter sd        = null;
            DataTable      dataTable = new DataTable();
            int            reslut    = -1;

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                sd = new SqlDataAdapter("SELECT SRV_ID,SRV_RMT_TIME,SRV_RMT_STATUS,SRV_PHYSICAL_CODE FROM Srv WITH(NOLOCK)", conn);
                SqlCommandBuilder scb = new SqlCommandBuilder(sd);
                sd.UpdateCommand = scb.GetUpdateCommand();
                sd.UpdateCommand = new SqlCommand("update Srv set SRV_RMT_TIME=@SRV_RMT_TIME, SRV_RMT_STATUS=@SRV_RMT_STATUS where SRV_PHYSICAL_CODE=@SRV_PHYSICAL_CODE", conn);
                sd.UpdateCommand.Parameters.Add("@SRV_RMT_TIME", SqlDbType.DateTime, 255, "SRV_RMT_TIME");
                sd.UpdateCommand.Parameters.Add("@SRV_RMT_STATUS", SqlDbType.VarChar, 255, "SRV_RMT_STATUS");
                sd.UpdateCommand.Parameters.Add("@SRV_PHYSICAL_CODE", SqlDbType.VarChar, 255, "SRV_PHYSICAL_CODE");
                sd.UpdateCommand.UpdatedRowSource = UpdateRowSource.None;

                sd.UpdateBatchSize = 0;
                sd.Fill(dataTable);


                if (dataTable.Rows.Count > 0)
                {
                    dataTable.Rows[0].BeginEdit();
                    var rows = dataTable.Select("SRV_PHYSICAL_CODE='" + selectone.Heartbeat + "'");
                    if (rows != null && rows.Length > 0)
                    {
                        rows[0]["SRV_RMT_TIME"]   = DateTime.Now;
                        rows[0]["SRV_RMT_STATUS"] = "在线";
                    }
                    dataTable.Rows[0].EndEdit();

                    reslut = sd.Update(dataTable);
                }
            }
            catch (Exception ex)
            {
                log.Error("批量更新设备在线状态发生异常", ex);
            }
            finally
            {
                dataTable.Clear();
                sd.Dispose();
                dataTable.Dispose();
                conn.Close();
            }
            return(reslut != -1);
        }
        private NSEquipmentDetail HandlerQueue_NationalStandard(EquipmentSource datare)
        {
            byte[] data = datare.RawData;
            if (data.Length < 15)
            {
                return(null);
            }

            NSEquipmentDetail equipmentDetail = new NSEquipmentDetail();

            try
            {
                log.Info("开始解析数据-" + data.Length);

                string outMsg; //返回的错误信息,正确解析则返回空
                var    detail = EquipmentHelper.HandleData_NS(data, out outMsg);

                if (detail != null && string.IsNullOrWhiteSpace(outMsg))
                {
                    #region 解析EquipmentDetail
                    foreach (var key in detail.Keys)
                    {
                        var proInfo = typeof(NSEquipmentDetail).GetProperty(key.ToString());
                        if (null != proInfo)
                        {
                            var eqValue = EquipmentHelper.GetNSEquipmentValue(key, detail[key], equipmentDetail);
                            proInfo.SetValue(equipmentDetail, eqValue, null);
                        }
                    }
                    #endregion
                }
                else
                {
                    equipmentDetail = null;
                }
            }
            catch (Exception ex)
            {
                log.Error("设备详细信息解析异常", ex);
                equipmentDetail = null;
            }
            return(equipmentDetail);
        }
Ejemplo n.º 3
0
        public static object GetNSEquipmentValue(EquipmentNS eq, byte[] eqData, NSEquipmentDetail ob)
        {
            try
            {
                switch (eq)
                {
                case EquipmentNS.DeviceTypeCode:
                    return(ConvertHelper.Byte2int(eqData).ToString());

                case EquipmentNS.DTMBStatus:
                    return(eqData[0].ToString() + ";" + eqData[1].ToString());

                case EquipmentNS.DTMB_FreqInfo:
                    return(ConvertHelper.GetDataLenth(eqData).ToString());

                case EquipmentNS.DVBCStatus:

                    return(eqData[0].ToString() + ";" + eqData[1].ToString());

                case EquipmentNS.DVBC_FreqInfo:
                    string MFreTMP       = ConvertHelper.GetDataLenth(eqData.Take(4).ToArray()).ToString();
                    string SymbolRatetmp = ConvertHelper.GetDataLenth(eqData.Skip(4).Take(4).ToArray()).ToString();
                    string QAMtmp        = eqData.Skip(8).Take(1).ToArray()[0].ToString();

                    return(MFreTMP + ";" + SymbolRatetmp + ";" + QAMtmp);

                case EquipmentNS.FaultCode:

                    return(eqData[0].ToString());

                case EquipmentNS.FMStatus:
                    return(eqData[0].ToString() + ";" + eqData[1].ToString());

                case EquipmentNS.FM_CurrentFreqInfo:

                    //数据有3个字节 实际只用到两个
                    string IF = eqData.Skip(1).Take(1).ToArray()[0].ToString() + "." + eqData.Skip(1 + 1).Take(1).ToArray()[0].ToString();
                    string PF = eqData.Skip(4).Take(1).ToArray()[0].ToString() + "." + eqData.Skip(5).Take(1).ToArray()[0].ToString();
                    return(IF + ";" + PF);

                case EquipmentNS.FM_FreqScanList:
                    int    FreCount = eqData[0];
                    string strlist  = "";
                    for (int i = 0; i < FreCount; i++)
                    {
                        string fre      = "";
                        string freNo    = eqData[1 + 5 * i].ToString();
                        string priority = eqData[1 + 5 * i + 1].ToString();
                        string fretmp   = eqData.Skip(1 + 5 * i + 1 + 1 + 1).Take(1).ToArray()[0].ToString() + "." + eqData.Skip(1 + 5 * i + 1 + 1 + 1 + 1).Take(1).ToArray()[0].ToString();

                        fre      = freNo + "," + priority + "," + fretmp;
                        strlist += ";" + fre;
                    }

                    return(strlist.Substring(1, strlist.Length - 1));

                case EquipmentNS.FM_KeepOrderInfo:

                    string onoff = eqData[0].ToString();

                    string keepcycle = "";
                    if (onoff == "0")
                    {
                        //禁用 维持周期 为0
                        keepcycle = "0";
                    }
                    else
                    {
                        keepcycle = ConvertHelper.Byte2int(eqData.Skip(1).Take(2).ToArray()).ToString();
                    }

                    return(onoff + ";" + keepcycle);

                case EquipmentNS.HardwareVersionNum:
                    return(ConvertHelper.Byte2wareVersion(eqData));

                case EquipmentNS.RebackInfo:
                    int    rebacktype    = eqData[0];
                    string RebackInfotmp = "";
                    switch (rebacktype)
                    {
                    case 1:
                        //IP+端口
                        string iptmp   = ConvertHelper.Bytes2IP(eqData.Skip(1).Take(4).ToArray());
                        string porttmp = ConvertHelper.Byte2int(eqData.Skip(5).Take(2).ToArray()).ToString();
                        RebackInfotmp = iptmp + ";" + porttmp;
                        break;

                    case 2:
                        //域名+端口
                        string domaintmp = System.Text.Encoding.UTF8.GetString(eqData.Skip(1).Take(eqData.Length - 3).ToArray());
                        string porttmp1  = ConvertHelper.Byte2int(eqData.Skip(eqData.Length - 2).Take(2).ToArray()).ToString();
                        RebackInfotmp = domaintmp + ";" + porttmp1;

                        break;

                    case 3:
                        //11位电话号码
                        RebackInfotmp = ConvertHelper.Byte2PhoneNum(eqData.Skip(1).Take(eqData.Length - 1).ToArray());
                        break;
                    }
                    return(RebackInfotmp);

                case EquipmentNS.ResourceCode:
                    string resourcecodetmp = "";
                    resourcecodetmp = ConvertHelper.bcd2Str(eqData);
                    resourcecodetmp = resourcecodetmp.Substring(1, resourcecodetmp.Length - 1);
                    return(resourcecodetmp);

                case EquipmentNS.SoftwareVersionNum:
                    return(ConvertHelper.Byte2wareVersion(eqData));

                case EquipmentNS.srv_physical_code:
                    return(ConvertHelper.bcd2Str(eqData));

                case EquipmentNS.TerminalAddressInfo:

                    return(ConvertHelper.Bytes2IP(eqData.Take(4).ToArray()) + ";" + ConvertHelper.Bytes2IP(eqData.Skip(4).Take(4).ToArray()) + ";" + ConvertHelper.Bytes2IP(eqData.Skip(8).Take(4).ToArray()));

                case EquipmentNS.TerminalVolume:
                    int volumntmp = eqData[0];
                    if (volumntmp > 100)
                    {
                        return("--");
                    }
                    else
                    {
                        return(volumntmp.ToString());
                    }

                case EquipmentNS.WorkStatus:
                    string str = eqData[0].ToString();
                    return(str);

                case EquipmentNS.Heartbeat:
                    return(ConvertHelper.bcd2Str(eqData));
                }
                return(eqData);
            }
            catch
            {
                return(null);
            }
        }