using System.Text.Json; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.BackgroundWorkers; using Win_in.Sfs.Auth.Application.Contracts; using Win_in.Sfs.Auth.Users; using Win_in.Sfs.Auth.Users.Inputs; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts; using Win_in.Sfs.Wms.DataExchange.Domain; using Win_in.Sfs.Wms.Store.Application.Contracts; namespace Win_in.Sfs.Wms.DataExchange.Agent; public static class IncomingToWmsExtensions { public static async Task HandlePurchaseOrdersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var purchaseOrder = JsonSerializer.Deserialize(incomingConverted.DataContent); var purchaseOrderAppService = workerContext.ServiceProvider.GetRequiredService(); await purchaseOrderAppService.CreateAsync(purchaseOrder).ConfigureAwait(false); } public static async Task HandleAsnsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var supplierAsn = JsonSerializer.Deserialize(incomingConverted.DataContent); var supplierAsnAppService = workerContext.ServiceProvider.GetRequiredService(); await supplierAsnAppService.CreateAsync(supplierAsn).ConfigureAwait(false); } public static async Task HandleDictsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var Dict = JsonSerializer.Deserialize(incomingConverted.DataContent); var DictBasicAppService = workerContext.ServiceProvider.GetRequiredService(); await DictBasicAppService.UpdateAsync(Dict).ConfigureAwait(false); } public static async Task HandleUsersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var user = JsonSerializer.Deserialize(incomingConverted.DataContent); var userBasicAppService = workerContext.ServiceProvider.GetRequiredService(); await userBasicAppService.UpdateByNmaeAsync(user).ConfigureAwait(false); } public static async Task HandleDepartmentsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var Department = JsonSerializer.Deserialize(incomingConverted.DataContent); var DepartmentBasicAppService = workerContext.ServiceProvider.GetRequiredService(); await DepartmentBasicAppService.UpdateAsync(Department).ConfigureAwait(false); } public static async Task HandleItemsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var item = JsonSerializer.Deserialize(incomingConverted.DataContent); var itemBasicAppService = workerContext.ServiceProvider.GetRequiredService(); await itemBasicAppService.UpsertAsync(item).ConfigureAwait(false); } public static async Task HandleErpLocationsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var erpLocation = JsonSerializer.Deserialize(incomingConverted.DataContent); var erpLocationAppService = workerContext.ServiceProvider.GetRequiredService(); await erpLocationAppService.UpsertAsync(erpLocation).ConfigureAwait(false); } public static async Task HandleBomsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var bom = JsonSerializer.Deserialize(incomingConverted.DataContent); var bomAppService = workerContext.ServiceProvider.GetRequiredService(); await bomAppService.UpsertAsync(bom).ConfigureAwait(false); } public static async Task HandleSuppliersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var supplier = JsonSerializer.Deserialize(incomingConverted.DataContent); var supplierAppService = workerContext.ServiceProvider.GetRequiredService(); await supplierAppService.UpsertAsync(supplier).ConfigureAwait(false); } public static async Task HandleSupplierItemsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var supplierItem = JsonSerializer.Deserialize(incomingConverted.DataContent); var supplierItemAppService = workerContext.ServiceProvider.GetRequiredService(); await supplierItemAppService.UpsertAsync(supplierItem).ConfigureAwait(false); } public static async Task HandleItemPacksAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var itemPack = JsonSerializer.Deserialize(incomingConverted.DataContent); var itemPackAppService = workerContext.ServiceProvider.GetRequiredService(); await itemPackAppService.UpsertAsync(itemPack).ConfigureAwait(false); } public static async Task HandleCustomersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var customer = JsonSerializer.Deserialize(incomingConverted.DataContent); var customerAppService = workerContext.ServiceProvider.GetRequiredService(); await customerAppService.UpsertAsync(customer).ConfigureAwait(false); } public static async Task HandleCustomerItemsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var customerItem = JsonSerializer.Deserialize(incomingConverted.DataContent); var customerItemAppService = workerContext.ServiceProvider.GetRequiredService(); await customerItemAppService.UpsertAsync(customerItem).ConfigureAwait(false); } public static async Task HandleSaleOrdersAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var saleOrder = JsonSerializer.Deserialize(incomingConverted.DataContent); var saleOrderAppService = workerContext.ServiceProvider.GetRequiredService(); await saleOrderAppService.UpsertAsync(saleOrder).ConfigureAwait(false); } public static async Task HandleProductReceiptsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var productReceipt = JsonSerializer.Deserialize(incomingConverted.DataContent); var productReceiptAppService = workerContext.ServiceProvider.GetRequiredService(); await productReceiptAppService.CreateAsync(productReceipt).ConfigureAwait(false); } public static async Task HandleMaterialRequestsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var materialRequest = JsonSerializer.Deserialize(incomingConverted.DataContent); var materialRequestAppService = workerContext.ServiceProvider.GetRequiredService(); await materialRequestAppService.CreateAndHandleAsync(materialRequest).ConfigureAwait(false); } public static async Task HandleScrapsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var scrap = JsonSerializer.Deserialize(incomingConverted.DataContent); var scrapAppService = workerContext.ServiceProvider.GetRequiredService(); await scrapAppService.CreateAsync(scrap).ConfigureAwait(false); } public static async Task HandleIssueNoteConfirmAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var number = incomingConverted.DataIdentityCode; var issueNoteAppService = workerContext.ServiceProvider.GetRequiredService(); await issueNoteAppService.ConfirmAsync(number).ConfigureAwait(false); } public static async Task HandleInventoryLabelsAsync(this IncomingToWms incomingConverted, PeriodicBackgroundWorkerContext workerContext) { var inventoryLabel = JsonSerializer.Deserialize(incomingConverted.DataContent); var inventoryLabelAppService = workerContext.ServiceProvider.GetRequiredService(); await inventoryLabelAppService.CreateAsync(inventoryLabel).ConfigureAwait(false); } }