public static List <CustomerRet> GetAllCustomersQuery(string QBCompanyFile) { int increment = 1000000; double startNumber = 0; double endNumber = 0; string errstring = null; var lst = new List <CustomerRet>(); while (errstring == null) { endNumber += increment; var requestXml = ItemInventoryViewModel.BuildCustomerQueryRq(startNumber.ToString(), endNumber.ToString()); var res = QBPosContext.ProcessXML(requestXml.OuterXml, QBCompanyFile); var itms = GetQBCustomers(res); lst.AddRange(itms); startNumber = endNumber; if (startNumber > 9999999) { break; } } return(lst); }
public static async Task <List <ItemInventoryRet> > GetAllInventoryQuery(string QBCompanyFile) { int increment = 1000; int toItemNumber = 0; int fromItemNumber = 0; string errstring = null; var lst = new List <ItemInventoryRet>(); while (errstring == null) { toItemNumber += increment; var requestXml = ItemInventoryViewModel.BuildItemInventoryQueryRq(fromItemNumber, toItemNumber); fromItemNumber = toItemNumber; var res = QBPosContext.ProcessXML(requestXml.OuterXml, QBCompanyFile); var itms = GetQBInventoryItems(res); if (!itms.Any()) { break; } lst.AddRange(itms); } return(lst); }
public static List <ItemInventoryRet> GetInventoryItemQuery(string QBCompanyFile, string itemNumber) { var modxml = ItemInventoryViewModel.BuildModifiedItemInventoryQuery(itemNumber); var modres = QBPosContext.ProcessXML(modxml.OuterXml, QBCompanyFile); //if(sessionBegun == true) var lst = new List <ItemInventoryRet>(); lst.AddRange(GetQBInventoryItems(modres)); return(lst.GroupBy(x => x.ListID).Select(grp => grp.First()).ToList()); }
public IEnumerable <ItemInventoryRet> GetInventoryItemQuery(int days = 1) { IMsgSetRequest ItemInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); ItemInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; ItemInventoryViewModel inventoryVM = new ItemInventoryViewModel(); inventoryVM.BuildItemInventoryQueryRq(ItemInventoryRequestMsgSet, days); BeginSession(); ////Send the request and get the response from QuickBooks IMsgSetResponse ItemInventoryResponseMsgSet = sessionManager.DoRequests(ItemInventoryRequestMsgSet); CloseSession(); return(inventoryVM.WalkItemInventoryQueryRs(ItemInventoryResponseMsgSet)); }
public List <ItemInventoryRet> GetInventoryItemQuery(int days = 1) { if (sessionManager != null) { IMsgSetRequest ItemModifiedInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); IMsgSetRequest ItemCreatedInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); ItemModifiedInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; ItemCreatedInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; ItemInventoryViewModel inventoryVM = new ItemInventoryViewModel(); inventoryVM.BuildModifiedItemInventoryQuery(ItemModifiedInventoryRequestMsgSet, days); inventoryVM.BuildCreatedItemInventoryQuery(ItemCreatedInventoryRequestMsgSet, days); //if(sessionBegun == false) // BeginSession(); ////Send the request and get the response from QuickBooks IMsgSetResponse ModifiedItemsLst = sessionManager.DoRequests(ItemModifiedInventoryRequestMsgSet); IMsgSetResponse CreatedItemsLst = sessionManager.DoRequests(ItemCreatedInventoryRequestMsgSet); //if(sessionBegun == true) var lst = new List <ItemInventoryRet>(); var tlst = new TrackableCollection <ItemInventoryRet>(null); if (ModifiedItemsLst != null) { tlst = inventoryVM.WalkItemInventoryQueryRs(ModifiedItemsLst); } if (tlst != null) { lst.AddRange(tlst.ToList()); } if (CreatedItemsLst != null) { tlst = inventoryVM.WalkItemInventoryQueryRs(CreatedItemsLst); } if (tlst != null) { lst.AddRange(tlst.ToList()); } return(lst.GroupBy(x => x.ListID).Select(grp => grp.First()).ToList()); } return(new List <ItemInventoryRet>()); }
public async Task <List <ItemInventoryRet> > GetAllInventoryQuery() { if (sessionManager != null) { var ItemInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); ItemInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; var inventoryVM = new ItemInventoryViewModel(); int increment = 1000; int toItemNumber = 0; int fromItemNumber = 0; string errstring = null; var lst = new List <ItemInventoryRet>(); while (errstring == null) { toItemNumber += increment; ItemInventoryRequestMsgSet.ClearRequests(); inventoryVM.BuildItemInventoryQueryRq(ItemInventoryRequestMsgSet, fromItemNumber, toItemNumber); fromItemNumber = toItemNumber; ItemInventoryRequestMsgSet.Verify(out errstring); IMsgSetResponse ItemInventoryResponseMsgSet = null; ItemInventoryResponseMsgSet = sessionManager.DoRequests(ItemInventoryRequestMsgSet); var responseStatus = new Tuple <string, TrackableCollection <ItemInventoryRet> >("", null); if (ItemInventoryResponseMsgSet != null) { responseStatus = await inventoryVM.WalkItemInventoryQueryRsAsync(ItemInventoryResponseMsgSet).ConfigureAwait(false); } if (errstring != null || responseStatus.Item1 == "0") { break; } lst.AddRange(responseStatus.Item2); } return(lst); } return(new List <ItemInventoryRet>()); }
public static async Task DownloadQbData(DateTime startDate, DateTime endDate, AsycudaDocumentSet currentAsycudaDocumentSet, bool ImportSales, bool ImportInventory) { StatusModel.Timer("Connecting to QuickBooks"); var sessionBegun = false; var connectionOpen = false; QBPOSSessionManager sessionManager = null; //try //{ // get qbpos filename var qbposfile = ""; //Create the session Manager object sessionManager = new QBPOSSessionManager(); sessionManager.OpenConnection("1", "Insight's Asycuda Toolkit"); short majorVersion; short minorVersion; ENReleaseLevel releaseLevel; short releaseNumber; // sessionManager.GetVersion(out majorVersion, out minorVersion, out releaseLevel, out releaseNumber); connectionOpen = true; sessionManager.BeginSession(qbposfile); sessionBegun = true; try { if (ImportInventory) { var ItemInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); ItemInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; var inventoryVM = new ItemInventoryViewModel(); int increment = 1000; int toItemNumber = 0; int fromItemNumber = 0; string errstring = null; while (errstring == null) { toItemNumber += increment; ItemInventoryRequestMsgSet.ClearRequests(); inventoryVM.BuildItemInventoryQueryRq(ItemInventoryRequestMsgSet, fromItemNumber, toItemNumber); fromItemNumber = toItemNumber; ItemInventoryRequestMsgSet.Verify(out errstring); IMsgSetResponse ItemInventoryResponseMsgSet = null; ItemInventoryResponseMsgSet = sessionManager.DoRequests(ItemInventoryRequestMsgSet); var responseStatus = new Tuple <string>(null); if (ItemInventoryResponseMsgSet != null) { responseStatus = await inventoryVM.WalkItemInventoryQueryRs(ItemInventoryResponseMsgSet).ConfigureAwait(false); } if (errstring != null || responseStatus.Item1 == "0") { break; } } } } catch (Exception) { throw; } if (ImportSales) { StatusModel.Timer("Getting Data Request"); var SalesReceiptRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); SalesReceiptRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; var SalesReceiptVM = new SalesReceiptViewModel(); SalesReceiptVM.BuildSalesReceiptQueryRq(SalesReceiptRequestMsgSet, startDate, endDate); IMsgSetResponse SalesReceiptResponseMsgSet = null; SalesReceiptResponseMsgSet = sessionManager.DoRequests(SalesReceiptRequestMsgSet); if (SalesReceiptResponseMsgSet != null) { await SalesReceiptVM.WalkSalesReceiptQueryRs(SalesReceiptResponseMsgSet, currentAsycudaDocumentSet).ConfigureAwait(false); } } //End the session and close the connection to QuickBooks sessionManager.EndSession(); sessionBegun = false; sessionManager.CloseConnection(); connectionOpen = false; StatusModel.StopStatusUpdate(); }