AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Разработка
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 12.05.2009, 17:47   #14  
Elka is offline
Elka
Участник
Аватар для Elka
 
431 / 22 (1) +++
Регистрация: 02.12.2008
Адрес: г. Ростов-на-Дону
Цитата:
Сообщение от a33ik Посмотреть сообщение
Каст - немного другое. Код плагина выкладывайте - плдскажу, где проблема.

Спасибо Вам большое !!

Вот код:

using
System;
using System.Collections.Generic;
using Microsoft.Win32;
using Microsoft.Crm.Sdk.Query;
// Microsoft Dynamics CRM namespaces
using Microsoft.Crm.Sdk;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.SdkTypeProxy.Metadata;
using System.Text;
namespace Crm.Plugins
{
publicclassMyPlugin : IPlugin
{
privatestring _secureInformation;
privatestring _unsecureInformation;
public MyPlugin(string unsecureInfo, string secureInfo)
{
_secureInformation = secureInfo;
_unsecureInformation = unsecureInfo;
}
publicvoid Execute(IPluginExecutionContext context)
{
DynamicEntity entity = null;
if (context.InputParameters.Properties.Contains(ParameterName.Target) && context.InputParameters.Properties[ParameterName.Target] isDynamicEntity)
{
entity = (
DynamicEntity)context.InputParameters.Properties[ParameterName.Target];
}
else
{
return;
}
try
{
ICrmService crmService = context.CreateCrmService(true);
decimal sum = ((CrmMoney)entity.Properties["new_esum"]).Value;
String new_productname = "";
if (entity.Properties.Contains("productid"))
{
ColumnSet cs = newColumnSet();
Lookup regarding = (Lookup)entity.Properties["productid"];
cs.Attributes.Add(
"name");
product _product = (product)crmService.Retrieve(EntityName.product.ToString(), regarding.Value, cs);
if (_product == null || _product.name == null)
{
return;
}
else
{
new_productname = _product.name;
}
}
QueryByAttribute query = newQueryByAttribute();
query.ColumnSet =
newAllColumns();
query.EntityName =
EntityName.productpricelevel.ToString();
query.Attributes =
newstring[] { "productidname" };
query.Values =
newstring[] { new_productname };
BusinessEntityCollection retrieved = crmService.RetrieveMultiple(query);
foreach (DynamicEntity product in retrieved.BusinessEntities)
{
product[
"amount"] = newCrmDecimal(sum);
crmService.Update(product);
}
}
catch (System.Web.Services.Protocols.SoapException ex)
{
thrownewInvalidPluginExecutionException(String.Format("An error occurred in the {0} plug-in.", this.GetType().ToString()), ex);
}
}
}
}
Теги
c#, plugin, pluginregistrationtool, регистрация

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
CRM DE LA CREME! Three Top Tips for CRM 4.0 Plugin Development Blog bot Dynamics CRM: Blogs 0 13.08.2009 15:05
haditeo: Is it possible to register different event handlers in only one assembly to be registered in Dynamics CRM Plugin ? Blog bot Dynamics CRM: Blogs 0 13.08.2009 15:05
a33ik: Plugin for copying notes and attachements from lead to contact whis is converted from lead for Microsoft Dynamics CRM 4.0 Blog bot Dynamics CRM: Blogs 0 10.07.2009 17:05
Ronald Lemmen: Plugin registration tools for Visual Studio 2005 Blog bot Dynamics CRM: Blogs 0 17.04.2009 01:05
PlugIn ImageEntity Konstantin Katsovich Dynamics CRM: Разработка 3 16.01.2009 17:35

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 12:46.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.