Ejemplo n.º 1
0
        /// <summary>
        /// Method for handling different versions of QuickBooks.
        /// </summary>
        private double QBFCLatestVersion()
        {
            // Use oldest version to ensure that this application work with any QuickBooks (US)
            IMsgSetRequest msgset = SessionManager.CreateMsgSetRequest("US", 1, 0);

            msgset.AppendHostQueryRq();
            IMsgSetResponse QueryResponse = SessionManager.DoRequests(msgset);
            //Console.WriteLine("Host query = " + msgset.ToXMLString());

            // The response list contains only one response,
            // which corresponds to our single HostQuery request.
            IResponse response = QueryResponse.ResponseList.GetAt(0);

            // Please refer to QBFC Developers Guide for details on why
            // "as" clause was used to link this derived class to its base class.
            IHostRet  HostResponse      = response.Detail as IHostRet;
            IBSTRList supportedVersions = HostResponse.SupportedQBXMLVersionList as IBSTRList;

            double LastVers = 0;

            for (var i = 0; i <= supportedVersions.Count - 1; i++)
            {
                string svers = null;
                svers = supportedVersions.GetAt(i);
                var vers = Convert.ToDouble(svers);
                if (vers > LastVers)
                {
                    LastVers = vers;
                }
            }
            return(LastVers);
        }
        /// <summary>
        /// Requests and sets the latest quickbooks sdk version.
        /// </summary>
        /// <param name="queryResponse"></param>
        private void ProcessSDkQuery(IMsgSetResponse queryResponse)
        {
            IResponse response     = queryResponse.ResponseList.GetAt(0);
            IHostRet  HostResponse = (IHostRet)response.Detail;

            IBSTRList supportedVersions = HostResponse.SupportedQBXMLVersionList;

            ParseSDK(supportedVersions);
        }
        /// <summary>
        /// Parses the reponse for the latest sdk version number.
        /// </summary>
        /// <param name="supportedVersions"></param>
        private void ParseSDK(IBSTRList supportedVersions)
        {
            string svers         = string.Empty;
            double version       = 0.0;
            double latestVersion = 0.0;

            for (int i = 0; i < supportedVersions.Count; i++)
            {
                svers         = supportedVersions.GetAt(i);
                version       = Convert.ToDouble(svers);
                latestVersion = (version > latestVersion) ? version : latestVersion;
            }

            _qbsdkMajor = (short)Math.Floor(latestVersion);
            _qbsdkMinor = (short)((latestVersion * 100) - (_qbsdkMajor * 100));
        }
Ejemplo n.º 4
0
        // IY: CODE FOR HANDLING DIFFERENT VERSIONS
        private double QBFCLatestVersion(QBSessionManager SessionManager)
        {
            // IY: Use oldest version to ensure that we work with any QuickBooks (US)
            IMsgSetRequest msgset = SessionManager.CreateMsgSetRequest("US", 1, 0);

            msgset.AppendHostQueryRq();
            // MessageBox.Show(msgset.ToXMLString());

            // IY: Use SessionManager object to open a connection and begin a session
            // with QuickBooks. At this time, you should add interop.QBFCxLib into
            // your Project References
            SessionManager.OpenConnection("", "IDN InvoiceAdd C# sample");
            SessionManager.BeginSession("", ENOpenMode.omDontCare);

            IMsgSetResponse QueryResponse = SessionManager.DoRequests(msgset);
            // IY: The response list contains only one response,
            // which corresponds to our single HostQuery request
            IResponse response = QueryResponse.ResponseList.GetAt(0);
            // IY: Please refer to QBFC Developers Guide/pg for details on why
            // "as" clause was used to link this derrived class to its base class
            IHostRet  HostResponse      = response.Detail as IHostRet;
            IBSTRList supportedVersions = HostResponse.SupportedQBXMLVersionList as IBSTRList;

            int    i;
            double vers;
            double LastVers = 0;
            string svers    = null;

            for (i = 0; i <= supportedVersions.Count - 1; i++)
            {
                svers = supportedVersions.GetAt(i);
                vers  = Convert.ToDouble(svers);
                if (vers > LastVers)
                {
                    LastVers = vers;
                    //svers = supportedVersions.GetAt(i);
                }
            }

            // IY: Close the session and connection with QuickBooks
            SessionManager.EndSession();
            SessionManager.CloseConnection();
            return(LastVers);
        }
Ejemplo n.º 5
0
        // Code for handling different versions of QuickBooks
        private double QBFCLatestVersion(QBSessionManager SessionManager)
        {
            string Country           = ConfigurationManager.AppSettings["QBCountry"].ToString();
            short  qbXMLMajorVersion = 0;
            short  qbXMLMinorVersion = 0;

            short.TryParse(ConfigurationManager.AppSettings["QBXMLMajorVersion"].ToString(), out qbXMLMajorVersion);
            short.TryParse(ConfigurationManager.AppSettings["QBXMLMinorVersion"].ToString(), out qbXMLMinorVersion);

            // Use oldest version to ensure that this application work with any QuickBooks (US)
            IMsgSetRequest msgset = SessionManager.CreateMsgSetRequest(Country, qbXMLMajorVersion, qbXMLMinorVersion);    //("US", 13, 0);

            msgset.AppendHostQueryRq();
            IMsgSetResponse QueryResponse = SessionManager.DoRequests(msgset);
            //MessageBox.Show("Host query = " + msgset.ToXMLString());
            //SaveXML(msgset.ToXMLString());


            // The response list contains only one response,
            // which corresponds to our single HostQuery request
            IResponse response = QueryResponse.ResponseList.GetAt(0);

            // Please refer to QBFC Developers Guide for details on why
            // "as" clause was used to link this derrived class to its base class
            IHostRet  HostResponse      = response.Detail as IHostRet;
            IBSTRList supportedVersions = HostResponse.SupportedQBXMLVersionList as IBSTRList;

            int    i;
            double vers;
            double LastVers = 0;
            string svers    = null;

            for (i = 0; i <= supportedVersions.Count - 1; i++)
            {
                svers = supportedVersions.GetAt(i);
                vers  = Convert.ToDouble(svers);
                if (vers > LastVers)
                {
                    LastVers = vers;
                }
            }
            return(LastVers);
        }