/// <summary> /// Termina a ligação à API e liberta todos os recursos /// </summary> public static void Terminate() { if (apiInitialized) { //1. QuickSearch if (rtlSystemGlobals != null) { rtlSystemGlobals.DisposeQuickSearch(); } //3. Business globals if (rtlBLGlobals != null) { rtlBLGlobals.Dispose(); rtlBLGlobals = null; } //4. Dispose CORE Global Settings if (rtlCoreGlobals != null) { rtlCoreGlobals.Dispose(); //System.Runtime.InteropServices.Marshal.ReleaseComObject(rtlCoreGlobals); rtlCoreGlobals = null; } //2. Dispose Printing Manager if (rtlPrintGlobals != null) { rtlPrintGlobals.Dispose(); rtlPrintGlobals = null; } //5. DISPOSE DataLayer Global Settings if (rtlDLGlobals != null) { rtlDLGlobals.Dispose(); //System.Runtime.InteropServices.Marshal.ReleaseComObject(rtlDLGlobals); rtlDLGlobals = null; } //6. Dispose DataProvider if (rtlDataGlobals != null) { rtlDataGlobals.DataManager.CloseConnections(); rtlDataGlobals.Dispose(); //System.Runtime.InteropServices.Marshal.ReleaseComObject(rtlDataGlobals); rtlDataGlobals = null; } //7. Dispose System if (rtlSystemGlobals != null) { rtlSystemGlobals.Dispose(); //System.Runtime.InteropServices.Marshal.ReleaseComObject(rtlSystemGlobals); rtlSystemGlobals = null; } // Dispose System manager if (rtlSystemManager != null) { rtlSystemManager = null; } // apiInitialized = false; // // Fire event if (APIStopped != null) { APIStopped(null, null); } } }