Пример #1
0
        static ChangeRecord CreateCorrection(ChangeRecord originalChangeRecord, BusinessEntity businessEntity)
        {
            ChangeRecordNewData changeRecordNewData = originalChangeRecord.Payload as ChangeRecordNewData;

            changeRecordNewData.Entity = businessEntity;

            ChangeRecordCorrection changeRecordCorrection = new ChangeRecordCorrection();

            changeRecordCorrection.ChangeRecord = originalChangeRecord;

            return(new ChangeRecord(changeRecordCorrection));
        }
Пример #2
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);
        }