Exemple #1
0
        public async Task <Stream> ParseCsvAsync(string csvUri, OutputFormats outputFormat)
        {
            try
            {
                IReader csvReader = await CsvReaderService.GetCsvReaderAsync(csvUri);

                if (csvReader != null)
                {
                    IAsyncEnumerable <ParsedCsvRow> filteredRows = CsvFilterService.FilterCsvOnSumAsync(csvReader);

                    ICsvPrinterService CsvPrinter = Printers[outputFormat];

                    Stream outputStream = await CsvPrinter.PrintCsvAsync(filteredRows);

                    csvReader.Dispose();

                    return(outputStream);
                }

                return(null);
            }
            catch (Exception e)
            {
                Logger.LogError($"Error: {e.Message}");

                return(null);
            }
        }
Exemple #2
0
        public void Dispose()
        {
            bool isBusy = true;

            do
            {
                idCardReader.Cancelled             = true;
                icCardReaderWriter.Cancelled       = true;
                magneticCardReaderWriter.Cancelled = true;
                caller.Cancelled    = true;
                evaluator.Cancelled = true;
                log.Info("set idCardReader, icCardReaderWriter, magneticCardReaderWriter caller, evaluator Cancelled = true");

                isBusy = idCardReader.IsBusy || icCardReaderWriter.IsBusy || magneticCardReaderWriter.IsBusy || caller.IsBusy || evaluator.IsBusy;
                Thread.Sleep(200);
            }while (isBusy);
            log.Info("wait idCardReader, icCardReaderWriter, magneticCardReaderWriter caller, evaluator exit loop ok");

            magneticCardReaderWriter.Dispose();
            icCardReaderWriter.Dispose();
            idCardReader.Dispose();
            needlePrinter.Dispose();
            barScreen.Dispose();
            compScreen.Dispose();
            caller.Dispose();
            //voicePlayer.Dispose();

            Thread.Sleep(2000);
        }
Exemple #3
0
 private void dispose(bool disposing)
 {
     if (disposing)
     {
         parser.Dispose();
     }
     isClosed = true;
 }
Exemple #4
0
 private void CloseReader()
 {
     if (_reader != null)
     {
         _reader.Dispose();
         _reader = null;
     }
 }
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            try
            {
                if (!File.Exists(sourceFile))
                {
                    e.Result = false;
                    return;
                }

                FileInfo fi = new FileInfo(sourceFile);
                if (fi.Length == 0)
                {
                    e.Result = false;
                    return;
                }

                using (Stream stream = File.OpenRead(sourceFile))
                {
                    reader = ReaderFactory.Open(stream);


                    while (reader.MoveToNextEntry())
                    {
                        if (!reader.Entry.IsDirectory)
                        {
                            //Console.WriteLine(reader.Entry.Key);
                            reader.WriteEntryToDirectory(destinationPath,
                                                         new ExtractionOptions()
                            {
                                ExtractFullPath = true, Overwrite = true
                            });
                        }
                        else
                        {
                            Directory.CreateDirectory(string.Format("{0}\\{1}", destinationPath, reader.Entry.Key));
                        }



                        if (CancellationPending)
                        {
                            reader.Dispose();
                            e.Result = false;
                            break;
                        }
                        else
                        {
                            e.Result = true;
                        }
                    }
                }
            }
            catch
            {
                e.Result = false;
            }
        }
Exemple #6
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;
            _reader.Dispose();
        }
Exemple #7
0
        /// <summary>
        /// Tokenizes the input.
        /// </summary>
        public void Tokenize(IReader reader)
        {
            this.reader = reader;

            try
            {
                CurrentLine       = 1;
                PositionOnLine    = 0;
                LastToken         = null;
                LastTokenPosition = 0;
                Tokens.Clear();
                CurrentTokenChars.Clear();

                TokenizeCore();
            }
            finally
            {
                reader.Dispose();
            }
        }
Exemple #8
0
        private IArchResult GetResult()
        {
            _waitHandle.WaitOne();

            _reader.Dispose();
            _writer.Dispose();
            _scheduler.Dispose();

            //Console.WriteLine($"Thread count: {((SimpleAchScheduler)_scheduler).ThreadCount}");

            if (IsCancelled)
            {
                return(ArchResult.Cancelled());
            }
            if (IsFaulted)
            {
                var exception = new AggregateException(exceptions.ToArray());
                var message   = exception.Flatten().Message;
                return(ArchResult.Faulted(message));
            }
            return(ArchResult.Success());
        }
 public void Dispose()
 {
     reader.Dispose();
     writer.Dispose();
 }
Exemple #10
0
 public virtual void Dispose()
 {
     _underlying.Dispose();
 }
Exemple #11
0
 public void Dispose()
 {
     _reader.Dispose();
 }
 private void DisconnectScud()
 {
     _scudReader.Disconnect();
     _scudReader.Dispose();
 }
Exemple #13
0
 protected override void DisposeCore()
 {
     _reader.Dispose();
     base.DisposeCore();
 }
 public void Dispose()
 {
     _csvReader.Dispose();
     _streamReader.Dispose();
     _stream.Dispose();
 }
Exemple #15
0
 public void Dispose()
 {
     _reader?.Dispose();
     _writer?.Dispose();
     _blocksLimiter?.Dispose();
 }
Exemple #16
0
 public void Dispose()
 {
     _securedReader.Dispose();
 }
 private void DisconnectIpt()
 {
     _iptReader.Disconnect();
     _iptReader.Dispose();
     _isIptConnected = false;
 }