Sage BOI - 在AR_Customer_bus上调用 NewObject 时出现错误 200。我的目标是使用 C# 通过 BOI 创建新客户



这是一个Sage cloud 2019业务对象接口问题。

我在尝试新建AR_Customer_bus对象时遇到了问题,我的最终目标是能够使用BOI创建新客户。我得到的错误是200。

充分披露;我是Sage BOI的新手,虽然我是一个经验丰富的开发人员,我没有Sage背景,但我确实有Sage BOI的教学材料。我也在Sage论坛上发布了这个问题,但论坛上的活动量很低,所以我在报道我的基本情况:https://www.sagecity.com/support_communities/sage100_erp/f/sage-100-business-object-interface/146142/unable-to-newobject-the-ar_customer_bus

我们非常感谢在这个问题上提供的任何帮助,它甚至不一定是一个确切的解决方案,只需提供有助于促进解决方案的一般指导即可。

到目前为止,这是我的代码,还请注意,我已经把它写在了我发现的几个例子的后面:

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Instantiate a ProvidexX.Script object and initialize with the path to MAS90Home
using (DispatchObject pvx = new DispatchObject("ProvideX.Script"))
{
// Replace the text "*PATH TO MAS90HOME*" with the correct MAS90Home path in the line below
pvx.InvokeMethod("Init", @"[Correct path]");
// Instantiate a new Session object and initialize the session
// by setting the user, company, date and module
using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session")))
{
oSS.InvokeMethod("nLogon");
oSS.InvokeMethod("nSetUser", new object[] {"[Username]", "[Password]"});
oSS.InvokeMethod("nSetCompany", "[CompanyName]");
oSS.InvokeMethod("nSetDate", "A/R", "05312006");
oSS.InvokeMethod("nSetModule", "A/R");
// Get the Task ID for the AR_Customer_ui program
int TaskID = (int) oSS.InvokeMethod("nLookupTask", "AR_Customer_ui");
//int TaskID = (int)oSS.InvokeMethod("nLookupTask", "AR_Invoice_ui");
oSS.InvokeMethod("nSetProgram", TaskID);
CreateCustomer(pvx, oSS, out var customerNumber);
GetCustomerList(pvx, oSS, out var bob);
}
}

}
private static string CreateCustomer(DispatchObject pvx, DispatchObject oSS, out string customerNumber)
{
customerNumber = "";

using (DispatchObject oARCustomerEntry = new DispatchObject(pvx.InvokeMethod("NewObject", "AR_Customer_bus", oSS.GetObject()))) //Error 200 throw here.
{
try
{
object[] nextCustomerNumber = new object[] { "CustomerNo$" };
//Getting Next Customer Number
oARCustomerEntry.InvokeMethodByRef("nGetNextCustomerNo", nextCustomerNumber);
Console.WriteLine(nextCustomerNumber[0].ToString());
object retVal = 0;
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "ARDivisionNo$", "01" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "CustomerNo$", nextCustomerNumber[0].ToString() });
retVal = oARCustomerEntry.InvokeMethod("nSetKey");
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CustomerName$", "ROSE DAWSON" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine1$", "1234 LONG DREAM ST" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine2$", "" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "AddressLine3$", "" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "City$", "CITRUS HEIGHTS" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "State$", "CA" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "ZipCode$", "95621" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "CountryCode$", "USA" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "SalespersonDivisionNo$", "01" });
retVal = oARCustomerEntry.InvokeMethodByRef("nSetValue", new object[] { "SalespersonNo$", "RAP" });
Console.WriteLine(retVal.ToString());
retVal = oARCustomerEntry.InvokeMethod("nWrite");
if (retVal.ToString() == "0")
{
object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
Console.WriteLine(errorMsg.ToString());
Console.Read();
}
customerNumber = nextCustomerNumber[0].ToString();
Console.WriteLine(retVal.ToString());
Console.Read();
}
catch (Exception ex)
{
object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
Console.WriteLine(errorMsg.ToString());
Console.WriteLine(ex.Message);
Console.Read();
}
finally
{
oARCustomerEntry.Dispose();
}
}
return customerNumber;
}

下面是抛出错误的行:

public object GetObject() 
{
return m_object;
}

然后它调用InvokeMethod,如下所示,这正是抛出错误200的地方:

public object InvokeMethod(string sMethodName, params object[] aryParams)
{
return m_object.GetType().InvokeMember(sMethodName, m_flgMethod, null, m_object, aryParams);
}

我最初的想法是这是一个权限问题(因为我以前遇到过这种情况,但我设置的用户具有"完全管理员"角色,当查看sage的角色维护部分时,我可以看到该角色分配了每个安全权限。

请注意:我已经能够毫无问题地新建其他业务对象,如AR_DositHistory_bus,而且我还成功地新建了AR_Customer_ui和AR_Customer.svc,所以我不知道为什么会出现问题。

以下是适用于我的解决方案

解决方案1解决这个阻塞问题需要一段时间,但以下是对我有效的解决方案:

  1. 我在上面的URL中使用了David Speck提供的VB脚本为了在VB.net中工作,我做了一些修改,在上面的链接中发布了我的完整脚本
  2. 我运行了这个脚本,发现我能够毫无问题地新建一个AR_Customer_bus对象
  3. 根据David Speck在URL中提供的建议,我再次测试了我的C#应用程序,发现它有效

替代解决方案

  1. 我相信遵循Sage100User提供的建议也会解决这个问题。链接到这里这篇文章向你展示了如何手动注册.dll文件

原因原因可能有以下几点:

  1. Sage在Windows 2012计算机上运行(这有时会导致BOI出现问题(
  2. 我们在公司使用Avatax,这也会引起BOI的问题
  3. 这很可能是我无法新建AR_Customer_bus的实际原因,因为我不相信.dll在我的工作站上正确注册

我真的希望这能帮助其他遇到同样问题的人,据我所知,这是一个相当常见的问题,需要很长时间才能解决。

相关内容

最新更新