internal static async Task <T> AddAttachmentToController <T>(VismaNetAuthorization auth, string url, Stream input, string fileName) where T : class { var client = GetHttpClient(auth); input.Seek(0, SeekOrigin.Begin); using (var stream = new MemoryStream()) { await input.CopyToAsync(stream); stream.Seek(0, SeekOrigin.Begin); var content = new StreamContent(stream); content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = fileName, Name = "v" }; var request = new MultipartFormDataContent { content }; return(await client.PostMessage <T>(url, request)); } }
internal static async Task <List <DimensionSegment> > FetchDimension(string dimension, VismaNetAuthorization auth) { using (var webclient = GetHttpClient(auth)) { var apiUrl = GetApiUrlForController(VismaNetControllers.Dimensions, string.Format("/{0}", dimension.TrimStart('/'))); try { var container = await webclient.Get <DimensionContainer>(apiUrl); return(container.segments); } catch (AggregateException e) { VismaNetExceptionHandler.HandleException(e); } catch (WebException e) { VismaNetExceptionHandler.HandleException(e); } } return(null); }
internal CashSaleData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.CashSale; }
/*[ * "ACCGROUP","ACCOUNT","BIZACCT","CASHACCOUNT", * "CONTRACT","CONTRACTITEM","CUSTOMER","EMPLOYEE","INLOCATION", * "INSITE","INSUBITEM","INVENTORY","LOCATION","MLISTCD","PROJECT", * "PROTASK","SALESPER","SUBACCOUNT","TMCONTRACT","VENDOR"] * */ public DimensionData(VismaNetAuthorization auth) : base(auth) { }
public SubaccountData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Subaccount; }
public ShipmentData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Shipments; }
internal LocationData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Location; }
/// <summary> /// This constructor is called by the client to create the data source. /// </summary> public QueryableVismaNetCustomerInvoiceData(VismaNetAuthorization auth) : base(auth) { Provider = new VismaNetQueryProvider(Authorization); Expression = Expression.Constant(this); }
public AttributeData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Attribute; }
internal static Task <List <T> > GetAllAsyncTask <T>(string apiControllerUri, VismaNetAuthorization authorization, NameValueCollection parameters = null) { var webclient = GetHttpClient(authorization); var endpoint = GetApiUrlForController(apiControllerUri, parameters: parameters); return(webclient.Get <List <T> >(endpoint)); }
public static async Task <List <T> > GetAllWithPagination <T>(string ApiControllerUri, VismaNetAuthorization Authorization, NameValueCollection parameters = null) where T : DtoPaginatedProviderBase, IProvideIdentificator { var firstPage = await GetAll <T>(ApiControllerUri, Authorization, CreatePagionationParameters(initialPageSize, 1, parameters)); var rsp = new List <T>(); if (firstPage == null) { return(rsp); } rsp.AddRange(firstPage); var count = firstPage.Sum(x => x.GetSubCount()); if (firstPage.FirstOrDefault()?.metadata?.totalCount > count && count > 0) { var totalCount = firstPage[0].metadata.totalCount; var pageSize = count; var pageCount = totalCount / pageSize; var semaphore = new SemaphoreSlim(VismaNet.MaxConcurrentRequests); var taskList = new List <Task <List <T> > >(); foreach (var page in Enumerable.Range(2, pageCount)) { await semaphore.WaitAsync(); taskList.Add(Task.Run(async() => { try { return(await GetAll <T>(ApiControllerUri, Authorization, CreatePagionationParameters(pageSize, page, parameters))); } finally { semaphore.Release(); } })); } var tasks = await Task.WhenAll(taskList); rsp.AddRange(tasks.SelectMany(x => x)); } rsp.ForEach(x => x.InternalPrepareForUpdate()); return(rsp.OrderBy(x => x.GetIdentificator()).ToList()); }
internal static async Task <List <ExchangeRate> > UpdateExchangeRate(ExchangeRate exchangeRate, VismaNetAuthorization auth) { var webClient = GetHttpClient(auth); { var apiUrl = GetApiUrlForController(VismaNetControllers.CurrencyRate, $"/"); return(await webClient.Put <List <ExchangeRate> >(apiUrl, exchangeRate.ToDto(), $"{GetApiUrlForController(VismaNetControllers.CurrencyRate)}?toCurrency={exchangeRate.toCurrencyId.TrimStart('/')}&fromDate={exchangeRate.effectiveDate.ToString("yyyy-MM-dd")}&toDate={exchangeRate.effectiveDate.ToString("yyyy-MM-dd")}", true)); } }
internal static async Task <List <ExchangeRate> > FetchExchangeRates(string toCurrencyId, DateTime effectiveDate, VismaNetAuthorization auth) { var webClient = GetHttpClient(auth); { var apiUrl = GetApiUrlForController(VismaNetControllers.CurrencyRate, $"?toCurrency={toCurrencyId.TrimStart('/')}&fromDate={effectiveDate.ToString("yyyy-MM-dd")}&toDate={effectiveDate.ToString("yyyy-MM-dd")}"); return(await webClient.Get <List <ExchangeRate> >(apiUrl)); } }
public BranchData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Branch; }
public static async Task <List <Contact> > FetchContactsForCustomer(string customerNumber, VismaNetAuthorization authorization) { using (var webclient = GetHttpClient(authorization)) { var apiUrl = GetApiUrlForController(VismaNetControllers.Customers); try { var fullUrl = $"{apiUrl}/{customerNumber}/contact"; return(await webclient.Get <List <Contact> >(fullUrl)); } catch (AggregateException e) { VismaNetExceptionHandler.HandleException(e); } catch (WebException e) { VismaNetExceptionHandler.HandleException(e); } return(null); } }
/// <summary> /// This constructor is called by the client to create the data source. /// </summary> internal CustomerInvoiceData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.CustomerInvoice; }
/// <summary> /// This constructor is called by the client to create the data source. /// </summary> internal CustomerDocumentData(VismaNetAuthorization auth) { _authorization = auth; }
public GeneralLedgerBalanceData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.GeneralLedgerBalanceV2; }
public SalesOrderData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.SalesOrder; }
internal SupplierInvoiceData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.SupplierInvoices; }
/// <summary> /// This constructor is called by the client to create the data source. /// </summary> internal CreditNoteData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.CreditNote; }
public static async Task <List <InventorySummary> > FetchInventorySummaryForItem(string itemNo, VismaNetAuthorization authorization) { var webclient = GetHttpClient(authorization); { var apiUrl = GetApiUrlForController(VismaNetControllers.InventorySummary); try { var fullUrl = $"{apiUrl}/{itemNo}"; return(await webclient.Get <List <InventorySummary> >(fullUrl)); } catch (AggregateException e) { VismaNetExceptionHandler.HandleException(e); } catch (WebException e) { VismaNetExceptionHandler.HandleException(e); } return(null); } }
internal ContactData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Contacts; }
internal static async Task <List <CustomerDocument> > FetchCustomerDocumentsForCustomerCd(string customerNumber, VismaNetAuthorization authorization) { var webclient = GetHttpClient(authorization); { var endpoint = GetApiUrlForController(VismaNetControllers.Customers); try { var url = $"{endpoint}/{customerNumber}/document"; return(await webclient.Get <List <CustomerDocument> >(url)); } catch (AggregateException e) { VismaNetExceptionHandler.HandleException(e); } catch (WebException e) { VismaNetExceptionHandler.HandleException(e); } return(null); } }
internal ProjectData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Project; }
internal static async Task <List <CustomerInvoice> > FetchInvoicesForCustomerCd(string customerCd, VismaNetAuthorization authorization) { var webclient = GetHttpClient(authorization); { var apiUrl = GetApiUrlForController(VismaNetControllers.Customers); var fullUrl = $"{apiUrl}/{customerCd}/invoice"; return(await webclient.Get <List <CustomerInvoice> >(fullUrl) ?? new List <CustomerInvoice>()); } }
public InventoryData(VismaNetAuthorization auth) : base(auth) { ApiControllerUri = VismaNetControllers.Inventory; }
private static VismaNetHttpClient GetHttpClient(VismaNetAuthorization auth = null) { return(new VismaNetHttpClient(auth)); }
internal VismaNetHttpClient(VismaNetAuthorization auth = null) { authorization = auth; }
public static async Task <List <CustomerSalesPrice> > FetchCustomerSalesPricesForItem(string itemNo, VismaNetAuthorization authorization, PriceType priceType = PriceType.Undefined) { var webclient = GetHttpClient(authorization); { var apiUrl = GetApiUrlForController(VismaNetControllers.CustomerSalesPrices); try { string fullUrl = string.Empty; if (priceType == PriceType.Undefined) { fullUrl = $"{apiUrl}?inventoryId={itemNo}"; } else { fullUrl = $"{apiUrl}?priceType={priceType.ToString()}&inventoryId={itemNo}"; } return(await webclient.Get <List <CustomerSalesPrice> >(fullUrl)); } catch (AggregateException e) { VismaNetExceptionHandler.HandleException(e); } catch (WebException e) { VismaNetExceptionHandler.HandleException(e); } return(null); } }