public async Task UpdateInventoryAsync(IEnumerable <Inventory> products) { var methodParameters = string.Format("{{products:{0}}}", products.ToJson()); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); if (products == null || !products.Any()) { return; } var response = await this._quickBooksOnlineServiceSdk.UpdateItemQuantityOnHand(products.ToQBInventoryItem().ToArray()).ConfigureAwait(false); QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark, methodResult: PredefinedValues.NotAvailable)); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task <IEnumerable <Models.GetOrders.Order> > GetOrdersAsync(params string[] docNumbers) { var methodParameters = string.Format("{{docNumbers:{0}}}", docNumbers.ToJson()); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); var result = new List <Models.GetOrders.Order>(); if (docNumbers.Length > 0) { var invoices = await this._quickBooksOnlineServiceSdk.GetInvoices(docNumbers).ConfigureAwait(false); var salesReceipts = await this._quickBooksOnlineServiceSdk.GetSalesReceipt(docNumbers).ConfigureAwait(false); var invoicesConverted = invoices.Invoices.ToQBOrder().ToList(); var salesReceiptsConverted = salesReceipts.SaleReceipts.ToQBOrder().ToList(); result = invoicesConverted.Concat(salesReceiptsConverted).ToList(); } QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark, methodResult: result.ToJson())); return(result); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task <IEnumerable <Models.GetOrders.Order> > GetOrdersAsync(DateTime dateFrom, DateTime dateTo) { var methodParameters = string.Format("{{dateFrom:{0}, dateTo:{1}}}", dateFrom, dateTo); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); dateFrom = dateFrom.ToUniversalTime(); dateTo = dateTo.ToUniversalTime(); var invoices = await this._quickBooksOnlineServiceSdk.GetInvoices(dateFrom, dateTo).ConfigureAwait(false); var salesReceipts = await this._quickBooksOnlineServiceSdk.GetSalesReceipt(dateFrom, dateTo).ConfigureAwait(false); var invoicesConverted = invoices.Invoices.ToQBOrder().ToList(); var salesReceiptsConverted = salesReceipts.SaleReceipts.ToQBOrder().ToList(); var result = invoicesConverted.Concat(salesReceiptsConverted); QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark, methodResult: result.ToJson())); return(result); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task <PingInfo> Ping() { try { //todo: replace me throw new NotImplementedException(); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task <IEnumerable <Models.GetOrders.Order> > GetOrdersAsync() { try { //todo: replace me throw new NotImplementedException(); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task CreateOrdersAsync(params Order[] purchaseOrders) { var methodParameters = string.Format("{{Orders:{0}}}", purchaseOrders.ToJson()); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); if (purchaseOrders == null || !purchaseOrders.Any()) { return; } var getItemsResponse = await this._quickBooksOnlineServiceSdk.GetItems(); var items = getItemsResponse.Items; FillOrdersLineItemsById(purchaseOrders, items.ToQBProduct()); var purchaseOrdersWithNotEmptyLineItems = GetOnlyPurchaseOrdersWithNotEmptyLineItemsId(purchaseOrders); var getVendorsResponse = await this._quickBooksOnlineServiceSdk.GetCustomers(); var customers = getVendorsResponse.Customers; FillOrdersByCustomerId(purchaseOrdersWithNotEmptyLineItems, customers); var ordersWithExistingCustomer = GetOnlyOrdersWithNotEmptyVendorId(purchaseOrdersWithNotEmptyLineItems); var paidOrders = ordersWithExistingCustomer.Where(x => x.OrderStatus == OrderStatusEnum.Paid).ToList(); var createPurchaseOrdersResponse = await this._quickBooksOnlineServiceSdk.CreateSaleReceipts(paidOrders.Select( x => x.ToQBSaleReceipt()).ToArray()).ConfigureAwait(false); QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark)); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task CreatePurchaseOrdersOrdersAsync(params Models.CreatePurchaseOrders.PurchaseOrder[] purchaseOrders) { var methodParameters = string.Format("{{purchaseOrders:{0}}}", purchaseOrders.ToJson()); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); if (purchaseOrders == null || !purchaseOrders.Any()) { return; } var getItemsResponse = await this._quickBooksOnlineServiceSdk.GetItems(); var items = getItemsResponse.Items; FillPurchaseOrdersLineItemsById(purchaseOrders, items.ToQBProduct()); var purchaseOrdersWithNotEmptyLineItems = GetOnlyPurchaseOrdersWithNotEmptyLineItemsId(purchaseOrders); var getVendorsResponse = await this._quickBooksOnlineServiceSdk.GetVendors(); var vendors = getVendorsResponse.Vendors; FillPurchaseOrdersByVendorId(purchaseOrdersWithNotEmptyLineItems, vendors); var ordersWithExistingVendor = GetOnlyPurchaseOrdersWithNotEmptyVendorId(purchaseOrdersWithNotEmptyLineItems); var createPurchaseOrdersResponse = await this._quickBooksOnlineServiceSdk.CreatePurchaseOrders(ordersWithExistingVendor.Select( x => x.ToQBPurchaseOrder()).ToArray()).ConfigureAwait(false); QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark)); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
public async Task <IEnumerable <PurchaseOrder> > GetPurchaseOrdersOrdersAsync(DateTime dateFrom, DateTime dateTo) { var methodParameters = string.Format("{{dateFrom:{0},dateTo:{1}}}", dateFrom, dateTo); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); var getPurchaseOrdersResponse = await this._quickBooksOnlineServiceSdk.GetPurchseOrders(dateFrom, dateTo).ConfigureAwait(false); var result = getPurchaseOrdersResponse.PurchaseOrders.ToQBPurchaseOrder().ToList(); QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark, methodResult: result.ToJson())); return(result); } catch (Exception exception) { var ebayException = new QuickBooksOnlineException(string.Format("Error. Was called:{0}", this.CreateMethodCallInfo(methodParameters, mark)), exception); LogTraceException(ebayException.Message, ebayException); throw ebayException; } }
public async Task <IEnumerable <Product> > GetProductsAsync() { var methodParameters = string.Format("{{{0}}}", PredefinedValues.NotAvailable); var mark = Guid.NewGuid().ToString(); try { QuickBooksOnlineLogger.LogTraceStarted(this.CreateMethodCallInfo(methodParameters, mark)); var itemsResponse = await this._quickBooksOnlineServiceSdk.GetTrackingItems().ConfigureAwait(false); var result = itemsResponse.Items.ToQBProduct(); QuickBooksOnlineLogger.LogTraceEnded(this.CreateMethodCallInfo(methodParameters, mark, methodResult: result.ToJson())); return(result); } catch (Exception exception) { var quickBooksException = new QuickBooksOnlineException(this.CreateMethodCallInfo(), exception); QuickBooksOnlineLogger.LogTraceException(quickBooksException); throw quickBooksException; } }
private static void LogTraceException(string message, QuickBooksOnlineException ebayException) { QuickBooksOnlineLogger.Log().Trace(ebayException, message); }