每当Web API代码运行以同步显示消息的数据时,我都会遇到从Acumatica网站(V5.2试用版)启动的问题;您已因超出而退出系统中的用户数"即使我已经实现了Web API注销代码。
我不想从Acumatica启动,之前问过问题How do I log out the Acumatica Web Api user?。 这是我获取注销代码的地方。但它在我的试用版上肯定无法正常工作..
所以我认为我的代码有问题,如果是这样的话,可以使用一些帮助来搞清楚。
复制步骤:在运行下面的示例代码之前,请登录Acumatica的试用版。运行后,您将从Acumatica启动,表示您已超出两个用户限制。
以下示例代码只需登录,按ID搜索销售人员,然后注销。它做了两次。
示例代码:
class Program
{
static AcumaticaApiWS.Screen context = null;
static string contextUrl = "http://localhost/Soap/WEBAPI.asmx";
static string screenUrl = "http://localhost/Soap/.asmx";
static string userName = "USERNAME";
static string passWord = "PASSWORD";
static void Main( string[] args )
{
LogIn();
DoWork("Test1");
LogOut();
LogIn();
DoWork("Test2");
LogOut();
}
static void LogIn()
{
Program.context = new AcumaticaApiWS.Screen();
Program.context.CookieContainer = new System.Net.CookieContainer();
Program.context.AllowAutoRedirect = true;
Program.context.EnableDecompression = true;
Program.context.Timeout = int.MaxValue;
Program.context.Url = Program.contextUrl;
AcumaticaApiWS.LoginResult result = context.Login( Program.userName, Program.passWord );
Program.context.SetLocaleName( System.Globalization.CultureInfo.CurrentCulture.Name );
}
static void LogOut()
{
AcumaticaScreenWS.Screen screen = new AcumaticaScreenWS.Screen();
Program.context.Url = Program.screenUrl;
screen.Url = Program.screenUrl;
screen.CookieContainer = Program.context.CookieContainer;
screen.Logout();
Program.context = null;
}
static void DoWork( string salesPersonId )
{
String[][] AR205000data = null;
AcumaticaApiWS.AR205000Content AR205000 = Program.context.AR205000GetSchema();
Program.context.AR205000Clear();
AR205000data = Program.context.AR205000Export
(
new AcumaticaApiWS.Command[]
{
AR205000.SalespersonInfo.ServiceCommands.EverySalespersonID,
AR205000.SalespersonInfo.SalespersonID,
AR205000.SalespersonInfo.Name
},
new AcumaticaApiWS.Filter[]
{
new AcumaticaApiWS.Filter
{
Field = new AcumaticaApiWS.Field() {
FieldName = AR205000.SalespersonInfo.SalespersonID.FieldName,
ObjectName = AR205000.SalespersonInfo.SalespersonID.ObjectName
},
Condition = AcumaticaApiWS.FilterCondition.Equals,
Value = salesPersonId
}
},
0, false, false
);
if( AR205000data.Length > 0 )
{
Console.WriteLine( AR205000data[0][0] + " " + AR205000data[0][1] );
}
else
{
Console.WriteLine( "'" + salesPersonId + "' not found." );
}
}
}
感谢您的帮助!