Exemple #1
0
        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);
        }
Exemple #2
0
 private void StartWatcher()
 {
     LoggerHelper.AddInfoLog(eventLog, "Start watcher in service");
     _unity.StartFileWatcher(_directoryPath);
     while (true)
     {
     }
 }
Exemple #3
0
 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");
 }
Exemple #4
0
 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");
 }
Exemple #5
0
 protected override void OnPause()
 {
     _unity.StopFileWatcher();
     LoggerHelper.AddInfoLog(eventLog, "Pause service");
 }
Exemple #6
0
 protected override void OnStop()
 {
     LoggerHelper.AddInfoLog(eventLog, "Stop service");
     eventLog.Dispose();
 }