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:
John Jenko 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

View File

@ -1044,6 +1044,16 @@ namespace Volian.Controls.Library
//if ((myItemInfo.MyContent.MyEntry.MyDocument.LibTitle ?? "") != "")
// MessageBox.Show("WARNING: All edits made to this Library Document will be applied to all uses of the Document");
pg = new DisplayTabItem(this.components, this, myItemInfo, key); // Open a new document page
// B2917-219 if MyEdWord is null that means we had trouble opening the word attachment and either a blank document was created or a previous version was recovered
// so we now we want to open the now blank or recovered attachment
if (pg.MyDSOTabPanel.MyEdWord == null)
{
pg = OpenDSOTabPage(myItemInfo);
if (pg.MyDSOTabPanel.MyEdWord == null)
return null; // even the blank or recovered attachment cannot be opened
else
return pg;
}
_MyDisplayTabItems.Add(key, pg);
}
SelectDisplayTabItem(pg);

View File

@ -111,6 +111,7 @@ namespace Volian.Controls.Library
else
SetupDSOTabPanel();
SetupSecurity(myItemInfo);
if (MyDSOTabPanel == null || MyDSOTabPanel.MyEdWord != null) // B2017-219 check needed if we could not open a word attachment
Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID);
}
private bool MesssageShown = false;
@ -302,6 +303,7 @@ namespace Volian.Controls.Library
EntryInfo myEntry = _MyItemInfo.MyContent.MyEntry;
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
_MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl, _MyItemInfo, UserInfo.CanEdit(ui,MyItemInfo.MyDocVersion));
if (_MyDSOTabPanel.MyEdWord == null) return; // B2017-219 if we could not open the word attachment just return
//
// tabItem
//