有没有办法区分 CRM 4.0 插件中的 SSIS 执行与 Web UI 执行?

发布于 2024-11-30 12:15:37 字数 770 浏览 4 评论 0原文

设置如下:

Custom_entity 接受用户的一些输入,计算一个数字,并将其与我们数据库中存储的总数进行比较,以获得总体百分比。总数每周更新一次。为了更新每个用户的 custom_entities 以反映新的总计和这些总计的百分比,我创建了一个每周运行的 SSIS 包。当然,我是友善且合规的,因此我使用 API 访问 CRM Web 服务来更新 custom_entities。

但是,用户还希望看到他们的custom_entity的实时更新,所以我创建了一个插件,在custom_entity更新时将重新计算他​​们的数字,检查“总计”的更新数据库,并更新与所有其他更新相关的百分比。

也许您现在看到了问题...

  • 当用户从网络更新时,更新插件会针对 custom_entity 的该实例触发,他们会得到即时反馈,看到他们的数字并感到高兴。
  • 当 SSIS 包运行时,更新插件会针对正在更新的 ALL custom_entity 行触发...

我的问题: 有没有一种方法(也许通过查看上下文)可以让我知道插件是通过 SSIS 作业还是 Web 调用的,然后退出插件?

目前只有很少的行,并且没有真正的性能影响,但很明显,这肯定是糟糕的编程和不必要的 CPU/带宽使用(插件本身在执行过程中多次访问 Web 服务)。我可以通过查找仅在 SSIS 包调用插件时才会出现的特定属性来短路插件,但我想找到比这更好的方法。

谢谢你!

Here's the setup:

Custom_entity takes a few inputs from a user, calculates a number, and compares it with a total stored in our database to get an overall percentage. The total is updated every week. To update every user's custom_entities to reflect the new totals and percentages of those totals, I've created an SSIS package to run every week. Of course I'm being nice and compliant, so I use the API to hit the CRM webservice to update the custom_entities.

However, users also want to see a real-time update of their custom_entity, so I created a plugin that, on a custom_entity update will re-calculate their numbers, check for updates of the "total" in the database, and update the percentage correlating the all the other updates.

Perhaps you're seeing the problem now...

  • When a user updates from the web the update plugin fires for THAT instance of the custom_entity, they get instant feedback, see their numbers and are happy.
  • When the SSIS package runs, the update plugin fires for ALL custom_entity rows being updated...

My question:
Is there a way (perhaps by looking at context) that I can tell whether the plugin was invoked via the SSIS job or the web, and then just exit out of the plugin?

Currently there are few rows, and no real performance hit, but it's obvious that this is certainly poor programming and unneeded CPU/bandwidth usage (the plugin itself hits the webservice several times over the course of execution). I could short-circuit the plugin by looking for a specific property that will only be present when the SSIS package calls the plugin, but I'd like to find a better way than that.

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

关于从前 2024-12-07 12:15:37

您可以查看 context.CallerOrigin 属性。它将向您显示触发该消息的源。在您的情况下,您应该检查 WebServiceApi

using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
 
public class OnlinePlugin : IPlugin
{
  public void Execute(IPluginExecutionContext context)
  {
     // Check to see if this is a playback context.
     CallerOrigin callerOrigin = context.CallerOrigin;
  
     if (callerOrigin is OfflineOrigin)
     {
       // This plug-in was fired from the playback queue after the user
       // selected to go online within Microsoft Dynamics CRM for Outlook.
       return;
     }
     else
     {
       // Do something here.
     }
  }
}

看一下我的文章 谁触发了我的插件?

You could take a look at the context.CallerOrigin property. It will show you the source, which triggered the message. In your case you should check for WebServiceApi

using System;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
 
public class OnlinePlugin : IPlugin
{
  public void Execute(IPluginExecutionContext context)
  {
     // Check to see if this is a playback context.
     CallerOrigin callerOrigin = context.CallerOrigin;
  
     if (callerOrigin is OfflineOrigin)
     {
       // This plug-in was fired from the playback queue after the user
       // selected to go online within Microsoft Dynamics CRM for Outlook.
       return;
     }
     else
     {
       // Do something here.
     }
  }
}

Take a look at my article Who triggered my plugin?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文