Ejemplo n.º 1
0
        public void ExecuteSetMessagesReadMarkByDate(ICommandContext context)
        {
            using (var mmrf = new MarkMsgReadForm(context))
            {
                var owner = context
                            .GetRequiredService <IUIShell>()
                            .GetMainWindowParent();

                if (mmrf.ShowDialog(owner) != DialogResult.OK)
                {
                    return;
                }

                var msgText = SR.Forum.MarkMessageCaption;
                var resText = string.Empty;

                // Заносим данные в замыкание, так как после диспоза формы часть
                // данный теряется.
                var forumIds =
                    mmrf.MarkAllForums
                                                ? Enumerable.Empty <int>()
                                                : mmrf.ForumsIdsForMark;
                ProgressWorker.Run(context, false,
                                   pi =>
                {
                    pi.SetProgressText(msgText);

                    context.LogInfo(msgText);

                    var markCount =
                        ForumHelper.MarkMessagesByDate(
                            context,
                            forumIds,
                            mmrf.MarkAsRead,
                            mmrf.BeforeDate,
                            mmrf.AfterDate,
                            mmrf.ExceptAnswersMe);

                    resText = SR.Forum.MarkMessageResult.FormatStr(
                        markCount,
                        markCount.GetDeclension(
                            SR.Forum.Message1,
                            SR.Forum.Message2,
                            SR.Forum.Message5));

                    context.LogInfo(resText);
                },
                                   () => MessageBox.Show(
                                       owner,
                                       resText,
                                       ApplicationInfo.ApplicationName,
                                       MessageBoxButtons.OK,
                                       MessageBoxIcon.Information));
            }
        }
Ejemplo n.º 2
0
        public void ExecuteStateImport(ICommandContext context)
        {
            using (var dialog = new RestoreStateDialog())
            {
                if (dialog.ShowDialog(context.GetRequiredService <IUIShell>().GetMainWindowParent()) != DialogResult.OK)
                {
                    return;
                }

                ProgressWorker.Run(
                    context,
                    false,
                    pi => new StateObject(context, dialog.FileName).RestoreState(dialog.Options));
            }
        }
Ejemplo n.º 3
0
        public void ExecuteSetAllMessagesInForumReadMark(
            ICommandContext context, int[] forumIds, bool isRead)
        {
            if (Config.Instance.ConfirmationConfig.ConfirmMarkAll &&
                MessageBox.Show(
                    context.GetRequiredService <IUIShell>().GetMainWindowParent(),
                    SR.Forum.PromptMarkAll.FormatStr(
                        isRead ? SR.Forum.PromptRead : SR.Forum.PromptUnread),
                    ApplicationInfo.ApplicationName,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2) != DialogResult.Yes)
            {
                return;
            }

            ProgressWorker.Run(
                context,
                false,
                info => ForumHelper.SetForumsReadMark(context, GetForums(context, forumIds), isRead));
        }
