예제 #1
0
    /// <summary>
    /// The GetQBAccounts.
    /// </summary>
    /// <param name="logsFile">The logsFile<see cref="StreamWriter"/>.</param>
    /// <returns>The <see cref="List{dynamic}"/>.</returns>
    public List <dynamic> GetQBAccounts(StreamWriter logsFile)
    {
        IMsgSetRequest requestSet = SessionManager.Instance.CreateMsgSetRequest();

        requestSet.Attributes.OnError = ENRqOnError.roeStop;
        requestSet.AppendAccountQueryRq();
        IMsgSetResponse responeSet     = SessionManager.Instance.DoRequests(requestSet, logsFile);
        IResponseList   responseList   = responeSet.ResponseList;
        List <dynamic>  accountsArray  = new List <dynamic>();
        var             account_number = "";

        try
        {
            for (int i = 0; i < responseList.Count; i++)
            {
                IResponse response = responseList.GetAt(i);

                if (response.StatusCode == 0)
                {
                    IAccountRetList AccountRet = (IAccountRetList)response.Detail;
                    Console.WriteLine("Number Of Records Being Fetched Are:\t" + AccountRet.Count + "\n");
                    for (int j = 0; j < AccountRet.Count; j++)
                    {
                        IAccountRet account = AccountRet.GetAt(j);
                        if (account.AccountNumber != null)
                        {
                            account_number = account.AccountNumber.GetValue();
                        }
                        else
                        {
                            account_number = "Account Number Not Defined...";
                        }
                        accountsArray.Add(new string[] { account.Name.GetValue().ToString(), account_number, account.AccountType.GetValue().ToString(), account.TotalBalance.GetValue().ToString() });
                    }
                }
            }
        }
        catch (Exception ex)
        {
            logsFile.WriteLine(DateTime.Now + "\tERROR\tError Message:\t" + ex.Message);
            logsFile.WriteLine();
            logsFile.WriteLine(DateTime.Now + "\tERROR\tError Message:\tStack Trace:\t" + ex.StackTrace);
            logsFile.WriteLine();
        }

        return(accountsArray);
    }
