Added sql procedure ‘ClearCBOverrideForProcedure’ to clear content/config’s Step CBOverride fields for an input itemID (that is a procedure), to fix B2015-039

B2015-039: Clear Change Bar Overrides for approval
This commit is contained in:
2016-02-08 17:17:36 +00:00
parent 54520ef0a2
commit cec6aa2e17
4 changed files with 153 additions and 0 deletions

View File

@@ -1067,5 +1067,72 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
#region ClearCBOverride
// B2015-039 fix:
// the following code clears the change bar override attribute from the step config, using the
// sql stored procedure 'ClearCBOverrideForProcedure'. The stored procedure returns
// a list of content records whose config was updated - so that this list can be used
// to refresh config data (caching) and refresh content (caching & User Interface)
[Serializable()]
private class ClearCBOverrideCriteria
{
public ClearCBOverrideCriteria(int? itemID)
{
_ItemID = itemID;
}
private int? _ItemID;
public int? ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
private void DataPortal_Fetch(ClearCBOverrideCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "ClearCBOverrideForProcedure";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
}
catch (Exception ex)
{
Database.LogException("ClearCBOverrideCriteria.DataPortal_Fetch", ex);
throw new DbCslaException("ClearCBOverrideCriteria.DataPortal_Fetch", ex);
}
}
public static ContentInfoList GetClearedCBOverrides(int itemID)
{
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ClearCBOverrideCriteria(itemID));
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentInfoList.GetClearedCBOverrides", ex);
}
}
#endregion
}
}

View File

@@ -5887,6 +5887,29 @@ namespace VEPROMS.CSLA.Library
tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup);
SetParentSectionAndDocVersionPageNum(tmp, tmp.MyDocVersion, null, tmp, tmp.MyDocVersion, tranLookup);
}
public void ClearChangeBarOverrides()
{
try
{
using (ContentInfoList cil = ContentInfoList.GetClearedCBOverrides(ItemID))
{
foreach (ContentInfo ci in cil)
{
using (Content c = ci.Get())
{
// first refresh configs because the ContentInfo.Refresh causes events to occur that refresh screen
// and if configs aren't done first, the screen refresh, if based on config data, will not be correct.
foreach (ItemInfo ii in ci.ContentItems) ii.RefreshConfig();
ContentInfo.Refresh(c);
}
}
}
}
catch (Exception ex)
{
throw new DbCslaException("Error on ProcedureInfo:ClearChangeBarOverrides", ex);
}
}
//jcb add 20120501 item and children by unit
public static ProcedureInfo GetItemAndChildrenByUnit(int? itemID, int? parentID, int? unitID)
{