コード例 #1
0
 public SqlGenerator(string fileName, EQStreamProcessor streamProcessor, SqlGeneratorConfiguration config, Action <string> logAction, Action <string> statusAction)
 {
     if (fileName == null)
     {
         throw new ArgumentNullException("fileName");
     }
     if (streamProcessor == null)
     {
         throw new ArgumentNullException("streamProcessor");
     }
     if (logAction == null)
     {
         throw new ArgumentNullException("logAction");
     }
     if (statusAction == null)
     {
         throw new ArgumentNullException("statusAction");
     }
     Log              = logAction;
     SetStatus        = statusAction;
     _fileName        = fileName;
     _streamProcessor = streamProcessor;
     _config          = config;
     SqlStream        = new StreamWriter(_fileName);
 }
コード例 #2
0
ファイル: SqlGenerator.cs プロジェクト: rumstil/EQExtractor
 public SqlGenerator(string fileName, EQStreamProcessor streamProcessor, SqlGeneratorConfiguration config,Action<string> logAction, Action<string> statusAction)
 {
     if (fileName == null) throw new ArgumentNullException("fileName");
     if (streamProcessor == null) throw new ArgumentNullException("streamProcessor");
     if (logAction == null) throw new ArgumentNullException("logAction");
     if (statusAction == null) throw new ArgumentNullException("statusAction");
     Log = logAction;
     SetStatus = statusAction;
     _fileName = fileName;
     _streamProcessor = streamProcessor;
     _config = config;
     SqlStream = new StreamWriter(_fileName);
 }
コード例 #3
0
        public void ProcessPCapFile(string capFile)
        {
            if (string.IsNullOrEmpty(capFile))
            {
                return;
            }
            OfflinePcapDevice device = null;

            try
            {
                device = new OfflinePcapDevice(capFile);
                device.Open();
            }
            catch (Exception ex)
            {
                if (Log != null)
                {
                    Log("Error: File does not exist, not in .pcap format ro you don't have winpcap installed.");
                }
                throw new PCapFormatException("Error: File does not exist, not in .pcap format ro you don't have winpcap installed.", ex);
            }
            StreamProcessor = new EQStreamProcessor();

            if (!StreamProcessor.Init(Application.StartupPath + "\\Configs", Log))
            {
                if (Log != null)
                {
                    Log("Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.");
                }
                if (SetStatus != null)
                {
                    SetStatus("Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.");
                }
                return;
            }

            if (Options.EQPacketDebugFilename.Text.Length > 0)
            {
                try
                {
                    if (PacketDebugStream == null)
                    {
                        PacketDebugStream = new StreamWriter(Options.EQPacketDebugFilename.Text);
                    }
                    StreamProcessor.Packets.SetDebugLogHandler(PacketDebugLogger);
                }
                catch
                {
                    if (Log != null)
                    {
                        Log("Failed to open netcode debug file for writing.");
                    }
                    Options.EQPacketDebugFilename.Text = "";
                    StreamProcessor.Packets.SetDebugLogHandler(null);
                }
            }
            else
            {
                StreamProcessor.Packets.SetDebugLogHandler(null);
            }

            SetStatus("Reading packets from " + capFile + ". Please wait...");
            device.OnPacketArrival += device_OnPacketArrival;
            BytesRead   = 0;
            PacketsSeen = 0;
            if (Log != null)
            {
                Log("-- Capturing from '" + capFile);
            }
            ReportProgress(0);
            CaptureFileSize = device.FileSize;
            device.Capture();
            device.Close();
            if (Log != null)
            {
                Log("End of file reached. Processed " + PacketsSeen + " packets and " + BytesRead + " bytes.");
            }
        }
コード例 #4
0
ファイル: PCapProcessor.cs プロジェクト: rumstil/EQExtractor
        public void ProcessPCapFile(string capFile)
        {
            if (string.IsNullOrEmpty(capFile)) return;
            OfflinePcapDevice device=null;
            try
            {
                device = new OfflinePcapDevice(capFile);
                device.Open();
            }
            catch (Exception ex)
            {
                if(Log!=null) Log("Error: File does not exist, not in .pcap format ro you don't have winpcap installed.");
                throw new PCapFormatException("Error: File does not exist, not in .pcap format ro you don't have winpcap installed.", ex);
            }
            StreamProcessor = new EQStreamProcessor();

            if (!StreamProcessor.Init(Application.StartupPath + "\\Configs", Log))
            {
                if (Log != null) Log("Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.");
                if (SetStatus != null) SetStatus("Fatal error initialising Stream Processor. No decoders could be initialised (mostly likely misplaced patch_XXXX.conf files.");
                return;
            }

            if (Options.EQPacketDebugFilename.Text.Length > 0)
            {
                try
                {
                    if(PacketDebugStream==null) PacketDebugStream = new StreamWriter(Options.EQPacketDebugFilename.Text);
                    StreamProcessor.Packets.SetDebugLogHandler(PacketDebugLogger);
                }
                catch
                {
                    if (Log != null) Log("Failed to open netcode debug file for writing.");
                    Options.EQPacketDebugFilename.Text = "";
                    StreamProcessor.Packets.SetDebugLogHandler(null);
                }
            }
            else
                StreamProcessor.Packets.SetDebugLogHandler(null);

            SetStatus( "Reading packets from " + capFile+ ". Please wait...");
            device.OnPacketArrival += device_OnPacketArrival;
            BytesRead = 0;
            PacketsSeen = 0;
            if (Log != null) Log("-- Capturing from '" + capFile);
            ReportProgress(0);
            CaptureFileSize = device.FileSize;
            device.Capture();
            device.Close();
            if(Log!=null)Log("End of file reached. Processed " + PacketsSeen + " packets and " + BytesRead + " bytes.");
        }