简体   繁体   English

Microsoft Dynamic GP扩展程序集

[英]Microsoft Dynamic GP extension assembly

I have created a Dynamic GP extension method to spec following the MSDN guidelines Dynamics GP Extension Assembly 我已经按照MSDN准则Dynamics GP Extension Assembly创建了一个Dynamic GP扩展方法来规范

Here is the code for my custom extension assembly: 这是我的自定义扩展程序集的代码:

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);
      }
    }
  }
}

This code includes some logging mechanisms that log any incoming data to the local drive (to give me a further understanding of whats passing through during testing). 此代码包括一些日志记录机制,该机制会将任何传入的数据记录到本地驱动器(以使我进一步了解测试过程中通过的内容)。

Below is my BusinessObjectsFile.config file entry (Further explained Business object configuration file 以下是我的BusinessObjectsFile.config文件条目(进一步解释了Business Object配置文件

<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>

After i have configured the appropriate changes (Placed the new extension assembly in C:\\Program Files\\Microsoft Dynamics\\GPWebServices, configured the BusinessObjectFile.config, then restarted Microsoft Dynamics GP Service Host . I then create a new customer, created a PO and SO for that customer and nothing is getting logged??? 配置了适当的更改后(将新的扩展程序集放置在C:\\ Program Files \\ Microsoft Dynamics \\ GPWebServices中,配置BusinessObjectFile.config,然后重新启动Microsoft Dynamics GP Service Host 。然后创建一个新客户,创建一个PO和所以对于那个客户,什么都没有记录?

Logging method: 记录方式:

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 { }
}

I have followed everything up to deployment and i cannot figure out why this extension method never gets called from GP? 我已经跟踪了部署的所有过程,但无法弄清楚为什么从未从GP调用此扩展方法? Am i missing (or should i say Microsoft) part of this puzzle? 我是这个谜题的一部分吗?

I was under the assumption this method would fire after altering data directly through the Dynamics GP application, i was wrong. 我当时以为这种方法会在直接通过Dynamics GP应用程序更改数据后触发,我错了。 The only way this method would have been hit would have been through using the methods in the GP Web Services SDK, apparently Microsoft didn't think the back-end of the Dynamics GP software should have this great functionality... 这种方法唯一可行的方法是使用GP Web服务SDK中的方法,显然Microsoft认为Dynamics GP软件的后端不应该具有如此强大的功能...

Since this did not fit our requirements i ended up using eConnect's incoming and outgoing services that work together with MSMQ. 由于这不符合我们的要求,因此我最终使用了与MSMQ一起使用的eConnect传入和传出服务。 I can now add the tables i need to monitor via eConnect's Requester Setup Tool. 现在,我可以通过eConnect的请求者设置工具添加需要监视的表。 Lastly, i have created a small client service that monitors my custom MSMQ path and instantly obtains the transaction from GP as it happens. 最后,我创建了一个小型客户端服务,该服务监视我的自定义MSMQ路径,并在发生时立即从GP获取事务。

GP development on the web is limited to none (if i did find anything it was irrelevant due to a different version of GP) ... It came down to lots of reading off MSDN to put this together... The GP forums were also no help for this particular case. Web上的GP开发仅限于无(如果我发现由于GP的不同版本而没有任何意义的话)...归因于很多MSDN的阅读,以将其整合在一起... GP论坛也对于这种特殊情况没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM