public static DataTable StopMonitoring(string database, LogSequenceNumber startLsn, string connectionString) { var logTable = DataAccess.GetDataTable(connectionString, Properties.Resources.SQL_TransactionLog, database, "Transaction Log", CommandType.Text, new SqlParameter[] { new SqlParameter("begin", startLsn.ToDecimal()) }); logTable.Columns.Add(new DataColumn("PageAddress", typeof(PageAddress))); foreach (DataRow row in logTable.Rows) { var pageAddress = row["PageId"].ToString(); if (!string.IsNullOrEmpty(pageAddress)) { var page = PageAddress.Parse(row["PageId"].ToString()); row["PageAddress"] = page; } } return(logTable); }
private void LoadValueAndConvert(TextBox master) { if (string.IsNullOrEmpty(master.Text)) { return; } try { _lsnValue = new LogSequenceNumber(master.Text, _inputTextBoxConverter[master]); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error Parsing LSN Value", MessageBoxButtons.OK); return; } foreach (TextBox textBox in _inputTextBoxConverter.Keys) { if (master != textBox) { textBox.Text = _lsnValue.ToString(_inputTextBoxConverter[textBox]); } } }
/// <summary> /// Loads the checkpoint LSN directly from the page data. /// </summary> private void LoadCheckpointLsn() { var checkpointLsnValue = new byte[10]; Array.Copy(PageData, CheckpointLsnOffset, checkpointLsnValue, 0, LogSequenceNumber.Size); CheckpointLsn = new LogSequenceNumber(checkpointLsnValue); }
/// <summary> /// Handles the AfterExecute event before a query has been executed /// </summary> /// <param name="Guid">The GUID.</param> /// <param name="ID">The ID.</param> /// <param name="CustomIn">The custom in.</param> /// <param name="CustomOut">The custom out.</param> private void QueryExecute_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { if (this.DisplayTransactionLog) { string database = ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo.AdvancedOptions["DATABASE"]; string connectionString = ConnectionManager.GetConnectionString(ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo); this.startLsn = LogMonitor.StartMonitoring(connectionString, database); } }
private void Update(object sender) { TextBox textBox = sender as TextBox; LogSequenceNumber previousLsnValue = _lsnValue; LoadValueAndConvert(textBox); if (previousLsnValue != _lsnValue) { SetBackgroundColor(textBox); ResetFocus(textBox); } textBox.SelectAll(); }
private static RecordInfo TryGetLatestRecord(string tableName, Operation operation) { //grab the latest LSN LogSequenceNumber latestLsn = TestUtil.GetLastTransactionBeginLsn(); if (latestLsn == null) { return(null); } //start log reader LogReader reader = new LogReader(TestUtil.Connection); List <RecordInfo> records = new List <RecordInfo>(); reader.RecordReceived += delegate(RecordInfo record) { if (record.Operation == operation && record.Table != null && tableName.Equals(record.Table.Name)) { records.Add(record); } }; reader.Poll(latestLsn); return(records.Count == 0 ? null : records[0]); }