強いテキスト[注エンティティにおけるプラグインエラー] [1]プラグインで変換ノートエンティティプリ既存の添付ファイルのXMLファイルをその新しい.MMPファイルに
[1]: http://i.stack.imgur.com/hRIi9.png
こんにちは、誰もが私はプラグを持って私の問題を解決しました私は、 "ノート"のエンティティの更新時に働いていた。私は、元のノートの添付ファイルXMLファイルを同じ名前の新しい.MMP拡張ファイルに変換するプラグインがほしいと思う。 私はここでファイルを.MMPするXMLファイルを変換し方法は、クラスのコンストラクタです)まず私は変換を(含む「Converter_Code.cs」DLLを作成し、以下の手順を行っています。 ConvertPlugin.csプラグインクラスで
public Converter(string xml, string defaultMapFileName, bool isForWeb)
{
Xml = xml;
DefaultMapFileName = defaultMapFileName;
Result = Environment.NewLine;
IsForWeb = isForWeb;
IsMapConverted = false;
ResultFolder = CreateResultFolder(MmcGlobal.ResultFolder);
}
まず私は
IPluginExecutionContext context =(IPluginExecutionContext)serviceProvider.
GetService (typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory= (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService
(context.UserId);
if (context.InputParameters.Contains("Target")
&& context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
var annotationid = entity.GetAttributeValue<Guid>("annotationid");
if (entity.LogicalName != "annotation")
{
return;
}
else
{
try
{
//retrieve annotation file
QueryExpression Notes = new QueryExpression { EntityName ="annotation"
,ColumnSet = new ColumnSet("filename", "subject", "annotationid",
"documentbody") };
Notes.Criteria.AddCondition("annotationid", ConditionOperator.Equal,
annotationid);
EntityCollection NotesRetrieve = service.RetrieveMultiple(Notes);
if (NotesRetrieve != null && NotesRetrieve.Entities.Count > 0)
{
{
//converting document body content to bytes
byte[] fill = Convert.FromBase64String(NotesRetrieve.Entities[0]
.Attributes["documentbody"].ToString());
//Converting to String
string content = System.Text.Encoding.UTF8.GetString(fill);
Converter objConverter = new Converter(content, "TestMap", true);
objConverter.Convert();
}
}
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("something is going wrong");
}
}
}
}
と文字列が「コンバータ」コンストラクタに渡されるよりの次のメソッドを使用して文字列に注意エンティティ添付XMLファイルを検索パラメータとして使用します。 ilmerge /out:NewConvertPlugin.dll ConvertPlugin.dll Converter_Code.dll
とNewConvertPluginが正常に登録されたが、その、その生成、次のエラー作業中れる:から
予期しない例外がプラグイン(実行): は最終的に、私は方法に従ってILMergeを使用して、すべてのDLLをマージConverterPlugin.Class1 :System.Security.SecurityException:アセンブリは、部分的に信頼できる呼び出し元を許可しません。 私もエラーログを使ってプラグインをデバッグしますが、うまくいきません。
大丈夫@Guidoご返信ありがとうございます。どうすればこの問題を解決できますか? –
私はすでにあなたがそれを解決する方法を書いていました –
大丈夫です。 –