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:
parent
54520ef0a2
commit
cec6aa2e17
@ -11352,4 +11352,64 @@ END CATCH
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_PurgeDisconnectedData Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: vesp_PurgeDisconnectedData Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'ClearCBOverrideForProcedure') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE ClearCBOverrideForProcedure;
|
||||
GO
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2016 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
|
||||
CREATE PROCEDURE [dbo].ClearCBOverrideForProcedure
|
||||
(
|
||||
@ItemID int=null
|
||||
)
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
begin
|
||||
DECLARE @CBConfigs TABLE
|
||||
(
|
||||
[ContentID] int,
|
||||
xConfig xml
|
||||
)
|
||||
insert into @CBConfigs select ContentID, cast(Config as xml) xConfig
|
||||
from Contents where config like '%CBOverride%' and contentid in (select icontentid from vefn_tblchilditems(@ItemID,@ItemID,0))
|
||||
|
||||
Update @CBConfigs Set xConfig.modify('delete //@CBOverride') From @CBConfigs
|
||||
Update @CBConfigs Set xConfig.modify('delete //Step[not(node())and not(./@*)]') From @CBConfigs
|
||||
|
||||
UPDATE CC SET config = cast(xconfig as varchar(max))
|
||||
FROM CONTENTS CC
|
||||
Join @CBConfigs CB on cc.contentid = cb.contentid
|
||||
where cc.contentid in (select contentid from @CBConfigs)
|
||||
|
||||
SELECT
|
||||
[ContentID],
|
||||
[Number],
|
||||
[Text],
|
||||
[Type],
|
||||
[FormatID],
|
||||
[Config],
|
||||
[DTS],
|
||||
[UserID],
|
||||
[LastChanged],
|
||||
(SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[Contents].[ContentID]) [DetailCount],
|
||||
(SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[Contents].[ContentID]) [EntryCount],
|
||||
(SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[Contents].[ContentID]) [GridCount],
|
||||
(SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[Contents].[ContentID]) [ImageCount],
|
||||
(SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[Contents].[ContentID]) [ItemCount],
|
||||
(SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[Contents].[ContentID]) [PartCount],
|
||||
(SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[Contents].[ContentID]) [RoUsageCount],
|
||||
(SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[Contents].[ContentID]) [TransitionCount],
|
||||
(SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[Contents].[ContentID]) [ZContentCount]
|
||||
FROM [Contents]
|
||||
where contentid in (select contentid from @CBConfigs)
|
||||
end
|
||||
go
|
||||
|
||||
-- Display the status of ClearCBOverrideForProcedure
|
||||
IF (@@Error = 0) PRINT 'StoredProcedure [ClearCBOverrideForProcedure] Succeeded'
|
||||
ELSE PRINT 'StoredProcedure [ClearCBOverrideForProcedure] Error on Creation'
|
||||
go
|
||||
PRINT '20160126 Improved performance for checkouts'
|
||||
|
@ -1146,6 +1146,9 @@ namespace VEPROMS
|
||||
version.Save();
|
||||
dlg.Dispose();
|
||||
UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, DateTime.Now, selectedSlave);
|
||||
|
||||
// Clear the change bar override for this procedure:
|
||||
pi.ClearChangeBarOverrides();
|
||||
}
|
||||
else
|
||||
UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS, selectedSlave);
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user