B2022-047: Tables search – refresh data to allow search to find text in tables

This commit is contained in:
2022-06-02 13:12:58 +00:00
parent d6d29a868a
commit fa5d78f844
7 changed files with 569 additions and 239 deletions

View File

@@ -409,6 +409,90 @@ namespace VEPROMS
this.Cursor = Cursors.Default;
}
// B2022-047 - refresh the Content/Text field for table, i.e. Grid, Data so that search will find text in the Grid
// NOTE that an out of memeory error occurs when having to process alot of tables. A config flag is used on the
// grid record to flag that this operation has been run. And a message is placed in the result window stating to
// rerun until all tables/text fields are completed.
private void RefreshTablesForSearch()
{
this.Cursor = Cursors.WaitCursor;
DateTime pStart = DateTime.Now;
txtProcess.AppendText("Refreshing Tables for Search");
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(string.Format("Started: {0}", pStart.ToString("MM/dd/yyyy @ HH:mm")));
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
int affectedRows = RefreshForSearch();
if (affectedRows < 0)
{
txtProcess.AppendText(string.Format("Error occurred in processing, completed {0} rows. Run again!", -affectedRows));
txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(string.Format("Error occurred in processing, completed {0} rows. Run again!", -affectedRows));
txtResults.AppendText(Environment.NewLine);
txtResults.AppendText(Environment.NewLine);
affectedRows = -affectedRows;
}
txtProcess.AppendText(string.Format("Tables for Search Refreshed: {0}", affectedRows));
txtProcess.AppendText(Environment.NewLine);
txtResults.AppendText(string.Format("{0} Tables for Search Refreshed.", affectedRows));
txtResults.AppendText(Environment.NewLine);
txtResults.AppendText(Environment.NewLine);
DateTime pEnd = DateTime.Now;
txtProcess.AppendText(string.Format("Completed: {0}", pEnd.ToString("MM/dd/yyyy @ HH:mm")));
txtProcess.AppendText(Environment.NewLine);
txtProcess.AppendText(Environment.NewLine);
Application.DoEvents();
this.Cursor = Cursors.Default;
}
private int RefreshForSearch()
{
int cntfix = 0;
List<int> gids = GridInfoList.GetIds(); // get all grids in database
pbProcess.Minimum = 0;
pbProcess.Maximum = gids.Count;
pbProcess.Step = 1;
foreach (int cid in gids)
{
using (Content cc = Content.Get(cid))
{
StepConfig sc = new StepConfig(cc.Config);
if (!sc.Step_FixedTblForSrch) // if not processed through this code already, get searchable text & save
{
try
{
using (VlnFlexGrid MyFlexGrid = new VlnFlexGrid(cc.ContentItems[0]))
{
using (StringReader sr = new StringReader(cc.MyGrid.Data))
{
MyFlexGrid.ReadXml(sr);
sr.Close();
}
string srchtxt = MyFlexGrid.GetSearchableText();
if (cc.Text != srchtxt)
{
cntfix++;
cc.UserID = Volian.Base.Library.VlnSettings.UserID;
cc.DTS = DateTime.Now;
cc.Text = srchtxt;
}
sc.Step_FixedTblForSrch = true;
cc.Config = sc.ToString();
cc.Save();
}
}
catch (Exception ex)
{
this.Cursor = Cursors.Default;
return -cntfix;
}
}
pbProcess.PerformStep();
Application.DoEvents();
}
}
return cntfix;
}
// C2017-030 - new Admin Tools user interface
// tool renamed to Identify Orphan Items
private void IdentifyDisconnectedItems()
@@ -1065,7 +1149,7 @@ namespace VEPROMS
DevComponents.DotNetBar.StepItem siObsoleteROData = new DevComponents.DotNetBar.StepItem("siObsoleteROData", "Obsolete RO Data");
DevComponents.DotNetBar.StepItem siStandardHyphens = new DevComponents.DotNetBar.StepItem("siStandardHyphens", "Standardize Hyphens");
DevComponents.DotNetBar.StepItem siRefreshAttmts = new DevComponents.DotNetBar.StepItem("siRefreshAttmts", "Refresh Word Attachments");
DevComponents.DotNetBar.StepItem siRefreshTblsSrchTxt = new DevComponents.DotNetBar.StepItem("siRefreshTblsSrchTxt", "Refresh Tables For Search");
// this will update/rebuild the progress bar in the bottom panel of Admin Tools
private void setupProgessSteps1()
{
@@ -1095,6 +1179,8 @@ namespace VEPROMS
progressSteps1.Items.Add(siStandardHyphens);
if (swRefreshWordAttmts.Value)
progressSteps1.Items.Add(siRefreshAttmts);
if (swRefreshTblsForSrch.Value)
progressSteps1.Items.Add(siRefreshTblsSrchTxt);
splitContainer3.Panel2Collapsed = false;
progressSteps1.Visible = true;
progressSteps1.Refresh();
@@ -1272,6 +1358,12 @@ namespace VEPROMS
DeletePDFs(); // refresh word attachments
StepProgress(prgStpIdx, 100);
}
if (swRefreshTblsForSrch.Value)
{
StepProgress(++prgStpIdx, 50);
RefreshTablesForSearch();
StepProgress(prgStpIdx, 100);
}
MessageBox.Show("Repair Functions Completed", "Repair");