/// <summary> /// Preparing RSTAB application /// </summary> /// <param name="dd">Flag for deletion RSTAB data structure</param> /// <param name="rd">Reading flag</param> private void PrepRSTABApp(bool dd, bool rd) { try { IStructure = Marshal.GetActiveObject("RSTAB6.Structure") as IrsStructure; } catch (COMException) { try { IStructure = Marshal.GetActiveObject("RSTAB6DEMO.Structure") as IrsStructure; } catch (COMException ce) { ecd = ErrCode.MARSH_COM; ems = ce.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name + "()"; } catch (Exception e) { ecd = ErrCode.MARSH; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } } catch (Exception e) { ecd = ErrCode.MARSH; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } if (ecd != ErrCode.NONE) { return; } try { IStructure.rsGetApplication().rsLockLicence(); IData = IStructure.rsGetStructuralData(); if (!rd) { IData.rsPrepareModification(); if (dd) { IData.rsDeleteStructuralData(); } } } catch (Exception e) { ecd = ErrCode.MARSH; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } }
/// <summary> /// Frees RSTAB COM object /// </summary> /// <param name="a">True if data was modified</param> private void FreeRSTAB(bool a) { if (IData != null) { try { if (a) { IData.rsFinishModification(); } } catch (Exception e) { ecd = ErrCode.RSTABDATA; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } finally { IData = null; } } if (IStructure != null) { try { IStructure.rsGetApplication().rsUnlockLicence(); // Releases COM object Marshal.ReleaseComObject(IStructure); } catch (Exception e) { ecd = ErrCode.RSTABSTRC; ems = e.Message; epl = this.GetType().Name + "->" + MethodBase.GetCurrentMethod().Name; } finally { IStructure = null; } } // Cleans Garbage Collector for releasing all COM interfaces and objects. System.GC.Collect(); }