Ejemplo n.º 1
0
        public ILogLoader Create(string cestaSouboru)
        {
            Session session = sessionManager.Current;
            var     parser  = new LogDataParser(session.RowTemplate);

            return(new LogLoader(parser, cestaSouboru));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Log convert process entrance.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LogConvertProcessEntrance(object sender, DoWorkEventArgs e)
        {
            this.PreworkForBGW();

            bool       isSuccessful = true;
            string     errorMsg     = "";
            FileStream sourceStream = new FileStream(logDataFilePath, FileMode.Open);

            try
            {
                if (saveDataType == 1)
                {
                    int          len     = 1000;
                    int          readNum = 0;
                    byte[]       bytes   = new byte[len];
                    StreamWriter writer  = new StreamWriter(this.exportDestFilePath);
                    int          wl      = 0;
                    writer.Write("00000---");

                    int  processValue = 1;
                    long all          = sourceStream.Length;
                    while ((readNum = sourceStream.Read(bytes, 0, len)) > 0)
                    {
                        for (int i = 0; i < readNum; i++)
                        {
                            writer.Write(bytes[i].ToString("X2"));
                            writer.Write("  ");
                            wl++;
                            if (wl % 10 == 0)
                            {
                                writer.WriteLine();
                                writer.Write(wl.ToString("X5") + "---");
                            }
                        }
                        long persent = sourceStream.Position * 100 / all;
                        if (persent > processValue)
                        {
                            processValue = (int)persent;
                            this.setProgressBarValue(processValue);
                        }
                    }
                }
                else
                {
                    while (this.GetAllMessages)
                    {
                        Thread.Sleep(1);
                    }
                    LogDataParser.ParseProcessBarDelegateEvent += this.setProgressBarValue;
                    isSuccessful = LogDataParser.parseLogData(sourceStream, this.exportDestFilePath, this.AllMessageModels, (saveDataType == 2));
                    LogDataParser.ParseProcessBarDelegateEvent -= this.setProgressBarValue;
                }
            }
            catch (Exception ee)
            {
                isSuccessful = false;
                errorMsg    += ee.Message;
            }
            try
            {
                this.Invoke((ThreadStart) delegate()
                {
                    if (isSuccessful)
                    {
                        this.setProgressBarValue(100);
                        MessageBoxEX.Show(this, "Log data converted successfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBoxEX.Show(this, "Failed to convert log data: " + errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                });
            }
            catch
            {
            }
            sourceStream.Close();
            //this.destFileWriter.Close();
            //this.destFileWriter = null;

            this.setProgressBarValue(0);
        }