尝试使用Web Services API将一些数据从客户端应用程序导入Acumatica系统时出现问题。我尝试在屏幕Bill And Adjusment(AP301000)中发送数据,并在详细交易中使用大量数据。事务中的数据大约是235行。我尝试导入数据时的错误消息是“操作已超时”。
我试图更改web.config文件,如下所示:
<httpRuntime
executionTimeout="36000".../>
<compilation
debug="false".../>
<sessionState
timeout="360".../>
以下是我的代码, 我使用button执行该过程,然后在另一个类中调用方法:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using JADEACCU.services;
using System.Data.SqlClient;
namespace JADEACCU
{
public partial class frmTest : Form
{
ServicesConnection con = new ServicesConnection();
COMClass comClass = new COMClass();
services.Screen context = new services.Screen();
servicesUntyped.Screen contextUntyped = new servicesUntyped.Screen();
public frmTest()
{
InitializeComponent();
}
private void btnSendBill_Click(object sender, EventArgs e)
{
string type, refNbr, dtdate, customerOrder, customer, terms, currency, dtDueDateString, dtCashDiscDateString, description, jadeRefNbr;
type = cmbType.Text;
refNbr = txtRefNbr.Text;
dtdate = dtDate.Text.ToString();
customerOrder = txtCustomerOrder.Text;
customer = txtCustomer.Text;
terms = cmbTerms.Text;
currency = cmbCurrency.Text;
dtDueDateString = dtDueDate.Text.ToString();
dtCashDiscDateString = dtCashDiscDate.Text.ToString();
description = txtDescription.Text;
jadeRefNbr = txtJadeRefNbr.Text;
comClass.InsertBill(jadeRefNbr, dtdate, customerOrder, description, customer, terms, currency, dtDueDateString, dtCashDiscDateString);
}
}
}
调用此方法:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using JADEACCU.services;
namespace JADEACCU
{
public class COMClass
{
ServicesConnection sCon = new ServicesConnection();
services.Screen context = new services.Screen();
servicesUntyped.Screen contextUntyped = new servicesUntyped.Screen();
public string InsertBill(string vBillNo, string vBillDate, string vVendorRef, string vDesc, string vVendCode, string vTerms, string vCcy, string vDueDate, string vCashDiscDate)
{
//sCon.getLogin(context);
sCon.getLoginBill(context);
AP301000Content konten = context.AP301000GetSchema();
List<Command> oCmds = new List<Command>();
//Create Header.
//oCmds.Add(konten.Actions.Insert);
oCmds.Add(new Value { Value = "Bill", LinkedCommand = konten.DocumentSummary.Type });
oCmds.Add(new Value { Value = "0000", LinkedCommand = konten.DocumentSummary.ReferenceNbr });
oCmds.Add(new Value { Value = vBillNo, LinkedCommand = konten.DocumentSummary.JadeRefNbr });
oCmds.Add(new Value { Value = vBillDate, LinkedCommand = konten.DocumentSummary.Date });
oCmds.Add(new Value { Value = vVendorRef, LinkedCommand = konten.DocumentSummary.VendorRef });
oCmds.Add(new Value { Value = vDesc, LinkedCommand = konten.DocumentSummary.Description });
oCmds.Add(new Value { Value = vVendCode, LinkedCommand = konten.DocumentSummary.Vendor });
oCmds.Add(new Value { Value = vTerms, LinkedCommand = konten.DocumentSummary.Terms });
oCmds.Add(new Value { Value = vCcy, LinkedCommand = konten.DocumentSummary.Currency });
oCmds.Add(new Value { Value = vDueDate, LinkedCommand = konten.DocumentSummary.DueDate });
oCmds.Add(new Value { Value = vCashDiscDate, LinkedCommand = konten.DocumentSummary.CashDiscountDate });
//oCmds.Add(konten.Actions.Save);
string serverDb, userDb, passDb, databaseDb;
serverDb = Properties.Settings.Default.serverDB;
databaseDb = "SGL";
userDb = "jade";
passDb = "jade1234";
SqlConnection con = new SqlConnection();
con.ConnectionString = @"server=" + serverDb + "; database=" + databaseDb + "; user=" + userDb + "; password=" + passDb + ";";
//con.ConnectionString = "Provider = SQLOLEDB.1; Persist Security Info = False; Server = 192.168.10.7; Initial Catalog = SGL; User ID = jade; Password = jade1234";
con.Open();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
cmd = new SqlCommand("select case when a.branchid = '0102' then 'KARAWANG' else 'CIKARANG' end as BranchID, " +
"BookingNo, b.RAccount as ICharges, BCostUnit, IQty, BCost, " +
"case when TaxSts = 'Y' and c.TaxRate = 10 then 'PPN' when TaxSts = 'Y' and c.TaxRate = 1 then 'PPN1' end as TaxID, " +
"case when isnull(WhseCode,'') = 'WH01' and a.branchid = '0101' then left(rcontcode,4) + 'C1' + right(rcontcode,2) when isnull(WhseCode, '') = 'WH02' and a.branchid = '0101' then left(rcontcode, 4) + 'C2' + right(rcontcode, 2) when isnull(WhseCode, '') = 'WH03' and a.branchid = '0101' then left(rcontcode, 4) + 'C3' + right(rcontcode, 2) when isnull(WhseCode, '') = 'WH04' and a.branchid = '0101' then left(rcontcode, 4) + 'C4' + right(rcontcode, 2) when isnull(WhseCode, '') = 'KLC' and a.branchid = '0102' then left(rcontcode, 4) + 'K1' + right(rcontcode, 2) when isnull(WhseCode, '') = 'GIIC' and a.branchid = '0105' then left(rcontcode, 4) + 'GL' + right(rcontcode, 2) when isnull(WhseCode, '') = 'TLC' and a.branchid = '0106' then left(rcontcode, 4) + 'TL' + right(rcontcode, 2) when isnull(WhseCode, '') = '' and a.branchid = '0101' then left(rcontcode, 4) + 'HO' + right(rcontcode, 2) when isnull(WhseCode, '') = '' and a.branchid = '0102' then left(rcontcode, 4) + 'KO' + right(rcontcode, 2) when isnull(WhseCode, '') = '' and a.branchid = '0103' then left(rcontcode, 4) + 'CO' + right(rcontcode, 2) when isnull(WhseCode, '') = '' and a.branchid = '0104' then left(rcontcode, 4) + 'PO' + right(rcontcode, 2) end as SubAccount from BookRates as a inner join revcodes as b on a.icharges = b.rcode inner join billmaster as c on a.billno = c.billno where a.BillNo = '" + vBillNo + "'", con);
cmd.CommandType = CommandType.Text;
da.SelectCommand = cmd;
da.Fill(dt);
foreach (DataRow dR in dt.Rows)
{
oCmds.Add(konten.DocumentDetails.ServiceCommands.NewRow);
oCmds.Add(new Value { Value = dR["BranchID"].ToString(), LinkedCommand = konten.DocumentDetails.Branch });
oCmds.Add(new Value { Value = dR["BookingNo"].ToString(), LinkedCommand = konten.DocumentDetails.JobOrderNbr });
oCmds.Add(new Value { Value = dR["ICharges"].ToString(), LinkedCommand = konten.DocumentDetails.InventoryID });
oCmds.Add(new Value { Value = dR["BCostUnit"].ToString(), LinkedCommand = konten.DocumentDetails.UnitCost });
oCmds.Add(new Value { Value = dR["SubAccount"].ToString(), LinkedCommand = konten.DocumentDetails.Subaccount });
oCmds.Add(new Value { Value = dR["IQty"].ToString(), LinkedCommand = konten.DocumentDetails.Quantity });
oCmds.Add(new Value { Value = dR["BCost"].ToString(), LinkedCommand = konten.DocumentDetails.Amount });
oCmds.Add(new Value { Value = dR["TaxID"].ToString(), LinkedCommand = konten.DocumentDetails.TaxCategory, Commit = true });
}
oCmds.Add(konten.Actions.Save);
try
{
context.AP301000Submit(oCmds.ToArray());
return "ACUMATICA - Save Bill SUCCESS";
}
catch (Exception ex)
{
return ex.Message;
//return "ACUMATICA - Save Bill FAILED";
}
}
}
}
但它仍然无效。 请提供一些参考如何解决此案例。 感谢
答案 0 :(得分:0)
创建屏幕对象时,可以选择设置超时。尝试将该值设置为无限。
样本
context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://blah blah";
context.Timeout = System.Threading.Timeout.Infinite;