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

@ -146,9 +146,35 @@ namespace Volian.Controls.Library
//System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab)); //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WordDSOTab));
//this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState"))); //this._DSOFramer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("_FC.OcxState")));
((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this._MyDSOFramer)).EndInit();
try
{
try try
{ {
this._MyDSOFramer.Open(MyDSOFile.MyFile.FullName); 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)
@ -360,10 +386,13 @@ namespace Volian.Controls.Library
} }
} }
public void StatusChanged(VolianStatusType type, int count, string text) 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; DisplayTabControl tc = Parent.Parent.Parent as DisplayTabControl;
tc.ONStatusChanged(this, new DisplayTabControlStatusEventArgs(type, count, text)); 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.
/// </summary> /// </summary>