The ConnectionMgr class is used to configure the application identity and as a source of SDK connections, which require the application identity
Example #1
0
        /// <summary>
        /// Closes this connection
        /// </summary>
        public void Close()
        {
            var sessionMgr = _sessionMgr;

            _sessionMgr = null;

            ConnectionMgr.ConnectionClosed(this);

            try
            {
                sessionMgr.EndSession();
                sessionMgr.CloseConnection();
            }
            catch (System.Runtime.InteropServices.COMException cex)
            {
                throw new SDKCloseException(cex);
            }
        }
Example #2
0
        internal SDKConnection(ConnectionMgr.ApplicationIdentity appID, 
            ConnectionMgr.ConnectionConfig config)
        {
            _SDKMajorVersion = HOST_QUERY_QBXML_VERSION;
            _SDKMinorVersion = 0;

            SDK.ENConnectionType cnType;

            switch (config.ConnectionType)
            {
                case ConnectionMgr.FCConnectionType.Desktop:
                    cnType = SDK.ENConnectionType.ctLocalQBD;
                    break;

                case ConnectionMgr.FCConnectionType.DesktopLaunchUI:
                    cnType = SDK.ENConnectionType.ctLocalQBDLaunchUI;
                    break;

                case ConnectionMgr.FCConnectionType.Online:
                    cnType = SDK.ENConnectionType.ctRemoteQBOE;
                    _SDKMajorVersion = ONLINE_QBXML_VERSION;
                    break;

                default:
                    throw new Exception("Unsupported connection type:" + config.ConnectionType.ToString());
            }

            try
            {
                //ToDo: use online session manager for online version
                var sessionMgr = new SDK.QBSessionManager();

                sessionMgr.OpenConnection2(appID.IntuitAppID, appID.Name, cnType);

                _sessionMgr = sessionMgr;
            }
            catch (System.Runtime.InteropServices.COMException cex)
            {
                throw new SDKSessionException(cex);
            }

            _country = string.Empty;

            switch (appID.TargetEdition)
            {
                case ConnectionMgr.QBEdition.Australia:
                case ConnectionMgr.QBEdition.US:
                    _country = "US";
                    break;

                case ConnectionMgr.QBEdition.Canada:
                    _country = "CA";
                    break;

                case ConnectionMgr.QBEdition.UK:
                    _country = "UK";
                    break;
            }

            SDK.ENOpenMode cnMode;

            if (config.RequireSingleUser)
            {
                cnMode = SDK.ENOpenMode.omSingleUser;
            }
            else
            {
                cnMode = SDK.ENOpenMode.omDontCare;
            }

            string filePath = config.FilePath;

            if (config.UseCurrentFile) filePath = string.Empty;

            try
            {
                _sessionMgr.BeginSession(filePath, cnMode);
            }
            catch(System.Runtime.InteropServices.COMException cex)
            {
                throw new SDKSessionException(cex);
            }
        }