If DSOFramer fails to open a document, replace the bad document with an empty document.

This commit is contained in:
Rich 2013-03-13 13:18:52 +00:00
parent f6d8b8f9d3
commit bcdc190caf

View File

@ -148,7 +148,33 @@ namespace Volian.Controls.Library
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit();
try 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.Menubar = false;
this._MyDSOFramer.Titlebar = false; this._MyDSOFramer.Titlebar = false;
//if (_MyCount < 20) //if (_MyCount < 20)
@ -361,8 +387,11 @@ namespace Volian.Controls.Library
} }
public void StatusChanged(VolianStatusType type, int count, string text) public void StatusChanged(VolianStatusType type, int count, string text)
{ {
DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl; if (Parent != null && Parent.Parent != null && Parent.Parent.Parent is DisplayTabControl)
tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text)); {
DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl;
tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text));
}
} }
/// <summary> /// <summary>
/// Before a document closes check to see if it's contents should be saved. /// Before a document closes check to see if it's contents should be saved.