private void WalkInvoiceAddRs(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return; } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return; } for (int i = 0; i < responseList.Count; i++) { IResponse response = responseList.GetAt(i); if (response.StatusCode >= 0) { if (response.Detail != null) { ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtInvoiceAddRs) { IInvoiceRet invoiceRet = (IInvoiceRet)response.Detail; WalkInvoiceRet(invoiceRet); } } } } Console.WriteLine(responseMsgSet.ToXMLString()); }
public DataExt CreateDataExt(DataExt dataExt) { requestMsgSet.ClearRequests(); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; IDataExtDefAdd DataDef = requestMsgSet.AppendDataExtDefAddRq(); DataDef.OwnerID.SetValue("0"); DataDef.DataExtName.SetValue(VaultID); DataDef.DataExtType.SetValue(ENDataExtType.detSTR255TYPE); DataDef.AssignToObjectList.Add(ENAssignToObject.atoCustomer); IDataExtAdd DataExtAddRq = requestMsgSet.AppendDataExtAddRq(); DataExtAddRq.OwnerID.SetValue("0"); DataExtAddRq.DataExtName.SetValue(VaultID); DataExtAddRq.ORListTxnWithMacro.ListDataExt.ListDataExtType.SetValue(ENListDataExtType.ldetCustomer); DataExtAddRq.ORListTxnWithMacro.ListDataExt.ListObjRef.ListID.SetValue(dataExt.ListID); //DataExtAddRq.ORListTxnWithMacro.ListDataExt.ListObjRef.FullName.SetValue("ab"); //Set field value for DataExtValue DataExtAddRq.DataExtValue.SetValue(dataExt.DataExtValue); responseMsgSet = sessionManager.DoRequests(requestMsgSet); IResponseList responseList = responseMsgSet.ResponseList; IResponse response = responseMsgSet.ResponseList.GetAt(0); 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.rtDataExtDefAddRs) { IDataExtDefRet DataExtRet = (IDataExtDefRet)response.Detail; if (DataExtRet == null) { return(null); } if (DataExtRet.OwnerID != null) { dataExt.OwnerID = (string)DataExtRet.OwnerID.GetValue(); } //Get value of DataExtName dataExt.DataExtName = (string)DataExtRet.DataExtName.GetValue(); //Get value of DataExtValue //dataExt.DataExtValue = (string)DataExtRet. .DataExtValue.GetValue(); } } } else { throw new QBException(response.StatusCode, response.StatusMessage.ToString(), requestMsgSet.ToXMLString()); } return(dataExt); }
public string CreatePayment(ReceivePayment Payment) { requestMsgSet.ClearRequests(); IReceivePaymentAdd PaymentAddRq = requestMsgSet.AppendReceivePaymentAddRq(); PaymentAddRq.CustomerRef.FullName.SetValue(Payment.CustomerName); PaymentAddRq.Memo.SetValue(Payment.Memo); PaymentAddRq.TotalAmount.SetValue(Payment.TotalAmount); //Adding Invoice Reference ...... if (!string.IsNullOrEmpty(Payment.InvoiceTxnID)) { IAppliedToTxnAdd TxnAdd = PaymentAddRq.ORApplyPayment.AppliedToTxnAddList.Append(); TxnAdd.TxnID.SetValue(Payment.InvoiceTxnID); TxnAdd.PaymentAmount.SetValue(Payment.TotalAmount); // TxnAdd.PaymentAmount.SetValue(Payment.TotalAmount); } else { PaymentAddRq.ORApplyPayment.IsAutoApply.SetValue(true); } string xml = requestMsgSet.ToXMLString(); responseMsgSet = sessionManager.DoRequests(requestMsgSet); if (responseMsgSet.ResponseList.GetAt(0).StatusCode == 0) { IResponse response = responseMsgSet.ResponseList.GetAt(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.rtReceivePaymentAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IReceivePaymentRet PaymentRet = (IReceivePaymentRet)response.Detail; if (PaymentRet != null) { return(PaymentRet.EditSequence.GetValue()); } } } return("-1"); } else { throw new QBException(responseMsgSet.ResponseList.GetAt(0).StatusCode, "QBEngine :" + responseMsgSet.ResponseList.GetAt(0).StatusMessage, requestMsgSet.ToXMLString()); return("-1"); } }
private IItemInventoryRet GetInventoryItem(string fullName) { IItemInventoryRetList itemInventoryRetList = null; IItemInventoryRet InventoryItem = null; try { QBItemInventory _QBItemInventory = new QBItemInventory(); IResponseList responseList = _QBItemInventory.GetItemInventor(fullName, sessionManager); //if we sent only one request, there is only one response. 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.rtItemInventoryQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above itemInventoryRetList = (IItemInventoryRetList)response.Detail; if (itemInventoryRetList != null && itemInventoryRetList.Count > 0) { for (int j = 0; j < itemInventoryRetList.Count; j++) { InventoryItem = itemInventoryRetList.GetAt(j); } } } } } else { int statusCode = response.StatusCode; string statusMessage = response.StatusMessage; string statusSeverity = response.StatusSeverity; } } } catch (Exception e) { } return(InventoryItem); }
public DataExt UpdateDataExt(DataExt dataExt) { requestMsgSet.ClearRequests(); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; IDataExtMod DataExtMod = requestMsgSet.AppendDataExtModRq(); DataExtMod.DataExtName.SetValue(VaultID); DataExtMod.DataExtValue.SetValue(dataExt.DataExtValue); DataExtMod.OwnerID.SetValue("0"); DataExtMod.ORListTxn.ListDataExt.ListDataExtType.SetValue(ENListDataExtType.ldetCustomer); DataExtMod.ORListTxn.ListDataExt.ListObjRef.ListID.SetValue(dataExt.ListID); responseMsgSet = sessionManager.DoRequests(requestMsgSet); IResponseList responseList = responseMsgSet.ResponseList; IResponse response = responseMsgSet.ResponseList.GetAt(0); 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.rtDataExtModRs) { //IDataExtMod DataExtRet = (IDataExtMod)response.Detail; //if (DataExtRet == null) return null; //if (DataExtRet.OwnerID != null) //{ // dataExt.OwnerID = (string)DataExtRet.OwnerID.GetValue(); //} ////Get value of DataExtName //dataExt.DataExtName = (string)DataExtRet.DataExtName.GetValue(); ////Get value of DataExtValue ////dataExt.DataExtValue = (string)DataExtRet. .DataExtValue.GetValue(); } } } else { throw new QBException(response.StatusCode, response.StatusMessage.ToString(), requestMsgSet.ToXMLString()); } return(dataExt); }
private IAccountRetList GetQBAccountDetails() { IAccountRetList AccountList = null; try { if (sessionManager != null) { QBAccount _qbAccount = new QBAccount(); IResponseList responseList = _qbAccount.GetQBAccountInfo(sessionManager); if (responseList == null) { return(null); } //if we sent only one request, there is only one response. 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 AccountList = (IAccountRetList)response.Detail; } } } else { //*** Error Handling. } } } } catch (Exception e) { } return(AccountList); }
private List <Invoice> walkInvoice(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return(null); } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return(null); } IResponse response = responseList.GetAt(0); //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.rtInvoiceQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IInvoiceRetList InvoiceRet = (IInvoiceRetList)response.Detail; int count = InvoiceRet.Count; if (count > 0) { InvoiceList = new List <Invoice>(); } for (int a = 0; a < count; a++) { InvoiceList.Add(WalkInvoiceSearchRet(InvoiceRet.GetAt(a))); } } } } else { throw new QBException(response.StatusCode, response.StatusMessage.ToString(), requestMsgSet.ToXMLString()); } return(InvoiceList); }
private QBResponceItem WalkInventoryAdjustmentAddRs(IMsgSetResponse responseMsgSet) { QBResponceItem _qbResponceItem = null; if (responseMsgSet == null) { return(null); } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return(null); } //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++) { _qbResponceItem = new QBResponceItem(); IResponse response = responseList.GetAt(i); _qbResponceItem.StatusCode = response.StatusCode; _qbResponceItem.StatusMessage = response.StatusMessage; _qbResponceItem.StatusSeverity = response.StatusSeverity; //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.rtInventoryAdjustmentAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IInventoryAdjustmentRet InventoryAdjustmentRet = (IInventoryAdjustmentRet)response.Detail; _qbResponceItem.InventoryItemAdjustment = InventoryAdjustmentRet; } } } } return(_qbResponceItem); }
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); } } } } } } }
string WalkInvoiceAddRs(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return(null); } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return(null); } //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.rtInvoiceAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IInvoiceRet InvoiceRet = (IInvoiceRet)response.Detail; return(WalkInvoiceRet(InvoiceRet)); } } } else { throw new QBException(response.StatusCode, response.StatusMessage, requestMsgSet.ToXMLString()); } } return(null); }
private IList <Customer> WalkCustomerQuery(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return(null); } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return(null); } int count = responseList.Count; //if we sent only one request, there is only one response, we'll walk the list for this sample for (int i = 0; i < count; i++) { IResponse response = responseList.GetAt(i); if (response.StatusCode == 0) { if (response.Detail != null) { ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtCustomerQueryRs) { ICustomerRetList CustomerRet = (ICustomerRetList)response.Detail; return(WalkCustomers(CustomerRet)); } } } else { throw new QBException(response.StatusCode, response.StatusMessage, requestMsgSet.ToXMLString()); } } return(null); }
/// <summary> /// Processes the returned query response. /// </summary> /// <param name="queryResponse"></param> private async Task <ObservableCollection <InventoryItem> > ProcessItemQuery(IMsgSetResponse queryResponse) { ObservableCollection <InventoryItem> inventoryItems = null; IResponse response = queryResponse.ResponseList.GetAt(0); int statusCode = response.StatusCode; if (statusCode == 0) { if (response.Detail != null) { ENResponseType resopnseType = (ENResponseType)response.Type.GetValue(); if (resopnseType == ENResponseType.rtItemQueryRs) { IORItemRetList itemList = response.Detail as IORItemRetList; inventoryItems = await ParseItemList(itemList); } } } return(inventoryItems); }
void WalkPaymentMethodQueryRs(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++) { MethodList = new List <PaymentMethod>(); 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.rtPaymentMethodQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IPaymentMethodRetList PaymentMethodRet = (IPaymentMethodRetList)response.Detail; int count = PaymentMethodRet.Count; for (int a = 0; a < count; a++) { MethodList.Add(WalkPaymentMethodRet(PaymentMethodRet.GetAt(a))); } } } } } }
void RequestNonInventory() { requestMsgSet.ClearRequests(); IItemNonInventoryQuery Inventory = requestMsgSet.AppendItemNonInventoryQueryRq(); //Inventory.IsActive.SetValue(true); responseMsgSet = sessionManager.DoRequests(requestMsgSet); IResponseList responseList = responseMsgSet.ResponseList; IResponse response = responseMsgSet.ResponseList.GetAt(0); 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.rtItemNonInventoryQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IItemNonInventoryRetList ItemNonInventoryRetList = (IItemNonInventoryRetList)response.Detail; int count = ItemNonInventoryRetList.Count; if (count > 0) { ItemList = new List <Items>(); } for (int a = 0; a < count; a++) { ItemList.Add(WalkNonInventoryItem(ItemNonInventoryRetList.GetAt(a))); } } } } else { throw new QBException(response.StatusCode, response.StatusMessage.ToString(), requestMsgSet.ToXMLString()); } }
public TrackableCollection <ItemInventoryRet> WalkItemInventoryQueryRs(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return(null); } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return(null); } //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.rtItemInventoryQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above IItemInventoryRetList ItemInventoryRet = (IItemInventoryRetList)response.Detail; return(WalkItemInventoryRet(ItemInventoryRet)); } } } } return(null); }
public string GetCompanyName() { ICompanyQuery CompanyQueryRq = requestMsgSet.AppendCompanyQueryRq(); responseMsgSet = sessionManager.DoRequests(requestMsgSet); ICompanyRet CompanyRet = null; if (responseMsgSet == null) { return(null); } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return(null); } for (int i = 0; i < responseList.Count; i++) { IResponse response = responseList.GetAt(i); if (response.StatusCode >= 0) { if (response.Detail != null) { ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtCompanyQueryRs) { CompanyRet = (ICompanyRet)response.Detail; } } } } return((string)CompanyRet.CompanyName.GetValue()); }
public void WalkSalesReceiptQueryRs(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.rtSalesReceiptQueryRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above ISalesReceiptRetList SalesReceiptRet = (ISalesReceiptRetList)response.Detail; SaveToDataBase(WalkSalesReceiptRet(SalesReceiptRet)); } } } } }
public static void Main() { QBSessionManager sessionManager = new QBSessionManager(); try { IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0); sessionManager.OpenConnection("", "TEST"); sessionManager.BeginSession("", ENOpenMode.omDontCare); requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; IItemInventoryQuery ItemInventoryQueryRq = requestMsgSet.AppendItemInventoryQueryRq(); IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet); if (responseMsgSet == null) { return; } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return; } for (int i = 0; i < responseList.Count; i++) { IResponse response = responseList.GetAt(i); if (response.StatusCode >= 0) { if (response.Detail != null) { ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtItemInventoryQueryRs) { IItemInventoryRetList ItemInventoryRet = (IItemInventoryRetList)response.Detail; for (int j = 0; j < ItemInventoryRet.Count; j++) { if (ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef != null) { string itemListId = ItemInventoryRet.GetAt(j).ListID.GetValue(); string itemFullName = ItemInventoryRet.GetAt(j).FullName.GetValue(); short ItemType = ItemInventoryRet.GetAt(j).Type.GetValue(); string unitOfMeasurementRefListId = ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.ListID.GetValue(); string unitOfMeasurementRefFullName = ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.FullName.GetValue(); short unitOfMeasurementRefType = ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.Type.GetValue(); Console.WriteLine($"Item Id: {itemListId}\r\nItem Full Name: {itemFullName}\r\n{ItemType}\r\nUnit of Measurement List Id: {unitOfMeasurementRefListId}\r\nUnit of Measurement Full Name: {unitOfMeasurementRefFullName}\r\nUnit of Measurement Type: {unitOfMeasurementRefType}\r\n"); IMsgSetRequest uomRequestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0); IUnitOfMeasureSetQuery UnitOfMeasureSetQueryRq = uomRequestMsgSet.AppendUnitOfMeasureSetQueryRq(); UnitOfMeasureSetQueryRq.ORListQuery.ListIDList.Add(ItemInventoryRet.GetAt(j).UnitOfMeasureSetRef.ListID.GetValue()); IMsgSetResponse unitOfMeaurementResponseMsgSet = sessionManager.DoRequests(uomRequestMsgSet); WalkUnitOfMeasureSetQueryRs(unitOfMeaurementResponseMsgSet); } } } } } } sessionManager.EndSession(); sessionManager.CloseConnection(); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.Message, "Error"); sessionManager.EndSession(); sessionManager.CloseConnection(); Console.ReadLine(); } }
static void WalkUnitOfMeasureSetQueryRs(IMsgSetResponse responseMsgSet) { if (responseMsgSet == null) { return; } IResponseList responseList = responseMsgSet.ResponseList; if (responseList == null) { return; } for (int i = 0; i < responseList.Count; i++) { IResponse response = responseList.GetAt(i); if (response.StatusCode >= 0) { if (response.Detail != null) { ENResponseType responseType = (ENResponseType)response.Type.GetValue(); if (responseType == ENResponseType.rtUnitOfMeasureSetQueryRs) { IUnitOfMeasureSetRetList UnitOfMeasureSetRet = (IUnitOfMeasureSetRetList)response.Detail; for (int j = 0; j < UnitOfMeasureSetRet.Count; j++) { if (UnitOfMeasureSetRet != null) { if (UnitOfMeasureSetRet.GetAt(j).BaseUnit != null) { if (UnitOfMeasureSetRet.GetAt(j).BaseUnit.Abbreviation != null) { string baseUnitAbbreviation = UnitOfMeasureSetRet.GetAt(j).BaseUnit.Abbreviation.GetValue(); Console.WriteLine($"Base Unit Abbreviation: {baseUnitAbbreviation}"); } if (UnitOfMeasureSetRet.GetAt(j).BaseUnit.Name != null) { string baseUnitName = UnitOfMeasureSetRet.GetAt(j).BaseUnit.Name.GetValue(); Console.WriteLine($"Base Unit Name: {baseUnitName}"); } if (UnitOfMeasureSetRet.GetAt(j).BaseUnit.Type != null) { short baseUnitType = UnitOfMeasureSetRet.GetAt(j).BaseUnit.Type.GetValue(); Console.WriteLine($"Base Unit Type: {baseUnitType}"); } } if (UnitOfMeasureSetRet.GetAt(j).DefaultUnitList != null) { for (int i22940 = 0; i22940 < UnitOfMeasureSetRet.GetAt(j).DefaultUnitList.Count; i22940++) { if (UnitOfMeasureSetRet.GetAt(j).DefaultUnitList.GetAt(i22940) != null) { IDefaultUnit DefaultUnit = UnitOfMeasureSetRet.GetAt(j).DefaultUnitList.GetAt(i22940); if (DefaultUnit.UnitUsedFor != null) { ENUnitUsedFor UnitUsedFor22941 = DefaultUnit.UnitUsedFor.GetValue(); Console.WriteLine($"Unit used for: {UnitUsedFor22941}"); } if (DefaultUnit.Unit != null) { string Unit22942 = DefaultUnit.Unit.GetValue(); Console.WriteLine($"Default Unit: {Unit22942}"); } } } } if (UnitOfMeasureSetRet.GetAt(j).EditSequence != null) { string editSequence = UnitOfMeasureSetRet.GetAt(j).EditSequence.GetValue(); Console.WriteLine($"Edit sequence: {editSequence}"); } if (UnitOfMeasureSetRet.GetAt(j).IsActive != null) { bool isActive = UnitOfMeasureSetRet.GetAt(j).IsActive.GetValue(); Console.WriteLine($"Is active: {isActive}"); } if (UnitOfMeasureSetRet.GetAt(j).ListID != null) { string listId = UnitOfMeasureSetRet.GetAt(j).ListID.GetValue(); Console.WriteLine($"List Id: {listId}"); } if (UnitOfMeasureSetRet.GetAt(j).Name != null) { string name = UnitOfMeasureSetRet.GetAt(j).Name.GetValue(); Console.WriteLine($"Name: {name}"); } if (UnitOfMeasureSetRet.GetAt(j).RelatedUnitList != null) { for (int i22936 = 0; i22936 < UnitOfMeasureSetRet.GetAt(j).RelatedUnitList.Count; i22936++) { if (UnitOfMeasureSetRet.GetAt(j).RelatedUnitList.GetAt(i22936) != null) { IRelatedUnit RelatedUnit = UnitOfMeasureSetRet.GetAt(j).RelatedUnitList.GetAt(i22936); if (RelatedUnit.Name != null) { string Name22937 = RelatedUnit.Name.GetValue(); Console.WriteLine($"Related Unit: {Name22937}"); } if (RelatedUnit.Abbreviation != null) { string Abbreviation22938 = RelatedUnit.Abbreviation.GetValue(); Console.WriteLine($"Related Unit Abbreviation: {Abbreviation22938}"); } if (RelatedUnit.ConversionRatio != null) { double ConversionRatio22939 = RelatedUnit.ConversionRatio.GetValue(); Console.WriteLine($"Conversion Ratio: {ConversionRatio22939}"); } } } } if (UnitOfMeasureSetRet.GetAt(j).TimeCreated != null) { DateTime timeCreated = UnitOfMeasureSetRet.GetAt(j).TimeCreated.GetValue(); Console.WriteLine($"Time created: {timeCreated}"); } if (UnitOfMeasureSetRet.GetAt(j).TimeModified != null) { DateTime timeModified = UnitOfMeasureSetRet.GetAt(j).TimeModified.GetValue(); Console.WriteLine($"Time modified: {timeModified}"); } if (UnitOfMeasureSetRet.GetAt(j).Type != null) { short type = UnitOfMeasureSetRet.GetAt(j).Type.GetValue(); Console.WriteLine($"Type: {type}"); } if (UnitOfMeasureSetRet.GetAt(j).UnitOfMeasureType != null) { ENUnitOfMeasureType unitOfMeasurementType = UnitOfMeasureSetRet.GetAt(j).UnitOfMeasureType.GetValue(); Console.WriteLine($"Unit of Measure Type: {unitOfMeasurementType}\r\n"); } } } } } } } }
private string[,] parseItemQueryRs(IMsgSetResponse responseMsgSet, int countOfRows, int arraySize) { /* * <?xml version="1.0" ?> * - <QBXML> * - <QBXMLMsgsRs> * - <ItemQueryRs requestID="2" statusCode="0" statusSeverity="Info" statusMessage="Status OK"> * - <ItemServiceRet> * <ListID>20000-933272655</ListID> * <TimeCreated>1999-07-29T11:24:15-08:00</TimeCreated> * <TimeModified>2007-12-15T11:32:53-08:00</TimeModified> * <EditSequence>1197747173</EditSequence> * <Name>Installation</Name> * <FullName>Installation</FullName> * <IsActive>true</IsActive> * <Sublevel>0</Sublevel> * - <SalesTaxCodeRef> * <ListID>20000-999022286</ListID> * <FullName>Non</FullName> * </SalesTaxCodeRef> * - <SalesOrPurchase> * <Desc>Installation labor</Desc> * <Price>35.00</Price> * - <AccountRef> * <ListID>190000-933270541</ListID> * <FullName>Construction Income:Labor Income</FullName> * </AccountRef> * </SalesOrPurchase> * </ItemServiceRet> * </ItemQueryRs> * </QBXMLMsgsRs> * </QBXML> */ string[,] retVal = new string[countOfRows, arraySize]; IResponse response = responseMsgSet.ResponseList.GetAt(0); int statusCode = response.StatusCode; if (statusCode == 0) { if (response.Detail == null) { return(null); } ENResponseType responseType = (ENResponseType)response.Type.GetValue(); IORItemRetList OR = null; if (responseType == ENResponseType.rtItemQueryRs) { OR = response.Detail as IORItemRetList; } else { return(null); } for (int i = 0; i < countOfRows; i++) { if (OR.GetAt(i) == null) { break; } if (OR.GetAt(i).ItemServiceRet != null) { string fullName = null, desc = null; double price = 0.0; if (OR.GetAt(i).ItemServiceRet.FullName != null) { fullName = OR.GetAt(i).ItemServiceRet.FullName.GetValue(); populateRetVal(ref retVal, i, 0, "fullName", fullName); } if (OR.GetAt(i).ItemServiceRet.ORSalesPurchase != null) { if (OR.GetAt(i).ItemServiceRet.ORSalesPurchase.SalesOrPurchase != null) { //Get value of Desc if (OR.GetAt(i).ItemServiceRet.ORSalesPurchase.SalesOrPurchase.Desc != null) { desc = (string)OR.GetAt(i).ItemServiceRet.ORSalesPurchase.SalesOrPurchase.Desc.GetValue(); populateRetVal(ref retVal, i, 0, "desc", desc); } if (OR.GetAt(i).ItemServiceRet.ORSalesPurchase.SalesOrPurchase.ORPrice != null) { if (OR.GetAt(i).ItemServiceRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price != null) { //Get value of Price price = (double)OR.GetAt(i).ItemServiceRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.GetValue(); populateRetVal(ref retVal, i, 1, "price", price.ToString()); } } } } } if (OR.GetAt(i).ItemNonInventoryRet != null) { string fullName = null, desc = null; double price = 0.0; if (OR.GetAt(i).ItemNonInventoryRet.FullName != null) { fullName = OR.GetAt(i).ItemNonInventoryRet.FullName.GetValue(); populateRetVal(ref retVal, i, 0, "fullName", fullName); } if (OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase != null) { if (OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase.SalesOrPurchase != null) { //Get value of Desc if (OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase.SalesOrPurchase.Desc != null) { desc = (string)OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase.SalesOrPurchase.Desc.GetValue(); populateRetVal(ref retVal, i, 0, "desc", desc); } if (OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase.SalesOrPurchase.ORPrice != null) { if (OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price != null) { //Get value of Price price = (double)OR.GetAt(i).ItemNonInventoryRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.GetValue(); populateRetVal(ref retVal, i, 1, "price", price.ToString()); } } } } } if (OR.GetAt(i).ItemOtherChargeRet != null) { string fullName = null, desc = null; double price = 0.0; if (OR.GetAt(i).ItemOtherChargeRet.FullName != null) { fullName = OR.GetAt(i).ItemOtherChargeRet.FullName.GetValue(); populateRetVal(ref retVal, i, 0, "fullName", fullName); } if (OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase != null) { if (OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase.SalesOrPurchase != null) { //Get value of Desc if (OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.Desc != null) { desc = (string)OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.Desc.GetValue(); populateRetVal(ref retVal, i, 0, "desc", desc); } if (OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.ORPrice != null) { if (OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price != null) { //Get value of Price price = (double)OR.GetAt(i).ItemOtherChargeRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.GetValue(); populateRetVal(ref retVal, i, 1, "price", price.ToString()); } } } } } if (OR.GetAt(i).ItemInventoryRet != null) { string fullName = null, desc = null; double price = 0.0; if (OR.GetAt(i).ItemInventoryRet.FullName != null) { fullName = OR.GetAt(i).ItemInventoryRet.FullName.GetValue(); populateRetVal(ref retVal, i, 0, "fullName", fullName); } if (OR.GetAt(i).ItemInventoryRet.SalesDesc != null) { //Get value of Desc desc = (string)OR.GetAt(i).ItemInventoryRet.SalesDesc.GetValue(); populateRetVal(ref retVal, i, 0, "desc", desc); } if (OR.GetAt(i).ItemInventoryRet.SalesPrice != null) { //Get value of Price price = (double)OR.GetAt(i).ItemInventoryRet.SalesPrice.GetValue(); populateRetVal(ref retVal, i, 1, "price", price.ToString()); } } if (OR.GetAt(i).ItemInventoryAssemblyRet != null) { string fullName = null, desc = null; double price = 0.0; if (OR.GetAt(i).ItemInventoryAssemblyRet.FullName != null) { fullName = OR.GetAt(i).ItemInventoryAssemblyRet.FullName.GetValue(); populateRetVal(ref retVal, i, 0, "fullName", fullName); } if (OR.GetAt(i).ItemInventoryAssemblyRet.SalesDesc != null) { //Get value of Desc desc = (string)OR.GetAt(i).ItemInventoryAssemblyRet.SalesDesc.GetValue(); populateRetVal(ref retVal, i, 0, "desc", desc); } if (OR.GetAt(i).ItemInventoryAssemblyRet.SalesPrice != null) { //Get value of Price price = (double)OR.GetAt(i).ItemInventoryAssemblyRet.SalesPrice.GetValue(); populateRetVal(ref retVal, i, 1, "price", price.ToString()); } } } } return(retVal); }
public string createCustomer(Customer customer) { requestMsgSet.ClearRequests(); ICustomerAdd CustomerAddRq = requestMsgSet.AppendCustomerAddRq(); //if (!string.IsNullOrEmpty(customer.Parent)) // CustomerAddRq.ParentRef.FullName.SetValue(customer.Parent); CustomerAddRq.Name.SetValue(customer.Name); CustomerAddRq.MiddleName.SetValue(customer.MiddleName); CustomerAddRq.AccountNumber.SetValue(customer.AccountNumber); CustomerAddRq.OpenBalance.SetValue(customer.OpeningBalance); CustomerAddRq.OpenBalanceDate.SetValue(customer.OpeningDate); CustomerAddRq.IsActive.SetValue(customer.isActive); CustomerAddRq.BillAddress.Addr1.SetValue(customer.BillAddress1); CustomerAddRq.BillAddress.Addr2.SetValue(customer.BillAddress2); CustomerAddRq.BillAddress.Addr3.SetValue(customer.BillAddress3); CustomerAddRq.BillAddress.Addr4.SetValue(customer.BillAddress4); //CustomerAddRq.BillAddress.Addr5.SetValue(customer.BillAddress5); CustomerAddRq.BillAddress.City.SetValue(customer.BillCity); CustomerAddRq.BillAddress.State.SetValue(customer.BillState); CustomerAddRq.BillAddress.PostalCode.SetValue(customer.BillPostcode); CustomerAddRq.BillAddress.Country.SetValue(customer.BillCounty); CustomerAddRq.Phone.SetValue(customer.Phone); CustomerAddRq.Email.SetValue(customer.Email); CustomerAddRq.Fax.SetValue(customer.Fax); CustomerAddRq.Pager.SetValue(customer.Pager); CustomerAddRq.Contact.SetValue(customer.Contact); CustomerAddRq.AltContact.SetValue(customer.AltContact); CustomerAddRq.AltPhone.SetValue(customer.AltPhone); CustomerAddRq.CreditCardInfo.CreditCardAddress.SetValue(customer.CreditCardAddress); CustomerAddRq.CreditCardInfo.CreditCardNumber.SetValue(customer.CreditCardNumber); CustomerAddRq.CreditCardInfo.CreditCardPostalCode.SetValue(customer.CreditCardPostalCode); if (customer.ExpirationMonth >= 1) { CustomerAddRq.CreditCardInfo.ExpirationMonth.SetValue(customer.ExpirationMonth); } if (customer.ExpirationYear >= 1) { CustomerAddRq.CreditCardInfo.ExpirationYear.SetValue(customer.ExpirationYear); } CustomerAddRq.CreditCardInfo.NameOnCard.SetValue(customer.NameOnCard); CustomerAddRq.Salutation.SetValue(customer.Salutation); CustomerAddRq.ShipAddress.Addr1.SetValue(customer.ShipAddress1); CustomerAddRq.ShipAddress.Addr2.SetValue(customer.ShipAddress2); CustomerAddRq.ShipAddress.Addr3.SetValue(customer.ShipAddress3); CustomerAddRq.ShipAddress.Addr4.SetValue(customer.ShipAddress4); CustomerAddRq.ShipAddress.City.SetValue(customer.ShipCity); CustomerAddRq.ShipAddress.Country.SetValue(customer.ShipCountry); CustomerAddRq.Notes.SetValue(customer.Note); CustomerAddRq.JobDesc.SetValue(customer.JobDesc); //------------------------- Customer Fields Need to be added if (customer.SalesRepRef_FullName != null) { CustomerAddRq.SalesRepRef.FullName.SetValue(customer.SalesRepRef_FullName); } if (customer.ResaleNumber != null) { CustomerAddRq.ResaleNumber.SetValue(customer.ResaleNumber); } if (customer.TermsRef_FullName != null) { CustomerAddRq.TermsRef.FullName.SetValue(customer.TermsRef_FullName); } if (customer.Preferd_PaymentMethod_FullName != null) { CustomerAddRq.PreferredPaymentMethodRef.FullName.SetValue(customer.Preferd_PaymentMethod_FullName); } responseMsgSet = sessionManager.DoRequests(requestMsgSet); if (responseMsgSet.ResponseList.GetAt(0).StatusCode == 0) { IResponse response = responseMsgSet.ResponseList.GetAt(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.rtCustomerAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above ICustomerRet CustomerRet = (ICustomerRet)response.Detail; if (CustomerRet != null) { return(CustomerRet.ListID.GetValue()); } } } return("-1"); } else { throw new QBException(responseMsgSet.ResponseList.GetAt(0).StatusCode, "QBEngine :" + responseMsgSet.ResponseList.GetAt(0).StatusMessage, requestMsgSet.ToXMLString()); return("-1"); } }
protected Dictionary <string, string> QuickBooksExcuet(IMsgSetRequest requestMsgSet, string externalId = null) { try { SessionManager.OpenConnection("QuickBooks Application", "QuickBooks Application"); ConnectionOpen = true; SessionManager.BeginSession("", ENOpenMode.omDontCare); SessionBegun = true; IMsgSetResponse responseMsgSet = SessionManager.DoRequests(requestMsgSet); SessionManager.EndSession(); SessionBegun = false; SessionManager.CloseConnection(); ConnectionOpen = false; if (responseMsgSet != null) { IResponseList responseList = responseMsgSet.ResponseList; 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) { var result = new Dictionary <string, string>(); result.Add("StatusCode", response.StatusCode + ""); //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.rtCustomerAddRs) { //upcast to more specific type here, this is safe because we checked with response.Type check above ICustomerRet customerRet = (ICustomerRet)response.Detail; if (customerRet != null) { string newId = customerRet.ListID.GetValue(); result.Add("Message", "Customer has been Added successfully"); result.Add("ListID", newId); return(result); } } if (responseType == ENResponseType.rtCustomerModRs) { ICustomerRet ItemInventoryRet = (ICustomerRet)response.Detail; if (ItemInventoryRet != null) { string newId = ItemInventoryRet.ListID.GetValue(); result.Add("Message", $"Customer with Id {newId} has been updated Successfully"); return(result); } } if (responseType == ENResponseType.rtListDelRs) { IQBENListDelTypeType ListDelType = (IQBENListDelTypeType)response.Detail; result.Add("Message", $"Customer with Id {externalId} has been deleted Successfully"); return(result); } if (responseType == ENResponseType.rtAccountQueryRs) { IAccountRetList AccountRet = (IAccountRetList)response.Detail; for (int j = 0; j < AccountRet.Count; j++) { var acc = AccountRet.GetAt(j); string FullName = (string)acc.FullName.GetValue(); result.Add("Name", FullName); } } } else { result.Add("Error", response.StatusMessage); return(result); } } } } } catch (Exception ex) { if (SessionBegun) { SessionManager.EndSession(); } if (ConnectionOpen) { SessionManager.CloseConnection(); } return(new Dictionary <string, string>() { { "Error", ex.Message } }); } return(new Dictionary <string, string>()); }
///<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); }
public List <InventoryItem> UpdateItemUPCAndListID(List <InventoryItem> inventoryItems) { //Item Request IMsgSetRequest itemRequestset = _MySessionManager.CreateMsgSetRequest("US", 13, 0); IItemQuery itemQuery = itemRequestset.AppendItemQueryRq(); itemQuery.OwnerIDList.Add("0"); //Get item codes from sales order and add to item request foreach (InventoryItem item in inventoryItems) { itemQuery.ORListQuery.FullNameList.Add(item.ItemCode); } IMsgSetResponse responseItemRq = _MySessionManager.DoRequests(itemRequestset); IResponseList itemResponseList = responseItemRq.ResponseList; IResponse itemResponse = itemResponseList.GetAt(0); ENResponseType responseType = (ENResponseType)itemResponse.Type.GetValue(); IORItemRetList QBItemList = (IORItemRetList)itemResponse.Detail; for (int i = 0; i <= QBItemList.Count - 1; i++) { if (QBItemList.GetAt(i).ItemNonInventoryRet != null) { if (QBItemList.GetAt(i).ItemNonInventoryRet.Name != null) { string itemCode = QBItemList.GetAt(i).ItemNonInventoryRet.Name.GetValue(); if (QBItemList.GetAt(i).ItemNonInventoryRet.ManufacturerPartNumber != null) { inventoryItems.First(a => a.ItemCode == itemCode).MPN = QBItemList.GetAt(i).ItemNonInventoryRet.ManufacturerPartNumber.GetValue(); } if (QBItemList.GetAt(i).ItemNonInventoryRet.ListID != null) { inventoryItems.First(a => a.ItemCode == itemCode).ListID = QBItemList.GetAt(i).ItemNonInventoryRet.ListID.GetValue(); } } } if (QBItemList.GetAt(i).ItemInventoryRet != null) { IItemInventoryRet iInventory = QBItemList.GetAt(i).ItemInventoryRet; //get item external data (custom fields) //IDataExtRetList dataExtRetList = OR.GetAt(i).ItemInventoryRet.DataExtRetList; //if (dataExtRetList != null) //{ // Console.WriteLine(dataExtRetList.Count); // IDataExtRet dataExtRet = dataExtRetList.GetAt(0); // Console.WriteLine(dataExtRet.DataExtName.GetValue() + " === " + dataExtRet.DataExtValue.GetValue()); //} if (QBItemList.GetAt(i).ItemInventoryRet.Name != null) { string itemCode = QBItemList.GetAt(i).ItemInventoryRet.Name.GetValue(); if (QBItemList.GetAt(i).ItemInventoryRet.ManufacturerPartNumber != null) { inventoryItems.First(a => a.ItemCode == itemCode).MPN = QBItemList.GetAt(i).ItemInventoryRet.ManufacturerPartNumber.GetValue(); } if (QBItemList.GetAt(i).ItemInventoryRet.ListID != null) { inventoryItems.First(a => a.ItemCode == itemCode).ListID = QBItemList.GetAt(i).ItemInventoryRet.ListID.GetValue(); } } } if (QBItemList.GetAt(i).ItemInventoryAssemblyRet != null) { if (QBItemList.GetAt(i).ItemInventoryAssemblyRet.Name != null) { string itemCode = QBItemList.GetAt(i).ItemInventoryAssemblyRet.Name.GetValue(); if (QBItemList.GetAt(i).ItemInventoryAssemblyRet.ManufacturerPartNumber != null) { inventoryItems.First(a => a.ItemCode == itemCode).MPN = QBItemList.GetAt(i).ItemInventoryAssemblyRet.ManufacturerPartNumber.GetValue(); } if (QBItemList.GetAt(i).ItemInventoryAssemblyRet.ListID != null) { inventoryItems.First(a => a.ItemCode == itemCode).ListID = QBItemList.GetAt(i).ItemInventoryAssemblyRet.ListID.GetValue(); } } } //if (item.ItemCode != null) // _inventoryItems.Add(item); } return(inventoryItems); }
public List <InventoryItem> getAllItems() { try { //Item Request IMsgSetRequest itemRequestset = _MySessionManager.CreateMsgSetRequest("US", 13, 0); IItemQuery itemQuery = itemRequestset.AppendItemQueryRq(); itemQuery.OwnerIDList.Add("0"); ////Get item codes from sales order and add to item request //for (int i = 0; i < SalesOrderItems.Count; ++i) //{ // IORSalesOrderLineRet SalesOrderItem = SalesOrderItems.GetAt(i); // itemQuery.ORListQuery.FullNameList.Add(SalesOrderItem.SalesOrderLineRet.ItemRef.FullName.GetValue()); //} //itemQuery.ORListQuery.FullNameList.Add("17531"); //itemQuery.ORListQuery.FullNameList.Add("17534"); //itemQuery.ORListQuery.FullNameList.Add("17535"); //itemQuery.ORListQuery.FullNameList.Add("17536"); //itemQuery.ORListQuery.FullNameList.Add("17537"); //itemQuery.ORListQuery.FullNameList.Add("17538"); //itemQuery.ORListQuery.FullNameList.Add("62231"); //itemQuery.ORListQuery.FullNameList.Add("12061"); IMsgSetResponse responseItemRq = _MySessionManager.DoRequests(itemRequestset); IResponseList itemResponseList = responseItemRq.ResponseList; IResponse itemResponse = itemResponseList.GetAt(0); ENResponseType responseType = (ENResponseType)itemResponse.Type.GetValue(); IORItemRetList QBItemList = (IORItemRetList)itemResponse.Detail; for (int i = 0; i <= QBItemList.Count - 1; i++) { InventoryItem item = new InventoryItem(); IDataExtRetList customFieldsList; if (QBItemList.GetAt(i).ItemNonInventoryRet != null) { IItemNonInventoryRet inventoryItem = QBItemList.GetAt(i).ItemNonInventoryRet; customFieldsList = QBItemList.GetAt(i).ItemNonInventoryRet.DataExtRetList; item.ListID = inventoryItem.ListID != null?inventoryItem.ListID.GetValue() : ""; item.ItemCode = inventoryItem.Name != null?inventoryItem.Name.GetValue() : ""; item.Description = inventoryItem.FullName.GetValue() != null?inventoryItem.FullName.GetValue() : ""; item.MPN = inventoryItem.ManufacturerPartNumber != null?inventoryItem.ManufacturerPartNumber.GetValue() : ""; } else if (QBItemList.GetAt(i).ItemInventoryRet != null) { IItemInventoryRet inventoryItem = QBItemList.GetAt(i).ItemInventoryRet; customFieldsList = QBItemList.GetAt(i).ItemInventoryRet.DataExtRetList; item.ListID = inventoryItem.ListID != null?inventoryItem.ListID.GetValue() : ""; item.ItemCode = inventoryItem.Name != null?inventoryItem.Name.GetValue() : ""; item.Description = inventoryItem.SalesDesc != null?inventoryItem.SalesDesc.GetValue() : ""; item.MPN = inventoryItem.ManufacturerPartNumber != null?inventoryItem.ManufacturerPartNumber.GetValue() : ""; item.Price = inventoryItem.SalesPrice.GetValue(); } else if (QBItemList.GetAt(i).ItemInventoryAssemblyRet != null) { IItemInventoryAssemblyRet inventoryItem = QBItemList.GetAt(i).ItemInventoryAssemblyRet; customFieldsList = QBItemList.GetAt(i).ItemInventoryAssemblyRet.DataExtRetList; item.ListID = inventoryItem.ListID != null?inventoryItem.ListID.GetValue() : ""; item.ItemCode = inventoryItem.Name != null?inventoryItem.Name.GetValue() : ""; item.Description = inventoryItem.SalesDesc.GetValue() != null?inventoryItem.SalesDesc.GetValue() : ""; item.MPN = inventoryItem.ManufacturerPartNumber != null?inventoryItem.ManufacturerPartNumber.GetValue() : ""; } else { customFieldsList = null; } //get item external data (custom fields) if (customFieldsList != null) { for (int iCustomField = 0; iCustomField <= customFieldsList.Count - 1; iCustomField++) { string fieldName = customFieldsList.GetAt(iCustomField).DataExtName.GetValue(); string fieldValue = customFieldsList.GetAt(iCustomField).DataExtValue.GetValue(); if (fieldName == "Inner") { item.Inner = fieldValue; } if (fieldName == "Case") { item.Case = fieldValue; } if (fieldName == "Price2") { item.Price2 = Convert.ToDouble(fieldValue); } if (fieldName == "Volume") { item.Volume = fieldValue; } if (fieldName == "Price3") { item.Price3 = Convert.ToDouble(fieldValue); } } } if (item.ItemCode != null) { _inventoryItems.Add(item); } } return(_inventoryItems); } catch (Exception) { throw new Exception("Failed to read Items from QuickBooks."); } }