Enhanced Document support

Null check
Move DisplayText.cs to CSLA
Enhanced Documents – don’t allow ‘Save’ RO on enhanced step
Enhanced Documents windowing
Enhanced Documents remove unnecessary options
Enhanced Documents – don’t allow ‘Save’ transition on enhanced step
Enhanced Documents/Insert,Delete,Paste
This commit is contained in:
2016-01-20 16:43:23 +00:00
parent 77cdf81736
commit 6366af8b47
17 changed files with 1132 additions and 243 deletions

View File

@@ -230,7 +230,8 @@ namespace Volian.Controls.Library
//btnCancelRO.Enabled = ((_SavCurROLink != null) && chld.roid.Substring(0, 12).ToLower() != SavROLink.ROID.Substring(0, 12).ToLower());
string childroid = chld.roid.ToLower() + "0000";
childroid = childroid.Substring(0, 16);
btnSaveRO.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi) && ((_SavCurROLink == null) || !(childroid.Equals(SavROLink.ROID.ToLower()))); //added security check (UserInfo.CanEdit)
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnSaveRO.Enabled = !isenh && UserInfo.CanEdit(MyUserInfo, Mydvi) && ((_SavCurROLink == null) || !(childroid.Equals(SavROLink.ROID.ToLower()))); //added security check (UserInfo.CanEdit)
btnCancelRO.Enabled = ((_SavCurROLink != null) && childroid != SavROLink.ROID.ToLower());
btnGoToRO.Enabled = UserInfo.CanEditROs(MyUserInfo, Mydvi); // Writers and Reviewers cannot edit ROs (run the RO Editor)
switch (chld.type)

View File

