public override void Import(ImportSourceType importSource, IDBReader dbReaderManager, bool modifyTimestamp) { this.upgradeTimestamp = modifyTimestamp; this.useTimeRange = false; IsRunning = true; try { // Reset the thread if ((readerThread != null) && ((readerThread.ThreadState == System.Threading.ThreadState.Running) || (readerThread.ThreadState == System.Threading.ThreadState.Background))) { readerThread.Abort(); } this.dbReaderManager = dbReaderManager; readerThread = null; // Create the thread switch (importSource) { case ImportSourceType.KParser: if (dbReaderManager is KParserReadingManager) { readerThread = new Thread(ImportKParserDB); } break; case ImportSourceType.DVSParse: case ImportSourceType.DirectParse: if (dbReaderManager is DirectParseReadingManager) { readerThread = new Thread(ImportDirectParseDB); } break; default: throw new NotImplementedException(); } readerThread.IsBackground = true; readerThread.Name = "Read database thread"; readerThread.Start(); } catch (Exception e) { Logger.Instance.Log(e); IsRunning = false; OnReaderStatusChanged(new ReaderStatusEventArgs(0, 0, false, true)); dbReaderManager.CloseDatabase(); } }
public virtual void Join(ImportSourceType importSource, IDBReader dbReaderManager, IDBReader dbReaderManager2) { throw new NotImplementedException(); }
public virtual void Import(ImportSourceType importSource, IDBReader dbReaderManager, bool modifyTimestamp) { throw new NotImplementedException(); }
public virtual void ImportRange(ImportSourceType importSource, IDBReader dbReaderManager, bool modifyTimestamp, DateTime startOfRange, DateTime endOfRange) { throw new NotImplementedException(); }
/// <summary> /// Import data from another database (reparse, DVS, DirectParse, etc) /// </summary> /// <param name="inFilename1">The name of the first database file to import.</param> /// <param name="inFilename2">The name of the second database file to import.</param> /// <param name="outputFileName">The name of the new database.</param> /// <param name="importSource">The type of database to import.</param> public void JoinAll(List <string> inFilenames, string outputFileName, ImportSourceType importSource) { try { if (currentReader.IsRunning == true) { throw new InvalidOperationException(string.Format( "{0} is already running", currentReader.GetType().Name)); } if (inFilenames.Count < 2) { throw new ArgumentOutOfRangeException("inFilenames", "At least two files must be selected for joining."); } if (importSource != ImportSourceType.KParser) { throw new ArgumentOutOfRangeException("importSource", "Can only perform joins on KParser parses."); } currentReader = DatabaseReader.Instance; DatabaseManager.Instance.CreateDatabase(outputFileName); System.Threading.Thread.Sleep(100); IDBReader dbReader = KParserReadingManager.Instance; IDBReader dbReader2 = new KParserReadingManager(); var mainParse = inFilenames.First(); var otherParses = inFilenames.Skip(1); dbReader.OpenDatabase(mainParse); if (dbReader.DatabaseParseVersion.CompareTo("1.3") < 0) { throw new InvalidOperationException("Reparse to upgrade timestamps first."); } foreach (var parse in otherParses) { try { dbReader2.OpenDatabase(parse); try { MsgManager.Instance.StartNewSession(); currentReader.Join(importSource, dbReader, dbReader2); } catch (Exception) { MsgManager.Instance.EndSession(); throw; } } finally { dbReader2.CloseDatabase(); } } } catch (Exception) { ReaderStatusListener(currentReader, new ReaderStatusEventArgs(0, 0, false, true)); throw; } }