From 78add0ccd20c2ff70bdfe6ccf1add241f7a8c5bb Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 1 Jul 2013 17:39:15 +0000 Subject: [PATCH] Added a missing MAXRECURSION 10000 Changed Through Transition Format and User Interface Added Automatic Print Options to shutoff DebugText (/NT), DebugPagination (/NP) and Compare (/NC) Added logic to allow the use of the default path for PDFs. Update the Print_PDFLocation property of the Working Draft when the user changes the value on the Working Draft property page. Fixed Bug B2013-117 Set the date/time stamp for the Document based upon the current time. Make sure that the output is set to Final without revisions and comments before ROs are replaced. Added function to restore valid previous version of MSWord document if the current version is not a valid document. Check for Null to eliminate errors. Removed Unused field DocPDF Support MSWord document restore function. Add check for Transition Node count before updating values. Restore latest valid MSWord document if the current version is not valid. Eliminate File Commands so that the user can only close the MSWord section, and then verify if the changes to the document will be saved. --- PROMS/DataLoader/PROMSFixes.Sql | 1 + .../DlgPrintProcedure.cs | 12 ++ .../frmVersionsProperties.cs | 8 +- .../Extension/DocumentExt.cs | 115 ++++++++++++++++-- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 2 +- .../Generated/DocumentAuditInfo.cs | 12 -- PROMS/Volian.Controls.Library/DSOTabPanel.cs | 43 +++++-- .../Volian.Controls.Library/DisplayTabItem.cs | 4 +- .../DisplayTransition.cs | 1 + PROMS/fmtxml/WST1all.xml | Bin 93858 -> 93698 bytes PROMS/fmtxml/WST2all.xml | Bin 84480 -> 84254 bytes PROMS/fmtxml/WSTALRall.xml | Bin 58064 -> 57834 bytes PROMS/fmtxml/WSTBCKall.xml | Bin 73474 -> 73244 bytes 13 files changed, 165 insertions(+), 33 deletions(-) diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index 07ea20f4..cee6bbca 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -5793,6 +5793,7 @@ select I.[Level],I.[FromType],I.[Ordinal], I.[ParentID], I.[ItemID],I.[PreviousI join Contents C on C.ContentID = I.ContentID where i.apple = 1 order by I.[Level] , I.[FromType], I.[Ordinal] + OPTION (MAXRECURSION 10000) END GO -- Display the status of Procedure Creation diff --git a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs index 0a4d1cce..d6512b48 100644 --- a/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs +++ b/PROMS/VEPROMS User Interface/DlgPrintProcedure.cs @@ -26,6 +26,17 @@ namespace VEPROMS cbxDebugPagination.Checked = true; cbxDebugText.Checked = true; Application.DoEvents(); + string[] parameters = System.Environment.CommandLine.Split(" ".ToCharArray()); + bool ranAuto = false; + foreach (string parameter in parameters) + { + if (parameter.ToUpper() == "/NT") + cbxDebugText.Checked = false; + else if (parameter.ToUpper() == "/NP") + cbxDebugPagination.Checked = false; + else if (parameter.ToUpper() == "/NC") + cbxDebug.Checked = false; + } CreatePDFs(); this.Close(); } @@ -566,6 +577,7 @@ namespace VEPROMS newPDFPath = PDFPath + @"\" + MyProcedure.MyDocVersion.DocVersionConfig.Unit_Text; if (_MultiunitPdfLocation == "Unit ID") newPDFPath = PDFPath + @"\" + MyProcedure.MyDocVersion.DocVersionConfig.Unit_ID; + if (newPDFPath == "") newPDFPath = Volian.Base.Library.VlnSettings.TemporaryFolder; if (!Directory.Exists(newPDFPath)) Directory.CreateDirectory(newPDFPath); return newPDFPath; diff --git a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs index ba311356..e28f8751 100644 --- a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs +++ b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs @@ -341,10 +341,16 @@ namespace VEPROMS btnApplicability.Visible = false; tiApplicability.Visible = false; } + ppTxtBxPDFLoc.TextChanged += new EventHandler(ppTxtBxPDFLoc_TextChanged); //end add new applicability stuff _Initializing = false; } - + // The following code was added to fix Bug B2013-117 + void ppTxtBxPDFLoc_TextChanged(object sender, EventArgs e) + { + if (_Initializing == false) + _DocVersionConfig.Print_PDFLocation = ppTxtBxPDFLoc.Text; + } #region General tab /// diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 220b4cd5..f54723e0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -34,6 +34,16 @@ namespace VEPROMS.CSLA.Library return _LibTitle; } } + private static LBApplicationClass _MyApp = null; + public static LBApplicationClass MyApp + { + get + { + if (_MyApp == null) + _MyApp = new LBApplicationClass(); + return _MyApp; + } + } public void UpdateDRoUsages(List roids) { _DocumentDROUsageCount = -1; @@ -57,6 +67,94 @@ namespace VEPROMS.CSLA.Library DocumentDROUsages.Add(parts[1], RODb.GetJustRoDb(int.Parse(parts[0]))); } } + private int _Unique = 0; + private string Unique + { + get + { + string retval = ""; + if (_Unique != 0) retval = "_" + _Unique.ToString(); + _Unique++; + return retval; + } + } + public void StatusChanged(VolianStatusType type, int count, string text) + { + //if (Parent != null && Parent.Parent != null && Parent.Parent.Parent is DisplayTabControl) + //{ + // DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl; + // tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text)); + //} + } + public void RestoreWordDoc(ItemInfo myItemInfo) + { + DocumentAuditInfo savDocAuditInfo = null; + using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(DocID)) + { + if (dail.Count > 0) + { + DocumentAuditInfo dai = dail[0]; + foreach (DocumentAuditInfo tmpa in dail) + { + FileInfo tmpFile = new FileInfo(string.Format(@"{0}\tmp_{1}{2}{3}", VlnSettings.TemporaryFolder, DocID, Unique, tmpa.FileExtension)); + while (tmpFile.Exists) + { + tmpFile = new FileInfo(string.Format(@"{0}\tmp_{1}{2}{3}", VlnSettings.TemporaryFolder, DocID, Unique, tmpa.FileExtension)); + } + FileStream fs = tmpFile.Create(); + if (tmpa.DocContent != null) fs.Write(tmpa.DocContent, 0, tmpa.DocContent.Length); + fs.Close(); + LBDocumentClass myDoc = null; + try + { + myDoc = MyApp.Documents.Open(tmpFile.FullName, false); + savDocAuditInfo = tmpa; + myDoc.Close(); + break; + } + catch (Exception ex) + { + if (myDoc != null) myDoc.Close(); + continue; // get next document audit item. + } + } + } + if (savDocAuditInfo != null) + { + FileExtension = savDocAuditInfo.FileExtension; + DocContent = savDocAuditInfo.DocContent; + DocAscii = savDocAuditInfo.DocAscii; + Config = savDocAuditInfo.Config; + UserID = savDocAuditInfo.UserID; + DTS = savDocAuditInfo.DTS; + Save(); + List roids = new List(); + DocumentInfo docinfo = DocumentInfo.Get(DocID); + + string pdfTmp = MSWordToPDF.ToPDFReplaceROs(docinfo, roids, myItemInfo, StatusChanged); + FileInfo pdfFile = new FileInfo(pdfTmp); + FileStream fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + Byte[] buf = new byte[pdfFile.Length]; + fs.Read(buf, 0, buf.Length); + fs.Close(); + pdfFile.Delete(); + Pdf.DeleteAll(DocID); // clear the PDF table for DocID first + DocStyle myDocStyle = myItemInfo.ActiveSection.MyDocStyle; + SectionConfig sc = myItemInfo.ActiveSection.MyConfig as SectionConfig; + if (sc != null && sc.Section_WordMargin == "Y") + { + using (Pdf myPdf = Pdf.MakePdf(this, MSWordToPDF.DebugStatus, 0, 0, 0, 0, (double)myItemInfo.MSWordPageCount, buf)) { ;} + } + else + { + using (Pdf myPdf = Pdf.MakePdf(this, MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopMargin, (int)myDocStyle.Layout.PageLength, + (int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth, (double)myItemInfo.MSWordPageCount, buf)) { ;} + } + UpdateDRoUsages(roids); + Save(); + } + } + } /// /// FixString processes the string returned and changes any symbols (0xF0??) to normal characters /// @@ -417,7 +515,8 @@ namespace VEPROMS.CSLA.Library cfg.Edit_Initialized = true; doc.Config = cfg.ToString(); doc.UserID = Volian.Base.Library.VlnSettings.UserID; - doc.DTS = _MyFile.LastWriteTimeUtc; + //doc.DTS = _MyFile.LastWriteTimeUtc; + doc.DTS = DateTime.Now.ToUniversalTime(); doc = doc.Save(); List roids = new List(); string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument, roids, myItemInfo,statusChange); @@ -658,7 +757,7 @@ namespace VEPROMS.CSLA.Library LBRange myRange = selxy.Paragraphs.First.Range; float yTop = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage); float yTop1 = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToTextBoundary); - + // some data had regular text embedded in the xyplot definition. If so, the plain text must // be left in the file. Otherwise, we can replace with empty text. string resXyPlot = xyplot; @@ -670,8 +769,8 @@ namespace VEPROMS.CSLA.Library } else { - selxy.Text = ""; - if (cnt>0)for (int icnt = 0; icnt < cnt; icnt++) selxy.Text = selxy.Text + "\r"; + selxy.Text = ""; + if (cnt > 0) for (int icnt = 0; icnt < cnt; icnt++) selxy.Text = selxy.Text + "\r"; } pngFile = VlnSettings.TemporaryFolder + @"\XYPlot" + filecount.ToString() + @".png"; //@"C:\Temp\XYPlot1.png"; @@ -694,6 +793,9 @@ namespace VEPROMS.CSLA.Library if(statusChange != null) statusChange(VolianStatusType.Initialize, sel.End, "Refreshing ROs"); sel = hasRos ? FindRO() : null; int roCount = 0; + // force Print of MS Word Attachment to Final without revisions and comments + myDoc.ActiveWindow.View.ShowRevisionsAndComments = false; + myDoc.ActiveWindow.View.RevisionsView = LBWdRevisionsView.wdRevisionsViewFinal; while (sel != null) { if (statusChange != null) statusChange(VolianStatusType.Update, sel.Start, string.Format("{0} ROs Refreshed", ++roCount)); @@ -817,9 +919,6 @@ namespace VEPROMS.CSLA.Library //sel.Range.Font.Color = (LBWdColor)WordColor(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); sel.Range.Font.Color = (LBWdColor)WordColor(OverrideColor == System.Drawing.Color.Transparent ? System.Drawing.Color.Black : OverrideColor); sect.MSWordPageCount = myDoc.Length; - // force Print of MS Word Attachment to Final without revisions and comments - myDoc.ActiveWindow.View.ShowRevisionsAndComments = false; - myDoc.ActiveWindow.View.RevisionsView = LBWdRevisionsView.wdRevisionsViewFinal; fileName = CreatePDF(fileName, openPdf); MyApp.ActiveDocument.Close(false); if (CloseWordWhenDone) @@ -987,7 +1086,7 @@ namespace VEPROMS.CSLA.Library , _MySection.ItemID, _MySection.MyDocVersion.MyFolder.Name, _MySection.ShortPath); } else - _MyLog.Error("Could not set margins", ex); + _MyLog.Error("Could not set margins", ex); } } } diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index f6c29114..1d7aed22 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -4730,7 +4730,7 @@ namespace VEPROMS.CSLA.Library string tmpstr = indx+1= 0) return -1; + if (tmpstr != null && tmpstr.IndexOf('-') >= 0) return -1; return tmpstr==null?0:System.Convert.ToInt32(tmpstr); } return (-1); diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentAuditInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentAuditInfo.cs index 594606a0..bb2d64b8 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentAuditInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentAuditInfo.cs @@ -180,16 +180,6 @@ namespace VEPROMS.CSLA.Library return _FileExtension; } } - private byte[] _DocPdf; - public byte[] DocPdf - { - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] - get - { - CanReadProperty("DocPdf", true); - return _DocPdf; - } - } private int _DeleteStatus; public int DeleteStatus { @@ -281,7 +271,6 @@ namespace VEPROMS.CSLA.Library _DTS = tmp.DTS; _UserID = tmp.UserID; _FileExtension = tmp.FileExtension; - _DocPdf = tmp.DocPdf; _DeleteStatus = tmp.DeleteStatus; _DocumentAuditInfoExtension.Refresh(this); OnChange();// raise an event @@ -350,7 +339,6 @@ namespace VEPROMS.CSLA.Library _DTS = dr.GetDateTime("DTS"); _UserID = dr.GetString("UserID"); _FileExtension = dr.GetString("FileExtension"); - _DocPdf = (byte[])dr.GetValue("DocPdf"); _DeleteStatus = dr.GetInt32("DeleteStatus"); } catch (Exception ex) diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index b883cf40..5bba3efc 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -90,9 +90,11 @@ namespace Volian.Controls.Library //private frmPG _frm = null; #region Constructors private Timer _RefreshTimer; - public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl) + private ItemInfo _ItemInfo; + public DSOTabPanel(DocumentInfo documentInfo, DisplayTabControl myDisplayTabControl, ItemInfo itemInfo) { _MyDisplayTabControl = myDisplayTabControl; + _ItemInfo = itemInfo; InitializeComponent(); SetupDSOTabPanel(); _MyDocumentInfo = documentInfo; @@ -159,14 +161,23 @@ namespace Volian.Controls.Library { if (dail.Count > 0) { - DocumentAuditInfo dai = dail[0]; - foreach (DocumentAuditInfo tmpa in dail) - { - if (tmpa.DTS > dai.DTS) dai = tmpa; - } + //DocumentAuditInfo dai = dail[0]; + //foreach (DocumentAuditInfo tmpa in dail) + //{ + // if (tmpa.DTS > dai.DTS) dai = tmpa; + //} if(MessageBox.Show("Do you want to revert to a previous version?", "Error in MS Word section", MessageBoxButtons.YesNo, MessageBoxIcon.Question)==DialogResult.Yes) - fs.Write(dai.DocContent, 0, dai.DocContent.Length); + { + //fs.Write(dai.DocContent, 0, dai.DocContent.Length); + using (Document myDoc = Document.Get(MyDocumentInfo.DocID)) + { + myDoc.RestoreWordDoc(_ItemInfo); + _DSOFile = null; + _MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID); + } + } + } else MessageBox.Show("Reverting to Blank Document", "Error in MS Word section", @@ -175,7 +186,20 @@ namespace Volian.Controls.Library fs.Close(); this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName); } - this._MyDSOFramer.Menubar = false; + LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); + Console.WriteLine("Version {0}", doc.Application.Version); + float ver; + if (!float.TryParse(doc.Application.Version, out ver)) + ver = 12.0F; + this._MyDSOFramer.Menubar = ver < 12.0F; + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileClose, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileNew, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFilePageSetup, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFilePrint, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFilePrintPreview, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileProperties, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSave, false); + this._MyDSOFramer.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSaveAs, false); this._MyDSOFramer.Titlebar = false; //if (_MyCount < 20) // this._MyDSOFramer.FrameHookPolicy = DSOFramer.dsoFrameHookPolicy.dsoResetNow; @@ -191,7 +215,6 @@ namespace Volian.Controls.Library //this.GotFocus += new EventHandler(DSOTabPanel_GotFocus); //this.LostFocus += new EventHandler(DSOTabPanel_LostFocus); Application.DoEvents(); - LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); // The following line corrects Symbol characters in MSWord Sections // CheckForSymbolCharacters(doc); InitializeWordDocument(doc); @@ -364,6 +387,8 @@ namespace Volian.Controls.Library return; } LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); + while (doc.Saved = false) + Application.DoEvents(); string tmp = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); if (System.IO.File.Exists(tmp)) MyDSOFile.FullName = tmp; diff --git a/PROMS/Volian.Controls.Library/DisplayTabItem.cs b/PROMS/Volian.Controls.Library/DisplayTabItem.cs index ec17a0db..4f81fda0 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabItem.cs @@ -204,7 +204,7 @@ namespace Volian.Controls.Library private void SetupDSOTabPanel() { EntryInfo myEntry = _MyItemInfo.MyContent.MyEntry; - _MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl); + _MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl, _MyItemInfo); // // tabItem // @@ -228,7 +228,7 @@ namespace Volian.Controls.Library } private void SetupLibraryDocumentDSOTabPanel() { - _MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl); + _MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo); // // tabItem // diff --git a/PROMS/Volian.Controls.Library/DisplayTransition.cs b/PROMS/Volian.Controls.Library/DisplayTransition.cs index f9261507..bec930e8 100644 --- a/PROMS/Volian.Controls.Library/DisplayTransition.cs +++ b/PROMS/Volian.Controls.Library/DisplayTransition.cs @@ -248,6 +248,7 @@ namespace Volian.Controls.Library } // Find sameParent1 in tree, expand down to toItem: + if (tvTran.Nodes.Count == 0) return; tvFillInRangeNodes(path, (VETreeNode)tvTran.Nodes[0], lev1, true); path.Clear(); parRng = rngItem; diff --git a/PROMS/fmtxml/WST1all.xml b/PROMS/fmtxml/WST1all.xml index 70804e31559b47419e41a4855c5e37f8d507c4d5..c4d2ea5b7e022be606aa047dcd397faee56d9296 100644 GIT binary patch delta 92 zcmZ2jtLNliyt8nH+FYYqG&jtLNlOLFKOn$J0WisC>rRfs_8QCV=opzZlaK?^TfgztEjX{B-n!%ny zZ}R(dlFT5Q|AaIvL?rN}@Z<;Q*}$R;FG@}>Ix91o<%}0@ebO2bvlxOIQW=sNN`Pj2 zFr+XPG1M|>PQHIpe6rOAmC0>q>?U8R=9Y)}(? delta 152 zcmbO?iM3%0>xQ0{lQ*PtO@6UNX!3@Yvv?I4@)^>2bXzh5iK45H)LO0vVm z9ka1`UWg48aVk49N^7Kyy79QW%ODY8f;q*Dsf!JZqf{doWNu Rm7!qr#x>%b|EyA)2LMa=E+PN` diff --git a/PROMS/fmtxml/WSTALRall.xml b/PROMS/fmtxml/WSTALRall.xml index 89163feaf70d138b21ca2747b9b507e1cbe3be6d..1d9c25e08a1e81bb7bb273ffc59abda490e0e7a1 100644 GIT binary patch delta 30 mcmca`l=;9`_ Hwb>>Bd+RAm diff --git a/PROMS/fmtxml/WSTBCKall.xml b/PROMS/fmtxml/WSTBCKall.xml index 46450e195f1545e385ae72cf226fadb25b834155..29553494131301dc267a74d66002a1c1d340ef4f 100644 GIT binary patch delta 34 scmV+-0NwwBz66}S1h8_xld!uElkma}lkU7ElS;lQlTf{Evns&YUN>nG;Q#;t delta 186 zcmbQUhoxyB%Z8$Tyb28Y3~3As4Al(w40@CE4@xqFX#GQyicm3zV1`tNWQG!;8b5|o zhFpePxN5~C;*+oJv75YMp9XGoWEB`RAf_XkRhazefZ5~;2^^E>?dO>6vy)@