From 73593b85467e30e3c1aa4a7bdab4bdee4a043795 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 22 Sep 2017 16:41:45 +0000 Subject: [PATCH] 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 --- PROMS/Volian.Controls.Library/DSOTabPanel.cs | 24 ++++++++--- .../DisplayTabControl.cs | 10 +++++ .../Volian.Controls.Library/DisplayTabItem.cs | 42 ++++++++++--------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 64e0c27d..9090386f 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -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 diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index 75e9562f..a070b397 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -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); diff --git a/PROMS/Volian.Controls.Library/DisplayTabItem.cs b/PROMS/Volian.Controls.Library/DisplayTabItem.cs index 2ae8c564..7977760a 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabItem.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabItem.cs @@ -93,26 +93,27 @@ namespace Volian.Controls.Library } #endregion #region Constructors - public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey) - { - _MyItemInfo = myItemInfo; - if(MyItemInfo.MyContent.MyEntry == null) - OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure); - else - OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document); - //Console.WriteLine("DisplayTabItem"); - _MyKey = myKey; - _MyDisplayTabControl = myDisplayTabControl; - container.Add(this); - InitializeComponent(); - this.Click += new EventHandler(DisplayTabItem_Click); - if (myItemInfo.MyContent.MyEntry == null) - SetupStepTabPanel(); - else - SetupDSOTabPanel(); - SetupSecurity(myItemInfo); - Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID); - } + public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey) + { + _MyItemInfo = myItemInfo; + if (MyItemInfo.MyContent.MyEntry == null) + OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure); + else + OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document); + //Console.WriteLine("DisplayTabItem"); + _MyKey = myKey; + _MyDisplayTabControl = myDisplayTabControl; + container.Add(this); + InitializeComponent(); + this.Click += new EventHandler(DisplayTabItem_Click); + if (myItemInfo.MyContent.MyEntry == null) + SetupStepTabPanel(); + 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; public void SetupSecurity(ItemInfo myItem) { @@ -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 //