Exemplo n.º 1
0
        public void AppendResultInfo(object resultInfo)
        {
            _lockSlim.EnterWriteLock();

            try
            {
                _dir = SubDirOp.NextDir(_baseDir, _dir);

                var cur = Path.Combine(_dir, _fn);

                Action <CsvFileWriter, object> act = null;

                if (FileBakOp.NextFile(new FileInfo(cur)))
                {
                    _curFileName = FileBakOp.NextFileName;
                    act          = InitHeraders;
                }

                using (var fs = File.Open(_curFileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write))
                {
                    fs.Seek(0, SeekOrigin.End);
                    using (var csv = new CsvFileWriter(fs, _encoding))
                    {
                        var csr = ResultInfoToCsvRow(resultInfo);
                        if (csr != null)
                        {
                            act?.Invoke(csv, resultInfo);
                            csv.WriteRow(csr);
                            csv.Flush();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //ignore
            }

            _lockSlim.ExitWriteLock();
        }
Exemplo n.º 2
0
 public virtual void InitHeraders(CsvFileWriter csv, object resultInfo)
 {
 }