|
![]() |
#1 |
Чайный пьяница
|
![]()
Подчистил код плагина. Попробуйте это:
Код: 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 { public class MyPlugin : IPlugin { private string _secureInformation; private string _unsecureInformation; public MyPlugin(string unsecureInfo, string secureInfo) { _secureInformation = secureInfo; _unsecureInformation = unsecureInfo; } public void Execute(IPluginExecutionContext context) { DynamicEntity entity = null; if (context.InputParameters.Properties.Contains(ParameterName.Target) && context.InputParameters.Properties[ParameterName.Target] is DynamicEntity) { 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 = new ColumnSet(); 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 = new QueryByAttribute(); query.ColumnSet = new AllColumns(); query.EntityName = EntityName.productpricelevel.ToString(); query.Attributes = new string[] { "productidname" }; query.Values = new string[] { new_productname }; BusinessEntityCollection retrieved = crmService.RetrieveMultiple(query); foreach (DynamicEntity product in retrieved.BusinessEntities) { product["amount"] = new CrmDecimal(sum); crmService.Update(product); } } catch (System.Web.Services.Protocols.SoapException ex) { throw new InvalidPluginExecutionException(String.Format("An error occurred in the {0} plug-in.", this.GetType().ToString()), ex); } } } }
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством. Подписывайтесь на мой блог, twitter и YouTube канал. Пользуйтесь моим Ultimate Workflow Toolkit |
|
![]() |
#2 |
Участник
|
Спасибо!!
Пока не изменилось ничего.. "для отладки - необходимо атачиться к w3p процессу." А это как? (стыдно, но правда не знаю.. ![]() |
|
![]() |
#3 |
Чайный пьяница
|
![]() Цитата:
Что говорит плагин регистратор при попытке регистрации?
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством. Подписывайтесь на мой блог, twitter и YouTube канал. Пользуйтесь моим Ultimate Workflow Toolkit Последний раз редактировалось a33ik; 08.05.2009 в 12:50. |
|
![]() |
#4 |
Участник
|
Цитата:
В Plagin Registration Tool нажимаю Register -> Register New Assembly Когда выбираю файл EditPriceList.dll (я его из папки Debug беру..в Release он тоже есть и еще там лежит файл key.snk.. Так и надо? ) Выскакивает ошибка "Unable to load PLugin Assembly" и текст ![]() Unhandled Exception: System.Runtime.Serialization.SerializationException: Тип "PluginRegistrationTool.CrmOrganization" в сборке "PluginRegistration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" не помечен как сериализуемый. Server stack trace: в System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) в System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) в System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() в System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) в System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) в System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) в System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) в System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) в System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeMessageParts(ArrayList argsToSerialize) в System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage..ctor(IMethodReturnMessage mrm) в System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.SmuggleIfPossible(IMessage msg) в System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm) в System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args) Exception rethrown at [0]: в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) в PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path) в PluginRegistrationTool.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly) в PluginRegistrationTool.PluginRegistrationForm.btnLoadAssembly_Click(Object sender, EventArgs e) |
|
![]() |
#5 |
Чайный пьяница
|
Очень странно. За годичную практику такого не было у меня.
Ещё такой вопрос. Под каким фреймворком собираете плагин? Нужно под 2.0. Гугл на вопрос по такой ошибке мне ничего не сказал...
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством. Подписывайтесь на мой блог, twitter и YouTube канал. Пользуйтесь моим Ultimate Workflow Toolkit |
|
![]() |
#6 |
Участник
|
Цитата:
Я не знаю что значит "Под каким фреймворком собираете плагин". Но на моем компе , где я пытаюсь соорудить plugin , установлены Microsoft .NET Compact Framework 1.0 Developer Microsoft .NET Compact Framework 2.0 Microsoft .NET Framework 3.5 SP1 А это не может быть из-за того что я работаю в Microsoft Visual C# 2008 Express Edition? |
|
![]() |
#7 |
Чайный пьяница
|
При создании плагина - необходимо выбрать версию фреймворка под который он будет писаться. Посмотрите скриншот (должен быть 2.0).
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством. Подписывайтесь на мой блог, twitter и YouTube канал. Пользуйтесь моим Ultimate Workflow Toolkit |
|
|
За это сообщение автора поблагодарили: Elka (1). |
Теги |
c#, plugin, pluginregistrationtool, регистрация |
|
|