public override void Execute()
        {
            base.Execute();

            TableInfoSynchronizer syncher = new TableInfoSynchronizer(_tableInfo);
            var listener = _autoYes ? new AcceptAllCheckNotifier() :(ICheckNotifier) new FromActivateItemsToCheckNotifier(BasicActivator);

            try
            {
                bool wasSynchedsuccessfully = syncher.Synchronize(listener);

                if (wasSynchedsuccessfully)
                {
                    BasicActivator.Show("Synchronization complete, TableInfo is Synchronized with the live database");
                }
                else
                {
                    BasicActivator.Show("Synchronization failed");
                }
            }
            catch (Exception exception)
            {
                BasicActivator.ShowException("Failed to sync", exception);
            }

            if (_alsoSyncAno)
            {
                var ANOSynchronizer = new ANOTableInfoSynchronizer(_tableInfo);

                try
                {
                    ANOSynchronizer.Synchronize(listener);

                    BasicActivator.Show("ANO synchronization successful");
                }
                catch (ANOConfigurationException e)
                {
                    BasicActivator.ShowException("Anonymisation configuration error", e);
                }
                catch (Exception exception)
                {
                    BasicActivator.ShowException("Fatal error while attempting to synchronize (" + exception.Message + ")", exception);
                }
            }

            Publish(_tableInfo);

            foreach (var c in syncher.ChangedCatalogues)
            {
                Publish(c);
            }
        }
Exemple #2
0
        private void SynchronizeANOConfiguration_Click(TableInfo tableInfo)
        {
            //let use check the TableInfo accurately reflects the underlying database first
            if (_activator.YesNo("Check that TableInfo is synchronized with underlying database first?", "Check database first?"))
            {
                try
                {
                    TableInfoSynchronizer synchronizer = new TableInfoSynchronizer(tableInfo);
                    bool isSynchronized = synchronizer.Synchronize(new ThrowImmediatelyCheckNotifier());
                    if (!isSynchronized)
                    {
                        MessageBox.Show("Unable to synchronize with ANO database because TableInfo is not synchronized with underlying database.");
                        return;
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(
                        "Unable to check synchronization of TableInfo with underlying database (this check must be performed before checking ANO synchronization):" +
                        exception.Message);
                    return;
                }
            }

            var ANOSynchronizer = new ANOTableInfoSynchronizer(tableInfo);

            try
            {
                ANOSynchronizer.Synchronize(new MakeChangePopup(new YesNoYesToAllDialog()));

                MessageBox.Show("ANO synchronization successful");
            }
            catch (ANOConfigurationException e)
            {
                ExceptionViewer.Show(e);
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show("Fatal error while attempting to synchronize (" + exception.Message + ")", exception);
            }

            Publish(tableInfo);
        }
        public void Check(ICheckNotifier notifier)
        {
            //check ANO stuff is synchronized
            notifier.OnCheckPerformed(new CheckEventArgs("Preparing to synchronize ANO configuration", CheckResult.Success, null));

            ANOTableInfoSynchronizer synchronizer = new ANOTableInfoSynchronizer(_tableInfo);

            try
            {
                synchronizer.Synchronize(notifier);
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Synchronization of Anonymsiation configurations of table " + _tableInfo.GetRuntimeName() + " failed with Exception", CheckResult.Fail, e, null));
            }

            if (_tableInfo.IdentifierDumpServer_ID != null)
            {
                var identifierDumper = new IdentifierDumper(_tableInfo);
                identifierDumper.Check(notifier);
            }
        }