private void correctionButton_Click(object sender, System.EventArgs e)
        {
            if (false == ValidatePublisher())
            {
                return;
            }

            try
            {
                ConnectionManager.BeginTransaction();

                //
                // Deserialize into a change record object
                //
                StringReader reader = new StringReader(correctionTextBox.Text);

                ChangeRecordCorrection changeRecordCorrection = ( ChangeRecordCorrection )correctionSerializer.Deserialize(reader);

                //
                // Validate what we created.
                //
                SchemaCollection.Validate(changeRecordCorrection);

                //
                // Create a new change record to hold the correction.
                //
                ChangeRecord changeRecord = new ChangeRecord(changeRecordCorrection);
                changeRecord.Process();
                ConnectionManager.Commit();

                //
                // If we made it this far, we were able to process the correction
                //
                MessageBox.Show("Correction processed!");

                //
                // Refresh our display.
                //
                ShowChangeRecord();
            }
            catch (Exception exception)
            {
                ConnectionManager.Abort();

                MessageBox.Show("An exception occurred when trying to process the correction:\r\n\r\n" + exception.ToString());
            }
        }
示例#2
0
        static void FixChangeRecords(BusinessEntity businessEntity)
        {
            //
            // Get all related change records
            //
            ArrayList newDataChangeRecords = GetChangeRecordsForEntity(businessEntity);

            //
            // Create and process a correction for each change record.
            //
            Log("\t\tSTART Processing Corrections");
            foreach (ChangeRecord changeRecord in newDataChangeRecords)
            {
                ChangeRecord changeRecordCorrection = CreateCorrection(changeRecord, businessEntity);
                changeRecordCorrection.Process();

                LogChangeRecordCorrection(changeRecord, changeRecordCorrection);
            }
            Log("\t\tDONE Processing Corrections");
        }
示例#3
0
        static void FixDefaultURLs()
        {
            //
            // Get a list of business keys that have non-default discovery URLs.
            //
            ArrayList businessEntities = GetBusinessEntities();
            int       total            = businessEntities.Count;
            int       current          = 1;
            int       numberFixed      = 0;

            foreach (BusinessEntity businessEntity in businessEntities)
            {
                //
                // Get values for this business.
                //
                businessEntity.Get();

                //
                // BusinessEntity.Get() may add the default one, we don't want it.
                //
                DiscoveryUrlCollection originalList = new DiscoveryUrlCollection();
                originalList.Get(businessEntity.BusinessKey);
                businessEntity.DiscoveryUrls = originalList;

                Log("*** Processing " + current++ + "/" + total + " *** ");

                LogStartBusinessEntity(businessEntity);

                DiscoveryUrlCollection filteredList = GetFilterList(businessEntity);

                if (filteredList.Count < businessEntity.DiscoveryUrls.Count)
                {
                    try
                    {
                        numberFixed++;

                        LogFixStart(filteredList);

                        ConnectionManager.BeginTransaction();

                        //
                        // Remove duplicate discovery URLs
                        //
                        businessEntity.DiscoveryUrls = filteredList;

                        //
                        // Fix change records
                        //
                        FixChangeRecords(businessEntity);

                        //
                        // Fix data.  Saving the BusinessEntity will also create a ChangeRecordNew data in our replication stream.
                        // Other operators will consume this change record, which will update their databases.
                        //

                        FixData(businessEntity);
#if never
                        ChangeRecordNewData changeRecordNewData = new ChangeRecordNewData(businessEntity);
                        ChangeRecord        fixData             = new ChangeRecord(changeRecordNewData);
                        fixData.Process();
#endif
                        ConnectionManager.Commit();

                        LogFixEnd(businessEntity);
                    }
                    catch (Exception e)
                    {
                        WriteException(e);
                        ConnectionManager.Abort();
                    }
                }
                LogDoneBusinessEntity(businessEntity);
            }
            Log("BusinessEntities fixed: " + numberFixed);
        }