diff --git a/PROMS/VEPROMS User Interface/frmBatchRefresh.cs b/PROMS/VEPROMS User Interface/frmBatchRefresh.cs index aafaab5f..aca7f7cd 100644 --- a/PROMS/VEPROMS User Interface/frmBatchRefresh.cs +++ b/PROMS/VEPROMS User Interface/frmBatchRefresh.cs @@ -42,6 +42,7 @@ namespace VEPROMS , false , UpdateROValues); adminToolsList.Add("Refresh Transitions", "Refresh Transitions Guidance", "Occasionally, transitions do not get updated.\r\n\r\nThis function will refresh transitions in all procedures selected below whether they were selected individually or as a group via a procedure set.", "If more than one procedure is selected, it is recommened that this be performed during off hours.", "WARNING:", false, false, RefreshTransitions); + adminToolsList.Add("Fix Hyphens", "Fix Hyphens", "Replace various forms of Hyphens with a consistent Hyphen so that search will find all Hyphens", "", "", true, true, "vesp_FixHyphens", FixHyphens); adminToolsList.Add("Delete PDFs", "Delete PDFs Guidance", "It is sometimes desirable to clean up the database by removing extra pdf files. This process allows for this to occur", "", "", true, true, "vesp_DeletePDFs", DeletePDFs); adminToolsList.Add("Identify Disconnected Items" , "Identify Disconnected Items Guidance" @@ -106,6 +107,24 @@ namespace VEPROMS cbxAdminTools.DisplayMember = "Title"; cbxAdminTools.SelectedIndex = -1; } + private void FixHyphens() + { + this.Cursor = Cursors.WaitCursor; + DateTime pStart = DateTime.Now; + txtProcess.AppendText(pStart.ToString("MM/dd/yyyy @ HH:mm")); + txtProcess.AppendText(Environment.NewLine); + txtProcess.AppendText(Environment.NewLine); + Application.DoEvents(); + int affectedRows = ESP_FixHyphens.Execute(selectedAdminTool.StoredProcedure)/2;// Two results for each change + txtProcess.AppendText(string.Format("Fixed {0} Hyphens", affectedRows)); + txtProcess.AppendText(Environment.NewLine); + txtProcess.AppendText(Environment.NewLine); + DateTime pEnd = DateTime.Now; + txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm")); + Application.DoEvents(); + this.Cursor = Cursors.Default; + MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title)); + } private Dictionary myProcedures = new Dictionary(); private Dictionary myDocVersions = new Dictionary(); private void frmBatchRefresh_Load(object sender, EventArgs e) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs index b9aacb3c..4f67e8b7 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs @@ -9,6 +9,53 @@ using Csla.Validation; namespace VEPROMS.CSLA.Library { + public class ESP_FixHyphens : CommandBase + { + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #region Factory Methods + private string _StoredProcedure; + public string StoredProcedure + { + get { return _StoredProcedure; } + set { _StoredProcedure = value; } + } + private int _AffectedRows; + public int AffectedRows + { + get { return _AffectedRows; } + set { _AffectedRows = value; } + } + public static int Execute(string storedProcedure) + { + ESP_DeletePDFs cmd = new ESP_DeletePDFs(); + cmd.StoredProcedure = storedProcedure; + DataPortal.Execute(cmd); + return cmd.AffectedRows; + } + #endregion + #region Server-Side code + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cmd = new SqlCommand(StoredProcedure, cn)) + { + cmd.CommandType = CommandType.StoredProcedure; + cmd.CommandTimeout = 0; + AffectedRows = cmd.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("ExecuteStoredProcedureRowsAffected Error", ex); + throw new ApplicationException("Failure on ExecuteStoredProcedureRowsAffected", ex); + } + } + #endregion + } public class ESP_DeletePDFs : CommandBase { private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index c2d79a51..88ee748c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -798,9 +798,14 @@ namespace VEPROMS.CSLA.Library } #endregion #region SaveData + /// + /// B2017-121 Regular Express for all RTF tokens for Hyphens + /// + private static Regex regHyphen = new Regex(@"(?", "\\\\"); + // B2017-121 Replace all types of hyphens with non-breaking hyphens + string rtbString = regHyphen.Replace( RtfToDbText(rtb.Rtf).Replace("", "\\\\"),@"\u8209?"); return Save(rtbString); } public bool Save(string modtext)