我创建了一个动态GP扩展方法符合规范遵循MSDN准则Dynamics GP Extension Assembly微软动态GP
这里延伸组件是我的自定义扩展汇编代码:
namespace MyGPService
{
public static class GPExtensions
{
public static void OnRecordCreated(object sender, BusinessObjectEventArgs e)
{
try
{
Customer customer;
Extension CustomerEmailExtension = new Extension();
//get current cust connection
//connection = Connection.GetInstance();
if (e.BusinessObject.GetType() == typeof(Customer))
{
customer = (Customer)e.BusinessObject;
// Look at the Extension list passed along
foreach (Extension ext in customer.Extensions)
{
Logger.LogExtention(ext);
}
}
else
{
Logger.LogExtentionType(e.GetType().ToString());
}
}
catch (Exception ex)
{
Logger.LogException(ex.Message);
}
}
}
}
,此代码包含一些日志机制将任何传入数据记录到本地驱动器(以便让我进一步了解测试期间通过的内容)。
下面是我的BusinessObjectsFile.config文件条目(进一步解释Business object configuration file
<DictionaryEntry>
<Key xsi:type="xsd:string">Microsoft.Dynamics.GP.Customer</Key>
<Value xsi:type="BusinessObjectConfiguration">
<Event>
<EventName>Created</EventName>
<EventHandlerType>
<Type>Microsoft.Dynamics.Common.BusinessObjectEventHandler</Type>
<Assembly>Microsoft.Dynamics.Common</Assembly>
</EventHandlerType>
EventHandler>
<SoftwareVendor>XYZ</SoftwareVendor>
<Type>MyGPService.GPExtentions</Type>
<StaticMethod>OnRecordCreated</StaticMethod>
<Assembly>MyGPExtensionMethods</Assembly>
<Execute>true</Execute>
</EventHandler>
</Event>
</Value>
</DictionaryEntry>
后,我已经配置了相应的变化(放置在新的扩展组件在C:\ Program Files文件\ Microsoft动态\ GPWebServices,配置BusinessObjectFile.config,然后重新启动Microsoft Dynamics GP Service Host然后创建一个新的客户,创造了PO和SO该客户,并没有什么得到记录???
记录方法:
public static void LogException(string error)
{
try
{
string path = Path.Combine(Utilities.SystemDirectory, "GPExtentionMethod\\Errors\\ExtErrorLog.txt");
if(!Directory.Exists(Path.GetDirectoryName(path)))
Directory.CreateDirectory(Path.GetDirectoryName(path));
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("GP Extention Error Log");
sw.WriteLine("");
}
}
using (StreamWriter sw = File.AppendText(path))
{
sw.WriteLine(Environment.NewLine);
sw.WriteLine("Error");
sw.WriteLine(DateTime.Now.ToString() + ": " + error);
}
}
catch { }
}
我已经跟随了所有部署,我不明白为什么这个扩展方法永远不会从GP调用?我是否错过(或者我应该说微软)这个难题的一部分?
乍一看你的代码看起来不错。如果我是你,下一步我会尝试远程调试你的类,看看程序集是否被加载,并最终如果你的静态方法被解雇。 –
今天早上我做了这件事,至今没有运气...我也尝试附加GP进程并编辑了一些客户记录并删除了其他人......但上述事件从未被解雇...... – devHead