public IResponse QueryCustomerList() { // Add the request to the message set request object ICustomerQuery CustQ = requestMsgSet.AppendCustomerQueryRq(); // Optionally, you can put filter on it. CustQ.ORCustomerListQuery.CustomerListFilter.MaxReturned.SetValue(5); // Do the request and get the response message set object IMsgSetResponse responseSet = SessionManager.DoRequests(requestMsgSet); // Uncomment the following to view and save the request and response XML //string requestXML = requestSet.ToXMLString(); //Console.WriteLine(requestXML); //string responseXML = responseSet.ToXMLString(); //Console.WriteLine(responseXML); IResponse response = responseSet.ResponseList.GetAt(0); //int statusCode = response.StatusCode; //string statusMessage = response.StatusMessage; //string statusSeverity = response.StatusSeverity; //Console.WriteLine("Status:\nCode = " + statusCode + "\nMessage = " + statusMessage + "\nSeverity = " + statusSeverity); return(response); }
public OrderStartedEventHandler(ILogger <OrderStartedEventHandler> logger, ICustomerQuery customerQuery, ICustomerRepository customerRepository, IIntegrationService integrationService) { _logger = logger; _customerQuery = customerQuery; _customerRepository = customerRepository; _integrationService = integrationService; }
public void OpenQB() { QBSessionManager sessionManager = null; try { sessionManager = new QBSessionManager(); IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("CA", 13, 0); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; sessionManager.OpenConnection("QBAPI", "Quickbooks SDK Demo Test"); string qbFile = ConfigurationSettings.AppSettings["companyfile"].ToString(); Console.WriteLine(qbFile); sessionManager.BeginSession( qbFile, ENOpenMode.omMultiUser); ICustomerQuery customerQueryRq = requestMsgSet.AppendCustomerQueryRq(); customerQueryRq.ORCustomerListQuery.CustomerListFilter.ActiveStatus.SetValue(ENActiveStatus.asAll); IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); sessionManager.EndSession(); sessionManager.CloseConnection(); } catch (Exception ex) { System.Console.WriteLine(ex.Message); sessionManager.EndSession(); sessionManager.CloseConnection(); } }
private void initializeObjects() { readBillPayment = new QBReadCustomer(); customerQuery = apiQBSession.getRequestMsgSet().AppendCustomerQueryRq(); customerQuery.IncludeRetElementList.Add("ListID"); customerQuery.IncludeRetElementList.Add("Name"); }
public ObservableCollection <customer> DbRead() { ObservableCollection <customer> Customers = new ObservableCollection <customer>(); QBSessionManager sessionManager = CreateSession(); IMsgSetRequest requestMsgSet = CreateRequestMessage(ref sessionManager); sessionManager = DbConnect(sessionManager); // Setup requestquery ICustomerQuery customerQueryReq = requestMsgSet.AppendCustomerQueryRq(); customerQueryReq = SetIncludedRetEliments(ref customerQueryReq); customerQueryReq = SetCustomerQuery(0, ref customerQueryReq); IResponse response = GetMessageResponse(ref sessionManager, ref requestMsgSet); ICustomerRetList customerRetList = (ICustomerRetList)response.Detail; if (customerRetList != null) { for (int i = 0; i < customerRetList.Count; i++) { ICustomerRet customerRet = customerRetList.GetAt(i); customer Customer = FillCustomer(customerRet); Customers.Add(Customer); } } return(Customers); }
public CustomersController(IMapper mapper, ICustomerQuery customerQuery, ICustomerRepository customerRepository) { _mapper = mapper; _customerQuery = customerQuery; _customerRepository = customerRepository; }
private ICustomerRet QueryCustomer(QBSessionManager session, string customerFullName) { // query for the customer information IMsgSetRequest requestMsgSet = getLatestMsgSetRequest(session); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; ICustomerQuery pCustomerQuery = requestMsgSet.AppendCustomerQueryRq(); ICustomerListFilter pCustomerFilter = pCustomerQuery.ORCustomerListQuery.CustomerListFilter; pCustomerFilter.ORNameFilter.NameFilter.Name.SetValue(customerFullName); pCustomerFilter.ORNameFilter.NameFilter.MatchCriterion.SetValue(ENMatchCriterion.mcContains); IMsgSetResponse responseMsgSet = session.DoRequests(requestMsgSet); // Uncomment the following to see the request and response XML for debugging //string rq = requestMsgSet.ToXMLString(); //string rs = responseMsgSet.ToXMLString(); //m_application.Messenger.AddInfo("Customer Resquest: " + rq); //m_application.Messenger.AddInfo("Customer Response: " + rs); // Interpret the response IResponseList rsList = responseMsgSet.ResponseList; // Retrieve the one response corresponding to our single request IResponse response = rsList.GetAt(0); if (response.StatusCode != 0) { string msg = ""; if (response.StatusCode == 1) //No record found { msg = "Customer not found: " + customerFullName; } else { msg = "Error getting customer. Status: " + response.StatusCode.ToString() + ", Message: " + response.StatusMessage; } throw new Exception(msg); } // We have one or more customers (expect one) ICustomerRetList customerList = response.Detail as ICustomerRetList; int customerCount = customerList.Count; if (customerCount > 1) { m_application.Messenger.AddWarning("Multiple customers found: " + customerFullName); } return(customerList.GetAt(0)); }
public MainViewModel() { _ProductQuery = LogicFactory.ProductQuery; _CustomerQuery = LogicFactory.CustomerQuery; _ProductCommand = LogicFactory.ProductCommand; SetViewModel(); }
ICustomerQuery SetIncludedRetEliments(ref ICustomerQuery customerQueryReq) { customerQueryReq.IncludeRetElementList.Add("ListID"); customerQueryReq.IncludeRetElementList.Add("TimeCreated"); customerQueryReq.IncludeRetElementList.Add("TimeModified"); customerQueryReq.IncludeRetElementList.Add("EditSequence"); customerQueryReq.IncludeRetElementList.Add("Name"); customerQueryReq.IncludeRetElementList.Add("FullName"); customerQueryReq.IncludeRetElementList.Add("IsActive"); customerQueryReq.IncludeRetElementList.Add("ClassRef"); customerQueryReq.IncludeRetElementList.Add("ParentRef"); customerQueryReq.IncludeRetElementList.Add("SubLevel"); customerQueryReq.IncludeRetElementList.Add("CompanyName"); customerQueryReq.IncludeRetElementList.Add("Salutation"); customerQueryReq.IncludeRetElementList.Add("FirstName"); customerQueryReq.IncludeRetElementList.Add("MiddleName"); customerQueryReq.IncludeRetElementList.Add("LastName"); customerQueryReq.IncludeRetElementList.Add("JobTitle"); customerQueryReq.IncludeRetElementList.Add("BillAddress"); customerQueryReq.IncludeRetElementList.Add("ShipAddress"); customerQueryReq.IncludeRetElementList.Add("Phone"); customerQueryReq.IncludeRetElementList.Add("AltPhone"); customerQueryReq.IncludeRetElementList.Add("Fax"); customerQueryReq.IncludeRetElementList.Add("Email"); customerQueryReq.IncludeRetElementList.Add("Cc"); customerQueryReq.IncludeRetElementList.Add("Contact"); customerQueryReq.IncludeRetElementList.Add("AltContact"); customerQueryReq.IncludeRetElementList.Add("AditionalContactRefList"); customerQueryReq.IncludeRetElementList.Add("ContactRetList"); customerQueryReq.IncludeRetElementList.Add("CustomerTypeRef"); customerQueryReq.IncludeRetElementList.Add("TermsRef"); customerQueryReq.IncludeRetElementList.Add("SaleRepRef"); customerQueryReq.IncludeRetElementList.Add("Balance"); customerQueryReq.IncludeRetElementList.Add("TotalBalance"); customerQueryReq.IncludeRetElementList.Add("SalesTaxCodeRef"); customerQueryReq.IncludeRetElementList.Add("ItemSalesTaxRef"); customerQueryReq.IncludeRetElementList.Add("ResaleNumber"); customerQueryReq.IncludeRetElementList.Add("AccountNumber"); customerQueryReq.IncludeRetElementList.Add("CreditLimit"); customerQueryReq.IncludeRetElementList.Add("PreferredPaymentMethodRef"); customerQueryReq.IncludeRetElementList.Add("CreditCardInfo"); customerQueryReq.IncludeRetElementList.Add("JobStatus"); customerQueryReq.IncludeRetElementList.Add("JobStartDate"); customerQueryReq.IncludeRetElementList.Add("JobProjectedEndDate"); customerQueryReq.IncludeRetElementList.Add("JobEndDate"); customerQueryReq.IncludeRetElementList.Add("JobDesc"); customerQueryReq.IncludeRetElementList.Add("JobTypeRef"); customerQueryReq.IncludeRetElementList.Add("Notes"); customerQueryReq.IncludeRetElementList.Add("AdditionalNotesRetList"); customerQueryReq.IncludeRetElementList.Add("PreferredDeliveryMethod"); customerQueryReq.IncludeRetElementList.Add("PriceLevelRef"); customerQueryReq.IncludeRetElementList.Add("ExternalGUID"); customerQueryReq.IncludeRetElementList.Add("CurrencyRef"); customerQueryReq.IncludeRetElementList.Add("DataExtRetList"); return(customerQueryReq); }
public MainViewModel(IProductQuery productQuery, ICustomerQuery customerQuery, IProductCommand productCommand) { _ProductQuery = productQuery; _CustomerQuery = customerQuery; _ProductCommand = productCommand; SetViewModel(); }
public IList <Customer> GetAllCustomer() { requestMsgSet.ClearRequests(); ICustomerQuery CustomerQueryRq = requestMsgSet.AppendCustomerQueryRq(); CustomerQueryRq.OwnerIDList.Add("0"); // CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.FromModifiedDate.SetValue(createdFrom, false); // CustomerQueryRq.ORCustomerListQuery.CustomerListFilter.ToModifiedDate.SetValue(createdTo, false); responseMsgSet = sessionManager.DoRequests(requestMsgSet); return(WalkCustomerQuery(responseMsgSet)); }
private void GetCustomers() { sessionManager = new QBSessionManager(); sessionManager.OpenConnection("appID", "Bluefire Integration TEST"); _connectionOpen = true; sessionManager.BeginSession(COMPANY_FILE, ENOpenMode.omDontCare); _sessionBegun = true; // Grab the list of customer names to populate our listbox IMsgSetRequest messageSet = sessionManager.CreateMsgSetRequest("CA", 12, 0); ICustomerQuery custQuery = messageSet.AppendCustomerQueryRq(); try { IMsgSetResponse responseSet = sessionManager.DoRequests(messageSet); sessionManager.EndSession(); _sessionBegun = false; IResponse response; ENResponseType responseType; for (int i = 0; i < responseSet.ResponseList.Count; i++) { response = responseSet.ResponseList.GetAt(i); if (response.Detail == null) { continue; } responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtCustomerQueryRs) { ICustomerRetList custList = (ICustomerRetList)response.Detail; for (int custIndex = 0; custIndex < custList.Count; custIndex++) { ICustomerRet customer = (ICustomerRet)custList.GetAt(custIndex); if (customer != null && customer.CompanyName != null) { customer_listbox.Items.Add(customer.CompanyName.GetValue()); } } } } } catch (System.Runtime.InteropServices.COMException comEx) { // something bad happened; tell the user, smash his computer, whatever; its your choice MessageBox.Show(comEx.Message); } }
/// <summary> /// The GetCustomersData. /// </summary> /// <param name="logsFile">The logsFile<see cref="StreamWriter"/>.</param> /// <returns>The <see cref="List{dynamic}"/>.</returns> public List <dynamic> GetCustomersData(StreamWriter logsFile) { IMsgSetRequest requestSet = SessionManager.Instance.CreateMsgSetRequest(); requestSet.Attributes.OnError = ENRqOnError.roeStop; ICustomerQuery CustomerQueryRq = requestSet.AppendCustomerQueryRq(); IMsgSetResponse responeSet = SessionManager.Instance.DoRequests(requestSet, logsFile); IResponseList responseList = responeSet.ResponseList; List <dynamic> customersArray = new List <dynamic>(); var accountNumber = ""; try { for (int i = 0; i < responseList.Count; i++) { IResponse response = responseList.GetAt(i); if (response.StatusCode == 0) { ICustomerRetList customerList = (ICustomerRetList)response.Detail; Console.WriteLine("Number Of Records Being Fetched Are:\t" + customerList.Count + "\n"); for (int j = 0; j < customerList.Count; j++) { ICustomerRet customer = customerList.GetAt(j); if (customer.AccountNumber != null) { accountNumber = customer.AccountNumber.GetValue(); } else { accountNumber = "Account Number Not Defined..."; } customersArray.Add(new string[] { customer.Name.GetValue().ToString(), accountNumber, customer.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(customersArray); }
private IMsgSetRequest buildCustomerQueryRq(string[] includeRetElement, string fullName) { IMsgSetRequest requestMsgSet = sessionManager.getMsgSetRequest(); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; ICustomerQuery custQuery = requestMsgSet.AppendCustomerQueryRq(); if (fullName != null) { custQuery.ORCustomerListQuery.FullNameList.Add(fullName); } for (int x = 0; x < includeRetElement.Length; x++) { custQuery.IncludeRetElementList.Add(includeRetElement[x]); } return(requestMsgSet); }
private ICustomerRet FindCustomer(Quickbooks qb, String fullName) { IMsgSetRequest msgRequest = qb.newRequest(); ICustomerQuery customerQuery = msgRequest.AppendCustomerQueryRq(); customerQuery.ORCustomerListQuery.FullNameList.Add(fullName); IMsgSetResponse response = qb.performRequest(msgRequest); ICustomerRetList qbCustomers = (ICustomerRetList)response.ResponseList.GetAt(0).Detail; if (qbCustomers == null) { return(null); } return(qbCustomers.GetAt(0)); }
private void button1_Click(object sender, EventArgs e) { coni(); requestMsgSetfr = sessionManager.CreateMsgSetRequest("US", 13, 0); requestMsgSetfr.Attributes.OnError = ENRqOnError.roeContinue; ICustomerQuery CustomerQueryRq = requestMsgSetfr.AppendCustomerQueryRq(); CustomerQueryRq.metaData.SetValue(ENmetaData.mdMetaDataAndResponseData); IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSetfr); //richTextBox1.Text += responseMsgSet.ToXMLString(); cerrar(); }
private void editCustomer_Click(object sender, EventArgs e) { _MySessionManager = SessionManager.NewQBSession(); IMsgSetRequest requestMsgSet = _MySessionManager.CreateMsgSetRequest("US", 13, 0); ICustomerQuery Query = requestMsgSet.AppendCustomerQueryRq(); IMsgSetResponse responseMsgSet = _MySessionManager.DoRequests(requestMsgSet); IResponseList rsList = responseMsgSet.ResponseList; IResponse response = rsList.GetAt(0); ICustomerRetList CustomerList = (ICustomerRetList)response.Detail; if (CustomerList == null) { throw new Exception("Sorry, no customers found."); } for (int i = 0; i <= CustomerList.Count - 1; i++) { ICustomerRet QBCustomer = CustomerList.GetAt(i); //string CustomerName = QBCustomer.Name.GetValue().ToString(); //string listID = QBCustomer.ListID.GetValue(); //string editSequence = QBCustomer.EditSequence.GetValue(); if (QBCustomer.Email != null) { string email = QBCustomer.Email.GetValue(); if (_emailsToDelete.Contains(email)) { modifyCustomer(QBCustomer); } } } }
/* private void loadItems() * { * string request = "ItemQueryRq"; * connectToQB(); * int count = getCount(request); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildItemQueryRq(new string[] { "FullName" }, null)); * string[,] retVal = parseItemQueryRs(responseMsgSet, count, 1); * disconnectFromQB(); * string[] itemList = getItemFullNames(retVal); * fillComboBox(comboBox_Item1, itemList); * fillComboBox(comboBox_Item2, itemList); * fillComboBox(comboBox_Item3, itemList); * fillComboBox(comboBox_Item4, itemList); * fillComboBox(comboBox_Item5, itemList); * } * * private string[] getItemFullNames(string[,] retVal) * { * //retVal[countOfRows, arraySize] * //arraySize is 3 for FullName, Desc, Price but in this case 1 for FullName only * int countOfRows = retVal.GetUpperBound(0); * string[] itemList = new string[countOfRows]; * for (int i = 0; i < countOfRows; i++) * { * itemList[i] = retVal[i, 0]; * } * return itemList; * } * * private void loadTerms() * { * string request = "TermsQueryRq"; * connectToQB(); * int count = getCount(request); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildTermsQueryRq()); * string[] termsList = parseTermsQueryRs(responseMsgSet, count); * disconnectFromQB(); * fillComboBox(this.comboBox_Terms, termsList); * } * * private void loadSalesTaxCodes() * { * string request = "SalesTaxCodeQueryRq"; * connectToQB(); * int count = getCount(request); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildSalesTaxCodeQueryRq()); * string[] salesTaxCodeList = parseSalesTaxCodeQueryRs(responseMsgSet, count); * disconnectFromQB(); * fillComboBox(this.comboBox_Tax1, salesTaxCodeList); * fillComboBox(this.comboBox_Tax2, salesTaxCodeList); * fillComboBox(this.comboBox_Tax3, salesTaxCodeList); * fillComboBox(this.comboBox_Tax4, salesTaxCodeList); * fillComboBox(this.comboBox_Tax5, salesTaxCodeList); * } * * private void loadCustomerMsg() * { * string request = "CustomerMsgQueryRq"; * connectToQB(); * int count = getCount(request); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildCustomerMsgQueryRq(new string[] { "Name" }, null)); * string[] customerMsgList = parseCustomerMsgQueryRs(responseMsgSet, count); * disconnectFromQB(); * fillComboBox(comboBox_CustomerMessage, customerMsgList); * } * * private string getBillShipTo(string customerName, string billOrShip) * { * connectToQB(); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildCustomerQueryRq(new string[] { billOrShip }, customerName)); * string[] billShipTo = parseCustomerQueryRs(responseMsgSet, 1); * if (billShipTo[0] == null) billShipTo[0] = ""; * disconnectFromQB(); * return billShipTo[0]; * } * * private string getCurrencyCode(string customerName) * { * connectToQB(); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildCustomerQueryRq(new string[] { "CurrencyRef" }, customerName)); * string[] currencyCode = parseCustomerQueryRs(responseMsgSet, 1); * disconnectFromQB(); * return currencyCode[0]; * } * * private string getExchangeRate(string currencyName) * { * connectToQB(); * IMsgSetResponse responseMsgSet = processRequestFromQB(buildCurrencyQueryRq(currencyName)); * string[] exrate = parseCurrencyQueryRs(responseMsgSet, 1); * disconnectFromQB(); * if (exrate[0] == null || exrate[0] == "") exrate[0] = "1.0"; * return exrate[0]; * } * * // REQUEST BUILDING * private IMsgSetRequest buildPreferencesQueryRq(string[] includeRetElement, string fullName) * { * IMsgSetRequest requestMsgSet = sessionManager.getMsgSetRequest(); * requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; * IPreferencesQuery prefQuery = requestMsgSet.AppendPreferencesQueryRq(); * for (int x = 0; x < includeRetElement.Length; x++) * { * prefQuery.IncludeRetElementList.Add(includeRetElement[x]); * } * return requestMsgSet; * } */ private IMsgSetRequest buildDataCountQuery(string request) { IMsgSetRequest requestMsgSet = sessionManager.getMsgSetRequest(); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; switch (request) { case "CustomerQueryRq": ICustomerQuery custQuery = requestMsgSet.AppendCustomerQueryRq(); custQuery.metaData.SetValue(ENmetaData.mdMetaDataOnly); break; case "ItemQueryRq": IItemQuery itemQuery = requestMsgSet.AppendItemQueryRq(); itemQuery.metaData.SetValue(ENmetaData.mdMetaDataOnly); break; case "TermsQueryRq": ITermsQuery termsQuery = requestMsgSet.AppendTermsQueryRq(); termsQuery.metaData.SetValue(ENmetaData.mdMetaDataOnly); break; case "SalesTaxCodeQueryRq": ISalesTaxCodeQuery salesTaxQuery = requestMsgSet.AppendSalesTaxCodeQueryRq(); salesTaxQuery.metaData.SetValue(ENmetaData.mdMetaDataOnly); break; case "CustomerMsgQueryRq": ICustomerMsgQuery custMsgQuery = requestMsgSet.AppendCustomerMsgQueryRq(); custMsgQuery.metaData.SetValue(ENmetaData.mdMetaDataOnly); break; default: break; } return(requestMsgSet); }
public override List <ITransactionEntity> Import() { StartSession(); IMsgSetRequest request = GetLatestMsgSetRequest(); ICustomerQuery query = request.AppendCustomerQueryRq(); query.ORCustomerListQuery.CustomerListFilter.ActiveStatus.SetValue(ENActiveStatus.asAll); IResponse res = GetResponse(request); ICustomerRetList returnList = res.Detail as ICustomerRetList; List <MaestroCustomer> mlist = new List <MaestroCustomer>(); for (int i = 0; i < returnList.Count; i++) { ICustomerRet qbc = returnList.GetAt(i); //if (ReadBool(qbc.IsActive)) //{ //mlist.Add(GetMaestroCustomer(qbc)); /* * if(qbc.ShipToAddressList != null) * { * Console.WriteLine("count:"+qbc.ShipToAddressList.Count); * }*/ //} mlist.Add(GetMaestroCustomer(qbc)); //WalkCustomerRet(qbc); // } return(mlist.Cast <ITransactionEntity>().ToList()); }
public List <Customer> getAllCustomers() { //Item Request IMsgSetRequest customerRequestset = _MySessionManager.CreateMsgSetRequest("US", 13, 0); ICustomerQuery customerQuery = customerRequestset.AppendCustomerQueryRq(); IMsgSetResponse responseCustomerRq = _MySessionManager.DoRequests(customerRequestset); IResponseList customerResponseList = responseCustomerRq.ResponseList; IResponse customerResponse = customerResponseList.GetAt(0); //ENResponseType responseType = (ENResponseType)customerResponse.Type.GetValue(); ICustomerRetList customerList = (ICustomerRetList)customerResponse.Detail; for (int i = 0; i <= customerList.Count - 1; i++) { ICustomerRet qbCustomer = customerList.GetAt(i); Address address = new Address(); Customer customer = new Customer(); customer.AccountNumber = qbCustomer.AccountNumber != null?qbCustomer.AccountNumber.GetValue() : null; customer.Name = qbCustomer.Name.GetValue(); customer.Address = address.getAddress(qbCustomer.BillAddress); customer.Email = qbCustomer.Email != null?qbCustomer.Email.GetValue() : null; customer.Phone = qbCustomer.Phone != null?qbCustomer.Phone.GetValue() : null; _customers.Add(customer); } return(_customers); }
/// <summary> /// Get customer by identifier /// </summary> /// <param name="query">Query object where logic of selection resides</param> /// <returns></returns> public Task <CustomerDto> GetCustomer(ICustomerQuery query) { return(query.Execute(UserContext)); }
public static void DoQbXml() { bool sessionBegun = false; bool connectionOpen = false; QBSessionManager sessionManager = null; sessionManager = new QBSessionManager(); //Connect to QuickBooks and begin a session sessionManager.OpenConnection("", "GenerateInvoicePDFs"); connectionOpen = true; sessionManager.BeginSession("", ENOpenMode.omDontCare); sessionBegun = true; //Create the message set request object to hold our request IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; IInvoiceQuery invoiceQueryRq = requestMsgSet.AppendInvoiceQueryRq(); invoiceQueryRq.IncludeLineItems.SetValue(true); //Send the request and get the response from QuickBooks IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); IResponse response = responseMsgSet.ResponseList.GetAt(0); IInvoiceRetList invoiceRetList = (IInvoiceRetList)response.Detail; var invoices = new List <Invoice>(); if (invoiceRetList != null) { for (int i = 0; i < invoiceRetList.Count; i++) { IInvoiceRet invoiceRet = invoiceRetList.GetAt(i); var invoice = new Invoice { QuickBooksID = invoiceRet.TxnID.GetValue(), EditSequence = invoiceRet.EditSequence.GetValue(), InvoiceNumber = invoiceRet.RefNumber?.GetValue(), Memo = invoiceRet.Memo?.GetValue(), JobNumber = invoiceRet.Other?.GetValue() }; Console.WriteLine($"INv:{invoice.InvoiceNumber}, EditSequence: {invoice.JobNumber}"); requestMsgSet.ClearRequests(); ICustomerQuery customerQueryRq = requestMsgSet.AppendCustomerQueryRq(); customerQueryRq.ORCustomerListQuery.ListIDList.Add(invoiceRet.CustomerRef.ListID.GetValue()); //Send the request and get the response from QuickBooks responseMsgSet = sessionManager.DoRequests(requestMsgSet); response = responseMsgSet.ResponseList.GetAt(0); ICustomerRetList customerRetList = (ICustomerRetList)response.Detail; ICustomerRet customerRet = customerRetList.GetAt(0); if (i > 200) { return; } invoice.Customer = new Customer { Name = customerRet.Name.GetValue(), QuickBooksID = customerRet.ListID.GetValue(), EditSequence = customerRet.EditSequence.GetValue() }; if (invoiceRet.ORInvoiceLineRetList != null) { for (int j = 0; j < invoiceRet.ORInvoiceLineRetList.Count; j++) { IORInvoiceLineRet ORInvoiceLineRet = invoiceRet.ORInvoiceLineRetList.GetAt(j); try { var invoiceItem = new InvoiceItem { Amount = ORInvoiceLineRet.InvoiceLineRet.Amount.GetValue(), QuickBooksID = ORInvoiceLineRet.InvoiceLineRet.TxnLineID.GetValue() }; requestMsgSet.ClearRequests(); IItemQuery itemQueryRq = requestMsgSet.AppendItemQueryRq(); itemQueryRq.ORListQuery.ListIDList.Add(ORInvoiceLineRet.InvoiceLineRet.ItemRef.ListID.GetValue()); //Send the request and get the response from QuickBooks responseMsgSet = sessionManager.DoRequests(requestMsgSet); response = responseMsgSet.ResponseList.GetAt(0); IORItemRetList itemRetList = (IORItemRetList)response.Detail; IORItemRet itemRet = itemRetList.GetAt(0); if (itemRet.ItemInventoryRet != null) { IItemInventoryRet itemInventoryRet = itemRet.ItemInventoryRet; var item = new Item { Name = itemInventoryRet.Name.GetValue(), Description = itemInventoryRet.SalesDesc.GetValue(), Rate = itemInventoryRet.SalesPrice.GetValue(), //ItemType = ItemType.Inventory, QuickBooksID = itemInventoryRet.ListID.GetValue(), EditSequence = itemInventoryRet.EditSequence.GetValue() }; invoiceItem.Item = item; } else if (itemRet.ItemServiceRet != null) { IItemServiceRet itemServiceRet = itemRet.ItemServiceRet; var item = new Item { Name = itemServiceRet.Name.GetValue(), Description = itemServiceRet.ORSalesPurchase.SalesOrPurchase.Desc.GetValue(), Rate = itemServiceRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.GetValue(), //ItemType = ItemType.Service, QuickBooksID = itemServiceRet.ListID.GetValue(), EditSequence = itemServiceRet.EditSequence.GetValue() }; invoiceItem.Item = item; } invoice.InvoiceItems.Add(invoiceItem); } catch (Exception ex) { Console.WriteLine(invoice.Customer.Name); throw; } } } invoices.Add(invoice); } } }
public MainController(int p2p_port = 8081) : base(p2p_port) { _ProductQuery = LogicFactory.ProductQuery; _CustomerQuery = LogicFactory.CustomerQuery; _ProductCommand = LogicFactory.ProductCommand; }
public CustomerService(ICustomerQuery customerQuery, ICustomerRepository customerRepository, ICustomerValidator customerValidator) { _customerQuery = customerQuery; _customerRepository = customerRepository; _customerValidator = customerValidator; }
public IList <Invoice> GetInvoiceDetail(DateTime fromDate, DateTime toDate) { bool sessionBegun = false; QBSessionManager sessionManager = null; var invoices = new List <Invoice>(); sessionManager = new QBSessionManager(); IMsgSetRequest requestMsgSet = null; try { //Connect to QuickBooks and begin a session sessionManager.OpenConnection("", "GenerateInvoiceSummary"); //connectionOpen = true; sessionManager.BeginSession("", ENOpenMode.omDontCare); sessionBegun = true; //Create the message set request object to hold our request requestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; IInvoiceQuery invoiceQueryRq = requestMsgSet.AppendInvoiceQueryRq(); // all invoices modified in the month of August 2016 // get all invoices for the month of august 2016 invoiceQueryRq.ORInvoiceQuery.InvoiceFilter.ORDateRangeFilter.TxnDateRangeFilter.ORTxnDateRangeFilter.TxnDateFilter.FromTxnDate.SetValue(fromDate); invoiceQueryRq.ORInvoiceQuery.InvoiceFilter.ORDateRangeFilter.TxnDateRangeFilter.ORTxnDateRangeFilter.TxnDateFilter.ToTxnDate.SetValue(toDate); // invoiceQueryRq.ORInvoiceQuery.InvoiceFilter.ORDateRangeFilter.ModifiedDateRangeFilter.FromModifiedDate.SetValue(new DateTime(2017, 12, 1), true); // invoiceQueryRq.ORInvoiceQuery.InvoiceFilter.ORDateRangeFilter.ModifiedDateRangeFilter.ToModifiedDate.SetValue(new DateTime(2017, 12, 31), true); invoiceQueryRq.IncludeLineItems.SetValue(true); //Send the request and get the response from QuickBooks IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); IResponse response = responseMsgSet.ResponseList.GetAt(0); IInvoiceRetList invoiceRetList = (IInvoiceRetList)response.Detail; Console.WriteLine($"Invoices found: {invoiceRetList.Count}"); if (invoiceRetList != null) { for (int i = 0; i < invoiceRetList.Count; i++) { IInvoiceRet invoiceRet = invoiceRetList.GetAt(i); var invoice = new Invoice { QuickBooksID = invoiceRet.TxnID.GetValue(), EditSequence = invoiceRet.EditSequence.GetValue(), InvoiceNumber = invoiceRet.RefNumber?.GetValue(), InvoiceDate = invoiceRet.TimeCreated?.GetValue(), Memo = invoiceRet.Memo?.GetValue(), JobNumber = invoiceRet.Other?.GetValue(), CustomerName = invoiceRet.CustomerRef.FullName?.GetValue(), Amount = invoiceRet.BalanceRemaining?.GetValue() }; if (invoice.Amount == 0) { invoice.Amount = invoiceRet.Subtotal?.GetValue(); } var customerListId = invoiceRet.CustomerRef?.ListID?.GetValue(); if (customerListId != null) { // Console.WriteLine($"{i}\tInv:{invoice.InvoiceNumber}, Job: {invoice.JobNumber}, Name:{invoice.CustomerName}"); requestMsgSet.ClearRequests(); ICustomerQuery customerQueryRq = requestMsgSet.AppendCustomerQueryRq(); customerQueryRq.ORCustomerListQuery.ListIDList.Add(customerListId); //Send the request and get the response from QuickBooks responseMsgSet = sessionManager.DoRequests(requestMsgSet); response = responseMsgSet.ResponseList.GetAt(0); ICustomerRetList customerRetList = (ICustomerRetList)response.Detail; ICustomerRet customerRet = customerRetList.GetAt(0); invoice.Customer = new Customer { Name = customerRet.Name?.GetValue(), QuickBooksID = customerRet.ListID?.GetValue(), EditSequence = customerRet.EditSequence?.GetValue(), FullName = customerRet.FullName?.GetValue(), CompanyName = customerRet.CompanyName?.GetValue(), }; // Console.WriteLine($"{i}\t{invoice.Customer.Name}\t{invoice.Customer.FullName}\t{invoice.Customer.CompanyName}"); // Console.WriteLine($"{i}\t\tInvoice detail starts"); if (invoiceRet.ORInvoiceLineRetList != null) { invoice.Description = ""; if (invoiceRet.ORInvoiceLineRetList.Count > 0) { try { IORInvoiceLineRet orInvoiceLineRet = invoiceRet.ORInvoiceLineRetList.GetAt(1); invoice.Description = orInvoiceLineRet?.InvoiceLineRet?.Desc?.GetValue(); if (string.IsNullOrEmpty(invoice.Description)) { orInvoiceLineRet = invoiceRet.ORInvoiceLineRetList.GetAt(0); invoice.Description = orInvoiceLineRet?.InvoiceLineRet?.Desc?.GetValue(); } } catch (Exception ex) { Console.WriteLine(ex.Message); try { IORInvoiceLineRet orInvoiceLineRet = invoiceRet.ORInvoiceLineRetList.GetAt(0); invoice.Description = orInvoiceLineRet?.InvoiceLineRet?.Desc?.GetValue(); } catch (Exception ex2) { Console.WriteLine(ex2.Message); } } Console.WriteLine($"{invoice.InvoiceNumber}\t{invoice.Amount} \t{invoice.JobNumber}\t{invoice.Description}"); } // Console.WriteLine($"InvoiceList Count: {invoiceRet.ORInvoiceLineRetList.Count}"); /* * for (int j = 0; j < invoiceRet.ORInvoiceLineRetList.Count; j++) * { * IORInvoiceLineRet orInvoiceLineRet = invoiceRet.ORInvoiceLineRetList.GetAt(j); * * * if (orInvoiceLineRet != null && orInvoiceLineRet.InvoiceLineRet != null) * { * var invoiceItem = new InvoiceItem * { * Amount = orInvoiceLineRet.InvoiceLineRet.Amount?.GetValue(), * QuickBooksID = orInvoiceLineRet.InvoiceLineRet.TxnLineID?.GetValue() * }; * * requestMsgSet.ClearRequests(); * IItemQuery itemQueryRq = requestMsgSet.AppendItemQueryRq(); * itemQueryRq.ORListQuery.ListIDList.Add(orInvoiceLineRet.InvoiceLineRet.ItemRef?.ListID?.GetValue()); * * //Send the request and get the response from QuickBooks * responseMsgSet = sessionManager.DoRequests(requestMsgSet); * response = responseMsgSet.ResponseList.GetAt(0); * IORItemRetList itemRetList = (IORItemRetList)response.Detail; * // Console.WriteLine($"ItemRetList.Count: {itemRetList.Count}"); * * IORItemRet itemRet = itemRetList.GetAt(0); * var ortype = itemRet.ortype; * if (itemRet.ItemInventoryRet != null) * { * IItemInventoryRet itemInventoryRet = itemRet.ItemInventoryRet; * * var item = new Item * { * Name = itemInventoryRet.Name?.GetValue(), * Description = itemInventoryRet.SalesDesc?.GetValue(), * Rate = itemInventoryRet.SalesPrice?.GetValue(), * ItemType = ortype.ToString(), * QuickBooksID = itemInventoryRet.ListID?.GetValue(), * EditSequence = itemInventoryRet.EditSequence?.GetValue() * * }; * if (string.IsNullOrEmpty(item.Name)) * { * item.Name = itemInventoryRet.FullName?.GetValue(); * } * * invoiceItem.Item = item; * } * else if (itemRet.ItemServiceRet != null) * { * IItemServiceRet itemServiceRet = itemRet.ItemServiceRet; * * var item = new Item * { * Name = itemServiceRet.Name.GetValue(), * Description = itemServiceRet.ORSalesPurchase.SalesOrPurchase.Desc?.GetValue(), * Rate = itemServiceRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price?.GetValue(), * //ItemType = ItemType.Service, * ItemType = ortype.ToString(), * QuickBooksID = itemServiceRet.ListID?.GetValue(), * EditSequence = itemServiceRet.EditSequence?.GetValue(), * // FullName = itemServiceRet.ToString() * }; * if (string.IsNullOrEmpty(item.Name)) * { * item.Name = itemServiceRet.FullName?.GetValue(); * } * invoiceItem.Item = item; * } * else if (itemRet.ItemOtherChargeRet != null) * { * IItemOtherChargeRet itemOtherChargeRet = itemRet.ItemOtherChargeRet; * var item = new Item * { * Name = itemOtherChargeRet.Name?.GetValue(), * Description = itemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.Desc?.GetValue(), * Rate = itemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price?.GetValue(), * ItemType = ortype.ToString() * * }; * if (string.IsNullOrEmpty(item.Name)) * { * item.Name = itemOtherChargeRet.FullName?.GetValue(); * } * invoiceItem.Item = item; * } * else if (itemRet.ItemNonInventoryRet != null) * { * IItemNonInventoryRet itemNonInventoryRet = itemRet.ItemNonInventoryRet; * var item = new Item * { * Name = itemNonInventoryRet.Name?.GetValue(), * Description = itemNonInventoryRet.ORSalesPurchase.SalesOrPurchase.Desc?.GetValue(), * ItemType = ortype.ToString() * * }; * if (string.IsNullOrEmpty(item.Name)) * { * item.Name = itemNonInventoryRet.FullName?.GetValue(); * } * invoiceItem.Item = item; * } * Console.WriteLine($"{invoiceItem.Item.FullName}\t{invoice.InvoiceNumber}\t{invoiceItem.Amount}\t{invoiceItem.Item.Description}"); * invoice.InvoiceItems.Add(invoiceItem); * * } * } */ } } invoices.Add(invoice); } } if (requestMsgSet != null) { Marshal.FinalReleaseComObject(requestMsgSet); } sessionManager.EndSession(); sessionBegun = false; sessionManager.CloseConnection(); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString() + "\nStack Trace: \n" + ex.StackTrace + "\nExiting the application"); if (requestMsgSet != null) { Marshal.FinalReleaseComObject(requestMsgSet); } if (sessionBegun) { sessionManager.EndSession(); sessionManager.CloseConnection(); } } return(invoices); }
public CustomerController(ICustomerQuery customerQuery) { this.customerQuery = customerQuery; }
private void view_customers_Click(object sender, RoutedEventArgs e) { bool sessionBegun = false; bool connectionOpen = false; QBSessionManager sessionManager = null; try { //Create the session Manager object sessionManager = new QBSessionManager(); //Create the message set request object to hold our request IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; //Connect to QuickBooks and begin a session sessionManager.OpenConnection("", "WpfApplication1"); connectionOpen = true; sessionManager.BeginSession(@"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\Imperial2.qbw", ENOpenMode.omDontCare); sessionBegun = true; ICustomerQuery customerQueryRq = requestMsgSet.AppendCustomerQueryRq(); //Send the request and get the response from QuickBooks IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); IResponse response = responseMsgSet.ResponseList.GetAt(0); ICustomerRetList customerRetList = (ICustomerRetList)response.Detail; var customers = new List <Customer>(); if (customerRetList != null) { for (int i = 0; i < customerRetList.Count; i++) { ICustomerRet customerRet = customerRetList.GetAt(i); var customer = new Customer { Name = customerRet.Name.GetValue(), Id = customerRet.ListID.GetValue() //EditSequence = customerRet.EditSequence.GetValue() }; customers.Add(customer); } } dataGrid.ItemsSource = customers; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } finally { //End the session and close the connection to QuickBooks if (sessionBegun) { sessionManager.EndSession(); } if (connectionOpen) { sessionManager.CloseConnection(); } } }
public CustomerController(ICustomerQuery customerQuery) { _customerQuery = customerQuery; }
public Task <IEnumerable <CustomerDto> > GetCustomers(ICustomerQuery query) { throw new System.NotImplementedException(); }
public CustomerController(ICustomerQuery query) { _query = query; }
// Get the ICustomerQuery through DI public SomeClass(ICustomerQuery customerQuery) { _customerQuery = customerQuery; }