Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
ZooY committed Sep 11, 2020
1 parent 4261937 commit 52887db
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ Workflow
<td>Getting the GUID of the Account entity.</td>
</tr>
<tr>
<td>:new: Add Account to Marketing List</td>
<td>Add Account to Marketing List</td>
<td>Добавление организации в маркетинговый список.</td>
</tr>
<tr>
<td>:new: Add Contact to Marketing List</td>
<td>Add Contact to Marketing List</td>
<td>Добавление контакта в маркетинговый список.</td>
</tr>
<tr>
<td>:new: Add Lead to Marketing List</td>
<td>Add Lead to Marketing List</td>
<td>Добавление интереса в маркетинговый список.</td>
</tr>
<tr>
Expand Down Expand Up @@ -278,10 +278,14 @@ Workflow
<td>Получение количества записей, возвращаемых запросом FetchXML.</td>
</tr>
<tr>
<td>:new: Delete</td>
<td>Delete</td>
<td>Удаление записей, найденных с помощью запроса FetchXML.</td>
</tr>
<tr>
<td>:new: <a href="https://github.com/ZooY/Dynamics365.Tools/wiki/FetchXML-Tools#entity-as-json">Entity as JSON</a></td>
<td>Получение сущности в виде строки в формате JSON.</td>
</tr>
<tr>
<td><a href="https://github.com/ZooY/Dynamics365.Tools/wiki/FetchXML-Tools#median">Median</a></td>
<td>Вычисление медианы ряда числовых значений, возвращаемых запросом FetchXML.</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion Source/Tools/FetchXML/FetchXML/FetchXML.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
<Compile Include="Workflow\Count.cs" />
<Compile Include="Workflow\Median.cs" />
<Compile Include="Workflow\Sum.cs" />
<Compile Include="Workflow\Value.cs" />
<Compile Include="Workflow\EntityAsJson.cs" />
<Compile Include="Workflow\FetchXmlWorkflow.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Workflow\Value.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Crm.Sdk.Proxy, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
4 changes: 2 additions & 2 deletions Source/Tools/FetchXML/FetchXML/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("8.0.3.2")]
[assembly: AssemblyFileVersion("8.0.3.2")]
[assembly: AssemblyVersion("8.0.3.3")]
[assembly: AssemblyFileVersion("8.0.3.3")]
48 changes: 48 additions & 0 deletions Source/Tools/FetchXML/FetchXML/Workflow/EntityAsJson.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Activities;
using System.Linq;
using Microsoft.Xrm.Sdk.Workflow;
using Newtonsoft.Json;
using PZone.Xrm;
using PZone.Xrm.Workflow;


namespace PZone.FetchXmlTools.Workflow
{
/// <summary>
/// Получение сущности в виде строки в формате JSON.
/// </summary>
/// <remarks>
/// <para>Если запрос возвращает несколько записей, будет возвращена первая.</para>
/// </remarks>
public class EntityAsJson : FetchXmlWorkflow
{
/// <summary>
/// Результирующее значение в виде логического значения.
/// </summary>
/// <remarks>
/// Свойство имеет значение <c>false</c>, если числовое значение равно <c>0</c> и <c>true</c> в случае любых других значений.
/// </remarks>
[Output("JSON")]
public OutArgument<string> Json { get; set; }

/// <inheritdoc />
protected override void Execute(Context context)
{
Json.Set(context, null);

var query = FetchXml.Get(context);

var entity = context.SystemService.RetrieveMultiple(query).Entities.FirstOrDefault();
if (entity == null)
return;

Json.Set(context, JsonConvert.SerializeObject(new
{
entity.LogicalName,
entity.Id,
Attributes = entity.Attributes.ToDictionary(e=>e.Key, e=>e.Value),
FormattedValues = entity.FormattedValues.ToDictionary(e => e.Key, e => e.Value)
}));
}
}
}

0 comments on commit 52887db

Please sign in to comment.