@@ -48,12 +48,39 @@ namespace Volian.Controls.Library
}
public partial class DisplayTabControl : UserControl
{
private static bool _SyncronizeEnahnced = false;
public static bool SyncronizeEnhanced
{
get { return DisplayTabControl._SyncronizeEnahnced; }
set { DisplayTabControl._SyncronizeEnahnced = value; }
}
private static Dictionary<int, DisplayTabControl> _AllDTCs = new Dictionary<int, DisplayTabControl>();
private int? _VersionID = null;
public int? VersionID
{
get { return _VersionID; }
set
{
if (_AllDTCs.ContainsKey((int)value))
_AllDTCs[(int)value] = this;
else
_AllDTCs.Add((int)value, this);
_VersionID = value;
}
}
public event ItemSelectedChangedEvent OpenEnhancedDocument;
public void OnOpenEnhancedDocument(ItemSelectedChangedEventArgs args)
{
if (OpenEnhancedDocument != null)
OpenEnhancedDocument(this, args);
}
public event ItemSelectedChangedEvent RefreshEnhancedDocument;
public void OnRefreshEnhancedDocument(ItemSelectedChangedEventArgs args)
{
if (RefreshEnhancedDocument != null)
RefreshEnhancedDocument(this, args);
}
public event DisplayTabControlStatusEvent StatusChanged;
public void ONStatusChanged(object Sender, DisplayTabControlStatusEventArgs args)
{
@@ -76,7 +103,7 @@ namespace Volian.Controls.Library
/// "Item - " + Procedure ItemID for step pages
/// "Doc - " + DocumentID for Word Documents
/// </summary>
private Dictionary<string, DisplayTabItem> _MyDisplayTabItems;
public Dictionary<string, DisplayTabItem> _MyDisplayTabItems;
/// <summary>
/// When a Tab is closed it is added to this list.
/// When another Tab is opened, any Tabs in this list are closed
@@ -398,14 +425,39 @@ namespace Volian.Controls.Library
}
#endregion
#region Public Methods
public void RefreshItem(ItemInfo myItemInfo)
{
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString();
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{
DisplayTabItem pg = _MyDisplayTabItems[key];
if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID))
OpenItem(myItemInfo,false);
}
}
public DisplayTabItem OpenItem(ItemInfo myItemInfo2)
{
return OpenItem(myItemInfo2, true);
}
/// <summary>
/// Open a Step Item or a Word Item
/// </summary>
/// <param name="myItemInfo"></param>
/// <returns></returns>
public DisplayTabItem OpenItem(ItemInfo myItemInfo2)
public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus)
{
ItemInfo myItemInfo = myItemInfo2;
if(VersionID!=myItemInfo.MyDocVersion.VersionID)
{
if(_AllDTCs.ContainsKey(myItemInfo.MyDocVersion.VersionID))
{
return _AllDTCs[myItemInfo.MyDocVersion.VersionID].OpenItem(myItemInfo);
}
if(VersionID != 0)
return _AllDTCs[0].OpenItem(myItemInfo);
}
string message = string.Empty;
if (myItemInfo.MyContent.MyEntry == null) //not a document
{
@@ -440,7 +492,7 @@ namespace Volian.Controls.Library
}
_MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item.
if (myItemInfo.MyContent.MyEntry == null) // If it is a Word document open in step editor
return OpenStepTabPage(myItemInfo);
return OpenStepTabPage(myItemInfo,setFocus);
else // Otherwise open it in the Word editor
return OpenDSOTabPage(myItemInfo);
}
@@ -637,12 +689,16 @@ namespace Volian.Controls.Library
{
get { return _PnlCaret; }
}
private static int trackerSC = 0;
public void ShowCaret()
{
if (_MyStepRTB != null)
{
if (_MyEditItem.RTBLastFocus)
{
trackerSC++;
/*if (trackerSC>20) */Console.WriteLine("ShowCaret: {0}", trackerSC);
//Volian.Base.Library.vlnStackTrace.ShowStack("ShowCaret: EI: {0} StepRTB: {1}", _MyEditItem.MyItemInfo.ItemID, _MyStepRTB.MyItemInfo.ItemID);
if (!_MyStepRTB.Visible)
_MyStepRTB.Visible = true;
if (_MyStepRTB.SelectionLength == 0)
@@ -665,10 +721,14 @@ namespace Volian.Controls.Library
}
}
}
private static int trackerHC = 0;
public void HideCaret()
{
if (_MyStepRTB != null && !_MyStepRTB.Disposing && !_MyStepRTB.Closed)
{
trackerHC++;
/* if (trackerHC>20)*/ Console.WriteLine("HideCaret {0}", trackerHC);
//Volian.Base.Library.vlnStackTrace.ShowStack("HideCaret: StepRTB: {0}", _MyStepRTB.MyItemInfo.ItemID);
if (_MyStepRTB.SelectionLength == 0)
{
tmrCaret.Enabled = false;
@@ -823,23 +883,23 @@ namespace Volian.Controls.Library
/// </summary>
/// <param name="myItemInfo"></param>
/// <returns></returns>
public bool IsItemInfoProcedureOpen(ItemInfo ii)
{
ItemInfo proc = ii.MyProcedure; // Find procedure Item
if (dicEnhancedDocuments.ContainsKey(ii.MyProcedure.MyDocVersion))
{
frmEnhanced frm = dicEnhancedDocuments[ii.MyProcedure.MyDocVersion];
string key = "Item - " + proc.ItemID.ToString();
if (frm.MyDisplayTabClntrol._MyDisplayTabItems.ContainsKey(key))
return true;
}
// return true;
//return false;
return false;
}
public Dictionary<DocVersionInfo, frmEnhanced> dicEnhancedDocuments = new Dictionary<DocVersionInfo, frmEnhanced>();
//public bool IsItemInfoProcedureOpen(ItemInfo ii)
// if (ii == null) return false; //{
// ItemInfo proc = ii.MyProcedure; // Find procedure Item
// if (dicEnhancedDocuments.ContainsKey(ii.MyProcedure.MyDocVersion))
// {
// frmEnhanced frm = dicEnhancedDocuments[ii.MyProcedure.MyDocVersion];
// string key = "Item - " + proc.ItemID.ToString();
// if (frm.MyDisplayTabClntrol._MyDisplayTabItems.ContainsKey(key))
// return true;
// }
// // return true;
// //return false;
// return false;
//}
//public Dictionary<DocVersionInfo, frmEnhanced> dicEnhancedDocuments = new Dictionary<DocVersionInfo, frmEnhanced>();
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo)
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo, bool setFocus)
{
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString();
@@ -847,18 +907,24 @@ namespace Volian.Controls.Library
if (_MyDisplayTabItems.ContainsKey(key)) // If procedure page open use it
{
pg = _MyDisplayTabItems[key];
pg.Selected = true;
HandleChangeId(myItemInfo, pg);
if (SelectedDisplayTabItem != pg) // If the selected page doesn't match
SelectDisplayTabItem(pg); // Set the selected page
if (setFocus)
{
pg.Selected = true;
HandleChangeId(myItemInfo, pg);
if (SelectedDisplayTabItem != pg) // If the selected page doesn't match
SelectDisplayTabItem(pg); // Set the selected page
}
}
else // If not already open, create a new Page
{
pg = new DisplayTabItem(this.components, this, proc, key); // Open a new Procedure Tab
_MyDisplayTabItems.Add(key, pg);
pg.Selected = true;
HandleChangeId(myItemInfo, pg);
SelectDisplayTabItem(pg);
if (setFocus)
{
pg.Selected = true;
HandleChangeId(myItemInfo, pg);
SelectDisplayTabItem(pg);
}
pg.MyStepTabPanel.MyProcedureItemInfo = proc;
// When more than one procedure is openned, the ribbon control cuts off the bottom of the buttons.

View File

@@ -66,6 +66,12 @@ namespace Volian.Controls.Library
get { return _MyUserRole; }
set { _MyUserRole = value; }
}
private bool _Closed = false;
public bool Closed
{
get { return _Closed; }
set { _Closed = value; }
}
/// <summary>
/// Current SelectedItemInfo for this page
/// </summary>

View File

@@ -216,8 +216,16 @@ namespace Volian.Controls.Library
//if ((fmtdata.ProcData.CheckOffData.CheckOffList == null || fmtdata.ProcData.CheckOffData.CheckOffList.Count == 0) ||
// fmtdata.ProcData.CheckOffData.Menu=="Signoff")
// cmbCheckoff.Enabled = false;
if (sc == null) // if there is no config data ...
cbCAS.Enabled = true;
if (((CurItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedBackgrounds) == E_PurchaseOptions.EnhancedBackgrounds) ||
((CurItemInfo.ActiveFormat.PlantFormat.FormatData.PurchaseOptions.Value & E_PurchaseOptions.EnhancedDeviations) == E_PurchaseOptions.EnhancedDeviations))
{
cbCAS.Enabled = false;
cbPageBreak.Enabled = false;
cbPlaceKeeper.Enabled = false;
cbPlaceKeeperCont.Enabled = false;
}
else if (sc == null) // if there is no config data ...
{
if (CurItemInfo.IsHigh)cbPageBreak.Checked = false; // Page Break is set to false
cbCAS.Checked = CurItemInfo.IncludeOnContActSum; // set based on step type format flag

View File

@@ -32,7 +32,8 @@ namespace Volian.Controls.Library
if (_CurTrans == value && _CurItemFrom == MyRTB.MyItemInfo) return;
_CurItemFrom = MyRTB.MyItemInfo;
_TranFmtIndx = 0;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnTranSave.Enabled = !isenh && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
btnTranCancel.Enabled = true;
}
else // Modify a transition
@@ -952,7 +953,8 @@ namespace Volian.Controls.Library
if (sectstartid == -1) btnTranSave.Enabled = false; // if there is an invalid section start - don't allow save.
IList chldrn = prcitm.GetChildren();
cbTranSectsFillIn((ItemInfo)chldrn[0], sectstartid, true);
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnTranSave.Enabled = !isenh && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
SaveCancelEnabling();
}
private void tvTran_AfterSelect(object sender, TreeViewEventArgs e)
@@ -961,7 +963,8 @@ namespace Volian.Controls.Library
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
if ((etm & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone && tvTran.SelectedNode.Tag==null)
{
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnTranSave.Enabled = !isenh && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
return;
}
// check if node is a true end-point, i.e. not a 'part' node. If part node, don't
@@ -994,7 +997,8 @@ namespace Volian.Controls.Library
tvTranRangeHilites(true, _RangeNode1, _RangeNode2);
lblxTranRangeTip.Text = "Select First Transition\r\nfor Range";
lblxTranRangeTip.BackColor = Color.Yellow;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnTranSave.Enabled = !isenh && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
}
}
}
@@ -1003,7 +1007,8 @@ namespace Volian.Controls.Library
//bool hasChanged = _CurItemFrom != _SavCurItemFrom || _TranFmtIndx != _SavTranFmtIndx
// || ( selii != null && _CurTrans.ToID != selii.ItemID);
bool hasChanged = SettingsChanged;
btnTranSave.Enabled = hasChanged && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep;
btnTranSave.Enabled = !isenh && hasChanged && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
btnTranCancel.Enabled = _CurTrans != null && hasChanged;
//btnTranSave.Enabled = allowSave;
//if (CurTrans != null && selii != null)

