-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdateWebresource.cs
42 lines (40 loc) · 1.65 KB
/
UpdateWebresource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Microsoft.Xrm.Sdk;
using System;
using System.Text;
namespace WebresourceEditor
{
public class UpdateWebresource : PluginBase
{
public UpdateWebresource(string unsecureConfiguration, string secureConfiguration)
: base(typeof(UpdateWebresource))
{
}
protected override void ExecuteDataversePlugin(ILocalPluginContext localPluginContext)
{
if (localPluginContext == null)
{
throw new ArgumentNullException(nameof(localPluginContext));
}
var context = localPluginContext.PluginExecutionContext;
var tracingService = localPluginContext.TracingService;
var service = localPluginContext.PluginUserService;
try
{
tracingService.Trace("In UpdateWebresource");
string webresourceid = (string)context.InputParameters["webresourceid"];
string content = (string)context.InputParameters["content"];
Entity webresource = new Entity("webresource", new Guid(webresourceid));
// webresource.Attributes["content"] = Convert.ToBase64String(Encoding.UTF8.GetBytes(content));
webresource.Attributes["content"] = content;
service.Update(webresource);
tracingService.Trace("webresourceid: " + webresourceid);
context.OutputParameters["response"] = "success";
}
catch (Exception ex)
{
tracingService.Trace("Error: " + ex.StackTrace);
context.OutputParameters["response"] = ex.StackTrace;
}
}
}
}