Пример #1
0
    /// <summary>
    /// WebMethod - authenticate()
    /// To verify username and password for the web connector that is trying to connect
    /// Signature: public string[] authenticate(string strUserName, string strPassword)
    ///
    /// IN:
    /// string strUserName
    /// string strPassword
    ///
    /// OUT:
    /// string[] authReturn
    /// Possible values:
    /// string[0] = ticket
    /// string[1]
    /// - "" = use current company file
    /// - "none" = no further request/no further action required
    /// - "nvu" = not valid user
    /// - "use this string as the company file path" = use this company file
    /// string[2] - (optional) contains the number of seconds to wait before
    /// the next update.
    /// string[3] - (optional) contains the number of seconds to be used as the
    /// MinimumRunEveryNSeconds time.
    ///
    /// The third and fourth elements allow you to to reduce QBWC updates during
    /// peak activity, basically telling QBWC clients not to update so frequently
    /// (the third element) or permanently resetting the minimum update time at the
    /// QBWC client (the fourth element).
    /// </summary>
    public string[] authenticate(string strUserName, string strPassword)
    {
        logEnter("authenticate()", new string[, ] {
            { "strUserName", strUserName }, { "strPassword", strPassword }
        });
        string[] authReturn = initAuthResponse();
        Session  sess       = new Session(authReturn[0], strUserName, strPassword);

        try {
            doAuthenticate(strUserName, strPassword, ref authReturn);
            checkWork(ref authReturn, sess);
        }
        catch (AuthenticateExceptionInvalid e) {
            logEvent(e.Message);
            authReturn = setAuthResponse("", "nvu");
            sess       = null;
        }
        catch (Exception e2) {
            logEvent(e2.Message);
            authReturn = setAuthResponse("", "none");
            sess       = null;
        }
        if (sess != null)
        {
            sessionPool.put(authReturn[0], sess);
        }
        logExit("authenticate()", new string[, ] {
            { "authReturn[0]", authReturn[0] }, { "authReturn[1]", authReturn[1] }
        });
        return(authReturn);
    }
Пример #2
0
        /// <summary>
        /// WebMethod - connectionError()
        /// To facilitate capturing of QuickBooks error and notifying it to web services
        /// Signature: public string connectionError (string ticket, string hresult, string message)
        ///
        /// IN:
        /// string ticket = A GUID based ticket string to maintain identity of QBWebConnector
        /// string hresult = An HRESULT value thrown by QuickBooks when trying to make connection
        /// string message = An error message corresponding to the HRESULT
        ///
        /// OUT:
        /// string retVal
        /// Possible values:
        /// - “done” = no further action required from QBWebConnector
        /// - any other string value = use this name for company file
        /// </summary>
        public string connectionError(string ticket, string hresult, string message)
        {
            logEnter("connectionError()", new string[, ] {
                { "ticket", ticket }, { "hresult", hresult }, { "message", message }
            });
            Session sess       = sessionPool.get(ticket);
            int     ce_counter = 0; // We must not get into an infinte loop, so we count our errors

            if (sess != null & sess.getProperty("ce_counter") != null)
            {
                ce_counter = (int)sess.getProperty("ce_counter");
            }
            string retVal = interpretHResult(hresult, message, ce_counter);

            sess.setProperty("ce_counter", ce_counter + 1);
            sessionPool.put(ticket, sess);
            logExit("connectionError()", new string[, ] {
                { "retVal", retVal }
            });
            return(retVal);
        }