From 3f7cbc10bc4ef09a3fcc505960defe121cd59d81 Mon Sep 17 00:00:00 2001 From: Jake Date: Fri, 3 Jun 2022 19:45:42 +0000 Subject: [PATCH] B2022-026 RO Memory reduction coding (Jakes Merge) --- .../frmVEPROMS.Designer.cs | 2 +- PROMS/VEPROMS User Interface/frmVEPROMS.cs | 945 ++++++++++-------- .../Config/ROFSTLookup.cs | 198 +++- .../Extension/ROFSTExt.cs | 30 +- .../Extension/RevisionInfoExt.cs | 2 +- .../Generated/ROFstInfo.cs | 7 +- PROMS/Volian.Controls.Library/DisplayRO.cs | 805 ++++++++------- .../PDFConsistencyCheckReport.cs | 2 +- 8 files changed, 1114 insertions(+), 877 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs index 94849f14..d5e9c4ea 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.Designer.cs @@ -1090,7 +1090,7 @@ namespace VEPROMS this.displayRO.Location = new System.Drawing.Point(1, 1); this.displayRO.Margin = new System.Windows.Forms.Padding(4); this.displayRO.MyROFST = null; - this.displayRO.MyROFSTLookup = null; + //this.displayRO.MyROFSTLookup = null; this.displayRO.MyRTB = null; this.displayRO.Name = "displayRO"; this.displayRO.ProgressBar = null; diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 5b0b2620..34efa7e0 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -48,7 +48,7 @@ namespace VEPROMS } public void RefreshLastChange() { - lblLastChange.Text = string.Format("Last Change: {0}", MySessionInfo.LastContentChange - this.LastContentChange); + lblLastChange.Text = string.Format("Last Change: {0}", MySessionInfo.LastContentChange - this.LastContentChange); } public StepTabPanel SelectedStepTabPanel { @@ -86,9 +86,9 @@ namespace VEPROMS _SelectedStepTabPanel.MyStepTabRibbon.ContActionSummaryRequest += MyStepTabRibbon_ContActionSummaryRequest; _SelectedStepTabPanel.MyStepTabRibbon.AddProcToDVInTree -= new StepTabRibbonEvent(MyStepTabRibbon_AddProcToDocVersionInTree); _SelectedStepTabPanel.MyStepTabRibbon.AddProcToDVInTree += new StepTabRibbonEvent(MyStepTabRibbon_AddProcToDocVersionInTree); + } } } - } void MyStepTabRibbon_ContActionSummaryRequest(object sender, StepTabRibbonEventArgs args) { @@ -177,7 +177,7 @@ namespace VEPROMS public frmVEPROMS(frmVEPROMS myParent, DocVersionInfo myDocVersion) { MyParent = myParent; - MyDocVersion=myDocVersion; + MyDocVersion = myDocVersion; InitializeComponent(); // B2019-082 set the date format on the VEPROMS.exe thread to U.S. for i/o of a date string // this is to correct an issue for a UAE customer who could not open some procedures due to the desktop date setting using the "DD/MM/YYYY" instead of the "MM/DD/YYYY" format @@ -245,9 +245,9 @@ namespace VEPROMS VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_RMARK_DEBUG"; else if (Environment.MachineName == "WINDOWS7-RHM") VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_RMARK_DEBUG"; - else if (Environment.UserName.ToUpper() == "BODINE") - VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_BODINE_DEBUG"; - else + else if (Environment.UserName.ToUpper() == "BODINE") + VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_BODINE_DEBUG"; + else VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_LOCAL"; } else @@ -256,11 +256,11 @@ namespace VEPROMS // - except for the volian laptop and Rich's Demo version where we need to use local data if (Environment.MachineName == "RMARK-PC") VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_RMARK_DEMO"; - else if (Environment.MachineName == "WINDOWS7-RHM") + else if (Environment.MachineName == "WINDOWS7-RHM") VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_RMARK_DEMO"; - else if (Environment.UserName.ToUpper() == "BODINE") - VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_BODINE_DEMO"; - else + else if (Environment.UserName.ToUpper() == "BODINE") + VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_BODINE_DEMO"; + else VEPROMS.CSLA.Library.Database.ConnectionName = "VEPROMS_LOCAL"; } InitializeComponent(); @@ -304,8 +304,8 @@ namespace VEPROMS cmbFont.SelectedIndex = -1; string[] parameters = System.Environment.CommandLine.Split(" ".ToCharArray()); string db = Volian.Base.Library.VlnSettings.GetDB(); - if(db != null) - Database.SelectedDatabase = db; + if (db != null) + Database.SelectedDatabase = db; if (Properties.Settings.Default["DefaultDB"] != string.Empty) //B2018-129 Most Recently Used list was being cleared. Needed to remove a (string) typecase in the IF statement Database.LastDatabase = Properties.Settings.Default.DefaultDB; // Setup the Context menu for DisplaySearch including the symbols @@ -321,7 +321,7 @@ namespace VEPROMS throw new Exception("Could not set PROMSBaseFormat"); if ((Database.LastDatabase ?? "") != (Database.SelectedDatabase ?? "")) { - if(Properties.Settings.Default.VersionWindows != null) + if (Properties.Settings.Default.VersionWindows != null) Properties.Settings.Default.VersionWindows.Clear(); Properties.Settings.Default.MRIList = null; Properties.Settings.Default.DefaultDB = Database.SelectedDatabase; @@ -335,7 +335,7 @@ namespace VEPROMS ChangeLogFileName("LogFileAppender", Database.ActiveDatabase + " " + dtSunday.ToString("yyyyMMdd") + " ErrorLog.txt"); // B2019-107 Error Log message for inconsistent PromsFixes _MyLog.InfoFormat("\r\nSession Beginning\r\n<===={0}[SQL:{1:yyMM.ddHH}]====== User: {2}/{3} Started {4} ===============>{5}" - , Application.ProductVersion,Database.RevDate, Environment.UserDomainName,Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"), FormatInfo.Failed ?? ""); + , Application.ProductVersion, Database.RevDate, Environment.UserDomainName, Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"), FormatInfo.Failed ?? ""); foreach (string parameter in parameters) { if (parameter.ToUpper().StartsWith("/UF=")) @@ -359,9 +359,10 @@ namespace VEPROMS public bool PauseRefresh { get { return _PauseRefresh; } - set { + set + { //_MyLog.WarnFormat(value ? "=== Pause" : "=== UnPause"); - _PauseRefresh = value; + _PauseRefresh = value; } } void tv_UnPauseRefresh(object sender, vlnTreeSectionInfoEventArgs args) @@ -437,6 +438,20 @@ namespace VEPROMS displayBookMarks.ResetBookMarksInPROMSWindows += displayBookMarks_ResetBookMarksInPROMSWindows; } + // Part of Separate Windows upgrade C2015-022 + // Extend changeds to BookMark information to all of the child windows + void displayBookMarks_ResetBookMarksInPROMSWindows(object sender, EventArgs args) + { + foreach (int k in PROMSWindowForms.Keys) + { + frmVEPROMS tmp = PROMSWindowForms[k]; + if (tmp.MyDocVersion.VersionID != this.SelectedDVI.VersionID) + tmp.displayBookMarks.ResetBookMarkList(); + else if (tmp.MyParent != null) + tmp.MyParent.displayBookMarks.ResetBookMarkList(); + } + } + // Part of Separate Windows upgrade C2015-022 // Extend changeds to BookMark information to all of the child windows void displayBookMarks_ResetBookMarksInPROMSWindows(object sender, EventArgs args) @@ -504,17 +519,17 @@ namespace VEPROMS tc.HandleChangeId(args.MyItemInfo, null); return tc.ChgId; } - ItemInfo tv_ClipboardStatus(object sender, vlnTreeEventArgs args) - { - return tc.MyCopyStep; - } - void tv_NodeCopy(object sender, vlnTreeEventArgs args) - { - VETreeNode tn = args.Node as VETreeNode; - ItemInfo ii = tn.VEObject as ItemInfo; - tc.MyCopyStep = ii; + ItemInfo tv_ClipboardStatus(object sender, vlnTreeEventArgs args) + { + return tc.MyCopyStep; + } + void tv_NodeCopy(object sender, vlnTreeEventArgs args) + { + VETreeNode tn = args.Node as VETreeNode; + ItemInfo ii = tn.VEObject as ItemInfo;? + tc.MyCopyStep = ii; tc_CopyStepSelected(sender, null); // C2015-022 set copy step info in the child windows - } + } void tv_PrintTransitionReport(object sender, vlnTreeEventArgs args) { FolderInfo fi = null; @@ -523,12 +538,12 @@ namespace VEPROMS fi = (args.Node as VETreeNode).VEObject as FolderInfo; if ((args.Node as VETreeNode).VEObject is ProcedureInfo) pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; - if (fi != null) //working with folder + if (fi != null) //working with folder { dlgTransitionReport dlg = new dlgTransitionReport(fi); dlg.ShowDialog(this); } - if (pi != null) //working with procedure + if (pi != null) //working with procedure { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); @@ -539,89 +554,89 @@ namespace VEPROMS } void tv_ExportImportProcedureSets(object sender, vlnTreeEventArgs args) - { - FolderInfo fi = null; - DocVersionInfo dvi = null; - ProcedureInfo pi = null; - if ((args.Node as VETreeNode).VEObject is FolderInfo) - fi = (args.Node as VETreeNode).VEObject as FolderInfo; - if ((args.Node as VETreeNode).VEObject is DocVersionInfo) - dvi = (args.Node as VETreeNode).VEObject as DocVersionInfo; - if ((args.Node as VETreeNode).VEObject is ProcedureInfo) - pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; - if (fi != null) - { - string msg = string.Empty; - // B2018-023: If exporting a procedure set, and someone else is in the database (but not this folder) - // don't stop the export (CheckOutType.Session was changed to CheckOutType.Folder). - bool ok = MySessionInfo.CanCheckOutItem(fi.FolderID, CheckOutType.Folder, ref msg); + { + FolderInfo fi = null; + DocVersionInfo dvi = null; + ProcedureInfo pi = null; + if ((args.Node as VETreeNode).VEObject is FolderInfo) + fi = (args.Node as VETreeNode).VEObject as FolderInfo; + if ((args.Node as VETreeNode).VEObject is DocVersionInfo) + dvi = (args.Node as VETreeNode).VEObject as DocVersionInfo; + if ((args.Node as VETreeNode).VEObject is ProcedureInfo) + pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; + if (fi != null) + { + string msg = string.Empty; + // B2018-023: If exporting a procedure set, and someone else is in the database (but not this folder) + // don't stop the export (CheckOutType.Session was changed to CheckOutType.Folder). + bool ok = MySessionInfo.CanCheckOutItem(fi.FolderID, CheckOutType.Folder, ref msg); //bool ok = MySessionInfo.CanCheckOutItem(fi.FolderID, (args.Index == 0)? CheckOutType.Folder : CheckOutType.Session, ref msg); - if (!ok) - { - if (args.Index == 0) - MessageBox.Show(this, msg, "Export Procedure Set Unavailable"); - else - MessageBox.Show(this, msg, "Import Procedure Set Unavailable"); - } - else - { - int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, CheckOutType.Session); + if (!ok) + { + if (args.Index == 0) + MessageBox.Show(this, msg, "Export Procedure Set Unavailable"); + else + MessageBox.Show(this, msg, "Import Procedure Set Unavailable"); + } + else + { + int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, CheckOutType.Session); //int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, (args.Index == 0) ? CheckOutType.Folder : CheckOutType.Session); - dlgExportImport dlg = new dlgExportImport(args.Index == 0 ? "Export" : "Import", fi, this, (E_UCFImportOptions)Properties.Settings.Default.UCFImportOpt);//Added frmVEPROMS Parameter - dlg.ShowDialog(this); - MySessionInfo.CheckInItem(ownerid); - if (args.Index == 1 && dlg.MyNewFolder != null) - tv.AddNewNode(dlg.MyNewFolder); - } - } - if (dvi != null) - { - string msg = string.Empty; - bool ok = MySessionInfo.CanCheckOutItem(dvi.VersionID, CheckOutType.DocVersion, ref msg); - if (!ok) - { - MessageBox.Show(this, msg, "Import Procedure Unavailable"); - } - else - { + dlgExportImport dlg = new dlgExportImport(args.Index == 0 ? "Export" : "Import", fi, this, (E_UCFImportOptions)Properties.Settings.Default.UCFImportOpt);//Added frmVEPROMS Parameter + dlg.ShowDialog(this); + MySessionInfo.CheckInItem(ownerid); + if (args.Index == 1 && dlg.MyNewFolder != null) + tv.AddNewNode(dlg.MyNewFolder); + } + } + if (dvi != null) + { + string msg = string.Empty; + bool ok = MySessionInfo.CanCheckOutItem(dvi.VersionID, CheckOutType.DocVersion, ref msg); + if (!ok) + { + MessageBox.Show(this, msg, "Import Procedure Unavailable"); + } + else + { dvi.RefreshDocVersionAssociations(); // Refresh Associations Count - //Only allow Import if the Referenced Object Database is set - if ( dvi.DocVersionAssociationCount == 0) + //Only allow Import if the Referenced Object Database is set + if (dvi.DocVersionAssociationCount == 0) { MessageBox.Show("Prior to Importing Procedures you must set the Referenced Object Database", "No RO Database set", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } - int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion); - dlgExportImport dlg = new dlgExportImport("Import", dvi, this, (E_UCFImportOptions)Properties.Settings.Default.UCFImportOpt);//Added frmVEPROMS Parameter + int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion); + dlgExportImport dlg = new dlgExportImport("Import", dvi, this, (E_UCFImportOptions)Properties.Settings.Default.UCFImportOpt);//Added frmVEPROMS Parameter dlg.MyNewProcedure = null; dlg.ExternalTransitionItem = null; - dlg.ShowDialog(this); - MySessionInfo.CheckInItem(ownerid); - if(dlg.MyNewProcedure != null) - tv.AddNewNode(dlg.MyNewProcedure); + dlg.ShowDialog(this); + MySessionInfo.CheckInItem(ownerid); + if (dlg.MyNewProcedure != null) + tv.AddNewNode(dlg.MyNewProcedure); if (dlg.ExternalTransitionItem != null) tc.OpenItem(dlg.ExternalTransitionItem); - } - } - if (pi != null) - { - string msg = string.Empty; - bool ok = MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref msg); - if (!ok) - { - MessageBox.Show(this, msg, "Export Procedure Unavailable"); - } - else - { - int ownerid = MySessionInfo.CheckOutItem(pi.ItemID, CheckOutType.Procedure); - dlgExportImport dlg = new dlgExportImport("Export", pi, this, (E_UCFImportOptions)0);//Added frmVEPROMS Parameter - dlg.ShowDialog(this); - MySessionInfo.CheckInItem(ownerid); - } - } - } + } + } + if (pi != null) + { + string msg = string.Empty; + bool ok = MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref msg); + if (!ok) + { + MessageBox.Show(this, msg, "Export Procedure Unavailable"); + } + else + { + int ownerid = MySessionInfo.CheckOutItem(pi.ItemID, CheckOutType.Procedure); + dlgExportImport dlg = new dlgExportImport("Export", pi, this, (E_UCFImportOptions)0);//Added frmVEPROMS Parameter + dlg.ShowDialog(this); + MySessionInfo.CheckInItem(ownerid); + } + } + } - private void MakeDatabaseChanges() + private void MakeDatabaseChanges() { // September 2012: Decided to store roimages as zipped. Any previous data may not have them zipped. // Check the top folders config to see, and if needed, zip them: @@ -700,11 +715,11 @@ namespace VEPROMS string fileName = Volian.Base.Library.VlnSettings.TemporaryFolder + "\\" + args.MyFilename; try { - FileStream fs = new FileStream(fileName, FileMode.Create); - fs.Write(buffer, 0, buffer.Length); - fs.Close(); - System.Diagnostics.Process.Start(fileName); - } + FileStream fs = new FileStream(fileName, FileMode.Create); + fs.Write(buffer, 0, buffer.Length); + fs.Close(); + System.Diagnostics.Process.Start(fileName); + } catch (Exception ex) { StringBuilder sb = new StringBuilder(); @@ -713,8 +728,8 @@ namespace VEPROMS sb.AppendLine(fileName + "."); sb.AppendLine(); sb.AppendLine("If it is open, close and retry."); - MessageBox.Show(sb.ToString(), "Error on CreatePdf",MessageBoxButtons.OK,MessageBoxIcon.Warning); -// MessageBox.Show("Could not create " + fileName + ". If it is open, close and retry.", "Error on CreatePdf"); + MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); + // MessageBox.Show("Could not create " + fileName + ". If it is open, close and retry.", "Error on CreatePdf"); } } @@ -757,7 +772,7 @@ namespace VEPROMS private bool DuplicateProcedureNumbers(DocVersionInfo dvi, ProcedureInfo pinfo) { dpl.Clear(); - dvi.ResetProcedures(); // B2021-035: Approve All – Pasted, modified number and deleted procedures not refreshed so missing from list + dvi.ResetProcedures(); // B2021-035: Approve All – Pasted, modified number and deleted procedures not refreshed so missing from list List pnList = new List(); foreach (ProcedureInfo pi in dvi.Procedures) { @@ -778,7 +793,7 @@ namespace VEPROMS { // C2020-036 Append to the list of duplicate procedure numbers // In this case we are approving All or Some procedures from tree view - if (!dpl.Contains(pi.DisplayNumber)) dpl.Add(pi.DisplayNumber); + if (!dpl.Contains(pi.DisplayNumber)) dpl.Add(pi.DisplayNumber); } } return dpl.Count > 0; @@ -792,8 +807,8 @@ namespace VEPROMS { // C2020-036 display list of duplicate procedure numbers FlexibleMessageBox.Show("This procedure set has two or more procedures with the same procedure number.\n\n" + - "Please make each procedure number unique before approving.\n\n"+ - "Below is a list of the dupicate procedure numbers:\n\n" +dupProcList, "Approve Some Procedures", MessageBoxButtons.OK, MessageBoxIcon.Warning); + "Please make each procedure number unique before approving.\n\n" + + "Below is a list of the dupicate procedure numbers:\n\n" + dupProcList, "Approve Some Procedures", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } tc.SaveCurrentEditItem(); @@ -822,7 +837,7 @@ namespace VEPROMS { // C2020-036 display list of duplicate procedure numbers FlexibleMessageBox.Show("This procedure set has two or more procedures with the same procedure number.\n\n" + - "Please make each procedure number unique before approving.\n\n"+ + "Please make each procedure number unique before approving.\n\n" + "Below is a list of the dupicate procedure numbers:\n\n" + dupProcList, "Approve All Procedures", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } @@ -835,7 +850,7 @@ namespace VEPROMS } int ownerid = MySessionInfo.CheckOutItem(dvi.VersionID, CheckOutType.DocVersion); dvi.DocVersionConfig.SelectedSlave = args.UnitIndex; - dlgApproveProcedure dlg = new dlgApproveProcedure(dvi,this);//Added frmVEPROMS Parameter + dlgApproveProcedure dlg = new dlgApproveProcedure(dvi, this);//Added frmVEPROMS Parameter dlg.MySessionInfo = MySessionInfo; dlg.ShowDialog(this); displayHistory.RefreshList(); @@ -863,7 +878,7 @@ namespace VEPROMS // B2021-036 Added a check if node is section when processing this first foreach loop. // The set the tree node to red text if the procedure or the section in the respected dictionary ProcedureInfo pi = (tn as VETreeNode).VEObject as ProcedureInfo; - SectionInfo si = (tn as VETreeNode).VEObject as SectionInfo; + SectionInfo si = (tn as VETreeNode).VEObject as SectionInfo; if ((pi != null && dicProcCheckedOut.ContainsKey(pi.ItemID)) || (si != null && !si.IsStepSection && dicDocCheckedOut.ContainsKey(si.MyContent.MyEntry.DocID))) tn.ForeColor = Color.Red; else @@ -893,7 +908,7 @@ namespace VEPROMS ProcedureInfo pi = null; SectionInfo si = null; pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; - if(pi == null) + if (pi == null) si = (args.Node as VETreeNode).VEObject as SectionInfo; UserInfo ui = UserInfo.GetByUserID(MySessionInfo.UserID); dlgCheckedOutProcedure cop = new dlgCheckedOutProcedure(pi, si, ui); @@ -906,10 +921,10 @@ namespace VEPROMS ProcedureInfo pi = (args.Node as VETreeNode).VEObject as ProcedureInfo; pi.MyDocVersion.DocVersionConfig.SelectedSlave = args.UnitIndex; if (pi == null) return; - // B2017-242 added check for duplicate procedure numbers in a procedure set + // B2017-242 added check for duplicate procedure numbers in a procedure set? if (DuplicateProcedureNumbers(pi.MyDocVersion, pi)) { - // C2020-036 display list of duplicate procedure numbers + // C2020-036 display list of duplicate procedure numbers FlexibleMessageBox.Show("Procedure number " + dupProcList + " is used by two or more procedures within this procedure set.\n\n" + "Please make each procedure number unique before approving.", "Approve Procedure", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; @@ -922,7 +937,7 @@ namespace VEPROMS return; } int ownerid = MySessionInfo.CheckOutItem(pi.ItemID, 0); - dlgApproveProcedure dlg = new dlgApproveProcedure(pi,this);//Added frmVEPROMS Parameter + dlgApproveProcedure dlg = new dlgApproveProcedure(pi, this);//Added frmVEPROMS Parameter dlg.MySessionInfo = MySessionInfo; dlg.ShowDialog(this); displayHistory.RefreshList(); @@ -949,7 +964,7 @@ namespace VEPROMS DlgPrintProcedure prnDlg = new DlgPrintProcedure(pi); prnDlg.MySessionInfo = MySessionInfo; prnDlg.SelectedSlave = args.UnitIndex; -// prnDlg.Show(this); // RHM 20120925 - Center dialog over PROMS window + // prnDlg.Show(this); // RHM 20120925 - Center dialog over PROMS window prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; } @@ -1017,7 +1032,7 @@ namespace VEPROMS DocVersionInfo myDV = veObj as DocVersionInfo; ; if (myFolder == null) doFolder = false; string message = string.Empty; - if (!MySessionInfo.CanCheckOutItem(doFolder?myFolder.FolderID:myDV.VersionID, doFolder?CheckOutType.Folder:CheckOutType.DocVersion, ref message)) + if (!MySessionInfo.CanCheckOutItem(doFolder ? myFolder.FolderID : myDV.VersionID, doFolder ? CheckOutType.Folder : CheckOutType.DocVersion, ref message)) { MessageBox.Show(this, message, "Item Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); return DialogResult.None; @@ -1044,23 +1059,27 @@ namespace VEPROMS { tmrTreeView.Enabled = true; } + private int _LastROFSTID = 0; + void frmVEPROMS_Activated(object sender, EventArgs e) { if (ActiveControl == tc) tc.HideCaret(); // refresh anything that pertains to external files or programs: - // if ro.fst was 'updated' from the roeditor, enable the update ro.fst values on - // the steptabribbon. + // if ro.fst was 'updated' from the roeditor, enable the update ro.fst values on the stepRibbon if (tc.ShuttingDown) return; + // B2017-202 update the RO tree in the step properties panel // B2017-205 - displayRO.MyROFST will be null if first thing opened is a Word section so added null check if (tc.MyBar.SelectedDockTab > -1 && displayRO.MyROFST != null) { DisplayTabItem myDTI = tc.MyBar.Items[tc.MyBar.SelectedDockTab] as DisplayTabItem; + if (myDTI.MyDSOTabPanel != null) { DSOTabPanel myDTP = myDTI.MyDSOTabPanel; + if (myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations == null) { SelectedROFst = null; // B2020-071 ROs are not associated with this procedure set. Set value to null so that PROMS does not try to generate the RO tree in Step Properties. @@ -1068,29 +1087,22 @@ namespace VEPROMS else { SelectedROFst = myDTP.MyDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; - if (_LastROFSTID != SelectedROFst.ROFstID) // B2017-240 Only refresh when the ROFSTID is different - { - _LastROFSTID = SelectedROFst.ROFstID; - displayRO.MyROFST = SelectedROFst; // need this to update RO Tree after UpdateRofst (B2015-226) - displayRO.MyROFSTLookup = SelectedROFst.GetROFSTLookup(SelectedDVI); - displayRO.RefreshRoTree(); - } } } else if (tc.MyEditItem != null && displayRO.MyROFST != null && tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].ROFstID != displayRO.MyROFST.ROFstID) { SelectedROFst = tc.MyEditItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; - if (_LastROFSTID != SelectedROFst.ROFstID)// B2017-240 Only refresh when the ROFSTID is different - { - _LastROFSTID = SelectedROFst.ROFstID; - displayRO.MyROFST = SelectedROFst; // need this to update RO Tree after UpdateRofst (B2015-226) - displayRO.MyROFSTLookup = SelectedROFst.GetROFSTLookup(SelectedDVI); - displayRO.RefreshRoTree(); - } } + + // need this to update RO Tree after UpdateRofst (B2015-226) + // B2022-026 RO Memory reduction coding (Jakes Merge) + displayRO.MyROFST = SelectedROFst; + displayRO.LoadTree(); } + if (SelectedStepTabPanel != null && SelectedStepTabPanel.MyStepTabRibbon != null) SelectedStepTabPanel.MyStepTabRibbon.SetUpdRoValBtn(SelectedStepTabPanel.MyStepTabRibbon.NewerRoFst()); + // C2015-022 needed when creating a separate window from a tree selection if (selectedChildWindow != null) { @@ -1098,12 +1110,14 @@ namespace VEPROMS selectedChildWindow = null; } } + // Add a tree node for a procedure if this is the first procedure in the docversion, added from // step editor (used for creating enhanced procedure in empty docversion) void MyStepTabRibbon_AddProcToDocVersionInTree(object sender, StepTabRibbonEventArgs args) { tv.AdjustTree(args.Proc as ProcedureInfo); } + void MyStepTabRibbon_PrintRequest(object sender, StepTabRibbonEventArgs args) { // Fix for B2013-173: @@ -1125,17 +1139,18 @@ namespace VEPROMS prnDlg.MySessionInfo = MySessionInfo; //end added by jcb 20130718 prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window - //added by jcb 20130718 to support create pdf button when multiunit and user selects a unit + //added by jcb 20130718 to support create pdf button when multiunit and user selects a unit pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; //end added by jcb 20130718 } + void displaySearch1_PrintRequest(object sender, DisplaySearchEventArgs args) { // C2020-002 paper size is now set in the format files - default is Letter, pass this PDFReport //C2019-013 pass in sorted by information Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.TypesSelected, args.MyItemInfoList, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\searchresults.pdf", args.PaperSize, args.SortedBy); - if (args.SearchString != null) + if (args.SearchString != null) myReport.SearchString = args.SearchString; if (!args.ReportTitle.Contains("Annotation")) { @@ -1159,7 +1174,7 @@ namespace VEPROMS // C2020-002 paper size is now set in the format files - default is Letter, pass this PDFReport if (args.TypesSelected == "RO Usage") { - Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.MyItemInfoList, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\ROUsageReport.pdf", args.SortUsageByProcedure,args.IncludeMissingROs, args.PaperSize); + Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, args.MyItemInfoList, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\ROUsageReport.pdf", args.SortUsageByProcedure, args.IncludeMissingROs, args.PaperSize); myReport.Build(); } else if (args.TypesSelected == "Complete RO Report") @@ -1171,20 +1186,20 @@ namespace VEPROMS { Volian.Print.Library.PDFReport myReport = new Volian.Print.Library.PDFReport(args.ReportTitle, Volian.Base.Library.VlnSettings.TemporaryFolder + @"\ROSummaryReport.pdf", args.RofstLookup, args.ROListForReport, args.PaperSize); myReport.Build(); - } } - bool tv_InsertItemInfo(object sender, vlnTreeItemInfoInsertEventArgs args) { // Don't select the newly created Step. This will be handled by tmrTreeView return tc.InsertRTBItem(args.MyItemInfo, args.StepText, args.InsertType, args.FromType, args.Type, false); } + private bool tv_DeleteItemInfo(object sender, vlnTreeItemInfoEventArgs args) { if (displayHistory.MyEditItem != null && displayHistory.MyItemInfo.MyProcedure.ItemID == args.MyItemInfo.ItemID) displayHistory.MyEditItem = null; + // bug fix B2016-005 - set MyCopyStep to null. This will take the paste options off of the tree node context menus. jsj 4-19-2016 // B2016-105 - added null reference check -jsj if (tc.MyCopyStep != null && args.MyItemInfo.ItemID == tc.MyCopyStep.ItemID) @@ -1192,20 +1207,24 @@ namespace VEPROMS tc.MyCopyStep = null; tc_CopyStepSelected(sender, null); // C2015-022 update copystep info in the child windows } + bool rtval = tc.DeleteRTBItem(args.MyItemInfo); + // Also disable the paste options on the ribbon if it is open. jsj 4-19-2016 if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyStepTabPanel != null) // MyStepTabPanel will be null if the active tab is a Word Attachment { StepPanel pnl = tc.SelectedDisplayTabItem.MyStepTabPanel.MyStepPanel; - if (pnl != null) - pnl.MyStepTabPanel.MyStepTabRibbon.SetPasteButtons(false); + if (pnl != null) pnl.MyStepTabPanel.MyStepTabRibbon.SetPasteButtons(false); } + return rtval; } + private bool tv_PasteItemInfo(object sender, vlnTreeItemInfoPasteEventArgs args) { return tc.PasteRTBItem(args.MyItemInfo, args.CopyStartID, args.PasteType, (int)args.Type); } + // C2020-033: Display the search panel with Incoming Transition info for the tree view // and for the editor. private ItemInfo tv_SearchIncTrans(object sender, vlnTreeItemInfoEventArgs args) @@ -1215,6 +1234,7 @@ namespace VEPROMS displaySearch1.UpdateSearchIncTransResults(); return args.MyItemInfo; } + private ItemInfo tc_SearchIncTrans(object sender, vlnTreeItemInfoEventArgs args) { displaySearch1.SearchIncTransII = args.MyItemInfo; @@ -1222,9 +1242,11 @@ namespace VEPROMS displaySearch1.UpdateSearchIncTransResults(); return args.MyItemInfo; } + private bool _RemoveFromPROMSWindowForms = true; public bool ClosingWithError = false; // B2019-098: prevent looping between error & exit dialog - private bool _WeAreExitingPROMS = false; // B2019-101 if exiting PROMS from main window don't prompt on each child window (separate windows) + private bool _WeAreExitingPROMS = false; // B2019-101 if exiting PROMS from main window don't prompt on each child window (separate windows) + private void frmVEPROMS_FormClosing(object sender, FormClosingEventArgs e) { // B2017-212 If the user uses the X button in Word to close the word attachment, PROMS thinks that the user wants to close out of PROMS as well @@ -1235,14 +1257,15 @@ namespace VEPROMS if (!_WeAreExitingPROMS && !ClosingWithError && tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0) { DlgCloseTabsOrExit dctoe = new DlgCloseTabsOrExit(MyParent == null, PROMSWindowForms.Count > 0); // B2019-071 dialog to ask user if we are to close one tab or exit - dctoe.ShowDialog(); - _WeAreExitingPROMS = MyParent == null && dctoe.ExitPROMS; // B2019-101 flag that we are exiting from PROMS main window (separate windows) - if (dctoe.Cancel) // B2019-071 user decided to not close any tab and not exit PROMS - so do nothing and continue working - { - e.Cancel = true; - dctoe.Close(); - return; - } + dctoe.ShowDialog(); + _WeAreExitingPROMS = MyParent == null && dctoe.ExitPROMS; // B2019-101 flag that we are exiting from PROMS main window (separate windows) + if (dctoe.Cancel) // B2019-071 user decided to not close any tab and not exit PROMS - so do nothing and continue working + { + e.Cancel = true; + dctoe.Close(); + return; + } + string stk = Volian.Base.Library.vlnStackTrace.StackToString(); if (!stk.Contains("Exception")) { @@ -1257,7 +1280,7 @@ namespace VEPROMS n = 0; e.Cancel = true; dctoe.Close(); - return; + return; } } if (tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0 && dctoe.ExitPROMS) @@ -1271,19 +1294,22 @@ namespace VEPROMS } //C2015-022 Separate Windows - if child windows are open and we are closing the main PROMS window, give user a chance to not close PROMS and that child windows // B2019-101 if we are exiting from PROMS main window no need to prompt user about child windows. - if (MyParent == null && PROMSWindowForms.Count > 0 && !_WeAreExitingPROMS) + if (MyParent == null && PROMSWindowForms.Count > 0 && !_WeAreExitingPROMS)? { - DialogResult dr = MessageBox.Show("Close all of the child windows and exit PROMS?", "Exit PROMS", MessageBoxButtons.YesNo); + DialogResult dr = MessageBox.Show("Close all of the child windows and exit PROMS?", "Exit PROMS", MessageBoxButtons.YesNo);? if (dr == System.Windows.Forms.DialogResult.No) { e.Cancel = true; return; } } - tc.ShuttingDown = true; // This keeps PROMS from Hanging under certain circumstances + + tc.ShuttingDown = true; // This keeps PROMS from Hanging under certain circumstances + // B2019-161 When shutting down output the timing information (to the error log) if (VolianTimer.TimingsOn) VolianTimer.ShowTimers(); + foreach (DisplayTabItem dti in tc.MyBar.Items) { if (dti.MyDSOTabPanel != null) @@ -1291,6 +1317,7 @@ namespace VEPROMS else MySessionInfo.CheckInItem(dti.OwnerID); //C2015-022 Separate Windows closing child form only left procedure ownership active } + //_MyLog.WarnFormat("frmVEPROMS_FormClosing"); if (MyParent == null) { @@ -1299,6 +1326,7 @@ namespace VEPROMS MyActivityTimer.Dispose(); _MyLog.Debug("VEPROMS FormClosing - dispose timer"); } + // part of separate windows upgrade C2015-022 // close all of the child windows before closing the main PROMS window if (PROMSWindowForms != null && PROMSWindowForms.Count > 0) @@ -1313,28 +1341,35 @@ namespace VEPROMS child.MySessionInfo.EndSession(); } } + if (MySessionInfo != null) MySessionInfo.EndSession(); + // Save the location and size of the VE-PROMS appication for this user if (this.WindowState == FormWindowState.Normal) { Settings.Default.Location = this.Location; Settings.Default.Size = this.Size; } + if (this.MyVersionWindowList != null) Settings.Default.VersionWindows = this.MyVersionWindowList.ToSettings(); + Settings.Default.WindowState = this.WindowState; Settings.Default.QATItems = ribbonControl1.QatLayout; SaveMRU(); + //Settings.Default.Save(); Volian.Base.Library.DebugPagination.Close(); Volian.Base.Library.DebugText.Close(); Volian.Base.Library.BaselineMetaFile.Close(); // C2018-004 create meta file for baseline compares } } + void frmVEPROMS_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e) { // Close any open documents tc.Dispose(); + // RHM 20121010 // Something was causing the process to remain in memory for an extended period of time // after printing procedures. The following lines kills the process immediately. @@ -1350,10 +1385,11 @@ namespace VEPROMS } } } - // Get the "Procedures" Panel Heading (title). - // by default the heading is "Procedures" (handled in the getting from the config) - // the heading is stored in the "title" field of the folder config. - // we currently only use the "title" field for the top (VEPROMS) tree node. + + // Get the "Procedures" Panel Heading (title). + // by default the heading is "Procedures" (handled in the getting from the config) + // the heading is stored in the "title" field of the folder config. + // we currently only use the "title" field for the top (VEPROMS) tree node. private string getProcedurePanelHeading() { VETreeNode jj_vetn = (VETreeNode)tv.Nodes[0]; // the VEPROMS tree node @@ -1362,6 +1398,7 @@ namespace VEPROMS else return jj_vetn.Text; // C2018-029 return the child window's procedure set name } + private int getTimeout() { VETreeNode jj_vetn = (VETreeNode)tv.Nodes[0]; // the VEPROMS tree node @@ -1369,14 +1406,14 @@ namespace VEPROMS int result = 30; if (!int.TryParse(s, out result)) result = 30; - return result; + return result; } private Timer _RefreshTimer; public Timer RefreshTimer { - get + get { if (_RefreshTimer == null) { @@ -1385,7 +1422,7 @@ namespace VEPROMS _RefreshTimer.Enabled = true; _RefreshTimer.Tick += _RefreshTimer_Tick; } - return _RefreshTimer; + return _RefreshTimer; } } private bool _RefreshTimerActive = false; @@ -1399,6 +1436,8 @@ namespace VEPROMS void _RefreshTimer_Tick(object sender, EventArgs e) { //_MyLog.DebugFormat("_RefreshTimer_Tick {0}", RefreshTimerActive); + + if (RefreshTimerActive) { _TimeActivity.Open(); @@ -1407,6 +1446,7 @@ namespace VEPROMS RefreshChanged(this); _TimeActivity.Close(); } + } private void btnStepRTF_Click(object sender, System.EventArgs e) @@ -1416,32 +1456,21 @@ namespace VEPROMS { PingSession(null); StartRefreshChanged(null); - //RefreshChanged(null); - //if (tc.MyStepRTB != null) - //{ - // StepConfig sc = new StepConfig(tc.MyStepRTB.MyItemInfo.MyContent.Config); - // if (sc.Step_SourceToBackground != null) - // OpenMyItem(sc.Step_SourceToBackground); - // if(sc.Step_BackgroundToSource != null) - // OpenMyItem(sc.Step_BackgroundToSource); - - //frmStepRTF frm = new frmStepRTF(); - //frm.MyStepRTB = tc.MyStepRTB; - //frm.Show(); - //} } } private SessionInfo _MySessionInfo; public SessionInfo MySessionInfo { - get { + get + { if (_MySessionInfo == null && MyParent != null)// B2017-152 Don't crash if MySessionInfo is null _MySessionInfo = MyParent.MySessionInfo; - return _MySessionInfo; + return _MySessionInfo; } set { _MySessionInfo = value; } } + private System.Threading.Timer MyActivityTimer; //private System.Threading.Timer MyRefreshTimer; private DevComponents.DotNetBar.ButtonItem btnManageSecurity; @@ -1449,24 +1478,27 @@ namespace VEPROMS private DevComponents.DotNetBar.ButtonItem btnAdministrativeTools; private DevComponents.DotNetBar.ButtonItem btnSecurity; private DevComponents.DotNetBar.ButtonItem btnFormats; - private DevComponents.DotNetBar.ButtonItem btnUserControlOfFormats; - private DevComponents.DotNetBar.ButtonItem btnUserControlOfFormatsExport; - private DevComponents.DotNetBar.ButtonItem btnUserControlOfFormatsImport; + private DevComponents.DotNetBar.ButtonItem btnUserControlOfFormats; + private DevComponents.DotNetBar.ButtonItem btnUserControlOfFormatsExport; + private DevComponents.DotNetBar.ButtonItem btnUserControlOfFormatsImport; private TabItemsToClose _MyCloseTabList = new TabItemsToClose(); + public TabItemsToClose MyCloseTabList { get { return _MyCloseTabList; } } + private bool _DisablePing = false; public bool DisablePing { get { return _DisablePing; } - set + set { _DisablePing = value; //_MyLog.WarnFormat("DisableSessionPing = {0}", value); } } + private void PingSession(Object obj) { MySemaphore.WaitOne(); @@ -1485,11 +1517,12 @@ namespace VEPROMS } MySemaphore.Release(); } + WindowsFormsSynchronizationContext mUIContext = new WindowsFormsSynchronizationContext(); public void MyFindNodeAndExpand(object obj) { if (tv == null || tv.SelectedNode == null) return; - IVEDrillDownReadOnly veObj1 = ((tv.SelectedNode as VETreeNode).VEObject as IVEDrillDownReadOnly); + IVEDrillDownReadOnly veObj1 = ((tv.SelectedNode as VETreeNode).VEObject as IVEDrillDownReadOnly); int id = (int)obj; ItemInfo ii = ItemInfo.Get(id); ii.ResetParts(); @@ -1509,6 +1542,7 @@ namespace VEPROMS } MySemaphore.Release(); // ping session control } + private void StartRefreshChanged(Object obj) { //_MyLog.Debug("StartRefreshChanged"); @@ -1517,6 +1551,7 @@ namespace VEPROMS RefreshTimerActive = !PauseRefresh; MySemaphore.Release(); } + private void RefreshChanged(Object obj) { //if (SkipRefresh) return; @@ -1536,8 +1571,10 @@ namespace VEPROMS MyFindNodeAndExpand(id); } } + // B2017-247 Error Handler for Ping Session if (MySessionInfo.ChangedContents != null && MySessionInfo.ChangedContents.Count > 0) + { foreach (int id in MySessionInfo.ChangedContents.Keys) { if (ContentInfo.IsInCache(id)) @@ -1554,20 +1591,23 @@ namespace VEPROMS } lastChanged = MySessionInfo.ChangedContents[id]; } + } + MySessionInfo.ChangedItems.Clear(); MySessionInfo.ChangedContents.Clear(); + if (lastChanged > 0) { MySessionInfo.LastContentChange = lastChanged; RefreshLastChange(); } } - catch - { - } + catch { } + //MySemaphore.Release(); //_MyLog.DebugFormat("{0},{1:X},{2:X},{3:X}", DateTime.Now.ToLongTimeString(), lastChanged, MySessionInfo.LastContentChange, MySessionInfo.LastChangedInt64); } + private int TotalCount(TreeNodeCollection tns) { int total = tns.Count; @@ -1575,6 +1615,7 @@ namespace VEPROMS total += TotalCount(tn.Nodes); return total; } + private bool ByteArrayIsEmpty(byte[] myArray) { for (int i = 0; i < myArray.Length; i++) @@ -1594,6 +1635,7 @@ namespace VEPROMS public Timer tmrCloseTabItems; public System.Threading.Semaphore MySemaphore = new System.Threading.Semaphore(1, 1); private bool _frmVEPROMSloading = false; + private void frmVEPROMS_Load(object sender, EventArgs e) { // B2019-116 Use Volian.Base.Library.VlnItextFont @@ -1606,16 +1648,16 @@ namespace VEPROMS btnFormats = new ButtonItem("btnFormats", "Formats"); btnAdmin.SubItems.Add(btnSecurity); btnAdmin.SubItems.Add(btnFormats); - btnUserControlOfFormats = new ButtonItem("btnUserControlOfFormats", "User Control of Formats"); + btnUserControlOfFormats = new ButtonItem("btnUserControlOfFormats", "User Control of Formats"); btnFormats.SubItems.Add(btnUpdateFormats); btnFormats.SubItems.Add(btnUserControlOfFormats); - btnUserControlOfFormats.Click += new EventHandler(btnUserControlOfFormats_Click); - btnUserControlOfFormatsExport = new ButtonItem("btnUserControlOfFormatsExport", "Export User Control of Formats"); + btnUserControlOfFormats.Click += new EventHandler(btnUserControlOfFormats_Click); + btnUserControlOfFormatsExport = new ButtonItem("btnUserControlOfFormatsExport", "Export User Control of Formats"); btnFormats.SubItems.Add(btnUserControlOfFormatsExport); - btnUserControlOfFormatsExport.Click += new EventHandler(btnUserControlOfFormatsExport_Click); - btnUserControlOfFormatsImport = new ButtonItem("btnUserControlOfFormatsImport", "Import User Control of Formats"); + btnUserControlOfFormatsExport.Click += new EventHandler(btnUserControlOfFormatsExport_Click); + btnUserControlOfFormatsImport = new ButtonItem("btnUserControlOfFormatsImport", "Import User Control of Formats"); btnFormats.SubItems.Add(btnUserControlOfFormatsImport); - btnUserControlOfFormatsImport.Click += new EventHandler(btnUserControlOfFormatsImport_Click); + btnUserControlOfFormatsImport.Click += new EventHandler(btnUserControlOfFormatsImport_Click); btnManageSecurity = new ButtonItem("btnManageSecurity", "Manage Security"); btnSecurity.SubItems.Add(btnManageSecurity); btnManageSecurity.Click += new EventHandler(btnManageSecurity_Click); @@ -1633,11 +1675,11 @@ namespace VEPROMS this.superTooltip1.SetSuperTooltip(btnPrint, new SuperTooltipInfo("Create PDF", null, null, null, null, eTooltipColor.Gray)); this.superTooltip1.SetSuperTooltip(btnExit, new SuperTooltipInfo("Exit", null, null, null, null, eTooltipColor.Gray)); this.superTooltip1.SetSuperTooltip(btnOptions, new SuperTooltipInfo("Options", null, null, null, null, eTooltipColor.Gray)); - this.superTooltip1.SetSuperTooltip(btnManageSecurity, new SuperTooltipInfo("Manage Security", null, null, null, null, eTooltipColor.Gray)); - this.superTooltip1.SetSuperTooltip(btnUserControlOfFormats, new SuperTooltipInfo("User Control Of Formats", null, null, null, null, eTooltipColor.Gray)); - this.superTooltip1.SetSuperTooltip(btnResetSecurity, new SuperTooltipInfo("Reset Security",null, null, null, null, eTooltipColor.Gray)); - this.superTooltip1.SetSuperTooltip(btnAdministrativeTools, new SuperTooltipInfo("Administrative Tools",null, null, null, null, eTooltipColor.Gray)); - this.superTooltip1.SetSuperTooltip(btnUpdateFormats, new SuperTooltipInfo("Update Formats",null, null, null, null, eTooltipColor.Gray)); + this.superTooltip1.SetSuperTooltip(btnManageSecurity, new SuperTooltipInfo("Manage Security", null, null, null, null, eTooltipColor.Gray)); + this.superTooltip1.SetSuperTooltip(btnUserControlOfFormats, new SuperTooltipInfo("User Control Of Formats", null, null, null, null, eTooltipColor.Gray)); + this.superTooltip1.SetSuperTooltip(btnResetSecurity, new SuperTooltipInfo("Reset Security", null, null, null, null, eTooltipColor.Gray)); + this.superTooltip1.SetSuperTooltip(btnAdministrativeTools, new SuperTooltipInfo("Administrative Tools", null, null, null, null, eTooltipColor.Gray)); + this.superTooltip1.SetSuperTooltip(btnUpdateFormats, new SuperTooltipInfo("Update Formats", null, null, null, null, eTooltipColor.Gray)); //end batch refresh transitions try { @@ -1668,9 +1710,9 @@ namespace VEPROMS StepRTB.MyUserInfo = MyUserInfo; // set the user's security information in the StepRTB VlnFlexGrid.MyUserInfo = MyUserInfo; // set the user's security information in the VlnFlexGrid bool isVisible = MyUserInfo.IsAdministrator(); - btnUserControlOfFormats.Visible = isVisible; - btnUserControlOfFormatsExport.Visible = isVisible; - btnUserControlOfFormatsImport.Visible = isVisible; + btnUserControlOfFormats.Visible = isVisible; + btnUserControlOfFormatsExport.Visible = isVisible; + btnUserControlOfFormatsImport.Visible = isVisible; btnManageSecurity.Visible = isVisible; btnUpdateFormats.Visible = isVisible; btnResetSecurity.Visible = isVisible; @@ -1704,12 +1746,12 @@ namespace VEPROMS //System.Diagnostics.Process xyzzy = System.Diagnostics.Process.GetCurrentProcess(); if (!System.Diagnostics.Debugger.IsAttached)// running in Production Mode (Not in the debugger) { - System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(this.PingSession); - if (this._MyParent == null) MyActivityTimer = new System.Threading.Timer(timerDelegate, autoEvent, 10000, 10000); - // System.Threading.Thread.Sleep(5000); - // System.Threading.TimerCallback timerRefresh = new System.Threading.TimerCallback(this.StartRefreshChanged); - // RefreshTimer.Enabled = true; - // MyRefreshTimer = new System.Threading.Timer(timerRefresh, autoEvent, 10000, 10000); + System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(this.PingSession); + if (this._MyParent == null) MyActivityTimer = new System.Threading.Timer(timerDelegate, autoEvent, 10000, 10000); + // System.Threading.Thread.Sleep(5000); + // System.Threading.TimerCallback timerRefresh = new System.Threading.TimerCallback(this.StartRefreshChanged); + // RefreshTimer.Enabled = true; + // MyRefreshTimer = new System.Threading.Timer(timerRefresh, autoEvent, 10000, 10000); } //string debugMode = ConfigurationManager.AppSettings["Debug"]; @@ -1766,14 +1808,14 @@ namespace VEPROMS ctrlAnnotationDetails.SetupAnnotations(displaySearch1); tc.MyAnnotationDetails = ctrlAnnotationDetails; SetupButtons(); - displayBookMarks.MyDisplayTabControl = tc; // allows bookmark selection to bring up steps/docs + displayBookMarks.MyDisplayTabControl = tc; // allows bookmark selection to bring up steps/docs office2007StartButton1.MouseDown += new MouseEventHandler(office2007StartButton1_MouseDown); //displayRO.EnabledChanged += new EventHandler(displayRO_EnabledChanged); tc.Enter += new EventHandler(tc_Enter); tc.Leave += new EventHandler(tc_Leave); tc.StatusChanged += new DisplayTabControlStatusEvent(tc_StatusChanged); tc.ToggleRibbonExpanded += new DisplayTabControlEvent(tc_ToggleRibbonExpanded); - tc.OpenInSeparateWindow += tc_OpenInSeparateWindow; + tc.OpenInSeparateWindow += tc_OpenInSeparateWindow; tc.RefreshEnhancedDocument += tc_RefreshEnhancedDocument; tc.CopyStepSelected += tc_CopyStepSelected; // will extend CopyStep info to all child windows (separate windows upgrade) this.Deactivate += new EventHandler(frmVEPROMS_Deactivate); @@ -1813,6 +1855,7 @@ namespace VEPROMS if (this.txtSearch.Text.Length > 0 && !this.txtSearch.Text.Contains("\r\n")) CurrentID = txtSearch.Text; } + } void tc_RefreshEnhancedDocument(object sender, ItemSelectedChangedEventArgs args) { @@ -1855,7 +1898,7 @@ namespace VEPROMS { SessionInfoList sil = SessionInfoList.Get(); int i = 0; - foreach(SessionInfo si in sil) + foreach (SessionInfo si in sil) { if (si.DTSEnd == null && si.MachineName == Environment.MachineName && si.UserID == Volian.Base.Library.VlnSettings.UserID) { @@ -1874,21 +1917,15 @@ namespace VEPROMS if (i == 0)// Turn-on Change Manger if there are no active Sessions TurnChangeManagerOn.Execute(); } - //public bool IsEnhancedDocumentOpen(ItemInfo ii) - //{ - // if (tc.dicEnhancedDocuments.ContainsKey(ii.MyProcedure)) - // return true; - // return false; - //} - - // C2015-022 Separate Windows. This is a dictionary of child PROMS windows forms (frmVEPROMS) - // - Dictionary _PROMSWindowForms=null; + + // C2015-022 Separate Windows. This is a dictionary of child PROMS windows forms (frmVEPROMS) + // + Dictionary _PROMSWindowForms = null; public Dictionary PROMSWindowForms { get { - if(_PROMSWindowForms == null) + if (_PROMSWindowForms == null) { if (_MyParent == null) _PROMSWindowForms = new Dictionary(); @@ -1900,54 +1937,54 @@ namespace VEPROMS set { _PROMSWindowForms = value; } } // This gets called when user opens an enhanced document (ex Background) from the source (ex EOP) - // C2015-022 - This also get called if opening a procedure in a child (separate) window - void tc_OpenInSeparateWindow(object sender, ItemSelectedChangedEventArgs args) - { - int versionID = args.MyItemInfo.MyDocVersion.VersionID; - if (MyParent != null && args.MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments.Count > 0 - && !args.MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments.HasSourcePointer) - { - MyParent.OpenItem(args.MyItemInfo); - return; - } - frmVEPROMS child = null; - if (PROMSWindowForms.ContainsKey(versionID)) - child = PROMSWindowForms[versionID]; // use existing child window - else - { - child = CreateChildPromsWindow(args.MyItemInfo.MyDocVersion); // create a new child window for the enhanced document procedure set - tv.AdjustTree(args.MyItemInfo); // find the position in the tree - VETreeNode _tn = tv.SelectedNode as VETreeNode; // get the tree node for args.MyItemInfo - while (!(_tn.VEObject is FolderInfo)) _tn = (VETreeNode)_tn.Parent; // back up to the first folder tree node - _tn.Nodes.Clear(); // remove the child nodes from main window - child window now has this part of the procedure tree - _tn.ChildrenLoaded = false; - _tn.MovedToSeparateWindow = true; // flag used to reload children nodes if the child window is closed and user clicks on the tree node in the main window - } + // C2015-022 - This also get called if opening a procedure in a child (separate) window + void tc_OpenInSeparateWindow(object sender, ItemSelectedChangedEventArgs args) + { + int versionID = args.MyItemInfo.MyDocVersion.VersionID; + if (MyParent != null && args.MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments.Count > 0 + && !args.MyItemInfo.MyDocVersion.DocVersionConfig.MyEnhancedDocuments.HasSourcePointer) + { + MyParent.OpenItem(args.MyItemInfo); + return; + } + frmVEPROMS child = null; + if (PROMSWindowForms.ContainsKey(versionID)) + child = PROMSWindowForms[versionID]; // use existing child window + else + { + child = CreateChildPromsWindow(args.MyItemInfo.MyDocVersion); // create a new child window for the enhanced document procedure set + tv.AdjustTree(args.MyItemInfo); // find the position in the tree + VETreeNode _tn = tv.SelectedNode as VETreeNode; // get the tree node for args.MyItemInfo + while (!(_tn.VEObject is FolderInfo)) _tn = (VETreeNode)_tn.Parent; // back up to the first folder tree node + _tn.Nodes.Clear(); // remove the child nodes from main window - child window now has this part of the procedure tree + _tn.ChildrenLoaded = false; + _tn.MovedToSeparateWindow = true; // flag used to reload children nodes if the child window is closed and user clicks on the tree node in the main window + } - child.OpenItem(args.MyItemInfo); // this opens to the enhanced document step and expands the tree to the related node (in the child window) - } - private frmVEPROMS CreateChildPromsWindow(DocVersionInfo dvi) // C2015-022 logic to create separate (child) windows for a procedure set + child.OpenItem(args.MyItemInfo); // this opens to the enhanced document step and expands the tree to the related node (in the child window) + } + private frmVEPROMS CreateChildPromsWindow(DocVersionInfo dvi) // C2015-022 logic to create separate (child) windows for a procedure set { frmVEPROMS child; - // create a new window for this doc version (procedure set) - child = new frmVEPROMS(this, dvi); - PROMSWindowForms.Add(dvi.VersionID, child); // keep track of child windows - child.Visible = false; - child.Show(); - if (MyVersionWindowList != null && MyVersionWindowList.Count > 0) - foreach (VersionWindow vw in MyVersionWindowList) - if (vw.VersionID == dvi.VersionID) - { - child.SetDesktopBounds(vw.MyRectangle.Left, vw.MyRectangle.Top, vw.MyRectangle.Width, vw.MyRectangle.Height); - break; - } - child.office2007StartButton1.Visible = false; // hide V button - child.qatCustomizeItem1.Visible = false; // hide quick access list - child.btnExit.Visible = false; // hide the exit button (closes all of PROMS not just the child window) - child.Visible = true; - child.Move += child_MoveOrSize; - child.Resize += child_MoveOrSize; - child.FormClosed += child_FormClosed; + // create a new window for this doc version (procedure set) + child = new frmVEPROMS(this, dvi); + PROMSWindowForms.Add(dvi.VersionID, child); // keep track of child windows + child.Visible = false; + child.Show(); + if (MyVersionWindowList != null && MyVersionWindowList.Count > 0) + foreach (VersionWindow vw in MyVersionWindowList) + if (vw.VersionID == dvi.VersionID) + { + child.SetDesktopBounds(vw.MyRectangle.Left, vw.MyRectangle.Top, vw.MyRectangle.Width, vw.MyRectangle.Height); + break; + } + child.office2007StartButton1.Visible = false; // hide V button + child.qatCustomizeItem1.Visible = false; // hide quick access list + child.btnExit.Visible = false; // hide the exit button (closes all of PROMS not just the child window) + child.Visible = true; + child.Move += child_MoveOrSize; + child.Resize += child_MoveOrSize; + child.FormClosed += child_FormClosed; // these next three lines of code will force the child window to display on top of all other windows on the screen child.TopMost = true; // force child window to the display on top of all others Application.DoEvents(); @@ -1962,11 +1999,11 @@ namespace VEPROMS } void child_MoveOrSize(object sender, EventArgs e) { - frmVEPROMS frm = sender as frmVEPROMS; - RectangleConverter rc = new RectangleConverter(); - string str = string.Format("{0}~{1}", frm.MyDocVersion.VersionID, rc.ConvertToString(frm.DesktopBounds)); - MyVersionWindowList.Add(new VersionWindow(str)); - + frmVEPROMS frm = sender as frmVEPROMS; + RectangleConverter rc = new RectangleConverter(); + string str = string.Format("{0}~{1}", frm.MyDocVersion.VersionID, rc.ConvertToString(frm.DesktopBounds)); + MyVersionWindowList.Add(new VersionWindow(str)); + } private bool HasSetAdministrator(UserInfo ui) { @@ -1977,17 +2014,17 @@ namespace VEPROMS return false; } - // RHM20150507 Table Scrunch + // RHM20150507 Table Scrunch // B2018-033 VCS SAG-6 Steps 3 and 9 and SACRG1 Step 13 // Set default Scrunching flags private TableScrunching _DefaultScrunchingRules = TableScrunching.AllPhases; void btnPrint1_Click(object sender, EventArgs e) { string[] ids = txtSearch.Text.Split("\r\n ".ToCharArray()); - Dictionary dicProcs= new Dictionary(); + Dictionary dicProcs = new Dictionary(); foreach (string id in ids) { - if(id != "") + if (id != "") { ItemInfo ii = GetItemInfoFromString(id); if (ii != null && !dicProcs.ContainsKey(ii.MyProcedure.ItemID))// B2018-087 - Don't fail if it doesn't exist @@ -1996,13 +2033,13 @@ namespace VEPROMS } DialogResult dr = System.Windows.Forms.DialogResult.Yes; //dr = MessageBox.Show("Do you want all of the PDFs to be opened?", "Open After Create", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - // RHM20150507 Table Scrunch + // RHM20150507 Table Scrunch Rtf2Pdf.AllowTableScrunching = cbScrunch.Checked ? _DefaultScrunchingRules : TableScrunching.None; foreach (int key in dicProcs.Keys) { ProcedureInfo proc = dicProcs[key]; //Console.WriteLine("{0}", proc.ShortPath); - DlgPrintProcedure prnDlg = new DlgPrintProcedure(proc,true);//dvi.DocVersionConfig,pnum); + DlgPrintProcedure prnDlg = new DlgPrintProcedure(proc, true);//dvi.DocVersionConfig,pnum); prnDlg.MySessionInfo = MySessionInfo; //prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window prnDlg.Prefix = proc.MyDocVersion.VersionID.ToString() + "_"; @@ -2052,6 +2089,7 @@ namespace VEPROMS OpenMyItem(value); } } + private string FindNextLine() { if (txtSearch.SelectionLength > 0) @@ -2065,6 +2103,7 @@ namespace VEPROMS } return null; } + private string FindPreviousLine() { if (txtSearch.SelectionLength > 0) @@ -2082,6 +2121,7 @@ namespace VEPROMS txtSearch.ScrollToCaret(); return GetCurrentLine(); } + void txtSearch_KeyUp(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.V) @@ -2093,7 +2133,7 @@ namespace VEPROMS txtSearch.SelectionLength = 0; txtSearch.SelectionStart = 0; txtSearch.ScrollToCaret(); - CurrentID= GetCurrentLine(); + CurrentID = GetCurrentLine(); e.Handled = true; } if (e.Control && e.KeyCode == Keys.A) @@ -2103,6 +2143,7 @@ namespace VEPROMS e.Handled = true; } } + private string GetCurrentLine() { while (txtSearch.SelectionStart > 0 && txtSearch.Text[txtSearch.SelectionStart - 1] != '\n') @@ -2111,6 +2152,7 @@ namespace VEPROMS if (sub.Contains("\r\n")) return sub.Substring(0, sub.IndexOf("\r\n")); return sub; } + void txtSearch_KeyPress(object sender, KeyPressEventArgs e) // used when running in debug mode, for text box where you enter an ItemID or ContextID number { if (e.KeyChar == '\r') @@ -2136,17 +2178,17 @@ namespace VEPROMS if (ii != null) { DisplayTabItem dti = tc.OpenItem(ii);// B2018-035 Allow procedure to be printed and property grid to be opened - // B2019-003: was crashing if another user was in same procedure (dti would have been null because procedure could not be opened): - if (dti == null) return; + // B2019-003: was crashing if another user was in same procedure (dti would have been null because procedure could not be opened): + if (dti == null) return;? SelectedStepTabPanel = dti.MyStepTabPanel; tc.SelectedDisplayTabItem = dti; dti.SelectedItemInfo = ii; tv.AdjustTree(ii); - lblItemID.Text = string.Format("ItemID = {0}",ii.ItemID); + lblItemID.Text = string.Format("ItemID = {0}", ii.ItemID); } else - MessageBox.Show(string.Format("Looking for: {0}",str),"No item found"); + MessageBox.Show(string.Format("Looking for: {0}", str), "No item found"); } private static ItemInfo GetItemInfoFromString(string str) // RHM20150506 Multiline ItemID TextBox @@ -2177,6 +2219,8 @@ namespace VEPROMS } private static VolianTimer _TimeActivity1 = new VolianTimer("frmVEPROMS.cs tmrCloseTabItems_Tick", 2108); + private static VolianTimer _TimeActivity1 = new VolianTimer("frmVEPROMS.cs tmrCloseTabItems_Tick", 2108); + void tmrCloseTabItems_Tick(object sender, EventArgs e) { _TimeActivity1.Open(); @@ -2255,43 +2299,45 @@ namespace VEPROMS } } lblUser.Text = VlnSettings.UserID; - lblUser.MouseDown += new MouseEventHandler(lblUser_MouseDown); + lblUser.MouseDown += new MouseEventHandler(lblUser_MouseDown); } - private string GetSecurityKey() - { - Random rnd = new Random(DateTime.Now.Year + DateTime.Now.DayOfYear * 1000); - return rnd.Next(10000).ToString(); - } - void lblUser_MouseDown(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Right) - { - /* -- Devin- Volian0 -- Diane- Volian0 -- Jess- Volian0 -- John- Volian0 -- Kathy- Volian0 -- Jim- JCB2-HP -- Rich- WINDOWS7-RHM -- Rich - RICH-WINDOWS10 -- Paul- Paul-PC -- Michelle- Michelle-PC -- Harrys Mac- WIN-04QLPEH7JKH -- Harrys PC- Harry-7100 -- Caitlin- Caitlin-PC - */ - if ("|VLN|RICH-WINDOWS10|WINDOWS7-RHM|PAUL-PC|MICHELLE-PC|WIN-O4QLPEH7JKH|HARRY-7100|CAITLIN-PC|".Contains("|" + Environment.UserDomainName.ToUpper() /*Environment.GetEnvironmentVariable("USERDOMAIN").ToUpper()*/ + "|")) - { - Random rnd = new Random(DateTime.Now.Year + DateTime.Now.DayOfYear * 1000); - MessageBox.Show(this, GetSecurityKey(), "Today's Security Key"); - } + + private string GetSecurityKey() + { + Random rnd = new Random(DateTime.Now.Year + DateTime.Now.DayOfYear * 1000); + return rnd.Next(10000).ToString(); + } + + void lblUser_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + /* + - Devin- Volian0 + - Diane- Volian0 + - Jess- Volian0 + - John- Volian0 + - Kathy- Volian0 + - Jim- JCB2-HP + - Rich- WINDOWS7-RHM + - Rich - RICH-WINDOWS10 + - Paul- Paul-PC + - Michelle- Michelle-PC + - Harrys Mac- WIN-04QLPEH7JKH + - Harrys PC- Harry-7100 + - Caitlin- Caitlin-PC + */ + if ("|VLN|RICH-WINDOWS10|WINDOWS7-RHM|PAUL-PC|MICHELLE-PC|WIN-O4QLPEH7JKH|HARRY-7100|CAITLIN-PC|".Contains("|" + Environment.UserDomainName.ToUpper() /*Environment.GetEnvironmentVariable("USERDOMAIN").ToUpper()*/ + "|")) + { + Random rnd = new Random(DateTime.Now.Year + DateTime.Now.DayOfYear * 1000); + MessageBox.Show(this, GetSecurityKey(), "Today's Security Key"); + } _MyLog.WarnFormat("Environment.UserName = '{0}'", Environment.UserName); _MyLog.WarnFormat("Environment.UserDomainName = '{0}'", Environment.UserDomainName); _MyLog.WarnFormat("Environment.MachineName = '{0}'", Environment.MachineName); _MyLog.WarnFormat("Environment.OSVersion = '{0}'", Environment.OSVersion); - } - } + } + } private ContextMenuStrip BuildUserMenu() { @@ -2330,27 +2376,27 @@ namespace VEPROMS proxyUser = ui.UserID; } } - void btnUserControlOfFormats_Click(object sender, EventArgs e) - { - frmUCF frmucf = new frmUCF(); - DialogResult dr = frmucf.ShowDialog(this); - } - void btnUserControlOfFormatsExport_Click(object sender, EventArgs e) - { - DocVersionInfo dvi = null; + void btnUserControlOfFormats_Click(object sender, EventArgs e) + { + frmUCF frmucf = new frmUCF(); + DialogResult dr = frmucf.ShowDialog(this); + } + void btnUserControlOfFormatsExport_Click(object sender, EventArgs e) + { + DocVersionInfo dvi = null; dlgExportImport dlg = new dlgExportImport("Export Formats", dvi, this, (E_UCFImportOptions)0); - dlg.MyNewProcedure = null; - dlg.ExternalTransitionItem = null; - dlg.ShowDialog(this); - } - void btnUserControlOfFormatsImport_Click(object sender, EventArgs e) - { - DocVersionInfo dvi = null; - dlgExportImport dlg = new dlgExportImport("Import Formats", dvi, this, (E_UCFImportOptions)0); - dlg.MyNewProcedure = null; - dlg.ExternalTransitionItem = null; - dlg.ShowDialog(this); - } + dlg.MyNewProcedure = null; + dlg.ExternalTransitionItem = null; + dlg.ShowDialog(this); + } + void btnUserControlOfFormatsImport_Click(object sender, EventArgs e) + { + DocVersionInfo dvi = null; + dlgExportImport dlg = new dlgExportImport("Import Formats", dvi, this, (E_UCFImportOptions)0); + dlg.MyNewProcedure = null; + dlg.ExternalTransitionItem = null; + dlg.ShowDialog(this); + } void btnManageSecurity_Click(object sender, EventArgs e) { dlgManageSecurity dlg = new dlgManageSecurity(); @@ -2361,7 +2407,7 @@ namespace VEPROMS string password = string.Empty; if (ShowInputDialog(ref password) == DialogResult.OK) { - if(password == "V3Pr0m5") + if (password == "V3Pr0m5") { StringBuilder sb = new StringBuilder(); sb.AppendLine("***** WARNING *****"); @@ -2488,7 +2534,7 @@ namespace VEPROMS bool ranAuto = false; foreach (string parameter in parameters) { - if(parameter.StartsWith("/P=")) + if (parameter.StartsWith("/P=")) { MSWordToPDF.Automatic = true; PromsPrinter.BaselineTesting = true;// Set Baseline Testing property for PROMsPrinter @@ -2505,8 +2551,8 @@ namespace VEPROMS prnDlg.SelectedSlave = -1; prnDlg.AllowDateTimePrefixSuffix = false; //C2018-033 don't append any selected date/time pdf file prefix or suffix (defined in working draft properties) prnDlg.ShowDialog(this); // RHM 20120925 - Center dialog over PROMS window - //prnDlg.FormClosed += new FormClosedEventHandler(prnDlg_FormClosed); - //while (!_RunNext) Application.DoEvents(); + //prnDlg.FormClosed += new FormClosedEventHandler(prnDlg_FormClosed); + //while (!_RunNext) Application.DoEvents(); } } ranAuto = true; @@ -2615,7 +2661,7 @@ namespace VEPROMS } private void SaveMRU() { - if(_MyMRIList != null) Properties.Settings.Default.MRIList = _MyMRIList.ToSettings(); + if (_MyMRIList != null) Properties.Settings.Default.MRIList = _MyMRIList.ToSettings(); Properties.Settings.Default.TreeviewExpanded = epProcedures.Expanded; Properties.Settings.Default.Save(); } @@ -2650,7 +2696,7 @@ namespace VEPROMS ItemInfo ii = node.VEObject as ItemInfo; if (ii != null) tc.OpenItem(ii); SetCaption(node); - return (ii != null); // return if successful on opening item in step editor or word + return (ii != null); // return if successful on opening item in step editor or word } // The following code is used to setup the user interface depending on what // is selected on the tree view (see vlnTreeView.cs) @@ -2663,7 +2709,7 @@ namespace VEPROMS { // if it is a word section, find the DisplayTabItem; DisplayTabItem tabItem = tc.GetProcDisplayTabItem(mySection); - if(tabItem != null)tabItem.MyStepTabPanel.MyStepPanel.Reset(); + if (tabItem != null) tabItem.MyStepTabPanel.MyStepPanel.Reset(); } // Don't select the newly created Step. This will be handled by tmrTreeView //SetupNodes((VETreeNode)args.Node); @@ -2686,7 +2732,7 @@ namespace VEPROMS } tn = (VETreeNode)tn.Parent; } - caption.Insert(0,VEPROMS.CSLA.Library.Database.DBServer + sep); + caption.Insert(0, VEPROMS.CSLA.Library.Database.DBServer + sep); this.Text = caption.ToString(); } void tv_OpenItem(object sender, vlnTreeItemInfoEventArgs args) @@ -2719,6 +2765,7 @@ namespace VEPROMS { _ExpandingTree = false; } + void tv_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (_ExpandingTree) @@ -2769,7 +2816,7 @@ namespace VEPROMS /// private void tmrTreeView_Tick(object sender, EventArgs e) { - + _TimeActivity2.Open(); bool giveTvFocus = true; @@ -2789,20 +2836,20 @@ namespace VEPROMS RunAutomatic(); _TimeActivity3.Close(); } - private bool _ExpandingTree=false; - private void tv_BeforeExpand(object sender, TreeViewCancelEventArgs e) - { - //_MyLog.DebugFormat("tv_BeforeExpand \n{0}",Volian.Base.Library.vlnStackTrace.StackToStringLocal(2,10)); - VETreeNode tn = ((VETreeNode)e.Node); - if (tn == null) - return; - _ExpandingTree = true; - tn.LoadingChildrenDone += new VETreeNodeEvent(tn_LoadingChildrenDone); - tn.LoadingChildrenMax += new VETreeNodeEvent(tn_LoadingChildrenMax); - tn.LoadingChildrenValue += new VETreeNodeEvent(tn_LoadingChildrenValue); - tn.LoadingChildrenSQL += new VETreeNodeEvent(tn_LoadingChildrenSQL); - tn.LoadChildren(true); - } + private bool _ExpandingTree = false; + private void tv_BeforeExpand(object sender, TreeViewCancelEventArgs e) + { + //_MyLog.DebugFormat("tv_BeforeExpand \n{0}",Volian.Base.Library.vlnStackTrace.StackToStringLocal(2,10)); + VETreeNode tn = ((VETreeNode)e.Node); + if (tn == null) + return; + _ExpandingTree = true; + tn.LoadingChildrenDone += new VETreeNodeEvent(tn_LoadingChildrenDone); + tn.LoadingChildrenMax += new VETreeNodeEvent(tn_LoadingChildrenMax); + tn.LoadingChildrenValue += new VETreeNodeEvent(tn_LoadingChildrenValue); + tn.LoadingChildrenSQL += new VETreeNodeEvent(tn_LoadingChildrenSQL); + tn.LoadChildren(true); + } #region Property Page and Grid DialogResult tv_NodeOpenProperty(object sender, vlnTreePropertyEventArgs args) { @@ -2853,7 +2900,7 @@ namespace VEPROMS toolsPanel.Expanded = true; toolsTabs.SelectedTab = toolstabResults; } - if (frmver._refreshProcedureList) tv.RefreshDocVersion(); //B2021-066: Refresh Procedure Numbers if Working Draft (docversion) applicability change + if (frmver._refreshProcedureList) tv.RefreshDocVersion(); //B2021-066: Refresh Procedure Numbers if Working Draft (docversion) applicability change? MySessionInfo.CheckInItem(ownerID); } else if (args.ProcedureConfig != null) @@ -3138,8 +3185,8 @@ namespace VEPROMS { //VlnWeb veWWW = new VlnWeb(); //veWWW.Show(); - System.Diagnostics.Process sdp = System.Diagnostics.Process.Start("http://www.volian.com"); - //sdp.WaitForInputIdle(); + System.Diagnostics.Process sdp = System.Diagnostics.Process.Start("http://www.volian.com"); + //sdp.WaitForInputIdle(); } #endregion @@ -3169,8 +3216,8 @@ namespace VEPROMS { if (!epProcedures.Expanded) return; VETreeNode vtn = tv.SelectedNode as VETreeNode; - if (vtn == null) return; // nothing was selected. - if (btnNew.SubItems.Count > 0) return; // submenu will be displayed + if (vtn == null) return; // nothing was selected. + if (btnNew.SubItems.Count > 0) return; // submenu will be displayed vtn.Expand(); // Determine type of 'new' based on tree node's object type. The @@ -3203,13 +3250,13 @@ namespace VEPROMS private void btnOptions_Click(object sender, EventArgs e) { frmSysOptions VeSysOpts = new frmSysOptions(); - VeSysOpts.CanChangeSeparateWindowsSetting = !tc.MoreThanOneProcedureSetIsOpen; + VeSysOpts.CanChangeSeparateWindowsSetting = !tc.MoreThanOneProcedureSetIsOpen; VeSysOpts.ShowDialog(); StepTabRibbon.PasteNoReturnsSetting = Properties.Settings.Default.PasteNoReturns; StepTabRibbon.PastePlainTextSetting = Properties.Settings.Default.PastePlainText; StepTabRibbon.SpecifiedVisioPath = Properties.Settings.Default.VisioPath; tc.SyncEnhancedDocuments = Properties.Settings.Default.SyncEnhancedDocuments; - tc.SeparateWindows = Properties.Settings.Default.SeparateWindows; + tc.SeparateWindows = Properties.Settings.Default.SeparateWindows; } /// /// Exit button on the dialog that appears when the V icon is clicked (top left of application window) @@ -3222,22 +3269,26 @@ namespace VEPROMS this.Close(); } #endregion + #region InfoTabRO + private void infotabRO_Click(object sender, EventArgs e) { infoPanel.Expanded = true; infoTabs.SelectedTab = infotabRO; - //if (dtp == null) return; + + displayRO.ProgressBar = bottomProgBar; - //displayRO.Mydvi = SelectedDVI; - displayRO.MyROFSTLookup = SelectedROFst.GetROFSTLookup(SelectedDVI); displayRO.MyRTB = (SelectedStepTabPanel == null) ? null : SelectedStepTabPanel.MyStepPanel.SelectedEditItem == null ? null : SelectedStepTabPanel.MyStepPanel.SelectedEditItem.MyStepRTB; - displayRO.ProgressBar = bottomProgBar; - displayRO.LoadTree(); // B2022-026 RO Memory Reduction code + + displayRO.LoadTree(); //B2022-026 RO Memory reduction coding (Jakes Merge) } + #endregion + #region InfoTabTransition + private void infotabTransition_Click(object sender, EventArgs e) { if (tc == null || tc.SelectedDisplayTabItem == null) return; @@ -3327,6 +3378,7 @@ namespace VEPROMS private void tc_PanelTabDisplay(object sender, StepPanelTabDisplayEventArgs args) { if (_SelectedDVI == null) return; + if (args.PanelTabName == "Bookmarks") { toolsPanel.Expanded = true; @@ -3376,30 +3428,34 @@ namespace VEPROMS else if (args.PanelTabName == "DisplayROUpdateROFST") { _SelectedROFst = null; - displayRO.MyROFST = SelectedROFst; // need this to update RO Tree after UpdateRofst (B2015-226) - displayRO.MyROFSTLookup = SelectedROFst.GetROFSTLookup(SelectedDVI); - displayRO.RefreshRoTree(); + + // need this to update RO Tree after UpdateRofst (B2015-226) + // B2022-026 RO Memory reduction coding (Jakes Merge) + displayRO.MyROFST = SelectedROFst; + displayRO.LoadTree(); + // resetting the MyROFSTLookup for the search & reports panels will refresh the RO trees after UpdateRofst in each of those panels (B2015-226) if (SelectedDVI != null) { displaySearch1.MyROFSTLookup = SelectedDVI.DocVersionAssociations[0].MyROFst.GetROFSTLookup(SelectedDVI); - displayReports.MyROFSTLookup = SelectedDVI.DocVersionAssociations[0].MyROFst.GetROFSTLookup(SelectedDVI); + displayReports.Mydocversion = SelectedDVI; // B2022-026 RO Memory reduction coding (Jakes Merge) } } } private void tc_SelectedDisplayTabItemChanged(object sender, EventArgs args) { if (tc.ShuttingDown) return; // B2022-026 RO Memory Reduction code - to prevent refreshing the RO tree again - - // If the current procedure or section in the treeview doesn't match then change the treeview selection. - //jcb added for error B2012-117 + // If the current procedure or section in the treeview doesn't match then change the treeview selection. + //jcb added for error B2012-117 ItemInfo tvii; if (tv.SelectedNode == null) tvii = null; else tvii = ((tv.SelectedNode as VETreeNode).VEObject) as ItemInfo; + if (tc.SelectedDisplayTabItem == null) return; if (tc.SelectedDisplayTabItem.MyItemInfo == null) return; // library document. + if (tc.SelectedDisplayTabItem.MyItemInfo.IsProcedure) { if (tvii == null || tvii.IsSection || tc.SelectedDisplayTabItem.MyItemInfo.ItemID != tvii.MyProcedure.ItemID) @@ -3418,16 +3474,26 @@ namespace VEPROMS SetCaption(tv.SelectedNode as VETreeNode); displayApplicability.MyDisplayTabItem = tc.SelectedDisplayTabItem; + if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) { - displayRO.MyROFSTLookup = tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion); - displayRO.LoadTree(); // B2022-026 RO Memory Reduction code + displayRO.MyROFST = tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; } + else + { + displayRO.MyROFST = null; + } + + // B2022-026 RO Memory reduction coding (Jakes Merge) + displayRO.LoadTree(); + lblUser.Text = tc.SelectedDisplayTabItem.MyUserRole; + if (tc.SelectedDisplayTabItem.MyItemInfo.MyDocVersion.MultiUnitCount > 1) btnPrint.Visible = false; else btnPrint.Visible = true; + // Reset the ribbon buttons B2016-148 (ex. a copystep done in a different procedure tab my require the paste step options to be active if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyStepTabPanel != null) // MyStepTabPanel will be null if the active tab is a Word Attachment { @@ -3444,6 +3510,7 @@ namespace VEPROMS } } } + private void tc_StepPanelModeChange(object sender, StepRTBModeChangeEventArgs args) { this.lblEditView.Text = args.ViewMode == E_ViewMode.Edit ? "Edit" : "View"; @@ -3455,6 +3522,7 @@ namespace VEPROMS if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyStepTabPanel != null && tc.SelectedDisplayTabItem.MyStepTabPanel.MyStepTabRibbon != null) tc.SelectedDisplayTabItem.MyStepTabPanel.MyStepTabRibbon.ToggleFindReplaceToolTip(args.ViewMode == E_ViewMode.View); } + private ItemInfo _CurrentItem = null; private StepRTB _LastStepRTB = null; //private Timer _TmrRefreshItem = null; @@ -3480,11 +3548,11 @@ namespace VEPROMS private void tc_ItemSelectedChanged(object sender, ItemSelectedChangedEventArgs args) { tc.HideTheCaret(); - - if (args != null && args.MyEditItem != null && !args.MyEditItem.MyStepPanel.ContainsFocus) + + if (args != null && args.MyEditItem != null && !args.MyEditItem.MyStepPanel.ContainsFocus) return; - - btnFixMSWord.Visible = (args != null && ( args.MyItemInfo != null && args.MyEditItem == null)); + + btnFixMSWord.Visible = (args != null && (args.MyItemInfo != null && args.MyEditItem == null)); if (_LastStepRTB != null && !_LastStepRTB.Disposing && !_LastStepRTB.Closed) _LastStepRTB.EditModeChanged -= new StepRTBEvent(_LastStepRTB_EditModeChanged); @@ -3520,7 +3588,7 @@ namespace VEPROMS if (_CurrentItem != null) _CurrentItem.Deleted -= new ItemInfoEvent(_CurrentItem_Deleted); _CurrentItem = args.MyItemInfo; } - + if (args.MyEditItem == null) { ctrlAnnotationDetails.Enabled = false; @@ -3531,10 +3599,11 @@ namespace VEPROMS if (args.MyItemInfo.MyDocVersion.DocVersionAssociations != null) { - displayRO.MyROFST = args.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; - displayRO.MyRTB = null; infotabRO.Visible = true; - displayRO.LoadTree(); // B2022-026 RO Memory Reduction code + + // B2022-026 RO Memory reduction coding (Jakes Merge) + displayRO.MyRTB = null; + displayRO.LoadTree(); } infotabTags.Visible = false; @@ -3552,6 +3621,7 @@ namespace VEPROMS { epAnnotations.Enabled = true; ctrlAnnotationDetails.Enabled = true; + if (args.MyEditItem.MyItemInfo.IsSection || args.MyEditItem.MyItemInfo.IsProcedure) { infotabRO.Visible = false; // B2022-039 Do NOT allow ROs to be inserted in section or procedures // B2017-245 Allow Ro Menu to be seen for Procedures and Sections @@ -3562,6 +3632,7 @@ namespace VEPROMS else { infotabTags.Visible = true; + if (_LastStepRTB != null) { infotabRO.Visible = _LastStepRTB.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0; @@ -3573,13 +3644,16 @@ namespace VEPROMS displayTransition.Enabled = _LastStepRTB.EditMode; } else + { infotabRO.Visible = infotabTransition.Visible = false; + } // When infotabTags is set to Visible, the matching panel also needs to be set to visible // the other panels will appear as they are selected by the user. infotabControlPanelTags.Visible = true; displayTags.IsVisible = true; } + infotabHistory.Visible = true; // C2021-027: Procedure level PC/PC // B2021-065: wasn't showing applicability tab for formats that didn't have procedure level flag. @@ -3589,7 +3663,10 @@ namespace VEPROMS displayApplicability.MyItemInfo = args.MyEditItem.MyItemInfo; } else + { infotabApplicability.Visible = false; + } + if (args.MyEditItem.MyItemInfo.ActiveFormat != null) { // see if format has floating foldouts, and if so, display the panel. @@ -3602,71 +3679,69 @@ namespace VEPROMS displayFoldoutMaint.MyItemInfo = args.MyItemInfo; } } + // When infotabTags is set to Visible, it is given focus. The next line returns focus to the StepRTB args.MyEditItem.SetFocus(); displayTransition.MyRTB = args.MyEditItem.MyStepRTB; + // B2022-026 RO Memory reduction coding (Jakes Merge) + displayRO.ProgressBar = bottomProgBar; displayRO.MyRTB = args.MyEditItem.MyStepRTB; + displayRO.LoadTree(); + displayBookMarks.MyEditItem = args.MyEditItem; displayHistory.MyEditItem = args.MyEditItem; - displayRO.ProgressBar = bottomProgBar; - lblEditView.Text = args.MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? "Edit" : "View"; _CurrentItem.Deleted += new ItemInfoEvent(_CurrentItem_Deleted); dlgFindReplace.MyEditItem = args.MyEditItem; SpellChecker.MyEditItem = args.MyEditItem; } + if (args.MyEditItem != null) { SelectedStepTabPanel = args.MyEditItem.MyStepPanel.MyStepTabPanel; displayTags.Mydvi = SelectedDVI; displayTags.MyEditItem = args.MyEditItem; + displayRO.ROTypeFilter = SelectedStepTabPanel.MyStepPanel.SelectedEditItem is Volian.Controls.Library.GridItem && (SelectedStepTabPanel.MyStepPanel.SelectedEditItem as Volian.Controls.Library.GridItem).MyFlexGrid.IsRoTable ? E_ROValueType.Table : (SelectedStepTabPanel.MyStepPanel.SelectedEditItem.MyItemInfo.IsFigure) ? E_ROValueType.Image : E_ROValueType.Text; - displayRO.LoadTree(); // B2022-026 RO Memory Reduction code - + if (_LastStepRTB.IsRoTable && _LastStepRTB.MyItemInfo.MyContent.ContentRoUsageCount > 0) displayRO.CurROLink = _LastStepRTB.MyItemInfo.MyContent.ContentRoUsages[0]; if (_LastStepRTB.IsRoFigure && _LastStepRTB.MyItemInfo.MyContent.ContentRoUsageCount > 0) displayRO.CurROLink = _LastStepRTB.MyItemInfo.MyContent.ContentRoUsages[0]; - // if this is an enhanced step (linked from a source document), don't bring up the ro or transition panel, - // and don't allow replace on the find/replace dialog. - if (args.MyItemInfo.IsEnhancedStep) - { - // originally had these two lines to make the step properties panel/tran & ro tabs invisitble for - // enhanced steps but this was causing an error in the caret management code in StepTabPanel (Hide/ShowCaret) - //infotabTransition.Visible = false; - //infotabRO.Visible = false; - // RHM: Had to use a timer to keep from getting into an infinite loop - // Not sure why , but tc_Leave was being called over and over again. - //KBR:TmrSetTransROInVisible.Enabled = true; - } + // B2022-026 RO Memory reduction coding (Jakes Merge) displayRO.SetFindDocROButton(false); + displayRO.LoadTree(); } else { - SelectedDVI = args.MyItemInfo.MyDocVersion; //B2017-244 Open RO Panel for MSWord Sections - if (args.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) + if (args.MyItemInfo != null && args.MyItemInfo.MyDocVersion != null && args.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) { - displayRO.MyROFSTLookup = args.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(args.MyItemInfo.MyDocVersion); displayRO.MyROFST = args.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; } + + // B2022-026 RO Memory reduction coding (Jakes Merge) + SelectedDVI = args.MyItemInfo.MyDocVersion; + displayRO.MyDvi = SelectedDVI; displayRO.ROTypeFilter = E_ROValueType.All; // allow all RO types for Word attachments (but fix) - displayRO.LoadTree(); // B2022-026 RO Memory Reduction code + displayRO.SetFindDocROButton(true); + displayRO.LoadTree(); } } + if (ctrlAnnotationDetails.Enabled && epAnnotations.Enabled) { ctrlAnnotationDetails.UpdateAnnotationGrid(_CurrentItem); AnnotationPanelView(); } - else if(_CurrentItem!=null) // B2017-127, B2017-131 Send message when a MSWord section is opened. + else if (_CurrentItem != null) // B2017-127, B2017-131 Send message when a MSWord section is opened. { ctrlAnnotationDetails.UpdateAnnotationGrid(_CurrentItem); // set the CurrentItem (send Message) when the MSWord section is opened. } @@ -3698,7 +3773,7 @@ namespace VEPROMS */ void _LastStepRTB_EditModeChanged(object sender, EventArgs args) { - if (_LastStepRTB.EditMode) // going into edit mode in a cell of the grid. + if (_LastStepRTB.EditMode) // going into edit mode in a cell of the grid. displayRO.Enabled = displayTransition.Enabled = _LastStepRTB.EditMode; else // going out of edit mode in a cell of the grid. { @@ -3711,8 +3786,11 @@ namespace VEPROMS { //displayBookMarks.DeleteItemBookMarkPanel(_CurrentItem); } + #endregion + #region Annotations + /// /// Display or hide the Annotation Details panel /// @@ -3733,8 +3811,11 @@ namespace VEPROMS ctrlAnnotationDetails.AnnotationText = null; } } + #endregion + #region LinkSupport + private void tc_LinkActiveChanged(object sender, StepPanelLinkEventArgs args) { // determine if any infotabs are visisble, and if it is the Transition, @@ -3744,6 +3825,7 @@ namespace VEPROMS displayTransition.CurTrans = null; } } + private void tc_LinkModifyTran(object sender, StepPanelLinkEventArgs args) { infoPanel.Expanded = true; @@ -3753,6 +3835,7 @@ namespace VEPROMS displayTransition.MyRTB = SelectedStepTabPanel.MyStepPanel.SelectedEditItem.MyStepRTB; displayTransition.CurTrans = args.MyLinkText.MyTransitionInfo; } + private void tc_LinkModifyRO(object sender, StepPanelLinkEventArgs args) { if (_SelectedROFst == null && (SelectedDVI == null || SelectedDVI.DocVersionAssociationCount == 0)) return; // B2016-128, not RO path associated to the working draft @@ -3761,17 +3844,21 @@ namespace VEPROMS infoPanel.Expanded = true; infoTabs.SelectedTab = infotabRO; - displayRO.MyROFSTLookup = SelectedROFst.GetROFSTLookup(SelectedDVI); + displayRO.ROTypeFilter = SelectedStepTabPanel.MyStepPanel.SelectedEditItem is Volian.Controls.Library.GridItem && (SelectedStepTabPanel.MyStepPanel.SelectedEditItem as Volian.Controls.Library.GridItem).MyFlexGrid.IsRoTable ? + E_ROValueType.Table : (SelectedStepTabPanel.MyStepPanel.SelectedEditItem.MyItemInfo.IsFigure) ? E_ROValueType.Image : E_ROValueType.Text; + + displayRO.ProgressBar = bottomProgBar; displayRO.MyRTB = SelectedStepTabPanel.MyStepPanel.SelectedEditItem.MyStepRTB; displayRO.CurROLink = args.MyLinkText.MyRoUsageInfo; - displayRO.ROTypeFilter = SelectedStepTabPanel.MyStepPanel.SelectedEditItem is Volian.Controls.Library.GridItem && (SelectedStepTabPanel.MyStepPanel.SelectedEditItem as Volian.Controls.Library.GridItem).MyFlexGrid.IsRoTable ? - E_ROValueType.Table : (SelectedStepTabPanel.MyStepPanel.SelectedEditItem.MyItemInfo.IsFigure) ? E_ROValueType.Image: E_ROValueType.Text; - //displayRO.Mydvi = SelectedDVI; - displayRO.ProgressBar = bottomProgBar; - displayRO.LoadTree(); // B2022-026 RO Memory Reduction code + + // B2022-026 RO Memory reduction coding (Jakes Merge) + displayRO.LoadTree(); } + #endregion + #region VButton + private void office2007StartButton1_Click(object sender, EventArgs e) { // If the V-Button is clicked, check to see what tree node is s selected @@ -3781,15 +3868,15 @@ namespace VEPROMS // reset in case previous selection changed items. btnNew.SubItems.Clear(); btnNew.Enabled = false; - // if focus is in the step editor, position in the tree view to match the location in the step editor - if (!tv.Focused && tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.SelectedItemInfo != null) - tv.AdjustTree(tc.SelectedDisplayTabItem.SelectedItemInfo); + // if focus is in the step editor, position in the tree view to match the location in the step editor + if (!tv.Focused && tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.SelectedItemInfo != null) + tv.AdjustTree(tc.SelectedDisplayTabItem.SelectedItemInfo);? VETreeNode vtn = tv.SelectedNode as VETreeNode; if (vtn == null) return; - StepInfo stpinf = vtn.VEObject as StepInfo; - if (stpinf == null || !stpinf.IsRNOPart) //B2017-037 is this a RNO step type element - don't allow insert before/after - btnNew.Enabled = true; + StepInfo stpinf = vtn.VEObject as StepInfo; + if (stpinf == null || !stpinf.IsRNOPart) //B2017-037 is this a RNO step type element - don't allow insert before/after + btnNew.Enabled = true; vtn.Expand(); // Folders can have either folders & docversions, but @@ -3803,10 +3890,10 @@ namespace VEPROMS // if at top, 'VEPROMS', folder and childfolders below this only // option is to create a new (sub)folder, i.e. no submenu items. - if (fi.ChildFolderCount > 0 && fi.MyParent == null) return; + if (fi.ChildFolderCount > 0 && fi.MyParent == null) return; // submenu folders/docversion - if (fi.MyParent != null && UserInfo.CanCreateFolders(MyUserInfo,fi)) + if (fi.MyParent != null && UserInfo.CanCreateFolders(MyUserInfo, fi)) { ButtonItem fldbbtn = new ButtonItem("fldbtn", "Folder Before"); ButtonItem fldabtn = new ButtonItem("fldabtn", "Folder After"); @@ -3876,19 +3963,19 @@ namespace VEPROMS } ButtonItem sbbtn = new ButtonItem("sbbtn", "Section Before"); ButtonItem sabtn = new ButtonItem("sabtn", "Section After"); - + btnNew.SubItems.Add(sbbtn); btnNew.SubItems.Add(sabtn); sbbtn.Click += new EventHandler(sbbtn_Click); sabtn.Click += new EventHandler(sabtn_Click); - + if (si.IsStepSection) { // B2016-282: Don't allow insert of subsections off Word Section. - if (si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections) + if (si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections) { ButtonItem subbtn = new ButtonItem("subbtn", "SubSection"); - btnNew.SubItems.Add(subbtn); + btnNew.SubItems.Add(subbtn);? subbtn.Click += new EventHandler(subbtn_Click); } ButtonItem stpbtn = new ButtonItem("stpbtn", "New Step"); @@ -4052,7 +4139,7 @@ namespace VEPROMS frmPropGrid pg = new frmPropGrid(tc.SelectedDisplayTabItem.SelectedItemInfo, tc.SelectedDisplayTabItem.SelectedItemInfo.ShortPath); pg.Show(); } - else + else MessageBox.Show("Select Item First", "Item not selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } private void lblItemID_Click(object sender, System.EventArgs e) @@ -4218,9 +4305,9 @@ namespace VEPROMS { if (tc.SelectedDisplayTabItem != null && tc.SelectedDisplayTabItem.MyStepTabPanel.SelectedEditItem != null) { - frmPropGrid pg = new frmPropGrid(tc.SelectedDisplayTabItem.MyStepTabPanel.SelectedEditItem, "EditItem"); - pg.Show(); - } + frmPropGrid pg = new frmPropGrid(tc.SelectedDisplayTabItem.MyStepTabPanel.SelectedEditItem, "EditItem"); + pg.Show(); + } else MessageBox.Show("Select Item First", "Item not selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } @@ -4323,7 +4410,7 @@ namespace VEPROMS { MessageBox.Show("Could not open the PROMS User Manual.\nDetails are in the error log.", "View User Manual"); string str = string.Format("Could not open {0}", promsUserManual); - _MyLog.Error(str,ex); + _MyLog.Error(str, ex); } } } @@ -4334,7 +4421,7 @@ namespace VEPROMS { lock (this) { - if(!this.Contains(dti)) + if (!this.Contains(dti)) this.Push(dti); } } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs index 14726ccb..8dbd9c60 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ROFSTLookup.cs @@ -8,8 +8,9 @@ using System.Data.SqlClient; using System.Linq; using Csla.Data; +using System.Threading; +using System.Threading.Tasks; -// B2022-026 New code for RO Memory reduction - now use SQL tables instead of building dictionarys to get RO values namespace VEPROMS.CSLA.Library { @@ -38,7 +39,7 @@ namespace VEPROMS.CSLA.Library #region Enums [Flags] - public enum SearchType + public enum SearchTypes { StartsWith = 1, EndsWith = 2, @@ -46,6 +47,15 @@ namespace VEPROMS.CSLA.Library ExactMatch = 4 } + public enum HeaderStatuses + { + Unknown = 0, + NotLoaded = 1, + InProgress = 2, + LoadComplete = 3, + LoadFailed = 4 + } + #endregion #region Structs / Internal Classes @@ -128,6 +138,7 @@ namespace VEPROMS.CSLA.Library } }; + #endregion #region Fields @@ -230,20 +241,39 @@ namespace VEPROMS.CSLA.Library #region (RO Info) - public ROFSTLookup.rochild GetRoChild12(string ROID16, bool loadChildren = false, bool loadAllChildren = false) + public bool HasChildren(ref ROFSTLookup.rochild child) { - string ROID = (ROID16.Length < 12) ? ROID16 : ROID16.Substring(0, 12); - - ROFSTLookup.rochild rc = RofstDataGetChildByRoid(_rofstID, ROID, loadChildren, loadAllChildren); - - if (rc.ID <= 0 && ROID16.Length == 4) - { - rc.title = GetRODatabaseTitle(GetRODatabaseTitleIndex(ROID16)); - } - - return rc; + LoadChildren(ref child); + return child.children.Any(); } + public bool HasChildren(ref ROFSTLookup.rodbi db) + { + LoadChildren(ref db); + return db.children.Any(); + } + + public void LoadChildren(ref ROFSTLookup.rochild child) + { + // If Children is null then it hasn't been loaded yet + if (child.children == null || child.children.Length <= 0) + { + if (!string.IsNullOrEmpty(child.appid)) + child = GetRoChild12(child.roid, true); + else + child.children = GetRoChildrenByRoid(child.roid, true); + } + } + + public void LoadChildren(ref ROFSTLookup.rodbi db) + { + // If Children is null then it hasn't been loaded yet + if (db.children == null || db.children.Length <= 0) + db.children = GetRoChildrenByID(db.ID, db.dbiID, true); + } + + + public ROFSTLookup.rochild GetRoChild(string ROID, bool loadChildren = false, bool loadAllChildren = false) { ROFSTLookup.rochild rc = new ROFSTLookup.rochild() { ID = -1 }; @@ -280,6 +310,34 @@ namespace VEPROMS.CSLA.Library } } } + + nextIDX = aplString.IndexOf(",UnitIdx", offsetIdx); + if (nextIDX == -1) nextIDX = aplString.IndexOf(" /APL>"); + sb.Append(aplString.Substring(offsetIdx, nextIDX - offsetIdx)); + + lastIndex = m.Index + m.Length; + } + + // B2022-018 append any remaining text + if (lastIndex < roval.Length) + { + sb.Append(roval.Substring(lastIndex)); + } + + return sb.ToString(); + } + + public List GetROReturnValue(string roval) + { + _lstRoValues = new List(); + _multiRoValues = new List(); + _dicRoVars = new Dictionary(); + + string tmp = ProcessRO(_myDocVersionInfo == null ? roval : _myDocVersionInfo.ProcessDocVersionSpecificInfo(roval), false); + + if (!string.IsNullOrEmpty(tmp) && _lstRoValues.Count == 0) // was not a multiple return value + { + _lstRoValues.Add(tmp); } return rc; @@ -392,22 +450,6 @@ namespace VEPROMS.CSLA.Library return sb.ToString(); } - public List GetROReturnValue(string roval) - { - _lstRoValues = new List(); - _multiRoValues = new List(); - _dicRoVars = new Dictionary(); - - string tmp = ProcessRO(_myDocVersionInfo == null ? roval : _myDocVersionInfo.ProcessDocVersionSpecificInfo(roval), false); - - if (!string.IsNullOrEmpty(tmp) && _lstRoValues.Count == 0) // was not a multiple return value - { - _lstRoValues.Add(tmp); - } - - return _lstRoValues; - } - public string GetTranslatedRoValue(string ROID16, bool DoCaret, bool DoDOSSuperSubScript) { string retval = GetRoValue(ROID16); @@ -425,6 +467,9 @@ namespace VEPROMS.CSLA.Library return retval.Replace("\r\n", @"\par "); } + + + public Dictionary Search(string value, int searchTypeID, int? maxNumRecords = null) { if (string.IsNullOrEmpty(value)) @@ -523,7 +568,7 @@ namespace VEPROMS.CSLA.Library rc = GetRoChild12(parentROID); if (rc.ID > 0) sb.Insert(0, rc.title + " - "); - } while (rc.ID > 0); + } while (rc.ID > 0);? return sb.ToString(); } @@ -641,6 +686,21 @@ namespace VEPROMS.CSLA.Library #region (Database Calls) private bool RofstDataExists(int rofstID) + { + int headerStatusID = RofstDataGetHeaderLoadStatus(rofstID); + + while (headerStatusID == (int)HeaderStatuses.InProgress) + { + // Wait 5 sec(s) then Check Header Status Again + Thread.Sleep(5000); + + headerStatusID = RofstDataGetHeaderLoadStatus(rofstID); + } + + return (headerStatusID == (int)HeaderStatuses.LoadComplete); // false includes [NotLoaded = 1 || LoadFailed = 4 || Unknown = 0] + } + + private int RofstDataGetHeaderLoadStatus(int rofstID) { try { @@ -650,17 +710,22 @@ namespace VEPROMS.CSLA.Library { cmd.CommandTimeout = Database.DefaultTimeout; cmd.CommandType = CommandType.StoredProcedure; - cmd.CommandText = "vesp_RofstDataExists"; + cmd.CommandText = "vesp_RofstDataGetHeaderRofstByID"; cmd.Parameters.Add(new SqlParameter("@RofstID", SqlDbType.Int)).Value = rofstID; - return Convert.ToBoolean(cmd.ExecuteScalar()); + using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader())) + { + if (dr.Read()) return Convert.ToInt32(dr.GetValue("RofstHeaderStatusID")); + } } } + + return 0; // Unknown Status } catch (Exception ex) { - throw new DbCslaException("RofstData.vesp_RofstDataExists", ex); + throw new DbCslaException("RofstData.vesp_RofstDataGetHeaderRofstByID", ex); } } @@ -759,6 +824,30 @@ namespace VEPROMS.CSLA.Library } } + private void RofstHeaderFinalizeLoad(int rofstID) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cmd = cn.CreateCommand()) + { + cmd.CommandTimeout = Database.DefaultTimeout; + cmd.CommandType = CommandType.StoredProcedure; + cmd.CommandText = "vesp_RofstHeaderFinalizeLoad"; + + cmd.Parameters.Add(new SqlParameter("@RofstID", SqlDbType.Int)).Value = rofstID; + + cmd.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + throw new DbCslaException("RofstData.vesp_RofstHeaderFinalizeLoad", ex); + } + } + private void RofstDatabaseInsert(int rofstID, int dbiID, int dbiType, int dbiAW, string dbiTitle, string dbiAP, int id, int parentID) { try @@ -1369,6 +1458,10 @@ namespace VEPROMS.CSLA.Library } } } + + //Finalized Load for Rofst Header / Rebuild Indexes + RofstHeaderFinalizeLoad(rofstID); + } private void LoadChild(int rofstID, int dbiID, ROFSTLookup.rochild child) @@ -1428,7 +1521,7 @@ namespace VEPROMS.CSLA.Library if (loadChildren || loadAllChildren) { - rd.children = RofstDataGetChildrenByID(_rofstID, rd.dbiID, rd.ID, loadAllChildren); + rd.children = RofstDataGetChildrenByID(_rofstID, rd.dbiID, rd.ID, false, loadAllChildren); } return rd; @@ -1451,10 +1544,9 @@ namespace VEPROMS.CSLA.Library rc.value = (string)dr.GetValue("value"); ProcessROReturnValue(ref rc, rc.value, GetRODatabaseTitleIndex(rc.roid)); } - - if (loadChildren || loadAllChildren) + else if (loadChildren || loadAllChildren) { - rc.children = RofstDataGetChildrenByRoid(_rofstID, rc.roid, loadAllChildren); + rc.children = RofstDataGetChildrenByRoid(_rofstID, rc.roid, false, loadAllChildren); } return rc; @@ -1464,6 +1556,36 @@ namespace VEPROMS.CSLA.Library #region (RO Values) + private ROFSTLookup.rochild GetRoChild12(string ROID16, bool loadChildren = false, bool loadAllChildren = false) + { + string ROID = (ROID16.Length < 12) ? ROID16 : ROID16.Substring(0, 12); + + ROFSTLookup.rochild rc = RofstDataGetChildByRoid(_rofstID, ROID, loadChildren, loadAllChildren); + + if (rc.ID <= 0 && ROID16.Length == 4) + { + rc.title = GetRODatabaseTitle(GetRODatabaseTitleIndex(ROID16)); + } + + return rc; + } + + private List GetROReturnValue(string roval) + { + _lstRoValues = new List(); + _multiRoValues = new List(); + _dicRoVars = new Dictionary(); + + string tmp = ProcessRO(_myDocVersionInfo == null ? roval : _myDocVersionInfo.ProcessDocVersionSpecificInfo(roval), false); + + if (!string.IsNullOrEmpty(tmp) && _lstRoValues.Count == 0) // was not a multiple return value + { + _lstRoValues.Add(tmp); + } + + return _lstRoValues; + } + private void ProcessROReturnValue(ref ROFSTLookup.rochild child, string rawvalue, int tableID) { // This function will take the raw RO return value and resolve any macros, conditionals, @@ -1773,7 +1895,7 @@ namespace VEPROMS.CSLA.Library s2 = s2.Replace("\x2190", @"\u8592?"); // Leftwards Arrow s2 = s2.Replace("\x2191", @"\u8593?"); // Upwards Arrow s2 = s2.Replace("\x2193", @"\u8595?"); // Downwards Arrow - s2 = s2.Replace("\x2207", @"\u8711?"); // Nabla (?) + s2 = s2.Replace("\x2207", @"\u8711?"); // Nabla s2 = s2.Replace("\x2591", @"\'b0"); // Degree Symbol s2 = s2.Replace("\xFF", @"\u8593?"); // Up Arrow s2 = s2.Replace("\xD6", @"\u8595?"); // Down Arrow diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs index 4f00bf44..2c3b2723 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs @@ -108,12 +108,12 @@ namespace VEPROMS.CSLA.Library public delegate List ROFstInfoROTableUpdateEvent(object sender, ROFstInfoROTableUpdateEventArgs args); public delegate void ROFstInfoProgressBarRefresh(int value, int max, string text); - + public partial class ROFstInfo { #region Log4Net - private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #endregion @@ -449,7 +449,7 @@ namespace VEPROMS.CSLA.Library { string cfg = docver.DocVersionAssociations[0].Config; - AssociationConfig ac = new AssociationConfig((cfg== null || cfg.Length == 0) ? "" : cfg); + AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "" : cfg); ac.ROUpdate_LastCompleted = value; docver.DocVersionAssociations[0].Config = ac.ToString(); docver.Save(); @@ -460,7 +460,7 @@ namespace VEPROMS.CSLA.Library { string cfg = docver.DocVersionAssociations[0].Config; - AssociationConfig ac = new AssociationConfig((cfg== null || cfg.Length == 0) ? "" : cfg); + AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "" : cfg); ac.ROUpdate_LoadingFigures = value; docver.DocVersionAssociations[0].Config = ac.ToString(); docver.Save(); @@ -497,7 +497,7 @@ namespace VEPROMS.CSLA.Library } SetAssociationROFiguresLoading(docVer, string.Empty); // B2017-125 loading RO Figures is completed - + return MyChangedFigureROIDs; } @@ -515,7 +515,7 @@ namespace VEPROMS.CSLA.Library List ChangedFiles = GetChangedFigures(origROFst, rofst, myProgressBarRefresh); // Get ROID associated with FileNames - List ROIDs = GetROIDsFromLookup(rofst,ChangedFiles,docver); + List ROIDs = GetROIDsFromLookup(rofst, ChangedFiles, docver); return ROIDs; } @@ -562,7 +562,7 @@ namespace VEPROMS.CSLA.Library { if (origROFst.ROFstFigures == null) return null; - Dictionary orig = new Dictionary(); + Dictionary orig = new Dictionary(); int i = 0; foreach (FigureInfo fi in origROFst.ROFstFigures) @@ -573,7 +573,7 @@ namespace VEPROMS.CSLA.Library } // B2018-032 Don't crash if there are no figures - if (rofst.ROFstFigures == null) + if (rofst.ROFstFigures == null) return null; i = 0; @@ -596,9 +596,9 @@ namespace VEPROMS.CSLA.Library return changedFigures; } - private static Dictionary BuildROImagesList(ROImageInfoList myROImages) + private static Dictionary BuildROImagesList(ROImageInfoList myROImages) { - Dictionary myRoImagesList = new Dictionary(); + Dictionary myRoImagesList = new Dictionary(); foreach (ROImageInfo myROImage in myROImages) { @@ -607,7 +607,7 @@ namespace VEPROMS.CSLA.Library return myRoImagesList; } - + private static string ROImageKey(string fileName, DateTime dts) { return string.Format("{0}:{1}", fileName, dts); @@ -652,7 +652,7 @@ namespace VEPROMS.CSLA.Library if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Getting List of ROs Used"); List activeRoids = BuildActiveROIDsForRoUsages12(RoidList, versionList); - + if (myProgressBarRefresh != null) myProgressBarRefresh(0, chgList.Count, "Updating RO Values"); int iCount = 0; @@ -790,7 +790,7 @@ namespace VEPROMS.CSLA.Library } } - if (myProgressBarRefresh != null) myProgressBarRefresh(100,100, "RO Values Updated"); + if (myProgressBarRefresh != null) myProgressBarRefresh(100, 100, "RO Values Updated"); } private static DateTime ShowDuration(DateTime dtLast, string message) @@ -837,7 +837,7 @@ namespace VEPROMS.CSLA.Library private static string GetRoidList(int dbid, List chgList) { StringBuilder sb = new StringBuilder(string.Format("{0}", dbid)); - string sep=":"; + string sep = ":"; foreach (string roid in chgList) { @@ -1145,7 +1145,7 @@ namespace VEPROMS.CSLA.Library } } - if (isDifferent) + if (isDifferent) break; } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs index 7d9715c1..16e17f63 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs @@ -82,7 +82,7 @@ namespace VEPROMS.CSLA.Library ROFSTLookup lu = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); foreach (ROCheck roc in MyDifferences.ROConsistency.MyROChecks) { - ROFSTLookup.rochild rocc = lu.GetRoChild12(roc.ROID); + ROFSTLookup.rochild rocc = lu.GetRoChild(roc.ROID); if (rocc.ID == -1) // B2020-125: View of Consistency check report displaying error message and crashing. { sb.Append(string.Format(" {0}\r\n", lu.GetROTitle(roc.ROID))); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ROFstInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ROFstInfo.cs index 3e63897e..011db645 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ROFstInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ROFstInfo.cs @@ -135,11 +135,6 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("ROLookup", true); - //if (_ROLookup == null) - //{ - // _ROLookup = ROFSTLookup.GetRofstLookupBytes(_ROFstID); - //} - //return _ROLookup; // B2022-026 RO Memory reduction return null; @@ -333,7 +328,7 @@ namespace VEPROMS.CSLA.Library } _MyRODb = null; // Reset list so that the next line gets a new list if (MyRODb != null) MyRODb.RefreshRODbROFsts(); // Update List for new value - //_ROLookup = tmp.ROLookup; + //_ROLookup = tmp.ROLookup; _ROLookup = null; // B2022-026 RO Memory reduction _Config = tmp.Config; _DTS = tmp.DTS; diff --git a/PROMS/Volian.Controls.Library/DisplayRO.cs b/PROMS/Volian.Controls.Library/DisplayRO.cs index dd58f13f..1ab26fec 100644 --- a/PROMS/Volian.Controls.Library/DisplayRO.cs +++ b/PROMS/Volian.Controls.Library/DisplayRO.cs @@ -12,6 +12,7 @@ using DevComponents.DotNetBar; using System.Text.RegularExpressions; using Volian.Base.Library; using JR.Utils.GUI.Forms; +using System.Linq; namespace Volian.Controls.Library { @@ -33,22 +34,25 @@ namespace Volian.Controls.Library private static Regex _regExGetNumber = new Regex(@"^ *[+-]?[.,0-9/]+(E[+-]?[0-9]+)?"); private static UserInfo _myUserInfo = null; - private Timer _searchTimer; + private Timer _searchTimer = null; private string _lastSearchValue = string.Empty; - + private ProgressBarItem _progressBar; private DisplayTabControl _tabControl; private StepRTB _myRTB; private string _selectedRoidBeforeRoEditor = null; private ROFstInfo _myROFST; - private ROFSTLookup _myROFSTLookup; private DocVersionInfo _docVersionInfo; private RoUsageInfo _savCurROLink; private E_ROValueType _roTypeFilter = E_ROValueType.All; - private ROFstInfo _curROFST = null; - private ROFSTLookup _curROFSTLookup = null; + //private ROFstInfo _curROFST = null; + private int? _currRofstID = null; + private int? _currDocVersionID = null; + private bool _isInitializedRofstID = false; + private bool _isInitializedDocVersionID = false; + private RoUsageInfo _curROLink; private E_ROValueType _curROTypeFilter = E_ROValueType.All; @@ -66,40 +70,73 @@ namespace Volian.Controls.Library public DisplayTabControl TabControl { - get { return _tabControl; } + get { return _tabControl; } set { _tabControl = value; } } + public bool IsRofstValid + { + get { return (_myROFST != null && _myROFST.ROFstAssociations != null && _myROFST.ROFstAssociationCount > 0); } + } + + public bool RoTreeNeedsReloaded + { + get { return (MyROFST != null && _currRofstID != null && MyROFST.ROFstID != (int)_currRofstID) || (MyDvi != null && _currDocVersionID != null && MyDvi.VersionID != (int)_currDocVersionID) ; } + } + public ROFstInfo MyROFST { get { return _myROFST; } set { - if (!Visible) return; // don't reset anything if the form is invisible. - - // define the tree nodes based on this rofst - _myROFST = value; - - if (_myROFST != null && _myROFST.ROFstAssociations != null && _myROFST.ROFstAssociationCount > 0) + // Define the tree nodes based on this rofst/docversion + // Rofst is required, DocVersion can be null. If Rofst is null then make DocVersion null + if (_myROFST != value) { - _myROFSTLookup = new ROFSTLookup(_myROFST.ROFstID, _myROFST.ROFstAssociations[0].MyDocVersion); - } + if (value == null) + { + _myROFST = null; + MyDvi = null; + } + else + { + _myROFST = value; - //LoadTree(); + if (MyDvi == null) + { + MyDvi = (IsRofstValid) ? _myROFST.ROFstAssociations[0].MyDocVersion : null; + } + } + + if (!_isInitializedRofstID && IsRofstValid) + { + _currRofstID = (IsRofstValid) ? (int?)_myROFST.RODbID : null; + } + } + } + } + + public DocVersionInfo MyDvi + { + get { return _docVersionInfo; } + set + { + // Check if DocVersion Has Changed + if (_docVersionInfo != value) + { + _docVersionInfo = value; + + if (!_isInitializedDocVersionID && _docVersionInfo != null) + { + _currDocVersionID = (int?) _docVersionInfo.VersionID;? + } + } } } public ROFSTLookup MyROFSTLookup { - get { return _myROFSTLookup; } - set - { - if (!Visible) return; // don't reset anything if the form is invisible. - - _myROFSTLookup = value; - _docVersionInfo = (_myROFSTLookup != null) ? _myROFSTLookup.MyDocVersionInfo : null; - //LoadTree(); - } + get { return (_myROFST != null) ? new ROFSTLookup(_myROFST.ROFstID, _docVersionInfo) : null;} } public E_ROValueType ROTypeFilter @@ -108,39 +145,40 @@ namespace Volian.Controls.Library set { _roTypeFilter = value; - if (!Visible) return; // don't reset anything if the form is invisible. + //if (!Visible) return; // don't reset anything if the form is invisible. //_roTypeFilter = value; + // LoadTree(); } } - public DocVersionInfo MyDvi - { - get { return _docVersionInfo; } - } - public RoUsageInfo CurROLink { get { return _curROLink; } set { - if (!Visible) return; // don't reset anything if the form is invisible. - - if (value != null) // modify - set the controls to the current ro + // modify - set the controls to the current ro + if (value != null) { - if (_curROLink == value) return; - _curROLink = value; - _savCurROLink = _curROLink; - UpdateROTree(); + if (_curROLink != value) + { + _curROLink = value; + _savCurROLink = _curROLink; + + ExpandNode(_curROLink.ROID); + } } else // insert - clear out controls { _curROLink = value; tbROValue.Text = null; - lbROId.Text = ""; + lbROId.Text = string.Empty; tvROFST.SelectedNode = null; - btnGoToRO.Enabled = btnSaveRO.Enabled = btnCancelRO.Enabled = false; + + btnGoToRO.Enabled = false; + btnSaveRO.Enabled = false; + btnCancelRO.Enabled = false; } } } @@ -150,53 +188,51 @@ namespace Volian.Controls.Library get { return _myRTB; } set { - if (!Visible) return; // don't reset anything if the form is invisible. + //if (_myRTB != null) + //{ + // MyRTB.LinkChanged -= new StepRTBLinkEvent(MyRTB_LinkChanged); + // MyRTB.SelectionChanged -= new EventHandler(MyRTB_SelectionChanged); + //} - int origRoDbId = -1; - if (_myRTB != null) + if (value == null) { - _myRTB.LinkChanged -= new StepRTBLinkEvent(MyRTB_LinkChanged); - _myRTB.SelectionChanged -= new EventHandler(MyRTB_SelectionChanged); - - if (_myRTB.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) - { - origRoDbId = _myRTB.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID; - } - } - - if (value == null) return; - - _myRTB = value; - MyRTB.LinkChanged += new StepRTBLinkEvent(MyRTB_LinkChanged); - MyRTB.SelectionChanged+=new EventHandler(MyRTB_SelectionChanged); - - if (MyRTB.MyLinkText == null) - { - CurROLink = null; - _savCurROLink = null; - } - - // Test to see if this myrtf is using the same rofst as the previous. If - // not we may have to reset the ro.fst for the tree if the new working - // draft has a different ro.fst than the original: - if (_myRTB != null && _myRTB.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) - { - if (origRoDbId != _myRTB.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst.RODbID) - { - MyROFST = _myRTB.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst; - LoadTree(); // B2022-026 RO Memory Reduction code - } - } - else if (_myRTB.MyItemInfo.MyDocVersion.DocVersionAssociationCount <= 0) - { - // This docversion doesn't have an rofst associated with it, clear the ro tree. + _myRTB = value; MyROFST = null; - LoadTree(); // B2022-026 RO Memory Reduction code + } + else if(_myRTB != value) + { + _myRTB = value; + + MyRTB.LinkChanged += new StepRTBLinkEvent(MyRTB_LinkChanged); + MyRTB.SelectionChanged += new EventHandler(MyRTB_SelectionChanged); + + if (MyRTB.MyLinkText == null) + { + CurROLink = null; + _savCurROLink = null; + } + + MyROFST = (_myRTB.MyItemInfo.MyDocVersion.DocVersionAssociationCount > 0) ? _myRTB.MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst : null; } } } + public bool IsEnhancedStep + { + get { return (MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep); } + } + + public bool IsNotStep + { + get { return (MyRTB != null && MyRTB.MyItemInfo != null && (MyRTB.MyItemInfo.IsProcedure || MyRTB.MyItemInfo.IsSection)); } + } + + public bool IsInWordDoc + { + get { return (TabControl != null && TabControl.SelectedDisplayTabItem != null && TabControl.SelectedDisplayTabItem.MyDSOTabPanel != null); } + } + public static UserInfo MyUserInfo { get { return _myUserInfo; } @@ -207,17 +243,23 @@ namespace Volian.Controls.Library #region Constructors - public DisplayRO() + public DisplayRO() { InitializeComponent(); panelRoValue.BackColor = Color.Cornsilk; panelValue.BackColor = Color.Cornsilk; + _currRofstID = null; + _currDocVersionID = null; + + _isInitializedRofstID = false; + _isInitializedDocVersionID = false; + if (_searchTimer == null) { _searchTimer = new Timer(); - _searchTimer.Interval = 1000; + _searchTimer.Interval = 500; _searchTimer.Tick += new EventHandler(SelectionTimer_Tick); _searchTimer.Stop(); } @@ -271,13 +313,15 @@ namespace Volian.Controls.Library public void MyRTB_SelectionChanged(object sender, EventArgs e) { - _timeActivity.Open(); + _timeActivity.Open(); _searchTimer.Stop(); - if (!string.IsNullOrEmpty(MyRTB.SelectedText)) - { - _searchTimer.Start(); - } + _searchTimer.Start(); + + //if (!string.IsNullOrEmpty(MyRTB.SelectedText)) + //{ + // _searchTimer.Start(); + //} _timeActivity.Close(); } @@ -287,18 +331,11 @@ namespace Volian.Controls.Library // Stop the timer _searchTimer.Stop(); - // Jake [2022.05.11]: Added try catch to prevent unhandled exception when the timer ticks and - // tries to process a search while the main tab/procedure is closing - try + // Process RO Search + if (MyRTB != null && !MyRTB.IsDisposed) { - // Process RO Search - if (MyRTB != null) - { - ProcessSearch(MyRTB.SelectedText, (int)ROFSTLookup.SearchType.StartsWith); - } - + ProcessSearch(MyRTB.SelectedText, (int)ROFSTLookup.SearchTypes.StartsWith); } - catch { } } #endregion @@ -308,10 +345,10 @@ namespace Volian.Controls.Library private void tvROFST_DoubleClick(object sender, EventArgs e) { // B2016-132: don't process a double click on an RO if on an enhanced step: - if (MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep) - return; - - SaveRO(); + if (!IsEnhancedStep) + { + SaveRO(); + } } private void tvROFST_BeforeExpand(object sender, TreeViewCancelEventArgs e) @@ -322,7 +359,7 @@ namespace Volian.Controls.Library private void tvROFST_AfterSelect(object sender, TreeViewEventArgs e) { tbROValue.Text = null; - lbROId.Text = ""; + lbROId.Text = string.Empty; btnCancelRO.Enabled = false; btnSaveRO.Enabled = false; btnPreviewRO.Enabled = false; @@ -336,26 +373,19 @@ namespace Volian.Controls.Library if (chld.value != null) { RoUsageInfo SavROLink = null; - if (_savCurROLink != null) SavROLink = _savCurROLink; + if (_savCurROLink != null) SavROLink = _savCurROLink; lbROId.Text = chld.appid; // Allow the user to select a different return value. - //btnSaveRO.Enabled = ((_savCurROLink == null) || !(chld.roid.Substring(0, 12).ToLower().Equals(SavROLink.ROID.Substring(0, 12).ToLower()))); - //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); - bool isenh = MyRTB != null && MyRTB.MyItemInfo != null && MyRTB.MyItemInfo.IsEnhancedStep; - - //B2017-245 Disable SAveRO button for Procedures and Sections - bool isNotStep = MyRTB != null && MyRTB.MyItemInfo != null && (MyRTB.MyItemInfo.IsProcedure || MyRTB.MyItemInfo.IsSection); + string childroid = string.Format("{0}{1}", chld.roid.ToLower(), "0000").Substring(0, 16); + //B2017-245 Disable SaveRO button for Procedures and Sections //B2020-049: Save button not enabled on Word docs, only if a procedure was opened first and immediately after the word document // section is opened (added 'IsInWorDoc') - bool isInWordDoc = TabControl.SelectedDisplayTabItem.MyDSOTabPanel != null; - btnSaveRO.Enabled = (isInWordDoc || (!isNotStep && !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()); + btnSaveRO.Enabled = (IsInWordDoc || (!IsNotStep && !IsEnhancedStep)) && 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) { case 1: // standard (regular) text RO type @@ -399,7 +429,8 @@ namespace Volian.Controls.Library { _curROLink = _savCurROLink; btnCancelRO.Enabled = false; - UpdateROTree(); + + ExpandNode(_curROLink.ROID); } private void btnPreviewRO_Click(object sender, EventArgs e) @@ -467,7 +498,7 @@ namespace Volian.Controls.Library } else { - ProcessSearch(mytext, (int)ROFSTLookup.SearchType.StartsWith); + ProcessSearch(mytext, (int)ROFSTLookup.SearchTypes.StartsWith); } } } @@ -478,12 +509,12 @@ namespace Volian.Controls.Library private void lbROId_DoubleClick(object sender, EventArgs e) { - if (tvROFST.SelectedNode == null) + if (tvROFST.SelectedNode == null) return; // do not allow writers and reviews to run the RO Editor - if (!UserInfo.CanEditROs(MyUserInfo, MyDvi)) - return; + if (!UserInfo.CanEditROs(MyUserInfo, MyDvi)) + return; if (VlnSettings.ReleaseMode.Equals("DEMO")) { @@ -538,18 +569,138 @@ namespace Volian.Controls.Library #region Public Methods - public void RefreshRoTree() + public void LoadTree() { - _curROFST = null; - _curROFSTLookup = null; - - LoadTree(); - - if (!string.IsNullOrEmpty(_selectedRoidBeforeRoEditor)) + if (MyROFST == null) { - ExpandNode(_selectedRoidBeforeRoEditor); - _selectedRoidBeforeRoEditor = null; + //_curROFST = null; + //_curROFSTLookup = null; + tvROFST.Nodes.Clear(); + lbFound.Visible = false; + return; } + + //if (MyROFST != _curROFST || tvROFST.Nodes == null || tvROFST.Nodes.Count <= 0) + if(RoTreeNeedsReloaded || tvROFST.Nodes == null || tvROFST.Nodes.Count <= 0) + { + ROFSTLookup.rodbi[] dbs = MyROFSTLookup.GetRODatabaseList(true); + + for (int i = 0; i < dbs.Length; i++) + { + ROFSTLookup.rodbi db = dbs[i]; + + TreeNode tn = new TreeNode(db.dbiTitle); + tn.Tag = db; + tvROFST.Nodes.Add(tn); + + AddDummyGroup(db, tn); + } + + _currRofstID = (int?)MyROFST.ROFstID; + _currDocVersionID = null; + if(_docVersionInfo != null) _currDocVersionID = (int?)_docVersionInfo.VersionID; + } + + var unitInfoNode = tvROFST.Nodes.Cast().Where(x => x.Text == "Unit Information").FirstOrDefault(); + + if ((ROTypeFilter == E_ROValueType.Text || ROTypeFilter == E_ROValueType.All) && this.MyDvi != null && this.MyDvi.MultiUnitCount > 1) + { + // Add Unit Information Database if it doesn't exist + if (unitInfoNode == null) + { + TreeNode tnn = tvROFST.Nodes.Add("Unit Information"); + + TreeNode cn = tnn.Nodes.Add("Number"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000001"); + + cn = tnn.Nodes.Add("Other Number"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000002"); + + cn = tnn.Nodes.Add("Text"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000003"); + + cn = tnn.Nodes.Add("Other Text"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000004"); + + cn = tnn.Nodes.Add("ID"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000005"); + + cn = tnn.Nodes.Add("Other ID"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000006"); + + cn = tnn.Nodes.Add("Name"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000007"); + + cn = tnn.Nodes.Add("Other Name"); + cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000008"); + } + } + else if (unitInfoNode != null) // Add Unit Information Database if it doesn't exist [Not Multi-Unit DocVersion] + { + tvROFST.Nodes.Remove(unitInfoNode); + } + + _curROTypeFilter = _roTypeFilter; + + + //if (MyROFST != _curROFST || MyROFSTLookup != _curROFSTLookup || tvROFST.Nodes == null || tvROFST.Nodes.Count <= 0) + //{ + // ROFSTLookup.rodbi[] dbs = MyROFSTLookup.GetRODatabaseList(true); + + // for (int i = 0; i < dbs.Length; i++) + // { + // ROFSTLookup.rodbi db = dbs[i]; + + // TreeNode tn = new TreeNode(db.dbiTitle); + // tn.Tag = db; + // tvROFST.Nodes.Add(tn); + + // AddDummyGroup(db, tn); + // } + //} + + //var unitInfoNode = tvROFST.Nodes.Cast().Where(x => x.Text == "Unit Information").FirstOrDefault(); + + //if ((ROTypeFilter == E_ROValueType.Text || ROTypeFilter == E_ROValueType.All) && this.MyDvi != null && this.MyDvi.MultiUnitCount > 1) + //{ + // // Add Unit Information Database if it doesn't exist + // if (unitInfoNode == null) + // { + // TreeNode tnn = tvROFST.Nodes.Add("Unit Information"); + + // TreeNode cn = tnn.Nodes.Add("Number"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000001"); + + // cn = tnn.Nodes.Add("Other Number"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000002"); + + // cn = tnn.Nodes.Add("Text"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000003"); + + // cn = tnn.Nodes.Add("Other Text"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000004"); + + // cn = tnn.Nodes.Add("ID"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000005"); + + // cn = tnn.Nodes.Add("Other ID"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000006"); + + // cn = tnn.Nodes.Add("Name"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000007"); + + // cn = tnn.Nodes.Add("Other Name"); + // cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000008"); + // } + //} + //else if (unitInfoNode != null) // Add Unit Information Database if it doesn't exist [Not Multi-Unit DocVersion] + //{ + // tvROFST.Nodes.Remove(unitInfoNode); + //} + + //_curROFST = _myROFST; + //_curROFSTLookup = _myROFSTLookup; + //_curROTypeFilter = _roTypeFilter; } public void SetFindDocROButton(bool enabled) @@ -560,19 +711,19 @@ namespace Volian.Controls.Library public static bool GreaterValue(string value1, string value2) { Match match1 = _regExGetNumber.Match(value1); - Match match2 = _regExGetNumber.Match(value2); + Match match2 = _regExGetNumber.Match(value2);? - if (match1.Success && !match1.Value.Contains("/") && match2.Success && !match2.Value.Contains("/")) // Compare the numeric value + if (match1.Success && !match1.Value.Contains("/") && match2.Success && !match2.Value.Contains("/")) // Compare the numeric value? { double dbl1; double dbl2; - //B2017-232 changed from Parse to TryParse. AEP had figure title that had a number containing two periods which caused Parse to error - if (double.TryParse(match1.ToString(), out dbl1) && double.TryParse(match2.ToString(), out dbl2)) - { - if (dbl1 != dbl2) //B2021-144 if the numerical is identical default to the string comparison - return dbl1 > dbl2; - } + //B2017-232 changed from Parse to TryParse. AEP had figure title that had a number containing two periods which caused Parse to error? + if (double.TryParse(match1.ToString(), out dbl1) && double.TryParse(match2.ToString(), out dbl2))? + {? + if (dbl1 != dbl2) //B2021-144 if the numerical is identical default to the string comparison? + return dbl1 > dbl2;? + }? } return string.Compare(value1, value2, true) > 0; @@ -580,171 +731,73 @@ namespace Volian.Controls.Library #endregion - #region Private Methods - - public void LoadTree() - { - if (_myROFST == null) - { - tvROFST.Nodes.Clear(); - _curROFST = null; - _curROFSTLookup = null; - return; - } - - if (MyROFST ==_curROFST && ROTypeFilter == _curROTypeFilter && MyROFSTLookup == _curROFSTLookup) - return; - - //_MyLog.WarnFormat("Load Tree \r\n_curROfst = {0}\r\n MyROFST {1}", _curROFST,MyROFST); - //_MyLog.WarnFormat("{0}", Volian.Base.Library.vlnStackTrace.StackToStringLocal(2, 3)); - - tvROFST.Nodes.Clear(); - - _myROFSTLookup = new ROFSTLookup(MyROFST.ROFstID, MyDvi); - - _curROFST = _myROFST; - _curROFSTLookup = _myROFSTLookup; - _curROTypeFilter = _roTypeFilter; - - ROFSTLookup.rodbi[] dbs = MyROFSTLookup.GetRODatabaseList(false); - - for (int i = 0; i < dbs.Length; i++) - { - ROFSTLookup.rodbi db = dbs[i]; - - db.children = MyROFSTLookup.GetRoChildrenByID(db.ID, db.dbiID, true); - - TreeNode tn = new TreeNode(db.dbiTitle); - tn.Tag = db; - tvROFST.Nodes.Add(tn); - - AddDummyGroup(db, tn); - } - - if ((ROTypeFilter == E_ROValueType.Text || ROTypeFilter == E_ROValueType.All) && this.MyDvi != null && this.MyDvi.MultiUnitCount > 1) - { - TreeNode tnn = tvROFST.Nodes.Add("Unit Information"); - TreeNode cn = tnn.Nodes.Add("Number"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000001"); - cn = tnn.Nodes.Add("Other Number"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000002"); - cn = tnn.Nodes.Add("Text"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000003"); - cn = tnn.Nodes.Add("Other Text"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000004"); - cn = tnn.Nodes.Add("ID"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000005"); - cn = tnn.Nodes.Add("Other ID"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000006"); - cn = tnn.Nodes.Add("Name"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000007"); - cn = tnn.Nodes.Add("Other Name"); - - cn.Tag = MyROFSTLookup.GetRoChild("FFFF00000008"); - } - //else - //{ - // _MyLog.Warn("Unit Designtor not loaded"); - // _MyLog.Warn(Volian.Base.Library.vlnStackTrace.StackToStringLocal(2,3)); - //} - } + #region Private Methods? private void LoadChildren(TreeNode tn) { //Check if node has already been loaded - if (tn.FirstNode != null && tn.FirstNode.Text != DummyNodeText) - return; + if (tn.FirstNode != null && tn.FirstNode.Text != DummyNodeText) return; + if (tn.FirstNode != null && tn.FirstNode.Text == DummyNodeText) tn.FirstNode.Remove(); - if (tn.FirstNode != null && tn.FirstNode.Text == DummyNodeText) - tn.FirstNode.Remove(); - - - object tag = tn.Tag; - - ROFSTLookup.rochild[] chld = null; + //object tag = tn.Tag; + ROFSTLookup.rochild[] children = null; if (tn.Tag is ROFSTLookup.rodbi) { ROFSTLookup.rodbi db = (ROFSTLookup.rodbi)tn.Tag; - chld = db.children; + MyROFSTLookup.LoadChildren(ref db); + children = db.children; } else if (tn.Tag is ROFSTLookup.rochild) { ROFSTLookup.rochild ch = (ROFSTLookup.rochild)tn.Tag; - - if (!string.IsNullOrEmpty(ch.appid)) - { - ch = MyROFSTLookup.GetRoChild(ch.roid); - } - else if (ch.children == null || ch.children.Length <= 0) - { - ch.children = MyROFSTLookup.GetRoChildrenByRoid(ch.roid, true); - } - - chld = ch.children; - } - else - { - Console.WriteLine("error - no type"); - return; + MyROFSTLookup.LoadChildren(ref ch); + children = ch.children;? } + // if children, add dummy node - if (chld != null && chld.Length > 0) - { - ProgressBar_Initialize(chld.Length, tn.Text); + if (children != null && children.Length > 0) + {? + //ProgressBar_Initialize(children.Length, tn.Text); - for (int i = 0; i < chld.Length; i++) + for (int i = 0; i < children.Length; i++) { - ProgressBar_SetValue(i); - TreeNode tmp = null; + //ProgressBar_SetValue(i); + TreeNode tmp = null;? + ROFSTLookup.rochild roc = children[i]; + // if this is a group, i.e. type 0, add a dummy node - if (chld[i].type == 0 && chld[i].children == null) + if (roc.type == 0 && !MyROFSTLookup.HasChildren(ref roc)) { - //skip it. - // TODO: KBR how to handle this? - //Console.WriteLine("ro junk"); - continue; + continue; // Ignore: Junk Scenario } - else if (ROTypeFilter != E_ROValueType.All && (chld[i].type & (uint)ROTypeFilter) == 0) + else if (ROTypeFilter != E_ROValueType.All && (roc.type & (uint)ROTypeFilter) == 0)? { - continue; // ignore if does not match filter + continue; // Ignore: Filter Doesn't Match } - else if (chld[i].value == null) + else if (roc.value == null) { - if (!string.IsNullOrEmpty(chld[i].appid)) - { - chld[i] = MyROFSTLookup.GetRoChild(chld[i].roid); - } - else if (chld[i].children == null || chld[i].children.Length <= 0) - { - chld[i].children = MyROFSTLookup.GetRoChildrenByRoid(chld[i].roid, true); - } + MyROFSTLookup.LoadChildren(ref roc); + + tmp = new TreeNode(roc.title); + tmp.Tag = roc; - tmp = new TreeNode(chld[i].title); - tmp.Tag = chld[i]; - //tn.Nodes.Add(tmp); int index = FindIndex(tn.Nodes, tmp.Text); tn.Nodes.Insert(index, tmp); + TreeNode sub = new TreeNode(DummyNodeText); tmp.Nodes.Add(sub); } else { - string ntitle = chld[i].title.Replace(@"\u160?", " "); + string ntitle = roc.title.Replace(@"\u160?", " "); ntitle = GetPCDefaultValue(ntitle); // C2021-026 get the default RO value from P/C RO value information tmp = new TreeNode(ntitle); - tmp.Tag = chld[i]; + tmp.Tag = roc; - if (chld[i].roid.Length == 16) + if (roc.roid.Length == 16) { tn.Nodes.Add(tmp); } @@ -757,12 +810,12 @@ namespace Volian.Controls.Library } } - ProgressBar_Clear(); + //ProgressBar_Clear(); } private void AddDummyGroup(ROFSTLookup.rodbi rodbi, TreeNode tn) { - if (rodbi.children != null && rodbi.children.Length > 0) + if (MyROFSTLookup.HasChildren(ref rodbi)) { TreeNode tmp = new TreeNode(DummyNodeText); tn.Nodes.Add(tmp); @@ -772,14 +825,11 @@ namespace Volian.Controls.Library private void ExpandNode(string roid) { string db = roid.Substring(0, 4); - bool multValSel = false; - - if (roid.Length == 16) - multValSel = true; + int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roid); + bool multValSel = (roid.Length == 16) ? true : false; ROFSTLookup.rochild rochld = MyROFSTLookup.GetRoChild(roid.Substring(0, 12).ToUpper()); - // use this to walk up tree until database - this is used to expand tree. List path = new List(); int myid = rochld.ID; @@ -788,46 +838,35 @@ namespace Volian.Controls.Library { path.Insert(0, myid); myid = rochld.ParentID; - string pROID = string.Format("{0}{1:X08}", db, myid); + string pROID = string.Format("{0:X04}{1:X08}", db, myid); rochld = MyROFSTLookup.GetRoChild(pROID); if (rochld.ID == -1) myid = -1; } TreeNode tnExpand = null; - int titm = System.Convert.ToInt32(db, 16); //(db); - // find database first - foreach (TreeNode tn in tvROFST.Nodes) + + //Find Database Node First + TreeNode dbNode = tvROFST.Nodes.Cast().Where(x => (x.Tag is ROFSTLookup.rodbi) && ((ROFSTLookup.rodbi)x.Tag).dbiID == dbiID).FirstOrDefault(); + if (dbNode != null) { - if (tn.Tag != null) - { - ROFSTLookup.rodbi thisdb = (ROFSTLookup.rodbi)tn.Tag; - - if (thisdb.dbiID == titm) - { - LoadChildren(tn); - tnExpand = tn; - break; - } - } + LoadChildren(dbNode); + tnExpand = dbNode; } - if (tnExpand == null) return; // something went wrong? - - // use the path id list to load/find the treeview's nodes. - foreach (int citm in path) + if (tnExpand != null) { - LoadChildren(tnExpand); - tnExpand.Expand(); - - foreach (TreeNode tn in tnExpand.Nodes) + // use the path id list to load/find the treeview's nodes. + foreach (int citm in path) { - ROFSTLookup.rochild chld = (ROFSTLookup.rochild)tn.Tag; - if (chld.ID == citm) + LoadChildren(tnExpand); + tnExpand.Expand(); + + TreeNode chldNode = tnExpand.Nodes.Cast().Where(x => (x.Tag is ROFSTLookup.rochild) && ((ROFSTLookup.rochild)x.Tag).ID == citm).FirstOrDefault(); + if (chldNode != null) { - tnExpand = tn; - break; + tnExpand = chldNode; } } } @@ -840,28 +879,15 @@ namespace Volian.Controls.Library LoadChildren(tnExpand); tnExpand.Expand(); - foreach (TreeNode tn in tnExpand.Nodes) + TreeNode chldNode = tnExpand.Nodes.Cast().Where(x => ((ROFSTLookup.rochild)x.Tag).roid.ToUpper() == roid.ToUpper()).FirstOrDefault(); + if (chldNode != null) { - if (tn.Tag != null) - { - ROFSTLookup.rochild chld = (ROFSTLookup.rochild)tn.Tag; - - if (chld.roid.ToUpper() == roid.ToUpper()) - { - tnExpand = tn; - break; - } - } + tnExpand = chldNode; } } - - tvROFST.SelectedNode = tnExpand; } - } - private void UpdateROTree() - { - ExpandNode(_curROLink.ROID); + tvROFST.SelectedNode = tnExpand; } private string GetPCDefaultValue(string roval) @@ -879,7 +905,7 @@ namespace Volian.Controls.Library int endDefIdx = rntval.IndexOf(",", startCVIdx); // C2022-001 - handle if there is no child value in the RO FSt - // B2022-051 - was sometimes leaving "/APL>" when processing return value maded up from multiple RO (editor) fields + // B2022-051 - was sometimes leaving "/APL>" when processing return value made up from multiple RO (editor) fields // added check to make where next found comma was within the current string defValue = rntval.Substring(startCVIdx + 16, ((endDefIdx > 0 && endDefIdx < EndCVidx) ? endDefIdx : EndCVidx) - (startCVIdx + 16)); rntval = rntval.Replace(aplicValues, defValue); @@ -915,33 +941,29 @@ namespace Volian.Controls.Library if (obj is ROFSTLookup.rochild) { - ROFSTLookup.rochild roch = (ROFSTLookup.rochild)obj; + ROFSTLookup.rochild roc = (ROFSTLookup.rochild)obj; DisplayTabItem dti = TabControl.SelectedDisplayTabItem; //.OpenItem(_ItemInfo); // open the corresponding procedure text if (dti.MyDSOTabPanel != null) // A Word Document tab is the active tab { - int dbiId = System.Convert.ToInt32(roch.roid.Substring(0, 4), 16); - ROFSTLookup.rodbi[] dbs = MyROFSTLookup.GetRODatabaseList(false); - bool dbFound = false; - ROFSTLookup.rodbi db = dbs[0]; + string AccPageID = string.Empty; - foreach (ROFSTLookup.rodbi rodbi in dbs) + if (roc.roid.StartsWith("FFFF")) { - if (dbiId == rodbi.dbiID) - { - db = rodbi; - dbFound = true; - break; - } + AccPageID = "<" + roc.appid + ">"; } - - string AccPageID; - - if (!dbFound) + else { - if (roch.roid.StartsWith("FFFF")) + int dbiID = MyROFSTLookup.GetRODatabaseTitleIndex(roc.roid); + ROFSTLookup.rodbi db = MyROFSTLookup.GetRODatabase(roc.roid, true, false); + + if (db.dbiID == dbiID) { - AccPageID = "<" + roch.appid + ">"; + string accPrefix = db.dbiAP.Replace(MyDvi.DocVersionConfig.RODefaults_graphicsprefix, "IG"); + accPrefix = accPrefix.Replace(MyDvi.DocVersionConfig.RODefaults_setpointprefix, "SP"); + + string suffix = (roc.roid.Length == 12 || roc.roid.Substring(12, 4) == "0041") ? string.Empty : "." + ((char)Convert.ToInt32(roc.roid.Substring(12, 4), 16)).ToString(); + AccPageID = string.Format("<{0}-{1}{2}>", accPrefix, roc.appid, suffix);// makes for example } else { @@ -949,49 +971,48 @@ namespace Volian.Controls.Library return; } } - else - { - string accPrefix = db.dbiAP.Replace(MyDvi.DocVersionConfig.RODefaults_graphicsprefix, "IG"); - accPrefix = accPrefix.Replace(MyDvi.DocVersionConfig.RODefaults_setpointprefix, "SP"); - // string accPrefix = (roch.type == 8) ? _Mydvi.DocVersionConfig.RODefaults_graphicsprefix : _Mydvi.DocVersionConfig.RODefaults_setpointprefix; - string suffix = (roch.roid.Length == 12 || roch.roid.Substring(12, 4) == "0041") ? "" : "." + ((char)Convert.ToInt32(roch.roid.Substring(12, 4), 16)).ToString(); - AccPageID = string.Format("<{0}-{1}{2}>", accPrefix, roch.appid, suffix);// makes for example - Console.WriteLine(AccPageID); - } // Insert the RO text at the current cursor position in the word document // NOTE: assuming any type of RO can be put in an Accessory (MSWord) Document if (dti.MyDSOTabPanel != null) + { dti.MyDSOTabPanel.InsertText(AccPageID); + } + } else if (MyRTB != null) // a Procedure Steps section tab is active { - if (CheckROSelection(roch)) // check for RO type is valid for this type of step/substep + if (CheckROSelection(roc)) // check for RO type is valid for this type of step/substep { // the roid may be 12 or 16 chars long, with the last 4 set if there is unit specific // menuing. Pad to 12 to store in the rousage table. - string padroid = (roch.roid.Length <= 12) ? roch.roid + "0000" : roch.roid; - string linktxt = string.Format(@"#Link:ReferencedObject: {0} {1}", padroid, _myROFST.MyRODb.RODbID); + string padroid = (roc.roid.Length <= 12) ? roc.roid + "0000" : roc.roid; + string linktxt = string.Format(@"#Link:ReferencedObject: {0} {1}", padroid, MyROFST.RODbID); + // Resolve symbols and scientific notation in the RO return value - string valtxt = _myROFSTLookup.GetTranslatedRoValue(padroid, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues); //ConvertSymbolsAndStuff(selectedChld.value); - MyRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, selectedChld.value, linktxt, padroid, _myROFST.MyRODb.RODbID)); + string valtxt = MyROFSTLookup.GetTranslatedRoValue(padroid, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, MyRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues); + + MyRTB.OnRoInsert(this, new StepRTBRoEventArgs(valtxt, selectedChld.value, linktxt, padroid, MyROFST.RODbID)); } - btnGoToRO.Enabled = btnSaveRO.Enabled = btnCancelRO.Enabled = btnPreviewRO.Enabled = false; - _savCurROLink = null; + btnGoToRO.Enabled = false; + btnSaveRO.Enabled = false; + btnCancelRO.Enabled = false; + btnPreviewRO.Enabled = false; + CurROLink = null; + _savCurROLink = null; } } - - ProcessSearch(string.Empty, (int)ROFSTLookup.SearchType.StartsWith); } private bool CheckROSelection(ROFSTLookup.rochild selectedRO) { bool goodToGo = true; bool replacingRO = (_savCurROLink != null); + string insrpl = (replacingRO) ? "Cannot Replace" : "Cannot Insert"; - string errormsg = ""; + string errormsg = string.Empty; switch (selectedRO.type) { @@ -1058,9 +1079,10 @@ namespace Volian.Controls.Library if (obj is ROFSTLookup.rochild) { - ROFSTLookup.rochild roch = (ROFSTLookup.rochild)obj; - _selectedRoidBeforeRoEditor = roch.roid; - string args = "\"" + _myROFST.MyRODb.FolderPath + "\" " + roch.roid.ToLower(); + ROFSTLookup.rochild roc = (ROFSTLookup.rochild)obj; + _selectedRoidBeforeRoEditor = roc.roid; + + string args = "\"" + _myROFST.MyRODb.FolderPath + "\" " + roc.roid.ToLower(); if (!Directory.Exists(_myROFST.MyRODb.FolderPath)) { @@ -1070,10 +1092,10 @@ namespace Volian.Controls.Library // C2017-003: ro data in sql server, check for sql connection string if (_myROFST.MyRODb.DBConnectionString != "cstring") args = args + " \"" + _myROFST.MyRODb.DBConnectionString + "\""; + // C2021-026 pass in Parent/Child information (list of the children) // B2022-019 look at all DocVersions to find ParentChild information // to ensure we pass in Parent/Child even when not coming from a Parent/Child procedure set - DocVersionInfoList dvil = DocVersionInfoList.Get(); foreach (DocVersionInfo dvi in dvil) @@ -1094,47 +1116,58 @@ namespace Volian.Controls.Library private void ProcessSearch(string searchValue, int searchTypeID) { - lbFound.SelectedValueChanged -= new EventHandler(lbFound_SelectedValueChanged); - - if (!string.IsNullOrEmpty(searchValue)) + // Jake [2022.05.11]: Added try catch to prevent unhandled exception when the timer ticks and + // tries to process a search while the main tab/procedure is closing + try { - Dictionary dicRoVals = new Dictionary(); + if (!this.Enabled) + searchValue = string.Empty; - searchValue = searchValue.Replace('\u2011', '-').Replace(@"\u9586?", @"\\"); - - if (MyROFST != null && searchValue.Length >= 2) + if (!string.IsNullOrEmpty(searchValue)) { - dicRoVals = new ROFSTLookup(MyROFST.ROFstID, MyDvi).Search(searchValue, searchTypeID, MaxNumSearchRecords); - } + Dictionary dicRoVals = new Dictionary(); + searchValue = searchValue.Replace('\u2011', '-').Replace(@"\u9586?", @"\\"); - if (dicRoVals != null && dicRoVals.Count > 0) - { - lbFound.DataSource = new BindingSource(dicRoVals, null); - lbFound.ValueMember = "Key"; // roid - lbFound.DisplayMember = "Value"; // default value + if (_lastSearchValue != searchValue) + { + if (MyROFST != null && searchValue.Length >= 2) + { + dicRoVals = MyROFSTLookup.Search(searchValue, searchTypeID, MaxNumSearchRecords); + } - lbFound.SelectionMode = SelectionMode.One; - lbFound.SelectedIndex = -1; - lbFound.Visible = true; + if (dicRoVals != null && dicRoVals.Count > 0) + { + lbFound.SelectedValueChanged -= new EventHandler(lbFound_SelectedValueChanged); + + lbFound.DataSource = new BindingSource(dicRoVals, null); + lbFound.ValueMember = "Key"; // roid + lbFound.DisplayMember = "Value"; // default value + + lbFound.SelectionMode = SelectionMode.One; + lbFound.SelectedIndex = -1; + lbFound.Visible = true; + + lbFound.SelectedValueChanged += new EventHandler(lbFound_SelectedValueChanged); + + if (lbFound.Items != null && lbFound.Items.Count == 1) + lbFound.SelectedIndex = 0; + } + else + { + lbFound.DataSource = null; + lbFound.Visible = false; + } + } } else { lbFound.DataSource = null; lbFound.Visible = false; } + + _lastSearchValue = searchValue; } - else - { - lbFound.DataSource = null; - lbFound.Visible = false; - } - - lbFound.SelectedValueChanged += new EventHandler(lbFound_SelectedValueChanged); - - if (lbFound.Items != null && lbFound.Items.Count == 1) - lbFound.SelectedIndex = 0; - - _lastSearchValue = searchValue; + catch { } } #endregion diff --git a/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs b/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs index 74c4e036..20252298 100644 --- a/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs +++ b/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs @@ -339,7 +339,7 @@ namespace Volian.Print.Library { foreach (ROCheck roc in pi.MyDifferences.ROConsistency.MyROChecks) { - ROFSTLookup.rochild rocc = lu.GetRoChild12(roc.ROID); + ROFSTLookup.rochild rocc = lu.GetRoChild(roc.ROID); if (rocc.type == 1) { string newROValue = lu.GetRoValue(roc.ROID).Replace('`', '\xb0');