diff --git a/PROMS/DataLoader/PROMS2010.SQL b/PROMS/DataLoader/PROMS2010.SQL index 0b7181f6..d255ce06 100644 --- a/PROMS/DataLoader/PROMS2010.SQL +++ b/PROMS/DataLoader/PROMS2010.SQL @@ -17002,3 +17002,187 @@ IF (@@Error = 0) PRINT 'Procedure Creation: vesp_SearchROItemAndChildren Succeed ELSE PRINT 'Procedure Creation: vesp_SearchROItemAndChildren Error on Creation' GO + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ListItemsTranFrom]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_ListItemsTranFrom]; +GO +/****** Object: StoredProcedure [dbo].[vesp_ListItemsTranFrom] Script Date: 10/03/2012 10:06:38 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +CREATE PROCEDURE [dbo].[vesp_ListItemsTranFrom] +WITH EXECUTE AS OWNER +AS +begin + +Select distinct I.ItemID,I.PreviousID,I.ContentID,I.[DTS],I.[UserID],I.[LastChanged], + (SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=I.[ItemID]) [AnnotationCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=I.[ItemID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Items] [Children] WHERE [Children].[PreviousID]=I.[ItemID]) [NextCount], + (SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=I.[ItemID]) [PartCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=I.[ItemID]) [Transition_RangeIDCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=I.[ItemID]) [Transition_ToIDCount] +from Items I +join Transitions T on I.ContentID = T.FromID +END +GO + +IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ListItemsTranFrom Succeeded' +ELSE PRINT 'Procedure Creation: vesp_ListItemsTranFrom Error on Creation' +GO + + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ListItemsTranTo]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_ListItemsTranTo]; +GO +/****** Object: StoredProcedure [dbo].[vesp_ListItemsTranTo] Script Date: 10/03/2012 10:08:03 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +CREATE PROCEDURE [dbo].[vesp_ListItemsTranTo] +WITH EXECUTE AS OWNER +AS +begin +with Itemz(ItemID, ContentID, PreviousID, [Type]) as ( + Select Distinct ItemID, C.ContentID, PreviousID, C.Type + FROM [Items] I + Join Contents C on C.ContentID = I.ContentID + JOIN Transitions T on t.ToID = I.ItemID or t.RangeID = I.ItemID + --where [ItemID]=@ItemID +Union ALL +-- Parent + select I.ItemID,I.ContentID, I.PreviousID, C.Type + from Itemz Z + join Parts P on P.ItemID = Z.ItemID + join Items I on I.ContentID = P.ContentID + Join Contents C on C.ContentID = I.ContentID +-- Previous +Union ALL + select I.ItemID,I.ContentID, I.PreviousID, C.Type + from Itemz Z + join Items I on Z.PreviousID = I.ItemID + Join Contents C on C.ContentID = I.ContentID + where Z.Type >= 10000 +) +Select distinct I.ItemID,I.PreviousID,I.ContentID,I.[DTS],I.[UserID],I.[LastChanged], + (SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=Z.[ItemID]) [AnnotationCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=Z.[ItemID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Items] [Children] WHERE [Children].[PreviousID]=Z.[ItemID]) [NextCount], + (SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=Z.[ItemID]) [PartCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=Z.[ItemID]) [Transition_RangeIDCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=Z.[ItemID]) [Transition_ToIDCount] +from Itemz Z join Items I on I.ItemID = Z.ItemID +OPTION (MAXRECURSION 1000) +END +GO + +IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ListItemsTranTo Succeeded' +ELSE PRINT 'Procedure Creation: vesp_ListItemsTranTo Error on Creation' +GO + + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ListItemsTranFromAndContent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_ListItemsTranFromAndContent]; +GO +/****** Object: StoredProcedure [dbo].[vesp_ListItemsTranFromAndContent] Script Date: 10/03/2012 10:52:31 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +CREATE PROCEDURE [dbo].[vesp_ListItemsTranFromAndContent] +WITH EXECUTE AS OWNER +AS +begin + +Select distinct I.ItemID,I.PreviousID,I.ContentID,I.[DTS],I.[UserID],I.[LastChanged], + C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] [cDTS],C.[UserID] [cUserID],C.[LastChanged] [cLastChanged], + (SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=[I].[ItemID]) [AnnotationCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=[I].[ItemID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Items] [Children] WHERE [Children].[PreviousID]=[I].[ItemID]) [NextCount], + (SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=[I].[ItemID]) [PartCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=[I].[ItemID]) [Transition_RangeIDCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=[I].[ItemID]) [Transition_ToIDCount], + (SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[C].[ContentID]) [DetailCount], + (SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[C].[ContentID]) [EntryCount], + (SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[C].[ContentID]) [GridCount], + (SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[C].[ContentID]) [ImageCount], + (SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[C].[ContentID]) [ItemCount], + (SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[C].[ContentID]) [cPartCount], + (SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[C].[ContentID]) [RoUsageCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[C].[ContentID]) [TransitionCount], + (SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[C].[ContentID]) [ZContentCount] +from Items I Join Contents C on I.ContentID = C.ContentID +join Transitions T on I.ContentID = T.FromID +END +GO +IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ListItemsTranFromAndContent Succeeded' +ELSE PRINT 'Procedure Creation: vesp_ListItemsTranFromAndContent Error on Creation' +GO + +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_ListItemsTranToAndContent]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [vesp_ListItemsTranToAndContent]; +GO +GO +/****** Object: StoredProcedure [dbo].[vesp_ListItemsTranToAndContent] Script Date: 10/03/2012 10:08:17 ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +CREATE PROCEDURE [dbo].[vesp_ListItemsTranToAndContent] +WITH EXECUTE AS OWNER +AS +begin +with Itemz(ItemID, ContentID, PreviousID, [Type]) as ( + Select Distinct ItemID, C.ContentID, PreviousID, C.Type + FROM [Items] I + Join Contents C on C.ContentID = I.ContentID + JOIN Transitions T on t.ToID = I.ItemID or t.RangeID = I.ItemID + --where [ItemID]=@ItemID +Union ALL +-- Parent + select I.ItemID,I.ContentID, I.PreviousID, C.Type + from Itemz Z + join Parts P on P.ItemID = Z.ItemID + join Items I on I.ContentID = P.ContentID + Join Contents C on C.ContentID = I.ContentID +-- Previous +Union ALL + select I.ItemID,I.ContentID, I.PreviousID, C.Type + from Itemz Z + join Items I on Z.PreviousID = I.ItemID + Join Contents C on C.ContentID = I.ContentID + where Z.Type >= 10000 +) +Select distinct I.ItemID,I.PreviousID,I.ContentID,I.[DTS],I.[UserID],I.[LastChanged], + C.[Number],C.[Text],C.[Type],C.[FormatID],C.[Config],C.[DTS] [cDTS],C.[UserID] [cUserID],C.[LastChanged] [cLastChanged], + (SELECT COUNT(*) FROM [Annotations] WHERE [Annotations].[ItemID]=[I].[ItemID]) [AnnotationCount], + (SELECT COUNT(*) FROM [DocVersions] WHERE [DocVersions].[ItemID]=[I].[ItemID]) [DocVersionCount], + (SELECT COUNT(*) FROM [Items] [Children] WHERE [Children].[PreviousID]=[I].[ItemID]) [NextCount], + (SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ItemID]=[I].[ItemID]) [PartCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[RangeID]=[I].[ItemID]) [Transition_RangeIDCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[ToID]=[I].[ItemID]) [Transition_ToIDCount], + (SELECT COUNT(*) FROM [Details] WHERE [Details].[ContentID]=[C].[ContentID]) [DetailCount], + (SELECT COUNT(*) FROM [Entries] WHERE [Entries].[ContentID]=[C].[ContentID]) [EntryCount], + (SELECT COUNT(*) FROM [Grids] WHERE [Grids].[ContentID]=[C].[ContentID]) [GridCount], + (SELECT COUNT(*) FROM [Images] WHERE [Images].[ContentID]=[C].[ContentID]) [ImageCount], + (SELECT COUNT(*) FROM [Items] WHERE [Items].[ContentID]=[C].[ContentID]) [ItemCount], + (SELECT COUNT(*) FROM [Parts] WHERE [Parts].[ContentID]=[C].[ContentID]) [cPartCount], + (SELECT COUNT(*) FROM [RoUsages] WHERE [RoUsages].[ContentID]=[C].[ContentID]) [RoUsageCount], + (SELECT COUNT(*) FROM [Transitions] WHERE [Transitions].[FromID]=[C].[ContentID]) [TransitionCount], + (SELECT COUNT(*) FROM [ZContents] WHERE [ZContents].[ContentID]=[C].[ContentID]) [ZContentCount] +from Itemz Z +Join Items I on Z.ItemID = I.ItemID +Join Contents C on I.ContentID = C.ContentID +OPTION (MAXRECURSION 1000) +END +GO + +IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ListItemsTranToAndContent Succeeded' +ELSE PRINT 'Procedure Creation: vesp_ListItemsTranToAndContent Error on Creation' +GO diff --git a/PROMS/DataLoader/Steps.cs b/PROMS/DataLoader/Steps.cs index 03d4a7d2..55d005ff 100644 --- a/PROMS/DataLoader/Steps.cs +++ b/PROMS/DataLoader/Steps.cs @@ -281,14 +281,28 @@ namespace DataLoader //recdirty |= AddContentDetail(content, STP_LNK_SEQ, TextConvert.ConvertSeq(tkstring.Substring(nxttok + 1))); tkstring = tkstring.Substring(0, nxttok); } - - if ((nxttok = tkstring.IndexOf("\x2")) > -1) // Multiple Change Ids + // verify that there are format flags for doing multiple change ids (DoMultipleChangeIDs) & + // getting the change bar message from the editor (ChgBarMessageFromEdit), if these + // two flags aren't set, don't migrate the data. + // This was put in to fix B2012-258. An extensive search/debug session was done in 16bit to + // see how these format flags and the data interracted. For OHLP/HLP, which only has + // ChgBarMessageFromEdit flag, the data after the Multiple change id token was not used in + // 16bit, at least anywhere that could be found when running the program through the debugger. + if (fmt.PlantFormat.FormatData.ProcData.ChangeBarData.ChgBarMessageFromEdit && + fmt.PlantFormat.FormatData.ProcData.ChangeBarData.MultipleChangeIds) { - //Console.WriteLine("Multiple Change ID: {0}", tkstring.Substring(nxttok + 1)); - ci.AddItem("Step", "MultipleChangeID", tkstring.Substring(nxttok + 1)); - recdirty = true; - //recdirty |= AddContentDetail(content, STP_MULT_CHGID, tkstring.Substring(nxttok + 1)); - tkstring = tkstring.Substring(0, nxttok); + if ((nxttok = tkstring.IndexOf("\x2")) > -1) // Multiple Change Ids + { + string tmpchgid = tkstring.Substring(nxttok + 1); + if (tmpchgid.Length > 0) + { + //Console.WriteLine("Multiple Change ID: {0}", tkstring.Substring(nxttok + 1)); + ci.AddItem("Step", "MultipleChangeID", tkstring.Substring(nxttok + 1)); + recdirty = true; + //recdirty |= AddContentDetail(content, STP_MULT_CHGID, tkstring.Substring(nxttok + 1)); + } + tkstring = tkstring.Substring(0, nxttok); + } } if ((nxttok = tkstring.IndexOf("\x1")) > -1) // Comment