2013-04-15 55 views
0

我创建了一个动态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调用?我是否错过(或者我应该说微软)这个难题的一部分?

+0

乍一看你的代码看起来不错。如果我是你,下一步我会尝试远程调试你的类,看看程序集是否被加载,并最终如果你的静态方法被解雇。 –

+0

今天早上我做了这件事,至今没有运气...我也尝试附加GP进程并编辑了一些客户记录并删除了其他人......但上述事件从未被解雇...... – devHead

回答

0

我是在假设这个方法会在通过Dynamics GP应用程序直接改变数据之后触发的,我错了。通过使用GP Web Services SDK中的方法,唯一的方法就是通过使用GP Web Services SDK中的方法,显然微软并不认为Dynamics GP软件的后端应该具备这个强大的功能......

由于这不符合我们的要求,我最终使用eConnect的传入和传出服务与MSMQ一起工作。我现在可以添加我需要通过eConnect的请求者设置工具进行监控的表格。最后,我创建了一个小型客户端服务,监视我的自定义MSMQ路径,并在GP发生时立即从GP获取事务。

在网络上的GP开发是无限的(如果我确实发现任何东西都是由于GP的不同版本而不相关的话)......它归结为许多MSDN的阅读内容,将它们放在一起...... GP论坛对于这种特殊情况也没有帮助。