private void BeginSession() { //sessionManager.OpenConnection("1", "Insight QBBulk"); //short majorVersion; //short minorVersion; //ENReleaseLevel releaseLevel; //short releaseNumber; //sessionManager.GetVersion(out majorVersion, out minorVersion, out releaseLevel, out releaseNumber); try { sessionManager.OpenConnection("1", "Insight QBPOS"); connectionOpen = true; sessionManager.BeginSession("Computer Name=user-think;Company Data=spice isle pharmacy;Version=9");//"" // MessageBox.Show(sessionManager.GetCurrentCompanyFileName()); // sessionManager.BeginSession(""); sessionBegun = true; } catch (Exception e) { MessageBox.Show(e.Message, "Error"); if (sessionBegun) { sessionManager.EndSession(); } if (connectionOpen) { sessionManager.CloseConnection(); } } }
private void BeginSession() { //sessionManager.OpenConnection("1", "Insight QBBulk"); //short majorVersion; //short minorVersion; //ENReleaseLevel releaseLevel; //short releaseNumber; //sessionManager.GetVersion(out majorVersion, out minorVersion, out releaseLevel, out releaseNumber); try { sessionManager.OpenConnection("1", "QS2QBPost"); connectionOpen = true; sessionManager.BeginSession("Computer Name=server;Company Data=hills and valley gd;Version=11");// //sessionManager.BeginSession(""); sessionBegun = true; } catch (Exception e) { MessageBox.Show(e.Message, "Error"); if (sessionBegun) { sessionManager.EndSession(); } if (connectionOpen) { sessionManager.CloseConnection(); } } }
private void BeginSession() { //sessionManager.OpenConnection("1", "Insight QBBulk"); //short majorVersion; //short minorVersion; //ENReleaseLevel releaseLevel; //short releaseNumber; //sessionManager.GetVersion(out majorVersion, out minorVersion, out releaseLevel, out releaseNumber); try { sessionManager.OpenConnection("1", "QuickSales"); connectionOpen = true; sessionManager.BeginSession("");//Computer Name=JOSEPH-PC;Company Data=test;Version=11 //sessionManager.BeginSession(""); sessionBegun = true; } catch (Exception e) { MessageBox.Show(e.Message, "Error"); if (sessionBegun) { sessionManager.EndSession(); } if (connectionOpen) { sessionManager.CloseConnection(); } } }
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(); }
public void DoSalesReceiptQuery() { bool sessionBegun = false; bool connectionOpen = false; QBPOSSessionManager sessionManager = null; //try //{ // get qbpos filename string qbposfile = ""; //Create the session Manager object sessionManager = new QBPOSSessionManager(); IMsgSetRequest ItemInventoryRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); ItemInventoryRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; ItemInventoryViewModel inventoryVM = new ItemInventoryViewModel(); inventoryVM.BuildItemInventoryQueryRq(ItemInventoryRequestMsgSet); //Create the message set request object to hold our request IMsgSetRequest SalesReceiptRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); SalesReceiptRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; SalesReceiptViewModel SalesReceiptVM = new SalesReceiptViewModel(); SalesReceiptVM.BuildSalesReceiptQueryRq(SalesReceiptRequestMsgSet); IMsgSetRequest InventoryAdjustmentRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0); InventoryAdjustmentRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue; InventoryAdjustmentViewModel AdjVM = new InventoryAdjustmentViewModel(); AdjVM.BuildInventoryAdjustmentQueryRq(InventoryAdjustmentRequestMsgSet); //Connect to QuickBooks and begin a session sessionManager.OpenConnection("1", "Insight POSAI"); 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; //Send the request and get the response from QuickBooks IMsgSetResponse ItemInventoryResponseMsgSet = sessionManager.DoRequests(ItemInventoryRequestMsgSet); IMsgSetResponse SalesReceiptResponseMsgSet = sessionManager.DoRequests(SalesReceiptRequestMsgSet); IMsgSetResponse InventoryAdjustmentResponseMsgSet = sessionManager.DoRequests(InventoryAdjustmentRequestMsgSet); //End the session and close the connection to QuickBooks sessionManager.EndSession(); sessionBegun = false; sessionManager.CloseConnection(); connectionOpen = false; inventoryVM.WalkItemInventoryQueryRs(ItemInventoryResponseMsgSet); SalesReceiptVM.WalkSalesReceiptQueryRs(SalesReceiptResponseMsgSet); AdjVM.WalkInventoryAdjustmentQueryRs(InventoryAdjustmentResponseMsgSet); //} //catch (Exception e) //{ // MessageBox.Show(e.Message, "Error"); // if (sessionBegun) // { // sessionManager.EndSession(); // } // if (connectionOpen) // { // sessionManager.CloseConnection(); // } //} }