예제 #1
0
        private void CheckIndexes()
        {
            if (indexDataProvider == null)
            {
                return;
            }

            if (state != State.Idle)
            {
                return;
            }

            try
            {
                state = State.Checking;

                SetStatus("Loading Indexes");
                viewModels = indexDataProvider.GetIndexes().Select(x => new IndexViewModel(x)).ToList();
                ApplyFilter();
                AutoResizeColumns();
                SetStatus("Checking Fragmentation");

                UpdateCaption();
                EnableDisable();
                QueryFragmentationBackgroupWorker.RunWorkerAsync();
            }
            catch
            {
                state = State.Idle;
                throw;
            }
        }
예제 #2
0
 private void QueryFragmentationBackgroupWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         for (int i = 0; i < viewModels.Count; i++)
         {
             try
             {
                 var ivm = viewModels[i];
                 try
                 {
                     indexDataProvider.LoadIndexPhysicalStats(ivm.Index);
                     ivm.Index.SetRecommendation(
                         Program.Settings.ReorganizeIndexFragmentationThreshold,
                         Program.Settings.ReorganizeIndexMinimumSize,
                         Program.Settings.RebuildIndexFragmentationThreshold,
                         Program.Settings.RebuildIndexMinimumSize);
                     ivm.UseRecommendation();
                 }
                 catch (Exception ex)
                 {
                     if (ex.Message.StartsWith("The user does not have permission to perform this action."))
                     {
                         ivm.Index.SetError("You do not have permission to load physical stats for this index");
                     }
                     else
                     {
                         ivm.Index.SetError("Physical stats could not be loaded for this index");
                     }
                     Trace.TraceError(ex.Message);
                 }
                 finally
                 {
                     var percentComplete = (i + 1) * 100 / viewModels.Count;
                     QueryFragmentationBackgroupWorker.ReportProgress(percentComplete, i);
                 }
             }
             catch (Exception ex)
             {
                 Trace.TraceError(ex.Message);
             }
         }
     }
     finally
     {
         state = State.Idle;
     }
 }