internal static IList <string[]> ReadCsvFile(string fullPath, string fileName) { IList <string[]> listStringLine = new List <string[]>(); var textFile = File.OpenText(fullPath); _currentLine = 0; var invalid = false; try { while (!textFile.EndOfStream) { _currentLine++; var stringLine = textFile.ReadLine(); listStringLine.Add(ParseCsvStringLine(fileName, stringLine)); } } catch (ParserException e) { LoggerHelper.AddErrorLog(new EventLog(), string.Join(" ", e.Message, "On line", _currentLine)); invalid = true; } finally { ((IDisposable)textFile).Dispose(); } MoveFile(fullPath, invalid); LoggerHelper.AddInfoLog(new EventLog(), string.Join(string.Empty, "File \"", fileName, "\" processing completed")); return(listStringLine); }
private void StartWatcher() { LoggerHelper.AddInfoLog(eventLog, "Start watcher in service"); _unity.StartFileWatcher(_directoryPath); while (true) { } }
protected override void OnContinue() { if (CheckProcessConsole()) { LoggerHelper.AddErrorLog(eventLog, "The service cannot be started while the console application is running"); Environment.Exit(0); } StartTaskWatcher(); LoggerHelper.AddInfoLog(eventLog, "Resume service"); }
protected override void OnStart(string[] args) { if (CheckProcessConsole()) { LoggerHelper.AddErrorLog(eventLog, "The service cannot be started while the console application is running"); Environment.Exit(0); } LoggerHelper.AddInfoLog(eventLog, "Start service"); StartTaskWatcher(); LoggerHelper.AddInfoLog(eventLog, "Start file watcher"); }
protected override void OnPause() { _unity.StopFileWatcher(); LoggerHelper.AddInfoLog(eventLog, "Pause service"); }
protected override void OnStop() { LoggerHelper.AddInfoLog(eventLog, "Stop service"); eventLog.Dispose(); }