diff --git a/PROMS/DataLoader/DocVersions.cs b/PROMS/DataLoader/DocVersions.cs index a6bc597e..8360d3c7 100644 --- a/PROMS/DataLoader/DocVersions.cs +++ b/PROMS/DataLoader/DocVersions.cs @@ -82,7 +82,10 @@ namespace DataLoader // Process Procedures Item itm = null; if (convertProcedures || docver.VersionType == (int)VEPROMS.CSLA.Library.VersionTypeEnum.WorkingDraft || docver.VersionType == (int)VEPROMS.CSLA.Library.VersionTypeEnum.Approved) + { + ResetApplesToOranges(); itm = MigrateProcedures(cn, pth, docver, convertProcedures, docver.MyDocVersionInfo.ActiveFormat); + } // Show any Missing Transtitons (i.e. Transitions which have not been processed) lTime = DateTime.Now.Ticks - lTime; if (convertProcedures) diff --git a/PROMS/DataLoader/LoadTreeDB.cs b/PROMS/DataLoader/LoadTreeDB.cs index 139b8e04..2f0e0c0d 100644 --- a/PROMS/DataLoader/LoadTreeDB.cs +++ b/PROMS/DataLoader/LoadTreeDB.cs @@ -208,7 +208,16 @@ namespace DataLoader { XmlNode unit = xSlave.SelectSingleNode("Config/Slave"); XmlAttribute oldindex = xSlave.CreateAttribute("oldindex"); - oldindex.InnerText = slave.Extension.ToUpper().Replace(".SL", ""); + for (int x = 0; x < names.Count; x++) + { + if (unit.Attributes.GetNamedItem("Name").InnerText == names[x]) + { + oldindex.InnerText = (x + 1).ToString(); + break; + } + } + if(oldindex.InnerText == "") + oldindex.InnerText = slave.Extension.ToUpper().Replace(".SL", ""); unit.Attributes.SetNamedItem(oldindex); XmlAttribute index = xSlave.CreateAttribute("index"); idx++; diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index fcbecb1b..18ef6ead 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -5356,23 +5356,15 @@ CREATE FUNCTION [dbo].[ve_GetItemApplicability] (@ItemID int) RETURNS varchar(ma WITH EXECUTE AS OWNER AS BEGIN -declare @apple varchar(max) -select @apple = isnull(r2.value('@Applicability','varchar(max)'),'-1') -from -( -select itemid,cast(config as xml) xconfig from items ii join contents cc on ii.contentid = cc.contentid -) t1 -outer apply xconfig.nodes('//MasterSlave') t2(r2) -where itemid = @ItemID -if @apple = '-1' begin - set @apple = '' - select @apple = coalesce(@apple + ',','') + r2.value('@index','varchar(max)') from - (select cast(config as xml) xconfig from docversions - where versionid = dbo.vefn_GetVersionIDByItemID(@ItemID)) ah - cross apply xconfig.nodes('//Slave') t2(r2) - set @apple = substring(@apple,2,len(@apple)) -end -return @apple + declare @apple varchar(max) + select @apple = r2.value('@Applicability','varchar(max)') + from + ( + select itemid,cast(config as xml) xconfig from items ii join contents cc on ii.contentid = cc.contentid + ) t1 + outer apply xconfig.nodes('//MasterSlave') t2(r2) + where itemid = @ItemID + return @apple END GO IF (@@Error = 0) PRINT 'ScalerFunction [vefn_GetItemApplicability] Succeeded' @@ -5410,7 +5402,7 @@ WITH EXECUTE AS OWNER AS BEGIN with Itemz([Relationship], [ItemID], [ContentID], [PreviousID]) as ( - Select 1 [Relati@Parentsonship], [ItemID], [ContentID], [PreviousID] + Select 1 [Relationship], [ItemID], [ContentID], [PreviousID] FROM [Items] where [ItemID]=@ItemID Union All @@ -5460,13 +5452,24 @@ WITH EXECUTE AS OWNER AS BEGIN declare @apple varchar(max) - set @apple = '' - select @apple = @apple + ',' + cast(id as varchar(10)) - from [dbo].[vefn_ParentItems](@ItemID) - cross apply vefn_SplitInt([dbo].[ve_GetItemApplicability](itemid),',') - where [dbo].[ve_GetItemApplicability](itemid) != '-1' - group by id having count(*) = (select count(*) from [dbo].[vefn_ParentItems](@ItemID) where [dbo].[ve_GetItemApplicability](itemid) != '-1') - return substring(@apple,2,len(@apple)) + select @apple = dbo.ve_getitemapplicability(@ItemID) + if @apple is null + begin + declare @ParentID int + select @ParentID = dbo.ve_getparentitem(@ItemID) + if @parentid is not null + set @apple = dbo.ve_GetItemDerivedApplicability(@ParentID) + else + begin + set @apple = '' + select @apple = coalesce(@apple + ',','') + r2.value('@index','varchar(max)') from + (select cast(config as xml) xconfig from docversions + where versionid = dbo.vefn_GetVersionIDByItemID(@ItemID)) ah + cross apply xconfig.nodes('//Slave') t2(r2) + set @apple = substring(@apple,2,len(@apple)) + end + end + return @apple END GO -- Display the status of TableFunction creation