Corrected comment

Added Ordinal to vefn_SiblingItems
Added Stored Procedure vesp_SortProcedures to sort procedures within a DocVersion
Added Error Handler in Range.Text
Corrected logic in FindRO to return a null when an RO is not found.
This commit is contained in:
Rich 2013-02-28 15:47:52 +00:00
parent 767e9762e0
commit 4abaceac23
3 changed files with 82 additions and 4 deletions

View File

@ -3903,7 +3903,7 @@ IF (@@Error = 0) PRINT 'TableFunction Creation: vefn_SiblingChildrenItems Succee
ELSE PRINT 'TableFunction Creation: vefn_SiblingChildrenItems Error on Creation'
GO
/****** Object: StoredProcedure [vefn_SiblingItems] ******/
/****** Object: Table Function [vefn_SiblingItems] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vefn_SiblingItems]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1)
DROP FUNCTION [vefn_SiblingItems];
GO
@ -3922,7 +3922,8 @@ CREATE FUNCTION [dbo].[vefn_SiblingItems](@ItemID int, @ParentID int)
RETURNS @Siblings TABLE
(
ItemID int PRIMARY KEY,
ContentID int
ContentID int,
Ordinal int
)
WITH EXECUTE AS OWNER
AS
@ -3939,7 +3940,7 @@ Union All
from Itemz Z
join Items I on I.PreviousID = Z.ItemID
)
insert into @Siblings select ItemID, ContentID from Itemz
insert into @Siblings select ItemID, ContentID, Ordinal from Itemz
OPTION (MAXRECURSION 10000)
RETURN
END
@ -5944,4 +5945,70 @@ GO
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ListItemsAndContent Succeeded'
ELSE PRINT 'Procedure Creation: vesp_ListItemsAndContent Error on Creation'
GO
/****** Object: StoredProcedure [vesp_SortProcedures] ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[vesp_SortProcedures]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [vesp_SortProcedures];
GO
/*
select versionid, ff.folderid, ff.name,itemid
from docversions dv
join folders ff on dv.folderid=ff.folderid
Westinghouse Data
exec vesp_SortProcedures 1 -- Abnormal Procedures
--exec vesp_SortProcedures 4 -- Emergency Operating Procedures - Rev 2
exec vesp_SortProcedures 5 -- System Operating Procedures
exec vesp_SortProcedures 6 -- Maintenance, Test, Inspection, Surveillance Procedures
--exec vesp_SortProcedures 7 -- Severe Accident Management Guidelines
--exec vesp_SortProcedures 8 -- Emergency Response Guidelines
exec vesp_SortProcedures 9 -- General Operating Procedures
exec vesp_SortProcedures 11 -- Post 72-Hour Procedures 103811
*/
/*****************************************************************************
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
Copyright 2013 - Volian Enterprises, Inc. All rights reserved.
*****************************************************************************/
CREATE PROCEDURE [dbo].[vesp_SortProcedures]( @VersionID int )
WITH EXECUTE AS OWNER
AS
BEGIN TRY -- Try Block
BEGIN TRANSACTION
DECLARE @TopID int
select @TopID = ItemID from DocVersions where versionID = @VersionID
DECLARE @Procs TABLE
(
ItemID int PRIMARY KEY,
ProcNum nvarchar(255)
)
DECLARE @Organize TABLE
(
ItemID int PRIMARY KEY,
NewPreviousID int
)
DECLARE @NewTopID as int
INSERT INTO @Procs select ZZ.ItemID, isnull(Replace(CC.Number,'\u8209?','-'),'') + ':' + substring('0000000000000000' + cast(ItemID as varchar(16)), 1+ len( cast(ItemID as varchar(16))), 16) ProcNum from vefn_SiblingItems(@TopID,0) ZZ Join Contents CC on CC.ContentID = ZZ.ContentID
--select * from @Procs order by ProcNum + cast(ItemID as nvarchar(max))
select top 1 @NewTopID = ItemID from @Procs order by ProcNum
INSERT INTO @Organize
select ItemID, (select top 1 ItemID from @Procs P2 where P1.ProcNum > P2.ProcNum order by P2.ProcNum DESC ) NewPreviousID
from @Procs P1 order by isnull(ProcNum,'') + cast(ItemID as nvarchar(max))
--select * from @Organize
Update DocVersions Set ItemID = @NewTopID where versionID = @VersionID
Update II Set II.PreviousID = ZZ.NewPreviousID
from Items II join @Organize ZZ On II.ItemID = ZZ.ItemID
IF( @@TRANCOUNT > 0 ) COMMIT
END TRY
BEGIN CATCH -- Catch Block
IF( @@TRANCOUNT = 1 ) ROLLBACK -- Only rollback if top level
ELSE IF( @@TRANCOUNT > 1 ) COMMIT -- Otherwise commit. Top level will rollback
EXEC vlnErrorHandler
END CATCH
GO
-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_SortProcedures Succeeded'
ELSE PRINT 'Procedure Creation: vesp_SortProcedures Error on Creation'
GO

View File

@ -414,7 +414,17 @@ namespace LBWordLibrary
}
public String Text
{
get { return (GetProperty("Text").ToString()); }
get
{
try
{
return (GetProperty("Text").ToString());
}
catch (Exception ex)
{
return "";
}
}
set { SetProperty("Text", value); }
}
public LBRange GoTo()

View File

@ -1022,6 +1022,7 @@ namespace VEPROMS.CSLA.Library
find.MatchSoundsLike = false;
find.MatchAllWordForms = false;
executeResult = find.Execute();
if (!executeResult) return null;
// MS Word found 'invalid' ro when text had "[335.0<T<335.6ºC]" (not sure what problem was).
// When this occurred, the selection was found, but it's end = 0, so move 1 char past it.
// Also, need to simulate a loop by saving first position and if loop back to first position,