您好我已经创建了一个连接两个系统的例程:XXXXWIN10,它是一个带有Acumatica的本地系统。 XXXWIN10系统必须向Acumatica发送有关销售订单的信息。我正在使用screen webservice来创建销售订单。当我执行测试我的代码时,每次收到customerID时都不能为空,但我发送所有信息,并且客户也存在。你在我的代码中看到了什么问题:
using System;
using System.Net.Security;
using System.Net;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Conexionspa.apitest;
using System.Globalization;
namespace Conexionspa
{
class Program
{
static void Main(string[] args)
{
string CVECLI = "";
string CVEORDEN = "";
string FEC_ORDEN = "";
string DESCUENTO = "";
string CVESERVI = "";
string CANTIDAD = "";
decimal QTY = 0;
string PIEZAS = "";
string CAPA_REQ = "";
string CAPA_OBT = "";
string KILOS = "";
string TIPO_ACERO = "";
string RECIPIENTE = "";
string DUREZA_OBT = "";
string FEC_PROMES = "";
string PRECIOME = "";
decimal PRECIO = 0;
string IMPORTE = "";
string PORPIEZA = "";
string MONEDA = "";
string TIPOCAMBIO = "";
string PLANTA = "";
string conexion = @"Data Source = XXXXWIN10,2433; Initial Catalog = SYSXXXX; User ID = sa; Password = XXXYYYZZZ";
string queryString = "SELECT CVECLI, CVEORDEN, FEC_ORDEN, DESCUENTO, CVESERVI, CANTIDAD, PIEZAS, CAPA_REQ, CAPA_OBT, KILOS, TIPO_ACERO, RECIPIENTE, DUREZA_OBT, FEC_PROMES, PRECIOME, IMPORTE, PORPIEZA, MONEDA, TIPOCAMBIO, PLANTA FROM [Ordenes de Trabajo] WHERE STATUS = 2";
SqlConnection conection = new SqlConnection(conexion);
try
{
conection.Open();
SqlDataReader leeordenes = null;
SqlCommand Command = new SqlCommand(queryString, conection);
leeordenes = Command.ExecuteReader();
while (leeordenes.Read())
{
CVECLI = leeordenes["CVECLI"].ToString();
CVEORDEN = leeordenes["CVEORDEN"].ToString();
FEC_ORDEN = leeordenes["FEC_ORDEN"].ToString();
DateTime FECORDEN = DateTime.Parse(FEC_ORDEN);
DESCUENTO = leeordenes["DESCUENTO"].ToString();
CVESERVI = leeordenes["CVESERVI"].ToString();
CANTIDAD = leeordenes["CANTIDAD"].ToString();
decimal.TryParse(CANTIDAD, out QTY);
PIEZAS = leeordenes["PIEZAS"].ToString();
CAPA_REQ = leeordenes["CAPA_REQ"].ToString();
CAPA_OBT = leeordenes["CAPA_OBT"].ToString();
KILOS = leeordenes["KILOS"].ToString();
TIPO_ACERO = leeordenes["TIPO_ACERO"].ToString();
RECIPIENTE = leeordenes["RECIPIENTE"].ToString();
DUREZA_OBT = leeordenes["DUREZA_OBT"].ToString();
FEC_PROMES = leeordenes["FEC_PROMES"].ToString();
DateTime FECPROMES = DateTime.Parse(FEC_PROMES);
PRECIOME = leeordenes["PRECIOME"].ToString();
decimal.TryParse(PRECIOME, out PRECIO);
IMPORTE = leeordenes["IMPORTE"].ToString();
PORPIEZA = leeordenes["PORPIEZA"].ToString();
MONEDA = leeordenes["MONEDA"].ToString();
TIPOCAMBIO = leeordenes["TIPOCAMBIO"].ToString();
PLANTA = leeordenes["PLANTA"].ToString();
apitest.Screen context = new apitest.Screen();
context.CookieContainer = new CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "http://localhost/XXXYYY/Soap/APITEST.asmx";
try
{
LoginResult result = context.Login("Admin@XXXYYY:P000", "AdminXXX");
}
catch(Exception ep)
{
Console.WriteLine("Error en las credenciales" + ep.Message );
}
try
{
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
SO301000Content[] SO301000result = context.SO301000Submit
(
new Command[]
{
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "TADEO", LinkedCommand = SO301000.OrderSummary.Customer },
new Value { Value = "0000007", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = CVEORDEN, LinkedCommand = SO301000.OrderSummary.ExternalReference },
new Value { Value = FEC_ORDEN, LinkedCommand = SO301000.OrderSummary.Date },
new Value { Value = CVESERVI, LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = CANTIDAD, LinkedCommand = SO301000.DocumentDetails.Quantity },
new Value { Value = PIEZAS, LinkedCommand = SO301000.OrderSummary.Description },
new Value { Value = CAPA_REQ + " " + CAPA_OBT + " " + KILOS + " " + TIPO_ACERO + " " + RECIPIENTE + " " + DUREZA_OBT, LinkedCommand = SO301000.DocumentDetails.LineDescription },
new Value { Value = FEC_ORDEN, LinkedCommand = SO301000.OrderSummary.RequestedOn },
new Value { Value = PRECIOME, LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true },
new Value { Value = "NA", LinkedCommand = SO301000.DocumentDetails.UOM },
new Value { Value = "USD", LinkedCommand = SO301000.OrderSummary.Currency },
new Value { Value = "AP3", LinkedCommand = SO301000.DocumentDetails.Warehouse },
SO301000.Actions.Save,
}
);
Console.WriteLine("Orden registrada");
Thread.Sleep(9000);
}
catch(Exception ex)
{
Console.WriteLine("Error al insertar O.T en Acumatica: " + ex.Message);
Thread.Sleep(5000);
}
}
}
catch (Exception mensaje)
{
Console.WriteLine("Error en las credenciales del SPA ó Acumatica Web Service: " + mensaje);
Thread.Sleep(5000);
}
}
}
}
答案 0 :(得分:0)
据我所知,您应首先设置订单类型和订单号,然后才设置所有其他字段,即
new Command[]
{
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "0000007", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = "TADEO", LinkedCommand = SO301000.OrderSummary.Customer },
//rest of fields
SO301000.Actions.Save,
}