コード例 #1
0
        private void go(string[] args)
        {
            try
            {
                var path = args[0];

                FileInfo info = new FileInfo(path);
                if (!info.Exists)
                {
                    Console.WriteLine("Source file does not exist");
                    return;
                }

                totalMaximumBytes += new FileInfo(path).Length;

                var connectionInfo = new SDCardFileConnectionInfo();
                connectionInfo.FilePath = path;

                var connection = new Connection(connectionInfo);

                var directory = args[1];
                var logger    = new SessionLogger(SessionSettings.CreateForFileAndPath(directory, info), connection);

                logger.Start();

                connection.Message += new MessageEvent(ConnectionMessage);
                connection.Connect();

                logger.Stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #2
0
        private bool StopLogging()
        {
            timer1.Enabled = false;

            pathSelector.Enabled     = true;
            m_SessionNameBox.Enabled = true;

            m_StartButton.Enabled      = true;
            m_LoggingPeriodBox.Enabled = true;
            m_StopButton.Enabled       = false;

            if (m_Logger == null)
            {
                return(false);
            }

            m_Logger.Exception -= DisplayException;
            m_Logger.Stopped   -= m_Logger_Stopped;

            m_Logger.Stop();

            lastSessionDirectory = m_Logger.SessionDirectory;

            TimeSpan span = m_Logger.LoggingTime;

            m_ClockPanel.CurrentTime = span;

            m_ClockPanel.Invalidate();

            m_Logger = null;

            openDirectory.Enabled = true;

            return(true);
        }
        private void ReadThread()
        {
            try
            {
                string[] paths = GetPaths();

                m_TotalMaximumBytes  = 0;
                m_TotalProgressBytes = 0;

                m_MaximumBytes  = 0;
                m_ProgressBytes = 0;

                foreach (string path in paths)
                {
                    m_TotalMaximumBytes += new FileInfo(path).Length;
                }

                foreach (string path in paths)
                {
                    try
                    {
                        FileInfo info = new FileInfo(path);

                        m_TotalProgressBytes += m_ProgressBytes;

                        m_CurrentFile = info.Name;

                        m_MaximumBytes  = info.Length;
                        m_ProgressBytes = 0;

                        string directory = directorySelector.SelectedPath;

                        using (m_Connection = new Connection(new SDCardFileConnectionInfo()
                        {
                            FilePath = path
                        }))
                            using (m_Logger = new SessionLogger(SessionSettings.CreateForFileAndPath(directory, info), m_Connection))
                            {
                                m_Logger.Start();

                                m_Connection.Message += new MessageEvent(m_Connection_Message);
                                m_Connection.Connect();

                                m_Logger.Stop();
                            }
                    }
                    catch (Exception ex)
                    {
                        this.InvokeShowError(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                this.InvokeShowError(ex.Message);
            }
            finally
            {
                //IsRunning = false;
                this.Invoke(new Action(Done));
            }
        }