Ejemplo n.º 1
0
Archivo: Sql.cs Proyecto: wpmyj/csharp
        public static void RealCollect()
        {
            RealTimePacket RPacket = new RealTimePacket();
            DensityPacket  DPacket = new DensityPacket();

            while (SysFlag.ServiceStart)
            {
                if (Configs.RealTimePacketQueue.Count > 0)
                {
                    lock (Configs.RealTimePacketQueue)
                    {
                        RPacket = (RealTimePacket)Configs.RealTimePacketQueue.Dequeue();
                        SysFlag.RealTimePacketCount++;
                    }
                    InsertToRealTimeSheet(RPacket);
                    Oracle.InsertToRealTimeSheet(RPacket);
                    Oracle.UpdataToRealTimeSheet(RPacket);
                }
                if (Configs.DensityPacketQueue.Count > 0)
                {
                    lock (Configs.DensityPacketQueue)
                    {
                        DPacket = (DensityPacket)Configs.DensityPacketQueue.Dequeue();
                        SysFlag.DensityPacketCount++;
                    }
                    InsertToDensitySheet(DPacket);
                }
                else
                {
                    System.Threading.Thread.Sleep(100);
                }
            }
            SqlConn.Close();
        }
Ejemplo n.º 2
0
Archivo: Sql.cs Proyecto: wpmyj/csharp
        private static bool InsertToDensitySheet(DensityPacket Packet)
        {
            string sCommand = "";

            try
            {
                Packet.StationId = ASearchBInSheet(Configs.SqlStationInforSheet, "StationNumber", Packet.StationNumber);
                sCommand         = "INSERT INTO " + Configs.SqlDensitySheet + " VALUES("
                                   + Packet.StationId + ","
                                   + Packet.StationNumber + ","
                                   + AddHead(Packet.RecordDataTime).ToString() + ","
                                   + Packet.RecordWaterLevel + ","
                                   + Packet.RecordRainFall + ","
                                   + Packet.RecordDimension + ","
                                   + Packet.RecordLongitude + ","
                                   + Packet.RecordTemperature + ","
                                   + Packet.RecordVoltage + ","
                                   + AddHead(Packet.RecordOther).ToString() + ","
                                   + AddHead(Packet.Note).ToString() + ")";
                TryOpen();
                SqlCommand objSqlCommand = new SqlCommand(sCommand, Sql.SqlConn);
                objSqlCommand.ExecuteNonQuery();
                TryClose();
            }
            catch (Exception E)
            {
                CreateInfor.WriteLogs(E.Message + "->导致【" + sCommand + "】入库失败");
                Console.WriteLine(sCommand);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
 public static void ClearDensityPacket(ref DensityPacket Packet)
 {
     Packet.RecordOther       = "NULL";
     Packet.RecordRainFall    = "NULL";
     Packet.RecordTemperature = "NULL";
     Packet.RecordVoltage     = "NULL";
     Packet.RecordWaterLevel  = "NULL";
     Packet.RecordDimension   = "NULL";
     Packet.RecordLongitude   = "NULL";
     Packet.StationPosition   = "NULl";
     Packet.Note = "NULL";
 }
Ejemplo n.º 4
0
        public static bool ExpendWithBAA(byte[] RxBuffer, int Length)
        {
            if (!IfTrueWithBAA(RxBuffer, Length))
            {
                return(false);
            }
            DensityPacket TempPacket = new DensityPacket();
            int           PacketLength;
            int           TimeSpace;
            int           DataType;
            int           BigBagSize;
            int           i = 4;
            int           TimeOffset;

            ClearDensityPacket(ref TempPacket);
            TempPacket.StationNumber = CheckTools.DAT_GetD32FromArray(RxBuffer, i, 0).ToString(); i += 4;
            TempPacket.StationOrder  = CheckTools.DAT_GetD32FromArray(RxBuffer, i, 0).ToString(); i += 4;
            TempPacket.Note          = Tools.DAT_GetString(RxBuffer, i, 16).Trim(); i += 16;
            PacketLength             = CheckTools.DAT_GetD16FromArray(RxBuffer, i, 0); i += 2;
            TimeSpace  = RxBuffer[i]; i += 1;
            DataType   = RxBuffer[i]; i += 1;
            TimeOffset = i;
            TempPacket.RecordDataTime = Tools.DAT_GetTime(RxBuffer, i).ToString(); i += 6;
            int N            = 60 / TimeSpace;
            int SmallBagSize = N * 4 + 6;

            BigBagSize = (PacketLength - 36) / (SmallBagSize);
            if (BigBagSize != 2)
            {
                return(false);//总共只有水位和雨量两项
            }
            for (int n = 0; n < N; n++)
            {
                TempPacket.RecordDataTime   = Tools.DAT_GetSpaceTime(RxBuffer, TimeOffset, TimeSpace, n).ToString();
                TempPacket.RecordWaterLevel = Tools.DAT_GetNum(RxBuffer, i + n * 4, 0, DataType);
                TempPacket.RecordRainFall   = Tools.DAT_GetNum(RxBuffer, i + SmallBagSize + n * 4, 0, DataType);
                lock (Configs.DensityPacketQueue)
                {
                    Configs.DensityPacketQueue.Enqueue(TempPacket);
                }
            }
            if (SmallBagSize > 0)
            {
                return(true);
            }
            return(false);
        }