예제 #2
0
        void WalkAccountQueryRs(IMsgSetResponse responseMsgSet)
        {
            if (responseMsgSet == null)
            {
                return;
            }
            IResponseList responseList = responseMsgSet.ResponseList;

            if (responseList == null)
            {
                return;
            }
            //if we sent only one request, there is only one response, we'll walk the list for this sample
            for (int i = 0; i < responseList.Count; i++)
            {
                IResponse response = responseList.GetAt(i);
                //check the status code of the response, 0=ok, >0 is warning
                if (response.StatusCode >= 0)
                {
                    //the request-specific response is in the details, make sure we have some
                    if (response.Detail != null)
                    {
                        //make sure the response is the type we're expecting
                        ENResponseType responseType = (ENResponseType)response.Type.GetValue();
                        if (responseType == ENResponseType.rtAccountQueryRs)
                        {
                            // var vs = response.Detail.GetType();
                            //upcast to more specific type here, this is safe because we checked with response.Type check above
                            IAccountRetList AccountRet = (IAccountRetList)response.Detail;
                            for (int j = 0; j < AccountRet.Count; j++)
                            {
                                IAccountRet accountInfo = AccountRet.GetAt(j);
                                if (accountInfo != null)
                                {
                                    WalkAccountRet(accountInfo);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        private IList <ChartOfAccount> WalkChartOfAccount(IAccountRetList Account)
        {
            if (Account == null)
            {
                return(null);
            }
            ChartOfAccountList = new List <ChartOfAccount>();
            ChartOfAccount BankAccount;

            for (int a = 0; a < Account.Count; a++)
            {
                IAccountRet AccountRet = Account.GetAt(a);
                BankAccount = new ChartOfAccount();
                //BankAccount.Name = (string)AccountRet.Name.GetValue();
                BankAccount.FullName = (string)AccountRet.FullName.GetValue();
                BankAccount.ListID   = AccountRet.ListID.GetValue().ToString();
                ChartOfAccountList.Add(BankAccount);
            }
            return(ChartOfAccountList);
        }
예제 #4
0
        void WalkAccountRet(IAccountRet AccountRet)
        {
            if (AccountRet == null)
            {
                return;
            }
            //Go through all the elements of IAccountRetList
            //Get value of ListID
            string ListID436 = (string)AccountRet.ListID.GetValue();
            // Get value of TimeCreated
            DateTime TimeCreated437 = (DateTime)AccountRet.TimeCreated.GetValue();
            //Get value of TimeModified
            DateTime TimeModified438 = (DateTime)AccountRet.TimeModified.GetValue();
            //Get value of EditSequence
            string EditSequence439 = (string)AccountRet.EditSequence.GetValue();
            //Get value of Name
            string Name440 = (string)AccountRet.Name.GetValue();
            // Get value of FullName
            string FullName441 = (string)AccountRet.FullName.GetValue();

            // Get value of IsActive
            if (AccountRet.IsActive != null)
            {
                bool IsActive442 = (bool)AccountRet.IsActive.GetValue();
            }
            if (AccountRet.ParentRef != null)
            {
                //  Get value of ListID
                if (AccountRet.ParentRef.ListID != null)
                {
                    string ListID443 = (string)AccountRet.ParentRef.ListID.GetValue();
                }
                //  Get value of FullName
                if (AccountRet.ParentRef.FullName != null)
                {
                    string FullName444 = (string)AccountRet.ParentRef.FullName.GetValue();
                }
            }
            // Get value of Sublevel
            int Sublevel445 = (int)AccountRet.Sublevel.GetValue();
            // Get value of AccountType
            ENAccountType AccountType446 = (ENAccountType)AccountRet.AccountType.GetValue();

            // Get value of SpecialAccountType
            if (AccountRet.SpecialAccountType != null)
            {
                ENSpecialAccountType SpecialAccountType447 = (ENSpecialAccountType)AccountRet.SpecialAccountType.GetValue();
            }
            // Get value of IsTaxAccount
            if (AccountRet.IsTaxAccount != null)
            {
                bool IsTaxAccount448 = (bool)AccountRet.IsTaxAccount.GetValue();
            }
            // Get value of AccountNumber
            if (AccountRet.AccountNumber != null)
            {
                string AccountNumber449 = (string)AccountRet.AccountNumber.GetValue();
            }
            // Get value of BankNumber
            if (AccountRet.BankNumber != null)
            {
                string BankNumber450 = (string)AccountRet.BankNumber.GetValue();
            }
            // Get value of Desc
            if (AccountRet.Desc != null)
            {
                string Desc451 = (string)AccountRet.Desc.GetValue();
            }
            // Get value of Balance
            if (AccountRet.Balance != null)
            {
                double Balance452 = (double)AccountRet.Balance.GetValue();
            }
            // Get value of TotalBalance
            if (AccountRet.TotalBalance != null)
            {
                double TotalBalance453 = (double)AccountRet.TotalBalance.GetValue();
            }
            if (AccountRet.SalesTaxCodeRef != null)
            {
                // Get value of ListID
                if (AccountRet.SalesTaxCodeRef.ListID != null)
                {
                    string ListID454 = (string)AccountRet.SalesTaxCodeRef.ListID.GetValue();
                }
                // Get value of FullName
                if (AccountRet.SalesTaxCodeRef.FullName != null)
                {
                    string FullName455 = (string)AccountRet.SalesTaxCodeRef.FullName.GetValue();
                }
            }
            if (AccountRet.TaxLineInfoRet != null)
            {
                // Get value of TaxLineID
                int TaxLineID456 = (int)AccountRet.TaxLineInfoRet.TaxLineID.GetValue();
                //Get value of TaxLineName
                if (AccountRet.TaxLineInfoRet.TaxLineName != null)
                {
                    string TaxLineName457 = (string)AccountRet.TaxLineInfoRet.TaxLineName.GetValue();
                }
            }
            //Get value of CashFlowClassification
            if (AccountRet.CashFlowClassification != null)
            {
                ENCashFlowClassification CashFlowClassification458 = (ENCashFlowClassification)AccountRet.CashFlowClassification.GetValue();
            }
            if (AccountRet.CurrencyRef != null)
            {
                // Get value of ListID
                if (AccountRet.CurrencyRef.ListID != null)
                {
                    string ListID459 = (string)AccountRet.CurrencyRef.ListID.GetValue();
                }
                // Get value of FullName
                if (AccountRet.CurrencyRef.FullName != null)
                {
                    string FullName460 = (string)AccountRet.CurrencyRef.FullName.GetValue();
                }
            }
            if (AccountRet.DataExtRetList != null)
            {
                /*for (int i461 = 0; i461 < AccountRet.DataExtRetList.Count; i461++)
                 * {
                 *  IDataExtRet DataExtRet = AccountRet.DataExtRetList.GetAt(i461);
                 *  Get value of OwnerID
                 *  if (DataExtRet.OwnerID != null)
                 *  {
                 *      string OwnerID462 = (string)DataExtRet.OwnerID.GetValue();
                 *  }
                 *  Get value of DataExtName
                 *  string DataExtName463 = (string)DataExtRet.DataExtName.GetValue();
                 *  Get value of DataExtType
                 *  ENDataExtType DataExtType464 = (ENDataExtType)DataExtRet.DataExtType.GetValue();
                 *  Get value of DataExtValue
                 *  string DataExtValue465 = (string)DataExtRet.DataExtValue.GetValue();
                 * }*/
            }
        }
예제 #5
0
        ///<summary>Returns list of all active accounts.</summary>
        public static List <string> GetListOfAccounts()
        {
            List <string> accountList = new List <string>();

            try {
                OpenConnection(8, 0, PrefC.GetString(PrefName.QuickBooksCompanyFile));
                QueryListOfAccounts();
                DoRequests();
                CloseConnection();
            }
            catch (Exception e) {
                if (SessionBegun)
                {
                    SessionManager.EndSession();
                }
                if (ConnectionOpen)
                {
                    SessionManager.CloseConnection();
                }
                throw e;
            }
            if (ResponseMsgSet == null)
            {
                return(accountList);
            }
            IResponseList responseList = ResponseMsgSet.ResponseList;

            if (responseList == null)
            {
                return(accountList);
            }
            //Loop through the list to pick out the AccountQueryRs section.
            for (int i = 0; i < responseList.Count; i++)
            {
                IResponse response = responseList.GetAt(i);
                //Check the status code of the response, 0=ok, >0 is warning.
                if (response.StatusCode >= 0)
                {
                    //The request-specific response is in the details, make sure we have some.
                    if (response.Detail != null)
                    {
                        //Make sure the response is the type we're expecting.
                        ENResponseType responseType = (ENResponseType)response.Type.GetValue();
                        if (responseType == ENResponseType.rtAccountQueryRs)
                        {
                            //Upcast to more specific type here, this is safe because we checked with response.Type check above.
                            IAccountRetList AccountRetList = (IAccountRetList)response.Detail;
                            for (int j = 0; j < AccountRetList.Count; j++)
                            {
                                IAccountRet AccountRet = AccountRetList.GetAt(j);
                                if (AccountRet.FullName != null)
                                {
                                    accountList.Add(AccountRet.FullName.GetValue());
                                }
                            }
                        }
                    }
                }
            }
            return(accountList);
        }