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); } }
private bool StartLogging(SessionSettings settings) { if (ActiveConnections.Count == 0) { this.ShowError("No connection."); return(false); } if (m_Logger != null) { this.ShowError("Already logging."); return(false); } pathSelector.Enabled = false; m_SessionNameBox.Enabled = false; m_StartButton.Enabled = false; m_LoggingPeriodBox.Enabled = false; m_StopButton.Enabled = true; openDirectory.Enabled = false; try { m_Logger = new SessionLogger(settings, ActiveConnections.ToArray()); m_Logger.Exception += DisplayException; m_Logger.Stopped += m_Logger_Stopped; m_Logger.Start(); timer1.Enabled = true; return(true); } catch (Exception ex) { StopLogging(); DisplayException(ex); return(false); } }
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)); } }