From bcdc190caf04d6351d1666703991046cae0e4963 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 13 Mar 2013 13:18:52 +0000 Subject: [PATCH] If DSOFramer fails to open a document, replace the bad document with an empty document. --- PROMS/Volian.Controls.Library/DSOTabPanel.cs | 35 ++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 29c576bb..b883cf40 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -148,7 +148,33 @@ namespace Volian.Controls.Library ((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit(); try { - this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName); + try + { + this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName); + } + catch (Exception ex) + { + System.IO.FileStream fs = MyDSOFile.MyFile.Create(); + using (DocumentAuditInfoList dail = DocumentAuditInfoList.Get(MyDocumentInfo.DocID)) + { + if (dail.Count > 0) + { + 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); + } + else + MessageBox.Show("Reverting to Blank Document", "Error in MS Word section", + MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + fs.Close(); + this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName); + } this._MyDSOFramer.Menubar = false; this._MyDSOFramer.Titlebar = false; //if (_MyCount < 20) @@ -361,8 +387,11 @@ namespace Volian.Controls.Library } public void StatusChanged(VolianStatusType type, int count, string text) { - DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl; - tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, 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)); + } } /// /// Before a document closes check to see if it's contents should be saved.