/// **************************************************************** /// public Process /// ---------------------------------------------------------------- /// <summary> /// </summary> /// **************************************************************** /// public void Process() { // // Add the change record to our change log as a foreign change. // long LSN = Log(); // // Process the change record payload. // Payload.Process(LSN); // // If an acknowledgement was requested, generate a // acknowledgement change record. // if (AcknowledgementRequested) { // // Save the log entry as our local system account, not the // current user. // string puid = Context.User.ID; Context.User.ID = null; ChangeRecord changeRecord = new ChangeRecord(); changeRecord.Payload = new ChangeRecordAcknowledgement(ChangeID); changeRecord.Log(); Context.User.ID = puid; } }
/// **************************************************************** /// public Get /// ---------------------------------------------------------------- /// <summary> /// </summary> /// **************************************************************** /// public ChangeRecordDetail Get() { Debug.VerifySetting("OperatorKey"); ChangeRecordDetail detail = new ChangeRecordDetail(); try { // // Get the list of known operators. // StringCollection operators = new StringCollection(); SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor(); sp.ProcedureName = "net_operators_get"; SqlDataReaderAccessor reader = sp.ExecuteReader(); try { while (reader.Read()) { operators.Add(reader.GetGuidString("operatorKey")); } } finally { reader.Close(); } // // Set the search criteria for change records. // foreach (string operatorKey in operators) { long startUSN; long stopUSN; startUSN = 0; foreach (ChangeRecordVector mark in ChangesAlreadySeen) { if (0 == String.Compare(operatorKey, mark.NodeID, true)) { startUSN = mark.OriginatingUSN + 1; break; } } stopUSN = System.Int64.MaxValue; foreach (ChangeRecordVector mark in ResponseLimitVector) { if (0 == String.Compare(operatorKey, mark.NodeID, true)) { stopUSN = mark.OriginatingUSN; break; } } FindChangeRecords.SetRange(operatorKey, startUSN, stopUSN); } // // Retrieve the change records. // int limit = Config.GetInt("Replication.ResponseLimitCountDefault"); if (ResponseLimitCount >= 0 && ResponseLimitCount <= limit) { limit = ResponseLimitCount; } reader = FindChangeRecords.RetrieveResults(limit); try { while (reader.Read()) { XmlSerializer serializer = null; switch ((ChangeRecordPayloadType)reader.GetShort("changeTypeID")) { case ChangeRecordPayloadType.ChangeRecordNull: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordNull)); break; case ChangeRecordPayloadType.ChangeRecordNewData: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordNewData)); break; case ChangeRecordPayloadType.ChangeRecordDelete: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordDelete)); break; case ChangeRecordPayloadType.ChangeRecordPublisherAssertion: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordPublisherAssertion)); break; case ChangeRecordPayloadType.ChangeRecordHide: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordHide)); break; case ChangeRecordPayloadType.ChangeRecordDeleteAssertion: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordDeleteAssertion)); break; case ChangeRecordPayloadType.ChangeRecordAcknowledgement: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordAcknowledgement)); break; case ChangeRecordPayloadType.ChangeRecordCorrection: serializer = XmlSerializerManager.GetSerializer(typeof(ChangeRecordCorrection)); break; } StringReader stringReader = new StringReader(reader.GetString("changeData")); try { ChangeRecord changeRecord = new ChangeRecord(); changeRecord.AcknowledgementRequested = (reader.GetInt("flag") & (int)ChangeRecordFlags.AcknowledgementRequested) > 0; changeRecord.ChangeID.NodeID = reader.GetString("OperatorKey"); changeRecord.ChangeID.OriginatingUSN = reader.GetLong("USN"); ChangeRecordBase changeRecordBase = ( ChangeRecordBase )serializer.Deserialize(stringReader); if (changeRecordBase is ChangeRecordCorrection) { // // The query to find change records will do correction 'fixups'. That is, the changeData of this // change record will be replaced with the changeData from the correction. The problem with this is // that the original change data will now look like a correction. To distinguish these types of // change records, we look to see if the OriginatingUSN's match. If the OriginatingUSN's match, // we want they payload of the change record in this correction. This payload will contain the // corrected data that we want. // ChangeRecordCorrection changeRecordCorrection = ( ChangeRecordCorrection )changeRecordBase; if (changeRecordCorrection.ChangeRecord.ChangeID.OriginatingUSN == changeRecord.ChangeID.OriginatingUSN) { changeRecordBase = changeRecordCorrection.ChangeRecord.Payload; } } changeRecord.Payload = changeRecordBase; detail.ChangeRecords.Add(changeRecord); } finally { stringReader.Close(); } } } finally { reader.Close(); } } catch (Exception e) { Debug.OperatorMessage( SeverityType.Error, CategoryType.Replication, OperatorMessageType.None, "Could not retrieve change records:\r\n" + e.ToString()); FindChangeRecords.CleanUp(); throw; } return(detail); }
public void Remove(ChangeRecord changeRecord) { List.Remove(changeRecord); }
public bool Contains(ChangeRecord changeRecord) { return(List.Contains(changeRecord)); }
public int IndexOf(ChangeRecord changeRecord) { return(List.IndexOf(changeRecord)); }
public void Insert(int index, ChangeRecord changeRecord) { List.Insert(index, changeRecord); }
public int Add(ChangeRecord changeRecord) { return(List.Add(changeRecord)); }