private void loadDocuments <T>(IEnumerable <T> documents, IBulkLoader <T> loader, BulkInsertMode mode, NpgsqlConnection conn, CharArrayTextWriter writer) { if (mode == BulkInsertMode.InsertsOnly) { loader.Load(_tenant, Serializer, conn, documents, writer); } else { loader.LoadIntoTempTable(_tenant, Serializer, conn, documents, writer); } }
public void Start() { if (!Directory.Exists(_directory)) { throw new DirectoryNotFoundException(_directory); } var info = new DirectoryInfo(_directory); _model.Clear(); OnStatus(this, "Getting initial directory list."); _loader.Load(_directory, _filter, _model); OnStatus(this, "Getting baseline counts for list."); List <FileEvent> initialpopulation = _model.AsFileEvents(FileEventType.Initialize); var batchCountTask = _counter.CountBatchAsync(initialpopulation, this); batchCountTask.Wait(); OnStatus(this, Monitoring); List <FileEvent> addUpdateBatch; List <FileEvent> deleteBatch; DateTime lastScanStart; for (int generation = 1; true; generation++) { lastScanStart = DateTime.Now; try { //_model.EnforceLocks = false; Scan(_model, info, generation, out addUpdateBatch, out deleteBatch); } finally { //_model.EnforceLocks = true; } Task addUpdateCounterTask = _counter.CountBatchAsync(addUpdateBatch, this); foreach (FileEvent e in deleteBatch) { OnFolderChanged(this, e); } double timeLeftInCycle = PollTimeMilliseconds - (DateTime.Now - lastScanStart).TotalMilliseconds; addUpdateCounterTask.Wait((int)timeLeftInCycle); // be courteous but don't delay next cycle. timeLeftInCycle = PollTimeMilliseconds - (DateTime.Now - lastScanStart).TotalMilliseconds; if (timeLeftInCycle > 1.0) { Thread.Sleep((int)(timeLeftInCycle)); } } }
public void Load(ISerializer serializer, NpgsqlConnection conn, IEnumerable <T> documents) { _parentBulkLoader.Load(serializer, conn, documents); }
public void Load(ITenant tenant, ISerializer serializer, NpgsqlConnection conn, IEnumerable <T> documents) { _inner.Load(tenant, serializer, conn, documents.OfType <TRoot>()); }
public void Load(ITenant tenant, ISerializer serializer, NpgsqlConnection conn, IEnumerable <T> documents, CharArrayTextWriter pool) { _inner.Load(tenant, serializer, conn, documents.OfType <TRoot>(), pool); }