コード例 #1
0
        // step ready to be parsed collection
        public void parseAllReadyData(DBWriter myDBWriter)
        {
            if (!closing)
            {
                DateTime start          = DateTime.Now;
                var      parseDurations = new List <double>();
                lock (currentlyParsingLock)
                {
                    lock (failedParsing)
                    {
                        currentlyParsingIndex = 0;

                        // Parse all data
                        currentlyParsing.ForEach(delegate(RawData obj)
                        {
                            try
                            {
                                Logger.GetInstance().WritePayloadToLogFile(obj.rawData, obj.rawDataLength, LogType.RawData);
                                Logger.GetInstance().WritePayloadBinaryToLogFile(obj.rawData, obj.rawDataLength, LogType.RawBinary);
                            }
                            catch (Exception ex)
                            {
                                Logger.GetInstance().Exception("Failed to write the log file", ex, EventLogPostfix);
                            }

                            bool moreDataExpected      = false; // currently ignored
                            bool packetParsedOK        = false;
                            IPacketParser packetParser = PacketParserCommon.selectPacketParser(obj.rawData, obj.rawDataLength);

                            currentlyParsingIndex++;

                            var parseStart = DateTime.Now;

                            if (packetParser != null)
                            {
                                packetParser.TrackerID = obj.trackerID;
                                packetParsedOK         = packetParser.Parse(myDBWriter, obj.rawData, obj.rawDataLength, ref moreDataExpected);
                                obj.parsedOK           = packetParsedOK;
                                if (!packetParsedOK)
                                {
                                    obj.parseRetryCount++;
                                }
                            }

                            parseDurations.Add((DateTime.Now - parseStart).TotalMilliseconds);
                        });

                        currentlyParsing.Clear();
                    }
                }
                previousParseDurationAverage = Average(parseDurations);
                previousParseDuration        = DateTime.Now - start;
            }
        }
コード例 #2
0
 internal void LogStatsDataBase(int port, DBWriter myDBWriter)
 {
     try
     {
         myDBWriter.WriteParseLog(configuration, port,
                                  "ListenerService" + port,
                                  DateTime.Now,
                                  rawData.Count,
                                  currentlyParsing.Count,
                                  currentlyParsingIndex,
                                  Convert.ToInt32(previousParseDuration.TotalSeconds),
                                  previousParseDurationAverage);
     }
     catch (Exception ex)
     {
         Logger.GetInstance().Exception("Failed to write parse log to DB: ", ex, EventLogPostfix);
     }
 }
コード例 #3
0
        private void ParseData(DBWriter myDBWriter, RawData obj, List <double> parseDurations)
        {
            bool          moreDataExpected = false; // currently ignored
            bool          packetParsedOK   = false;
            IPacketParser packetParser     = PacketParserCommon.selectPacketParser(obj.rawData, obj.rawDataLength);

            currentlyParsingIndex++;

            var parseStart = DateTime.Now;

            if (packetParser != null)
            {
                packetParser.TrackerID = obj.trackerID;
                packetParsedOK         = packetParser.Parse(myDBWriter, obj.rawData, obj.rawDataLength, ref moreDataExpected);
                obj.parsedOK           = packetParsedOK;
                if (!packetParsedOK)
                {
                    obj.parseRetryCount++;
                }
            }

            parseDurations.Add((DateTime.Now - parseStart).TotalMilliseconds);
        }