コード例 #1
0
        /// ****************************************************************
        ///   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);
        }
コード例 #2
0
 public ChangeRecord()
 {
     ChangeID.NodeID         = null;
     ChangeID.OriginatingUSN = 0;
     Payload = null;
 }
コード例 #3
0
 public ChangeRecord(ChangeRecordBase payload)
 {
     ChangeID.NodeID         = null;
     ChangeID.OriginatingUSN = 0;
     Payload = payload;
 }
コード例 #4
0
 public ChangeRecord(ChangeRecordVector changeID, ChangeRecordBase payload)
 {
     ChangeID = changeID;
     Payload  = payload;
 }