Acumatica 以编程方式生成波浪拾取列表
你好 我想通过编程从创建和打印拾取列表(SO50305)屏幕生成一个波浪拾取列表 其思想是,每当wave pick列表的状态更改为picking时,就会发出推送通知,然后在webhook处理程序中使用该通知 我已经成功地获得了推送通知设置,webhook处理程序正在很好地接收通知。到目前为止,我已经设法在webhook处理程序中获得了一些很好的身份验证(遵循中的概念),但是我有点不了解如何真正实现以编程方式生成wave picklist的目标 据我所知,我需要做3件事才能让它工作:Acumatica 以编程方式生成波浪拾取列表,acumatica,Acumatica,你好 我想通过编程从创建和打印拾取列表(SO50305)屏幕生成一个波浪拾取列表 其思想是,每当wave pick列表的状态更改为picking时,就会发出推送通知,然后在webhook处理程序中使用该通知 我已经成功地获得了推送通知设置,webhook处理程序正在很好地接收通知。到目前为止,我已经设法在webhook处理程序中获得了一些很好的身份验证(遵循中的概念),但是我有点不了解如何真正实现以编程方式生成wave picklist的目标 据我所知,我需要做3件事才能让它工作: 设置SOPi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Results;
using Newtonsoft.Json;
using PX.Common;
using PX.Data;
using PX.Data.Webhooks;
using PX.Objects;
using PX.Objects.SO;
using SHPNW.Helpers;
namespace SHPNW
{
public class WavePickListAutomationHandler : IWebhookHandler
{
public async Task<System.Web.Http.IHttpActionResult> ProcessRequestAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
var ok = new OkResult(request);
using (var scope = GetAdminScope())
{
try
{
// Deserialize JSON into our Notification class
var notification = JsonConvert.DeserializeObject<NotificationMessage>(await request.Content.ReadAsStringAsync());
// No changes to make, lets exit
if (notification == null || (notification?.Inserted?.Count ?? 0) < 1)
{
return ok;
}
// Authorization Check
var secret = string.Empty;
if (request.Headers.TryGetValues("AuthHeaderKey", out IEnumerable<string> headerValues))
{
secret = headerValues.FirstOrDefault();
}
var queryHash = 'A UNIQUE HASHED STRING';
// If secret does not match we reject the notification
if (secret != queryHash)
{
return new StatusCodeResult(System.Net.HttpStatusCode.Unauthorized, request);
}
// Use the Create & Print Pick Lists graph to generate the next wave.
var graph = PXGraph.CreateInstance<SOPickingWorksheetProcess>();
var filter = graph.Filter;
// Here I would need to set the values on the filter
// Here I would need to 'select' 4 shipments from the filtered list of shipments.
// Here I would need to 'trigger' the Process button.
}
catch (Exception ex)
{
var failed = new ExceptionResult(ex, false, new DefaultContentNegotiator(), request, new[] { new JsonMediaTypeFormatter() });
return failed;
}
}
return ok;
}
private IDisposable GetAdminScope()
{
var userName = "admin";
if (PXDatabase.Companies.Length > 0)
{
var company = PXAccess.GetCompanyName();
if (string.IsNullOrEmpty(company))
{
company = PXDatabase.Companies[0];
}
userName = userName + "@" + company;
}
return new PXLoginScope(userName);
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Net.Http;
使用System.Net.Http.Formatting;
使用系统线程;
使用System.Threading.Tasks;
使用System.Web.Http;
使用System.Web.Http.Results;
使用Newtonsoft.Json;
使用PX.Common;
使用PX数据;
使用PX.Data.Webhooks;
使用PX.Objects;
使用PX.Objects.SO;
使用SHPNW.Helpers;
命名空间SHPNW
{
公共类WavePickListAutomationHandler:IWebhookHandler
{
公共异步任务ProcessRequestAsync(
HttpRequestMessage请求,CancellationToken CancellationToken)
{
var ok=新的ok结果(请求);
使用(var scope=GetAdminScope())
{
尝试
{
//将JSON反序列化到我们的通知类中
var notification=JsonConvert.DeserializeObject(wait request.Content.ReadAsStringAsync());
//没有要做的更改,让我们退出
如果(通知==null | |(通知?.Inserted?.Count?0)<1)
{
返回ok;
}
//授权检查
var secret=string.Empty;
if(request.Headers.TryGetValues(“AuthHeaderKey”,out IEnumerable headerValues))
{
secret=headerValues.FirstOrDefault();
}
var queryHash='A UNIQUE hash STRING';
//如果机密不匹配,我们将拒绝通知
如果(机密!=查询)
{
返回新的StatusCodeResult(System.Net.HttpStatusCode.Unauthorized,request);
}
//使用“创建和打印拾取列表”图形生成下一个波浪。
var-graph=PXGraph.CreateInstance();
var filter=graph.filter;
//在这里,我需要设置过滤器上的值
//在这里,我需要从筛选的装运列表中“选择”4个装运。
//在这里,我需要“触发”进程按钮。
}
捕获(例外情况除外)
{
var failed=new ExceptionResult(例如,false,new defaultcontentcongregator(),request,new[]{new JsonMediaTypeFormatter()});
返回失败;
}
}
返回ok;
}
私有IDisposable GetAdminScope()
{
var userName=“admin”;
如果(PXDatabase.companys.Length>0)
{
var company=PXAccess.GetCompanyName();
if(string.IsNullOrEmpty(公司))
{
company=PXDatabase.companys[0];
}
用户名=用户名+“@”+公司;
}
返回新的PXLoginScope(用户名);
}
}
}
查看源代码中的processing delegate ProcessShipmentsHandler()方法,该方法可以让您了解如何以编程方式生成wave picklist。