public long Write() { if (_targets.Count < 1) { throw new IOException("No targets were set"); } var writeCount = 0L; while (RecordSource.MoveToNextRunData()) { var target = _targets[_currentTarget]; var writer = target.BeginWrite(); Line record; while ((record = RecordSource.Read()) != null) { writer.WriteLine($"{record.Number}. {record.Text}"); writeCount += 1; } target.EndWrite(); _currentTarget++; if (_currentTarget >= _targets.Count) { _currentTarget = 0; } } return(writeCount); }
public Factory(RecordSource source) { switch (source.SourceType.RSTID) { case 1: connection = new SQLite(source.ConnectionString); break; default: throw new NotImplementedException(); } }
public async Task <RecordSource[]> GetSources() { var processes = Process.GetProcesses(); var thisProcess = Process.GetCurrentProcess(); var list = new List <RecordSource>(); foreach (var process in processes) { if (process.Id == thisProcess.Id) { continue; } IntPtr mainWindowHandle = process.MainWindowHandle; RECT rect = new RECT(); if (GetWindowRect(mainWindowHandle, ref rect)) { var height = rect.right - rect.left; var width = rect.bottom - rect.top; if (width == 0 || height == 0) { continue; } //MoveWindow(mainWindowHandle, Rect.left, Rect.right, Rect.right - Rect.left, Rect.bottom - Rect.top + 50, true); //CaptureWindow(mainWindowHandle, process.ProcessName); var stream = CaptureApplication(process.ProcessName, rect); var source = new RecordSource { Name = process.ProcessName, Id = process.Id, Height = height, Width = width }; list.Add(source); await Task.Run(() => { source.SetImage(stream); }); } } return(list.ToArray()); }
public virtual string Next() { if (this.notUndo) { this.RecordBuffer = RecordSource.ReadLine(); if (null == RecordBuffer) { // sawangchai add Close(); due to error file being use by another process. Close(); throw new EndOfStreamException(); } else { ++this.LineNo; } } this.notUndo = true; return(this.RecordBuffer); }
public override RecordCountCache FetchCountCache(RecordSource source, int tik) { SQLiteCommand command = new SQLiteCommand("SELECT RCCID, TIK, Count, TimeStamp, DateTime() FROM RecordCountCache WHERE TIK=@tik AND RSID=@rsid", connection); command.Parameters.AddWithValue("@tik", tik); command.Parameters.AddWithValue("rsid", source.RSID); SQLiteDataReader reader = command.ExecuteReader(); if (reader.HasRows) { reader.Read(); return(new RecordCountCache(reader.GetInt32(0), reader.GetInt32(1), source, reader.GetInt32(2), Convert.ToDateTime(reader.GetString(3)), Convert.ToDateTime(reader.GetString(4)))); } else { //Need to create new count cache //Get the count from the source Records.Dispatcher dispatcher = new Records.Dispatcher(source); int count = dispatcher.FetchTestRecordCount(tik); //Insert and get the last ID so that it can be selected SQLiteCommand insertCommand = new SQLiteCommand("INSERT INTO RecordCountCache (RSID, TIK, Count, Timestamp) VALUES (@rsid, @tik, @count, DateTime())", connection); insertCommand.Parameters.AddWithValue("@rsid", source.RSID); insertCommand.Parameters.AddWithValue("@tik", tik); insertCommand.Parameters.AddWithValue("@count", count); insertCommand.ExecuteNonQuery(); //Created, now fetch by recursion return(FetchCountCache(source, tik)); } throw new NotImplementedException(); }
public abstract RecordCountCache FetchCountCache(RecordSource source, int tik);
public Dispatcher(RecordSource source) { Source = source; factory = new Data.Factory(source); }