B2017-219 if a word section cannot be opened because it is gotten from a bad database record, then create a blank word document and open it

This commit is contained in:
2017-09-22 16:41:45 +00:00
parent 61a31cec22
commit 73593b8546
3 changed files with 50 additions and 26 deletions

View File

@@ -18,6 +18,11 @@ namespace Volian.Controls.Library
private DisplayTabControl _MyDisplayTabControl;
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private AxEDWordLib.AxEDWord _MyEdWord; // B2017-133 Edraw DSO Framer Replacement
public AxEDWordLib.AxEDWord MyEdWord
{
get { return _MyEdWord; }
set { _MyEdWord = value; }
}
private TransparentPanel _MyTransparentPanel;
private static int _Count = 0;
private DocumentInfo _MyDocumentInfo;
@@ -108,6 +113,7 @@ namespace Volian.Controls.Library
SetupDSOTabPanel();
_MyDocumentInfo = documentInfo;
SetupDSO();
if (_MyEdWord == null) return; //B2017-219 could not open the word attachment so just return
_RefreshTimer = new Timer(); // Enabled is false and interval is 1/10th of second.
_RefreshTimer.Interval = 500;// B2017-133 Edraw
ClientSizeChanged += new EventHandler(DSOTabPanel_ClientSizeChanged);
@@ -220,12 +226,15 @@ namespace Volian.Controls.Library
System.IO.FileStream fs = MyDSOFile.MyFile.Create();
fs.Write(myDoc.DocContent, 0, myDoc.DocContent.Length);
fs.Close();
_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID);
DocumentInfo.Refresh(myDoc);
//_DSOFile = null;
this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
doc.Range(1, 1);
MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the restored document to database
this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
return;
//_MyDocumentInfo = DocumentInfo.Get(MyDocumentInfo.DocID);
//DocumentInfo.Refresh(myDoc);
////_DSOFile = null;
//this._MyEdWord.Open(MyDSOFile.MyFile.FullName);
//doc = new LBDocumentClass(_MyEdWord.ActiveDocument());
//doc.Range(1, 1);
}
}
@@ -234,8 +243,11 @@ namespace Volian.Controls.Library
{
System.IO.FileStream fs = MyDSOFile.MyFile.Create();
fs.Close();
MyDSOFile.SaveFile(0, "", _ItemInfo, false, StatusChanged); // B2017-219 save the blank document to database
MessageBox.Show("Reverting to Blank Document", "Error in MS Word section",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this._MyEdWord = null; // B2017-219 Set MyEdWord to null - we will check for this in the calling functions
return;
}
}
this._MyEdWord.Open(MyDSOFile.MyFile.FullName);// B2017-133 Edraw