Example #1
0
        public bool ReloadDatabase()
        {
            try {
                if (ShouldCancelDbReload())
                {
                    return(false);
                }

                for (int i = 0; i < GdTabs.Count; i++)
                {
                    if (GdTabs[i].DbComponent.IsCustom)
                    {
                        GDbTab tab = GdTabs[i];
                        _mainTabControl.Dispatch(p => p.Items.Remove(tab));
                        GdTabs.RemoveAt(i);
                        _holder.RemoveTable(tab.DbComponent);
                        i--;
                    }
                }

                if (_asyncOperation.IsRunning)
                {
                    _reloadDatabase(true);
                }
                else
                {
                    _asyncOperation.SetAndRunOperation(new GrfThread(() => _reloadDatabase(false), this, 200, null, false, true));
                }
                return(true);
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
                return(false);
            }
        }
Example #2
0
        public bool ReloadDatabase(bool checkReload = true)
        {
            try {
                if (checkReload && ShouldCancelDbReload())
                {
                    return(false);
                }

                for (int i = 0; i < GdTabs.Count; i++)
                {
                    if (GdTabs[i].DbComponent.IsCustom)
                    {
                        GDbTab tab = GdTabs[i];
                        _mainTabControl.Dispatch(p => p.Items.Remove(tab));
                        GdTabs.RemoveAt(i);
                        _holder.RemoveTable(tab.DbComponent);
                        i--;
                    }
                }

                // Rechecks the paths
                _listItemClientTxtFiles.Dispatcher.Invoke(new Action(delegate {
                    foreach (TextViewItem tvi in _listItemClientTxtFiles.Items)
                    {
                        tvi.CheckValid();
                    }

                    foreach (TextViewItem tvi in _listItemClientLuaFiles.Items)
                    {
                        tvi.CheckValid();
                    }

                    _tviItemDb.CheckValid();
                }));

                if (_asyncOperation.IsRunning)
                {
                    _reloadDatabase(true);
                }
                else
                {
                    _asyncOperation.SetAndRunOperation(new GrfThread(() => _reloadDatabase(false), this, 200, null, false, true));
                }
                return(true);
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
                return(false);
            }
        }