From 37d067a74ebef3e346f85b08d479233e32359940 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 24 Jun 2011 21:47:40 +0000 Subject: [PATCH] Added table function to return a list of Content records that contain a specified string. Added stored procedure to standardize text (standard steps) Lazy Load font value. Return the correct EditItem when a step is deleted. Update the StepTabRibbon EditItem when the StepPanel EditItem is changed Get MyItemInfo if it is not set. Added missing logic to MyEditItem. --- PROMS/SQL/PROMS2010.SQL | 61 +++++++++++++++++++ .../Format/PlantFormat.cs | 8 ++- PROMS/Volian.Controls.Library/EditItem.cs | 12 ++-- PROMS/Volian.Controls.Library/StepPanel.cs | 1 + PROMS/Volian.Controls.Library/StepRTB.cs | 15 +++-- .../Volian.Controls.Library/StepTabRibbon.cs | 43 +++++++++---- 6 files changed, 116 insertions(+), 24 deletions(-) diff --git a/PROMS/SQL/PROMS2010.SQL b/PROMS/SQL/PROMS2010.SQL index a77425a8..f31aa98c 100644 --- a/PROMS/SQL/PROMS2010.SQL +++ b/PROMS/SQL/PROMS2010.SQL @@ -4235,6 +4235,32 @@ IF (@@Error = 0) PRINT 'Procedure Creation: existsZTransition Succeeded' ELSE PRINT 'Procedure Creation: existsZTransition Error on Creation' GO +/****** Object: StoredProcedure [FindText] ******/ +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[FindText]') AND OBJECTPROPERTY(id,N'IsTableFunction') = 1) + DROP FUNCTION [FindText]; +GO + +Create FUNCTION [dbo].[FindText](@LookFor varchar(255)) +RETURNS @Results TABLE +( + ItemID int PRIMARY KEY, + ContentID int +) +WITH EXECUTE AS OWNER +BEGIN + insert into @Results + select itemid,ii.contentid + from items ii + join contents cc on ii.contentid = cc.contentid + where text like @LookFor + RETURN +END +GO +-- Display the status of Proc creation +IF (@@Error = 0) PRINT 'TableFunction Creation: FindText Succeeded' +ELSE PRINT 'TableFunction Creation: FindText Error on Creation' +GO + /****** Object: StoredProcedure [getAffectedDRoUsages] ******/ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[getAffectedDRoUsages]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) DROP PROCEDURE [getAffectedDRoUsages]; @@ -10024,6 +10050,41 @@ IF (@@Error = 0) PRINT 'Procedure Creation: purgeData Succeeded' ELSE PRINT 'Procedure Creation: purgeData Error on Creation' GO +/****** Object: StoredProcedure [Standardize] ******/ +IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[Standardize]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) + DROP PROCEDURE [Standardize]; +GO + +/* +Standardize '%engineering evaluation%' +Standardize '%preferred running order%' +Standardize '%provide normal spray%' +*/ + +CREATE PROCEDURE [dbo].[Standardize] +( + @LookFor varchar(255) +) +WITH EXECUTE AS OWNER +AS +BEGIN TRY -- Try Block + BEGIN TRANSACTION + DECLARE @ContentID INT + SET @Contentid = (select min(ContentID) FROM FindText(@LookFor)) + UPDATE Items SET ContentID = @ContentID WHERE ItemID in(SELECT ItemID FROM FindText(@LookFor)) +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: Standardize Succeeded' +ELSE PRINT 'Procedure Creation: Standardize Error on Creation' +GO + /****** Object: StoredProcedure [updateAnnotation] ******/ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[updateAnnotation]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1) DROP PROCEDURE [updateAnnotation]; diff --git a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs index 8eedc068..ee61cf9c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/PlantFormat.cs @@ -4299,8 +4299,12 @@ namespace VEPROMS.CSLA.Library { get { - XmlNode xn = vlnFormatDocument.LookupSingleStepNode(base.XmlNode, "TabData[Font]"); - return (_Font == null ? _Font = new VE_Font(xn) : _Font); + if (_Font == null) + { + XmlNode xn = vlnFormatDocument.LookupSingleStepNode(base.XmlNode, "TabData[Font]"); + _Font = new VE_Font(xn); + } + return _Font; } } diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 01754e46..666e490a 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -592,7 +592,7 @@ namespace Volian.Controls.Library else if (MyPreviousEditItem != null) { MyPreviousEditItem.MyNextEditItem = null; - newFocus = MyPreviousEditItem; + newFocus = MyPreviousEditItem.BottomMostEditItem; MyPreviousEditItem = null; //Console.Write(",\"Previous\","); } @@ -749,7 +749,8 @@ namespace Volian.Controls.Library public EditItem AddChildBefore(ItemInfo MyItemInfo, EditItem nextEditItem) { EditItem child = null; - if (MyItemInfo.MyContent.ContentGridCount != 0) + //if (MyItemInfo.MyContent.ContentGridCount != 0) + if(MyItemInfo.MyContent.MyGrid != null) child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem); else child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.Before, true, nextEditItem); @@ -1138,10 +1139,11 @@ namespace Volian.Controls.Library private void EditItem_Move(object sender, EventArgs e) { int watchThis = _WatchThis; - //if (MyID == _lookForID || MyID == 2111) + //if (MyID == 136) //{ + // vlnStackTrace.ShowStack("{0} Move TO {1}", MyID, Top); // //vlnStackTrace.ShowStack("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); - // Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); + // //Console.WriteLine("{0} Move TO {1} - {2}, BottomMost {3}", MyID, Top, MyPath, BottomMostRTBItem.MyPath); //} //if (MyID > _StartingID) // Console.WriteLine("{0}--------------- {1} Top = {2} Bottom {3}", WatchThisIndent, MyID, Top, Bottom); @@ -1593,7 +1595,7 @@ namespace Volian.Controls.Library EditItem parent = EditItem.UpOneEditItem; int right = FindRight(); bool centeredTable = (MyItemInfo.IsTablePart && MyItemInfo.FormatStepData.Type.Contains("AER") == false && MyItemInfo.RNOLevel == 0); - while (parent != null && parent.MyItemInfo.IsSection == false) + while (parent != null && parent.MyItemInfo.IsSection == false && parent._MyChildRelation != ChildRelation.Before) { if (parent._MyRNOEditItems != null) { diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index 449dd7bc..fa231aa6 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -443,6 +443,7 @@ namespace Volian.Controls.Library } } _SelectedEditItem = value; + MyStepTabPanel.MyStepTabRibbon.MyEditItem = value;// Update StepTabRibbon.MyEditItem to match if (value != null) { _SelectedEditItem.RefreshDisplay(true); diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 94b9e427..3b8ec90a 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -319,7 +319,14 @@ namespace Volian.Controls.Library private ItemInfo _MyItemInfo; public ItemInfo MyItemInfo { - get { return _MyItemInfo; } + get + { + if (_MyItemInfo == null && Parent is EditItem) + _MyItemInfo = (Parent as EditItem).MyItemInfo; + else if (_MyItemInfo == null && Parent.Parent is EditItem) + _MyItemInfo = (Parent.Parent as EditItem).MyItemInfo; + return _MyItemInfo; + } set { _MyItemInfo = value; } } private string _OrigRTF; @@ -2104,9 +2111,7 @@ namespace Volian.Controls.Library public int SelectionStart { get { return _SelectionStart; } - set { - _SelectionStart = value; - } + set { _SelectionStart = value; } } int _SelectionLength; public int SelectionLength @@ -2116,8 +2121,6 @@ namespace Volian.Controls.Library } public SelectionData(RichTextBox richTextBox) { - //Console.WriteLine("SelectionData SelectionStart {0}", richTextBox.SelectionStart); - //Volian.Base.Library.vlnStackTrace.ShowStack("SelectionData SelectionStart",this);//.ShowStackLocal("SelectionData SelectionStart", 3); _SelectionStart = richTextBox.SelectionStart; _SelectionLength = richTextBox.SelectionLength; } diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 451bb39f..30ac589d 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -30,6 +30,7 @@ namespace Volian.Controls.Library get { return _MyEditItem; } set { + if (_MyEditItem == value) return; // Don't do this if the value is not different _MyEditItem = value; if (value != null) { @@ -37,9 +38,11 @@ namespace Volian.Controls.Library if (value is GridItem) { ToggleTableDesignButtons(true); - MyFlexGrid_SelChange(this,new EventArgs()); + MyFlexGrid_SelChange(this, new EventArgs()); } } + else + MyStepRTB = null; } } private DocVersionInfo _MyDVI; @@ -59,8 +62,14 @@ namespace Volian.Controls.Library } } private ItemInfo MyItemInfo - { get { return _MyStepRTB == null ? null : _MyStepRTB.MyItemInfo; } } - + { + get + { + if(_MyStepRTB != null && _MyStepRTB.MyItemInfo != null) return _MyStepRTB.MyItemInfo; + if(_MyEditItem != null && _MyEditItem.MyItemInfo != null) return _MyEditItem.MyItemInfo; + return null; + } + } private DevComponents.DotNetBar.ButtonItem _DefaultContextMenu; public void ClearContextMenu() @@ -183,11 +192,17 @@ namespace Volian.Controls.Library // ex. Positon on a substep, press , to list the substep types //_MyStepRTB.KeyUp -=new KeyEventHandler(_MyStepRTB_KeyUp); //_MyStepRTB.MouseUp -= new MouseEventHandler(_MyStepRTB_MouseUp); - _MyStepRTB.SelectionChanged -= new EventHandler(_MyStepRTB_SelectionChanged); - _MyEditItem.Leave -= new EventHandler(_MyEditItem_Leave); - _MyEditItem.Enter += new EventHandler(_MyEditItem_Enter); + if (_MyEditItem != null) + { + _MyEditItem.Leave -= new EventHandler(_MyEditItem_Leave); + _MyEditItem.Enter += new EventHandler(_MyEditItem_Enter); + } //_MyStepRTB.Leave -= new EventHandler(_MyStepRTB_Leave); - _MyStepRTB.LinkChanged -= new StepRTBLinkEvent(_MyStepRTB_LinkChanged); + if (_MyStepRTB != null) + { + _MyStepRTB.SelectionChanged -= new EventHandler(_MyStepRTB_SelectionChanged); + _MyStepRTB.LinkChanged -= new StepRTBLinkEvent(_MyStepRTB_LinkChanged); + } if (MyFlexGrid != null) { MyFlexGrid.CopyOptionChanged -= new VlnFlexGridEvent(MyFlexGrid_CopyOptionChanged); @@ -200,11 +215,17 @@ namespace Volian.Controls.Library // ex. Positon on a substep, press , to list the substep types //_MyStepRTB.KeyUp -=new KeyEventHandler(_MyStepRTB_KeyUp); //_MyStepRTB.MouseUp -= new MouseEventHandler(_MyStepRTB_MouseUp); - _MyStepRTB.SelectionChanged += new EventHandler(_MyStepRTB_SelectionChanged); - _MyEditItem.Leave += new EventHandler(_MyEditItem_Leave); - _MyEditItem.Enter -= new EventHandler(_MyEditItem_Enter); + if (_MyEditItem != null) + { + _MyEditItem.Leave += new EventHandler(_MyEditItem_Leave); + _MyEditItem.Enter -= new EventHandler(_MyEditItem_Enter); + } //_MyStepRTB.Leave -= new EventHandler(_MyStepRTB_Leave); - _MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged); + if (_MyStepRTB != null) + { + _MyStepRTB.LinkChanged += new StepRTBLinkEvent(_MyStepRTB_LinkChanged); + _MyStepRTB.SelectionChanged += new EventHandler(_MyStepRTB_SelectionChanged); + } if (MyFlexGrid != null) { MyFlexGrid.CopyOptionChanged += new VlnFlexGridEvent(MyFlexGrid_CopyOptionChanged);