Beispiel #1
0
        private async void InitConnection()
        {
            bool canReach      = false;
            bool cacheVerified = false;

            using (var spinner = new WaitSpinner(this, "Connecting to database...", 2000))
            {
                await Task.Run(() =>
                {
                    canReach = DBFactory.CanReachServer();

                    spinner.StatusText = "Checking cache...";

                    cacheVerified = CacheFunctions.VerifyCache();

                    if (canReach)
                    {
                        spinner.StatusText = "Loading data...";

                        CacheFunctions.RefreshCache();
                    }

                    SecurityFunctions.PopulateUserAccess();
                    SecurityFunctions.PopulateAccessGroups();
                });
            }

            if (!cacheVerified && !canReach)
            {
                await UserPrompts.PopupMessage(this, "Cannot connect to the database and the local cache was not verified.", "Cannot Run");

                Application.Current.Shutdown();
            }
            else if (cacheVerified && !canReach)
            {
                WatchDogInstance.WatchDog.Start(true);
            }
            else
            {
                WatchDogInstance.WatchDog.Start(false);
            }

            // If current user can modify, add edit button column to grid.
            AddEditButton();

            FieldsGrid.IsEnabled = true;
        }
Beispiel #2
0
 private void rebuildCacheToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CacheFunctions.CacheTables();
 }