public LogData ProcessLog(StatoscopeForm ssForm)
        {
            TcpClient client           = null;
            bool      bShouldLogToFile = false;
            string    connectionName   = "";

            using (ConnectMessageBox connectMsgBox = new ConnectMessageBox())
            {
                bool successful = false;
                while (!successful)
                {
                    if (connectMsgBox.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            client           = new TcpClient(connectMsgBox.IpAddress, connectMsgBox.Port);
                            bShouldLogToFile = connectMsgBox.logToFileCheckBox.Checked;
                            connectionName   = connectMsgBox.ConnectionName;
                            successful       = true;
                        }
                        catch (Exception ex)
                        {
                            ex.ToString();
                            ConnectionErrorDialog ced = new ConnectionErrorDialog();
                            ced.errorLabel.Text += connectMsgBox.IpAddress + ":" + connectMsgBox.Port;
                            ced.ShowDialog();
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            string logWriteFilename = "";

            if (bShouldLogToFile)
            {
                SaveFileDialog fd = new SaveFileDialog();
                fd.CheckFileExists = false;
                fd.FileName        = "log.bin";
                fd.Filter          = "Binary log files (*.bin)|*.bin|All files (*.*)|*.*";
                fd.FilterIndex     = 0;

                if (fd.ShowDialog() == DialogResult.OK)
                {
                    logWriteFilename = fd.FileName;
                }
            }

            SocketSessionInfo sessionInfo = new SocketSessionInfo(connectionName, logWriteFilename);
            SocketLogData     logData     = new SocketLogData(sessionInfo);

            logData.ProcessRecords();

            List <LogRange> logRanges = new List <LogRange>();
            LogRange        logRange  = new LogRange(logData, null);

            logRanges.Add(logRange);
            ssForm.AddToLogRangeList(logRange);

            ssForm.CreateLogControlTabPage(logRanges, connectionName, null);

            ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessSocketDataStreamCB), new SSocketParseArgs(logData, logWriteFilename, client));

            return(logData);
        }
Beispiel #2
0
 public SocketLogData(SocketSessionInfo session)
     : base(session)
 {
 }