Ejemplo n.º 4
0
 public static void UpdateForumsSubscriptions(
     [NotNull] System.IServiceProvider serviceProvider,
     [NotNull] IEnumerable <ForumSubscriptionRequest> requests,
     bool promptToDelete)
 {
     ProgressWorker.Run(
         serviceProvider,
         false,
         progressVisualizer =>
     {
         progressVisualizer.SetProgressText(Resources.SubscribeMessage);
         UpdateForumsSubscriptions(
             serviceProvider,
             requests,
             (id, name, descript) =>
             promptToDelete &&
             MessageBox.Show(
                 Resources.WarningOnUnsubscribeForum.FormatStr(descript),
                 Resources.WarningOnUnsubscribeForumCaption,
                 MessageBoxButtons.YesNo,
                 MessageBoxIcon.Question) == DialogResult.Yes);
     });
 }
        private void BtnSearchClick(object sender, EventArgs e)
        {
            var searchText = comboSearchEntry.Text.Trim();

            #region Проверка пустой строки поиска
            if (searchText.Trim().Length == 0 &&
                !Config.Instance.AdvancedSearch)
            {
                var text = SR.Search.NoParams;
                _serviceManager.LogInfo(text);

                MessageBox.Show(text, SR.Search.Title,
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #endregion

            #region Проверка строки поиска
            //TODO валится при вводе ]test[
            // нужно бы еще эту ситуацию доработать
            var cntLeftSquare  = 0;
            var cntRightSquare = 0;

            foreach (var t in searchText)
            {
                switch (t)
                {
                case '[':
                    cntLeftSquare++;
                    break;

                case ']':
                    cntRightSquare++;
                    break;
                }
            }

            if (cntLeftSquare != cntRightSquare)
            {
                var text = SR.Search.EntryContainsBadCode;
                _serviceManager.LogInfo(text);

                MessageBox.Show(text, SR.Search.Title,
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                comboSearchEntry.Focus();
                return;
            }
            #endregion

            Config.Instance.SearchText = searchText;

            // Чтобы последняя срока поиска была вверху и не дублировалась
            if (comboSearchEntry.Items.Contains(searchText))
            {
                comboSearchEntry.Items.Remove(searchText);
            }

            comboSearchEntry.Items.Insert(0, searchText);
            comboSearchEntry.Text = searchText;

            // Защита от переполнения списка, он не безразмерный
            while (comboSearchEntry.Items.Count > comboSearchEntry.MaxDropDownItems)
            {
                comboSearchEntry.Items.RemoveAt(comboSearchEntry.Items.Count - 1);
            }

            // Сохраним список сразу в конфиг
            Config.Instance.SearchList = new string[comboSearchEntry.Items.Count];
            comboSearchEntry.Items.CopyTo(Config.Instance.SearchList, 0);
            var searchFromValue = searchFromDate.Checked ? searchFromDate.Value : new DateTime(0);
            var searchToValue   = searchToDate.Checked ? searchToDate.Value : new DateTime(0);

            List <MsgBase> msgs = null;
            ProgressWorker.Run(_serviceManager, false,
                               pi =>
            {
                pi.SetProgressText(SR.Search.Searching);

                try
                {
                    msgs =
                        SearchHelper
                        .SearchMessagesByLucene(
                            _serviceManager,
                            Config.Instance.AdvancedSearch ? Config.Instance.SearchForumId : -1,
                            Config.Instance.SearchText,
                            Config.Instance.SearchInText,
                            Config.Instance.SearchInSubject,
                            Config.Instance.SearchAuthor,
                            Config.Instance.SearchInMarked,
                            Config.Instance.SearchInMyMessages,
                            Config.Instance.SearchAnyWord,
                            Config.Instance.SearchInQuestions,
                            searchFromValue,
                            searchToValue);
                }
                catch (FileNotFoundException)
                {
                    _asyncOperation.Post(
                        () =>
                    {
                        if (MessageBox.Show(
                                this,
                                Search.Search.NoSearchIndexQuestion,
                                Application.ProductName,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Exclamation) == DialogResult.Yes)
                        {
                            using (var bif = new BuildIndexForm(_serviceManager))
                                bif.ShowDialog(this);
                        }
                    });

                    msgs = new List <MsgBase>();
                }

                if (searchInOverquoting.Checked)
                {
                    FilterOverquoting(msgs);
                }

                _serviceManager
                .LogInfo(
                    msgs.Count > 0
                                                                ? string.Format(SR.Search.LogFound, msgs.Count)
                                                                : SR.Search.LogNotFound);

                pi.SetProgressText(SR.Search.OutResults);
            },
                               () => FillGrid(msgs));
        }
Ejemplo n.º 6
0
        private void GridDragDrop(object sender, DragEventArgs e)
        {
            var effect = DragDropEffects.None;

            if (sender == _grid)
            {
                int dummy;
                var point = _grid.PointToClient(new Point(e.X, e.Y));

                ITreeNode activeNode;
                _grid.GetNodeAndCellIndexAt(point.X, point.Y, out activeNode, out dummy);
                if (activeNode == null)
                {
                    activeNode = _favManager.RootFolder;
                }

                var activeEntry = activeNode as IFavoritesEntry;
                if (activeEntry != null)
                {
                    var activeFolder = activeEntry.IsContainer ? (FavoritesFolder)activeEntry : (FavoritesFolder)activeEntry.Parent;
                    if (e.Data.GetDataPresent(typeof(TreeNodeBag)))
                    {
                        var dropNodes = (TreeNodeBag)e.Data.GetData(typeof(TreeNodeBag));
                        if (dropNodes != null && dropNodes.Count > 0)
                        {
                            var select = LastActiveNode ?? _grid.ActiveNode;
                            if (dropNodes.IsAssignableFrom(typeof(IFavoritesEntry)))
                            {
                                var copy        = DragDropHelper.GetDropEffect(e.KeyState, true) == DragDropEffects.Copy;
                                var failedItems = new List <IFavoritesEntry>();
                                ProgressWorker.Run(_serviceManager, false,
                                                   pi =>
                                {
                                    pi.SetProgressText(SR.Favorites.MovingItems);
                                    // При одновременном перемещении контейнера и его элементов,
                                    // элементы оказываются не в "своём" контейнере, а в том, где отпустили мышь.
                                    // Так и задумано
                                    foreach (IFavoritesEntry entry in dropNodes)
                                    {
                                        if (copy)
                                        {
                                            Debug.Assert(entry is FavoritesLink, "entry is FavoritesLink");
                                            var link = (FavoritesLink)entry;
                                            if (!_favManager.AddMessageLink(link.MessageId, link.Comment, activeFolder))
                                            {
                                                failedItems.Add(entry);
                                            }
                                        }
                                        else if (!entry.Move(activeFolder))
                                        {
                                            failedItems.Add(entry);
                                        }
                                    }
                                },
                                                   () =>
                                {
                                    _favManager.Reload();

                                    if (failedItems.Count > 0)
                                    {
                                        var failedMessages = new StringBuilder();
                                        failedMessages.Append(Environment.NewLine);
                                        foreach (var entry in failedItems)
                                        {
                                            var itemText = string.IsNullOrEmpty(entry.Comment)
                                                                                                        ? (entry is FavoritesLink
                                                                                                                ? ((FavoritesLink)entry).Link
                                                                                                                : ((FavoritesFolder)entry).Name)
                                                                                                        : entry.Comment;
                                            failedMessages.AppendFormat(" \"{0}\"{1}", itemText, Environment.NewLine);
                                        }
                                        var message = String.Format(SR.Favorites.ItemsExists, failedMessages, activeFolder.Name);
                                        MessageBox.Show(this, message,
                                                        FavoritesFeature.Instance.Info,
                                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }

                                    effect = (dropNodes.Count > failedItems.Count) ? (copy ? DragDropEffects.Copy : DragDropEffects.Move) : DragDropEffects.None;
                                });
                            }
                            else if (dropNodes.IsAssignableFrom(typeof(IMsg)))
                            {
                                var failedItems =
                                    dropNodes
                                    .Cast <IMsg>()
                                    .Where(
                                        message =>
                                        !_favManager.AddMessageLink(message.ID, message.Subject, activeFolder))
                                    .ToList();

                                if (failedItems.Count > 0)
                                {
                                    var failedMessages = new StringBuilder();
                                    failedMessages.Append(Environment.NewLine);
                                    foreach (var message in failedItems)
                                    {
                                        failedMessages.AppendFormat("{0} - \"{1}\"{2}",
                                                                    message.ID, message.Subject, Environment.NewLine);
                                    }
                                    var messageText = String.Format(SR.Favorites.ItemsExists, failedMessages, activeFolder.Name);
                                    MessageBox.Show(this, messageText,
                                                    FavoritesFeature.Instance.Info,
                                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }                                //if

                                effect = (dropNodes.Count > failedItems.Count) ? DragDropEffects.Link : DragDropEffects.None;
                            }                            //if

                            if (select != null)
                            {
                                _grid.EnsureVisible(select, false);
                                if (_grid.ActiveNode != select)
                                {
                                    _grid.ActiveNode = select;
                                }
                            } //if
                        }     //if
                    }         //if
                }             //if
            }                 //if

            e.Effect = effect;
        }
Ejemplo n.º 7
0
        public static void Main()
        {
            TraceVerbose("Instance startup");
            try
            {
                Console.WriteLine(
                    @"Janus project. Copyright (C) 2002-2012 by Rsdn Team. " +
                    @"See rsdn.ru for more information.");

                // Проверка на единственность экземпляра приложения.
                bool cn;
                using (var m = new Mutex(true, "JanusRunningInstanceDetectionMutex", out cn))
                {
                    if (!m.WaitOne(0, false))
                    {
                        WindowActivator.ActivateWindow(MainForm.GetCaption());
                        return;
                    }

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    // Создаем контрол, чтобы инициализировать винформсный констекст синхронизации,
                    // если он еще не инициализирован
                    using (new Control()) { }

                    Thread.CurrentThread.CurrentUICulture = new CultureInfo((int)Config.Instance.UILanguage);

                    if (!CheckEnvironment())
                    {
                        return;
                    }

                    TraceVerbose("ResMgr");

                    var rootManager = new ServiceManager(true);

                    rootManager.Publish <IUIShell>(
                        new UIShell(
                            () => ApplicationManager.Instance.MainForm,
                            freeze => ApplicationManager.Instance.MainForm.Enabled = freeze));

                    if (Config.Instance.ShowSplash)
                    {
                        EventHandler hider = null;
                        IServiceRegistrationCookie informerCookie = null;
                        IServiceRegistrationCookie progressCookie = null;

                        hider =
                            (sender, e) =>
                        {
                            // ReSharper disable AccessToModifiedClosure
                            if (progressCookie != null)
                            {
                                rootManager.Unpublish(progressCookie);
                            }

                            rootManager.Publish <IProgressService>(
                                new DefaultProgressService(rootManager));

                            if (informerCookie != null)
                            {
                                rootManager.Unpublish(informerCookie);
                            }
                            SplashHelper.Hide();
                            Application.Idle -= hider;
                            // ReSharper restore AccessToModifiedClosure
                        };

                        Application.Idle += hider;

                        informerCookie = rootManager.Publish(
                            SplashHelper.Show(rootManager));

                        progressCookie = rootManager.Publish(
                            SplashHelper.GetProgressService());

                        //Thread.Sleep(20000);
                    }
                    else
                    {
                        rootManager.Publish <IProgressService>(
                            new DefaultProgressService(rootManager));
                    }

                    using (var host = new JanusHost(rootManager))
                    {
                        using (host.InitScope())
                        {
                            rootManager.SetSplashMessage(SR.Splash.ApplicationStart);

                            TraceVerbose("JanusHost");

                            // Подписка сервиса на извещения об изменении конфигурации.
                            var configChangedNotifier = host.GetRequiredService <ConfigChangedNotifier>();
                            Config.Instance.ConfigChanged +=
                                (o, args) => configChangedNotifier.FireConfigChanged(Config.Instance);

                            try
                            {
                                //Проверка наличия пользователя
                                if (!LocalUser.UserExists())
                                {
                                    using (var ouf = new OptionsUserForm(host, true))
                                        ouf.ShowDialog();
                                }

                                rootManager.SetSplashMessage(SR.Splash.CheckDatabase);

                                if (!DBSchemaManager.CheckDB(host))
                                {
                                    // User cancelled.
                                    //
                                    TraceVerbose("User cancelled");
                                }

                                var signal = new AutoResetEvent(true);
                                if (DBSchemaManager.IsNeedRestructuring(host))
                                {
                                    signal.Reset();
                                    ProgressWorker.Run(rootManager, false,
                                                       progressVisualizer =>
                                    {
                                        progressVisualizer.SetProgressText(SR.Splash.RestructureDatabase);
                                        try
                                        {
                                            DBSchemaManager.Restruct(host);
                                            //DatabaseManager.ClearTopicInfo(host);
                                            Config.Instance.BadRestruct = false;
                                        }
                                        catch
                                        {
                                            Config.Instance.BadRestruct = true;
                                            Config.Save();
                                            throw;
                                        }
                                        finally
                                        {
                                            // разрешаем выполнение главного потока
                                            signal.Set();
                                        }
                                    });
                                }

                                // блокируем поток, пока не завершится реструктуризация БД
                                while (!signal.WaitOne(100))
                                {
                                    Application.DoEvents();
                                }

                                // Проверяем наличие таблички topic_info
                                DatabaseManager.CheckTopicInfoIntegrity(host);

                                TraceVerbose("DB ready");

                                rootManager.Publish <IMainWindowService>(
                                    new MainWindowService(() => ApplicationManager.Instance.MainForm));
                                rootManager.Publish(
                                    new DockManager(rootManager, () => ApplicationManager.Instance.MainForm.DockPanel));

                                Application.ThreadException +=
                                    (sender, e) =>
                                {
                                    using (var ef = new ExceptionForm(host, e.Exception, true))
                                        ef.ShowDialog(
                                            rootManager
                                            .GetRequiredService <IUIShell>()
                                            .GetMainWindowParent());
                                };

                                TraceVerbose("Ready to Run()");
                            }
                            catch (LocalUserNotFoundException)
                            {
                                MessageBox.Show(
                                    SR.JanusImpossibleWork,
                                    ApplicationInfo.ApplicationName,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                                throw;
                            }
                        }
                        ApplicationManager.Instance.Run(host);
                    }
                }
            }
            catch (Exception ex)
            {
                using (var ef = new ExceptionForm(null, ex, false))
                    ef.ShowDialog();
            }
        }
Ejemplo n.º 8
0
        // TODO: Весь связанный с UI код вынести в отдельный класс
        public static void Export(IServiceProvider provider)
        {
            var activeMessagesSvc = provider.GetService <IActiveMessagesService>();
            var canExportMessages = activeMessagesSvc != null && activeMessagesSvc.ActiveMessages.Any();

            var activeForumSvc = provider.GetService <IActiveForumService>();
            var canExportForum = activeForumSvc != null && activeForumSvc.ActiveForum != null;

            var mainWnd = provider.GetRequiredService <IUIShell>().GetMainWindowParent();

            using (var emd = new ExportMessageDialog(canExportMessages, canExportForum))
            {
                if (emd.ShowDialog(mainWnd) != DialogResult.OK)
                {
                    return;
                }

                var uiInfo = new { emd.FileName, emd.ExportMode, emd.ExportFormat, emd.UnreadMessagesOnly };

                var noMessages = false;
                ProgressWorker.Run(
                    provider,
                    false,
                    pi =>
                {
                    pi.SetProgressText(_exportPrepareText);

                    var activeMsgSvc = provider.GetRequiredService <IActiveMessagesService>();

                    // Prepare msg list
                    IList <IMsg> messages = null;

                    switch (uiInfo.ExportMode)
                    {
                    case ExportMode.Messages:
                        messages = new List <IMsg>(
                            (!uiInfo.UnreadMessagesOnly
                                                                                ? activeMsgSvc.ActiveMessages
                                                                                : activeMsgSvc.ActiveMessages.Where(msg => !msg.IsRead))
                            .Cast <IMsg>());
                        break;

                    case ExportMode.Topics:
                        messages = new List <IMsg>(100);
                        foreach (var msg in activeMsgSvc.ActiveMessages)
                        {
                            GetAllChildren((IMsg)msg.Topic, messages, uiInfo.UnreadMessagesOnly);
                        }
                        break;

                    case ExportMode.Forum:
                        messages = new List <IMsg>(1000);
                        foreach (IMsg msg in Forums.Instance.ActiveForum.Msgs)
                        {
                            GetAllChildren(msg, messages, uiInfo.UnreadMessagesOnly);
                        }
                        break;

                    default:
                        throw new ArgumentException("Unknown export mode");
                    }
                    if (messages.Count == 0)
                    {
                        noMessages = true;
                        return;
                    }

                    ProgressDelegate pd =
                        (count, total) =>
                    {
                        pi.SetProgressText(_exportMessageText.FormatStr(count, total));
                        pi.ReportProgress(total, count);
                    };

                    using (var fs = new FileStream(uiInfo.FileName, FileMode.Create))
                        switch (uiInfo.ExportFormat)
                        {
                        case ExportFormat.Text:
                            Export2Text(messages, fs, pd);
                            break;

                        case ExportFormat.HTML:
                            Export2HTML(provider, messages, fs, pd);
                            break;

                        case ExportFormat.MHT:
                            Export2Mht(provider, messages, fs, pd);
                            break;
                        }
                });
                if (noMessages)
                {
                    MessageBox.Show(mainWnd, ExportResources.NoMessages);
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Переводит базу в другой формат.
        /// </summary>
        public static void Migrate(IServiceProvider serviceProvider)
        {
            using (var seldb = new SelectDB(serviceProvider))
            {
                var result = seldb.ShowDialog();

                if (result != DialogResult.OK || string.IsNullOrEmpty(seldb.ConnectionString))
                {
                    return;
                }

                if (Config.Instance.DbDriver == seldb.DbDriver &&
                    seldb.ConnectionString == Config.Instance.ConnectionString)
                {
                    MessageBox.Show(SR.Database.CannotMigrateToSelf,
                                    ApplicationInfo.ApplicationName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                var currentCulture = Thread.CurrentThread.CurrentCulture;

                try
                {
                    // Ugly hack to help Jet to convert DateTime to right formatted string
                    //
                    Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                    var dbswExistent = CreateSchemaDriver(serviceProvider, Config.Instance.DbDriver);
                    var dbswTarget   = CreateSchemaDriver(serviceProvider, seldb.DbDriver);

                    var dbscMustBe = Load(_dbscMustBeResource);

                    var targetConStr = seldb.ConnectionString;
                    dbswTarget.CompareDbsc(dbscMustBe, targetConStr);
                    dbswTarget.Prepare(targetConStr);

                    const int batchSize = 10000;
                    const int timeout   = 0;

                    ProgressWorker.Run(serviceProvider, false,
                                       progressVisualizer =>
                    {
                        progressVisualizer.SetProgressText(SR.Database.MigrationStarted);
                        foreach (var dbsmTable in dbscMustBe.Tables)
                        {
                            progressVisualizer.SetProgressText(dbsmTable.Name);

                            using (var srcConnection = dbswExistent.CreateConnection(Config.Instance.ConnectionString))
                                using (var dstConnection = dbswTarget.CreateConnection(targetConStr))
                                    using (var srcCommand = srcConnection.CreateCommand())
                                        using (var dstCommand = dstConnection.CreateCommand())
                                        {
                                            srcConnection.Open();
                                            srcCommand.CommandTimeout = timeout;
                                            srcCommand.CommandText    = dbswExistent.MakeSelect(dbsmTable, true);

                                            var recordsCount = 0;
                                            using (var reader = srcCommand.ExecuteReader(CommandBehavior.SequentialAccess))
                                                if (reader.Read())
                                                {
                                                    dstConnection.Open();

                                                    dstCommand.CommandTimeout = timeout;
                                                    dstCommand.CommandText    = dbswTarget.MakeInsert(dbsmTable);
                                                    dstCommand.Prepare();

                                                    foreach (var column in dbsmTable.Columns)
                                                    {
                                                        var p = dstCommand.CreateParameter();
                                                        dstCommand.Parameters.Add(dbswTarget.ConvertToDbParameter(column, p));
                                                    }

                                                    dbswTarget.BeginTableLoad(dstConnection, dbsmTable);
                                                    // Make sure we have all or none records inserted
                                                    //
                                                    using (var transaction = dstConnection.BeginTransaction())
                                                    {
                                                        dstCommand.Transaction = transaction;

                                                        do
                                                        {
                                                            for (var i = 0; i < dbsmTable.Columns.Length; i++)
                                                            {
                                                                ((IDbDataParameter)dstCommand.Parameters[i]).Value = reader[i];
                                                            }

                                                            dstCommand.ExecuteNonQuery();

                                                            if (++recordsCount % batchSize == 0)
                                                            {
                                                                progressVisualizer.SetProgressText(dbsmTable.Name + @" (" + recordsCount + @")");
                                                            }
                                                        } while (reader.Read());

                                                        transaction.Commit();
                                                    }
                                                    dbswTarget.EndTableLoad(dstConnection, dbsmTable);
                                                }
                                        }
                        }
                    });

                    if (MessageBox.Show(SR.Database.ConfirmRestartAfterMigrate,
                                        ApplicationInfo.ApplicationName,
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Config.Instance.DbDriver         = seldb.DbDriver;
                        Config.Instance.ConnectionString = seldb.ConnectionString;
                        Config.Save();

                        // Bye-bye all unsaved messages!
                        //
                        Application.Restart();
                    }
                }
                catch (Exception ex)
                {
                    throw new DBSchemaException(string.Format(
                                                    SchemaManagementResources.MigrationError,
                                                    Config.Instance.DbDriver, seldb.DbDriver, ex.Message), ex);
                }
                finally
                {
                    Thread.CurrentThread.CurrentCulture = currentCulture;
                }
            }
        }