View File

@@ -683,7 +683,25 @@ namespace Volian.Controls.Library
private static int xOffset = 0;
public void RemoveItem()
{
//Volian.Base.Library.VlnTimer _MyTimer = new VlnTimer();
// if this item has enhanced edititems, remove them:
StepConfig sc = MyItemInfo.MyConfig as StepConfig;
List<EnhancedDocument> thisEnhs = null;
if (sc != null)
thisEnhs = sc.MyEnhancedDocuments;
else
{
if (MyItemInfo.IsSection)
{
SectionConfig secc = MyItemInfo.MyConfig as SectionConfig;
if (secc.Section_LnkEnh=="Y")thisEnhs = secc.MyEnhancedDocuments;
}
}
List<int> enhIds = new List<int>();
foreach (EnhancedDocument ed in thisEnhs)
{
if (ed.Type != 0) enhIds.Add(ed.ItemID);
}
BeingRemoved = true;
MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
//ShowTops("\r\n");
@@ -717,6 +735,13 @@ namespace Volian.Controls.Library
//_MyTimer.ShowElapsedTimes("RemoveItem");
ForceEditItemRefresh(newFocus);
MyStepPanel.Controls.Remove(pnl);
foreach (int enhId in enhIds)
{
ItemInfo ii = ItemInfo.Get(enhId);
bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii);
if (!success) // item was not displayed in editor, just delete from database (add tree if necessarY)
Item.DeleteItemAndChildren(ii);
}
}
private static void ForceEditItemRefresh(EditItem newFocus)
@@ -998,9 +1023,9 @@ namespace Volian.Controls.Library
if (MyStepPanel.SelectedEditItem is RTBItem)
{
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
// see if this step has associated enhanced step(s):
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
// see if this step has associated enhanced step(s). If it does, flag it so
// that the enhanced steps get inserted also.
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
if (sc.MyEnhancedDocuments.Count > 0)
{
rtbi.EnhAddFromItemInfo = MyItemInfo;
@@ -1034,6 +1059,18 @@ namespace Volian.Controls.Library
ItemInfo newItemInfo = MyItemInfo.InsertSiblingAfter("", "", type);
AddGridIfNeeded(newItemInfo);
DoAddSiblingAfter(newItemInfo, updateStatus);
if (MyStepPanel.SelectedEditItem is RTBItem)
{
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
// see if this step has associated enhanced step(s). If it does, flag it so
// that the enhanced steps get inserted also.
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
if (sc.MyEnhancedDocuments.Count > 0)
{
rtbi.EnhAddFromItemInfo = MyItemInfo;
rtbi.EnhAddType = EnhancedAddTypes.After;
}
}
}
private void DoAddSiblingAfter(ItemInfo newItemInfo, bool updateStatus)
{
@@ -1083,7 +1120,8 @@ namespace Volian.Controls.Library
if (MyStepPanel.SelectedEditItem is RTBItem)
{
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
// see if this step has associated enhanced step(s):
// see if this step has associated enhanced step(s). If it does, flag it so
// that the enhanced steps get inserted also.
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
if (sc.MyEnhancedDocuments.Count > 0)
{
@@ -1206,9 +1244,21 @@ namespace Volian.Controls.Library
if (MyStepPanel.SelectedEditItem is RTBItem)
{
RTBItem rtbi = MyStepPanel.SelectedEditItem as RTBItem;
// see if this step has associated enhanced step(s):
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
if (sc.MyEnhancedDocuments.Count > 0)
// see if this step has associated enhanced step(s). If it does, flag it so
// that the enhanced steps get inserted also.
EnhancedDocuments cfgeds = null;
if (MyItemInfo.IsStepSection)
{
SectionConfig scfg = MyItemInfo.MyConfig as SectionConfig;
if (scfg.Section_LnkEnh != "Y") return;
cfgeds = scfg.MyEnhancedDocuments;
}
else
{
StepConfig sc = new StepConfig(MyItemInfo.MyContent.Config);
cfgeds = sc.MyEnhancedDocuments;
}
if (cfgeds != null && cfgeds.Count > 0)
{
rtbi.EnhAddFromItemInfo = MyItemInfo;
rtbi.EnhAddType = EnhancedAddTypes.Child;
@@ -1294,8 +1344,10 @@ namespace Volian.Controls.Library
if (newEditItem != null) MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type));
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Before, GetChangeId(MyItemInfo));
}
private string GetChangeId(ItemInfo iiDest)
{
// get the change id for the destination's procedure's change id.
@@ -1326,6 +1378,8 @@ namespace Volian.Controls.Library
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type));
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.After, GetChangeId(MyItemInfo));
}
public void PasteChild(int copyStartID)
{
@@ -1375,6 +1429,9 @@ namespace Volian.Controls.Library
break;
}
MyStepPanel.SelectedEditItem = newEditItem;//Update Screen
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Child, GetChangeId(MyItemInfo));
}
public EditItem PasteReplace(int copyStartID)
{
@@ -1389,6 +1446,7 @@ namespace Volian.Controls.Library
EditItem prevEditItem = MyPreviousEditItem;
EditItem parentEditItem = ActiveParent;
StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig;
int TopMostYBefore = TopMostEditItem.Top;
int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top));
int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top));
@@ -1452,6 +1510,8 @@ namespace Volian.Controls.Library
}
MyStepPanel.SelectedEditItem = newEditItem; //Update Screen
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type));
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Replace, GetChangeId(MyItemInfo));
return newEditItem;
}
private bool HandleSqlExceptionOnCopy(Exception ex)