diff --git a/Forms/MainBox.Designer.cs b/Forms/MainBox.Designer.cs index 136bafd..19bd350 100644 --- a/Forms/MainBox.Designer.cs +++ b/Forms/MainBox.Designer.cs @@ -108,7 +108,6 @@ private void InitializeComponent() { this.boxSearch = new DevExpress.XtraBars.BarEditItem(); this.boxSearchControl = new DevExpress.XtraEditors.Repository.RepositoryItemSearchControl(); this.labelSeparator = new DevExpress.XtraBars.BarStaticItem(); - this.buttonFeedback = new DevExpress.XtraBars.BarButtonItem(); this.toolTipController = new DevExpress.Utils.ToolTipController(this.components); this.taskbar = new DevExpress.Utils.Taskbar.TaskbarAssistant(); this.buttonFind = new DevExpress.XtraBars.BarButtonItem(); @@ -1301,7 +1300,6 @@ private void InitializeComponent() { // // buttonLog // - this.buttonLog.ButtonStyle = DevExpress.XtraBars.BarButtonStyle.Check; this.buttonLog.Id = 26; this.buttonLog.ImageOptions.Image = global::SQLIndexManager.Properties.Resources.IconLog; this.buttonLog.Name = "buttonLog"; @@ -1348,8 +1346,7 @@ private void InitializeComponent() { this.labelSavedSpace, this.labelIndexesSize, this.labelElapsedTime, - this.labelServerInfo, - this.buttonFeedback}); + this.labelServerInfo}); this.ribbonControl1.Location = new System.Drawing.Point(0, 0); this.ribbonControl1.MaxItemId = 41; this.ribbonControl1.Name = "ribbonControl1"; @@ -1360,7 +1357,6 @@ private void InitializeComponent() { this.ribbonControl1.QuickToolbarItemLinks.Add(this.buttonOptions); this.ribbonControl1.QuickToolbarItemLinks.Add(this.buttonAbout); this.ribbonControl1.QuickToolbarItemLinks.Add(this.labelSeparator); - this.ribbonControl1.QuickToolbarItemLinks.Add(this.buttonFeedback); this.ribbonControl1.QuickToolbarItemLinks.Add(this.boxSearch); this.ribbonControl1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { this.boxSearchControl}); @@ -1482,15 +1478,7 @@ private void InitializeComponent() { this.labelSeparator.Id = 16; this.labelSeparator.Name = "labelSeparator"; this.labelSeparator.ShowImageInToolbar = false; - this.labelSeparator.Width = 68; - // - // buttonFeedback - // - this.buttonFeedback.Caption = "Feature Requests && Bugs"; - this.buttonFeedback.Id = 36; - this.buttonFeedback.ImageOptions.Image = global::SQLIndexManager.Properties.Resources.IconFeedback; - this.buttonFeedback.Name = "buttonFeedback"; - this.buttonFeedback.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonFeedbackClick); + this.labelSeparator.Width = 25; // // toolTipController // @@ -1571,6 +1559,5 @@ private void InitializeComponent() { private BarStaticItem labelIndexesSize; private BarStaticItem labelElapsedTime; private BarStaticItem labelServerInfo; - private BarButtonItem buttonFeedback; } } \ No newline at end of file diff --git a/Forms/MainBox.cs b/Forms/MainBox.cs index 76529f9..7bc42ab 100644 --- a/Forms/MainBox.cs +++ b/Forms/MainBox.cs @@ -221,7 +221,12 @@ private void ScanIndexesFinish(object sender, RunWorkerCompletedEventArgs e) { List indexes = _indexes.Where(_ => _.Fragmentation >= (Settings.Options.SkipOperation == IndexOp.IGNORE ? Settings.Options.FirstThreshold : 0) && _.PagesCount >= Settings.Options.MinIndexSize.PageSize() && _.PagesCount <= Settings.Options.MaxIndexSize.PageSize()) - .OrderBy(_ => _.Fragmentation < Settings.Options.FirstThreshold ? 3 : (_.Fragmentation < Settings.Options.SecondThreshold ? 2 : 1 )) + .OrderBy(_ => _.Fragmentation < Settings.Options.FirstThreshold + && Settings.Options.SkipOperation != Settings.Options.FirstOperation + ? 3 + : _.Fragmentation < Settings.Options.SecondThreshold + && Settings.Options.FirstOperation != Settings.Options.SecondOperation + ? 2 : 1 ) .ThenByDescending(_ => (_.Fragmentation + 0.1) * _.PagesCount).ToList(); QueryEngine.UpdateFixType(indexes); @@ -312,11 +317,16 @@ private void buttonFix_ItemClick(object sender, ItemClickEventArgs e) { buttonStopFix.Visibility = BarItemVisibility.Always; - List selIndex = ((List)view.DataSource).Where(_ => _.IsSelected).ToList(); + List selIndex = ((List)view.DataSource).Where(_ => _.IsSelected && _.FixType != IndexOp.SKIP).ToList(); List fixIndex = - selIndex.Where(x => Settings.ActiveHost.Databases.Any(y => y == x.DatabaseName) && x.FixType != IndexOp.SKIP) - .OrderBy(_ => _.Fragmentation < Settings.Options.FirstThreshold ? 3 : (_.Fragmentation < Settings.Options.SecondThreshold ? 2 : 1 )) + selIndex.Where(x => Settings.ActiveHost.Databases.Any(y => y == x.DatabaseName)) + .OrderBy(_ => _.Fragmentation < Settings.Options.FirstThreshold + && Settings.Options.SkipOperation != Settings.Options.FirstOperation + ? 3 + : _.Fragmentation < Settings.Options.SecondThreshold + && Settings.Options.FirstOperation != Settings.Options.SecondOperation + ? 2 : 1 ) .ThenByDescending(_ => (_.Fragmentation + 0.1) * _.PagesCount).ToList(); _ps = new ProgressStatus @@ -362,9 +372,20 @@ private void buttonFix_ItemClick(object sender, ItemClickEventArgs e) { } private void FixIndexesProgressChanged(object sender, ProgressChangedEventArgs e) { - taskbar.ProgressCurrentValue = e.ProgressPercentage; - view.RefreshData(); + taskbar.ProgressCurrentValue = e.ProgressPercentage + 1; UpdateProgressStats(); + + if (e.UserState != null) { + Index index = (Index)e.UserState; + var rowHandle = view.FindRow(index); + if (rowHandle != GridControl.InvalidRowHandle) { + view.RefreshRow(rowHandle); + view.SelectRow(rowHandle); + view.MakeRowVisible(rowHandle); + } + } + + view.RefreshData(); } private BackgroundWorker _workerFix; @@ -376,50 +397,48 @@ private void FixIndexes(object sender, DoWorkEventArgs e) { using (var connectionList = new ConnectionList(Settings.ActiveHost)) { for (int i = 0; i < indexes.Count; i++) { - Index item = indexes[i]; + Index index = indexes[i]; if (_workerFix.CancellationPending) { Output.Current.Add("Canceled"); e.Cancel = true; return; } - item.Progress = Resources.IconRun; + index.Progress = Resources.IconRun; _ps.Indexes++; - _ps.IndexesSize += item.PagesCount; - _workerFix.ReportProgress(i + 1); + _ps.IndexesSize += index.PagesCount; + _workerFix.ReportProgress(i, index); - Output.Current.AddCaption(item.ToString()); + Output.Current.AddCaption(index.ToString()); Stopwatch watch = Stopwatch.StartNew(); string sql = string.Empty; - SqlConnection connection = connectionList.Get(item.DatabaseName); + SqlConnection connection = connectionList.Get(index.DatabaseName); if (connection != null) { - sql = QueryEngine.FixIndex(connection, item); + sql = QueryEngine.FixIndex(connection, index); } - - item.Progress = Resources.IconOk; - watch.Stop(); + Output.Current.Add(index.ToString(), sql, index.Duration); - item.Duration = watch.ElapsedMilliseconds; - Output.Current.Add(item.ToString(), sql, item.Duration); - _workerFix.ReportProgress(i + 1); + index.Progress = Resources.IconOk; + index.Duration = watch.ElapsedMilliseconds; + _ps.SavedSpace += (index.PagesCountBefore ?? 0); - if (!string.IsNullOrEmpty(item.Error)) { - Output.Current.Add(item.ToString(), item.Error); - item.Progress = Resources.IconError; + if (!string.IsNullOrEmpty(index.Error)) { + Output.Current.Add(index.ToString(), index.Error); + index.Progress = Resources.IconError; _ps.Errors++; } else { if (Settings.Options.DelayAfterFix > 0 && i < indexes.Count - 1) { - item.Progress = Resources.IconDelay; + _workerFix.ReportProgress(i, index); + index.Progress = Resources.IconDelay; Thread.Sleep(Settings.Options.DelayAfterFix); - item.Progress = Resources.IconOk; + index.Progress = Resources.IconOk; } } - _ps.SavedSpace += (item.PagesCountBefore ?? 0); - _workerFix.ReportProgress(i + 2); + _workerFix.ReportProgress(i, index); } } } @@ -893,16 +912,6 @@ private void ButtonAboutClick(object sender, ItemClickEventArgs e) { } } - private void ButtonFeedbackClick(object sender, ItemClickEventArgs e) { - try { - Process.Start(Resources.GitHubLink); - } - catch (Exception ex) { - Output.Current.Add($"Error: {ex.Source}", ex.Message); - XtraMessageBox.Show(ex.Message.Replace(". ", "." + Environment.NewLine), ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - #endregion #region Save/Restore Sort diff --git a/Images/icon_feedback.png b/Images/icon_feedback.png deleted file mode 100644 index f5669b3..0000000 Binary files a/Images/icon_feedback.png and /dev/null differ diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c4a61cb..b5ebde6 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -7,5 +7,5 @@ [assembly: AssemblyCopyright("Sergii Syrovatchenko")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.0.0.64")] -[assembly: AssemblyFileVersion("1.0.0.64")] +[assembly: AssemblyVersion("1.0.0.65")] +[assembly: AssemblyFileVersion("1.0.0.65")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index e30c9ac..c024066 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -304,16 +304,6 @@ internal static System.Drawing.Bitmap IconExclude { } } - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap IconFeedback { - get { - object obj = ResourceManager.GetObject("IconFeedback", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index c5ca9ae..ab91634 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -205,9 +205,6 @@ IsSparse - - ..\Images\icon_feedback.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - FixType diff --git a/SQLIndexManager.csproj b/SQLIndexManager.csproj index 5dcf9be..4c6890a 100644 --- a/SQLIndexManager.csproj +++ b/SQLIndexManager.csproj @@ -236,7 +236,6 @@ -