@@ -221,7 +221,12 @@ private void ScanIndexesFinish(object sender, RunWorkerCompletedEventArgs e) {
221221 List < Index > indexes = _indexes . Where ( _ => _ . Fragmentation >= ( Settings . Options . SkipOperation == IndexOp . IGNORE ? Settings . Options . FirstThreshold : 0 )
222222 && _ . PagesCount >= Settings . Options . MinIndexSize . PageSize ( )
223223 && _ . PagesCount <= Settings . Options . MaxIndexSize . PageSize ( ) )
224- . OrderBy ( _ => _ . Fragmentation < Settings . Options . FirstThreshold ? 3 : ( _ . Fragmentation < Settings . Options . SecondThreshold ? 2 : 1 ) )
224+ . OrderBy ( _ => _ . Fragmentation < Settings . Options . FirstThreshold
225+ && Settings . Options . SkipOperation != Settings . Options . FirstOperation
226+ ? 3
227+ : _ . Fragmentation < Settings . Options . SecondThreshold
228+ && Settings . Options . FirstOperation != Settings . Options . SecondOperation
229+ ? 2 : 1 )
225230 . ThenByDescending ( _ => ( _ . Fragmentation + 0.1 ) * _ . PagesCount ) . ToList ( ) ;
226231
227232 QueryEngine . UpdateFixType ( indexes ) ;
@@ -312,11 +317,16 @@ private void buttonFix_ItemClick(object sender, ItemClickEventArgs e) {
312317
313318 buttonStopFix . Visibility = BarItemVisibility . Always ;
314319
315- List < Index > selIndex = ( ( List < Index > ) view . DataSource ) . Where ( _ => _ . IsSelected ) . ToList ( ) ;
320+ List < Index > selIndex = ( ( List < Index > ) view . DataSource ) . Where ( _ => _ . IsSelected && _ . FixType != IndexOp . SKIP ) . ToList ( ) ;
316321
317322 List < Index > fixIndex =
318- selIndex . Where ( x => Settings . ActiveHost . Databases . Any ( y => y == x . DatabaseName ) && x . FixType != IndexOp . SKIP )
319- . OrderBy ( _ => _ . Fragmentation < Settings . Options . FirstThreshold ? 3 : ( _ . Fragmentation < Settings . Options . SecondThreshold ? 2 : 1 ) )
323+ selIndex . Where ( x => Settings . ActiveHost . Databases . Any ( y => y == x . DatabaseName ) )
324+ . OrderBy ( _ => _ . Fragmentation < Settings . Options . FirstThreshold
325+ && Settings . Options . SkipOperation != Settings . Options . FirstOperation
326+ ? 3
327+ : _ . Fragmentation < Settings . Options . SecondThreshold
328+ && Settings . Options . FirstOperation != Settings . Options . SecondOperation
329+ ? 2 : 1 )
320330 . ThenByDescending ( _ => ( _ . Fragmentation + 0.1 ) * _ . PagesCount ) . ToList ( ) ;
321331
322332 _ps = new ProgressStatus
@@ -362,9 +372,20 @@ private void buttonFix_ItemClick(object sender, ItemClickEventArgs e) {
362372 }
363373
364374 private void FixIndexesProgressChanged ( object sender , ProgressChangedEventArgs e ) {
365- taskbar . ProgressCurrentValue = e . ProgressPercentage ;
366- view . RefreshData ( ) ;
375+ taskbar . ProgressCurrentValue = e . ProgressPercentage + 1 ;
367376 UpdateProgressStats ( ) ;
377+
378+ if ( e . UserState != null ) {
379+ Index index = ( Index ) e . UserState ;
380+ var rowHandle = view . FindRow ( index ) ;
381+ if ( rowHandle != GridControl . InvalidRowHandle ) {
382+ view . RefreshRow ( rowHandle ) ;
383+ view . SelectRow ( rowHandle ) ;
384+ view . MakeRowVisible ( rowHandle ) ;
385+ }
386+ }
387+
388+ view . RefreshData ( ) ;
368389 }
369390
370391 private BackgroundWorker _workerFix ;
@@ -376,50 +397,48 @@ private void FixIndexes(object sender, DoWorkEventArgs e) {
376397 using ( var connectionList = new ConnectionList ( Settings . ActiveHost ) ) {
377398
378399 for ( int i = 0 ; i < indexes . Count ; i ++ ) {
379- Index item = indexes [ i ] ;
400+ Index index = indexes [ i ] ;
380401 if ( _workerFix . CancellationPending ) {
381402 Output . Current . Add ( "Canceled" ) ;
382403 e . Cancel = true ;
383404 return ;
384405 }
385406
386- item . Progress = Resources . IconRun ;
407+ index . Progress = Resources . IconRun ;
387408 _ps . Indexes ++ ;
388- _ps . IndexesSize += item . PagesCount ;
389- _workerFix . ReportProgress ( i + 1 ) ;
409+ _ps . IndexesSize += index . PagesCount ;
410+ _workerFix . ReportProgress ( i , index ) ;
390411
391- Output . Current . AddCaption ( item . ToString ( ) ) ;
412+ Output . Current . AddCaption ( index . ToString ( ) ) ;
392413 Stopwatch watch = Stopwatch . StartNew ( ) ;
393414
394415 string sql = string . Empty ;
395- SqlConnection connection = connectionList . Get ( item . DatabaseName ) ;
416+ SqlConnection connection = connectionList . Get ( index . DatabaseName ) ;
396417 if ( connection != null ) {
397- sql = QueryEngine . FixIndex ( connection , item ) ;
418+ sql = QueryEngine . FixIndex ( connection , index ) ;
398419 }
399-
400- item . Progress = Resources . IconOk ;
401-
402420 watch . Stop ( ) ;
421+ Output . Current . Add ( index . ToString ( ) , sql , index . Duration ) ;
403422
404- item . Duration = watch . ElapsedMilliseconds ;
405- Output . Current . Add ( item . ToString ( ) , sql , item . Duration ) ;
406- _workerFix . ReportProgress ( i + 1 ) ;
423+ index . Progress = Resources . IconOk ;
424+ index . Duration = watch . ElapsedMilliseconds ;
425+ _ps . SavedSpace += ( index . PagesCountBefore ?? 0 ) ;
407426
408- if ( ! string . IsNullOrEmpty ( item . Error ) ) {
409- Output . Current . Add ( item . ToString ( ) , item . Error ) ;
410- item . Progress = Resources . IconError ;
427+ if ( ! string . IsNullOrEmpty ( index . Error ) ) {
428+ Output . Current . Add ( index . ToString ( ) , index . Error ) ;
429+ index . Progress = Resources . IconError ;
411430 _ps . Errors ++ ;
412431 }
413432 else {
414433 if ( Settings . Options . DelayAfterFix > 0 && i < indexes . Count - 1 ) {
415- item . Progress = Resources . IconDelay ;
434+ _workerFix . ReportProgress ( i , index ) ;
435+ index . Progress = Resources . IconDelay ;
416436 Thread . Sleep ( Settings . Options . DelayAfterFix ) ;
417- item . Progress = Resources . IconOk ;
437+ index . Progress = Resources . IconOk ;
418438 }
419439 }
420440
421- _ps . SavedSpace += ( item . PagesCountBefore ?? 0 ) ;
422- _workerFix . ReportProgress ( i + 2 ) ;
441+ _workerFix . ReportProgress ( i , index ) ;
423442 }
424443 }
425444 }
@@ -893,16 +912,6 @@ private void ButtonAboutClick(object sender, ItemClickEventArgs e) {
893912 }
894913 }
895914
896- private void ButtonFeedbackClick ( object sender , ItemClickEventArgs e ) {
897- try {
898- Process . Start ( Resources . GitHubLink ) ;
899- }
900- catch ( Exception ex ) {
901- Output . Current . Add ( $ "Error: { ex . Source } ", ex . Message ) ;
902- XtraMessageBox . Show ( ex . Message . Replace ( ". " , "." + Environment . NewLine ) , ex . Source , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
903- }
904- }
905-
906915 #endregion
907916
908917 #region Save/Restore Sort
0 commit comments