Skip to content

Commit

Permalink
Release DynamicsCrm.DevKit.Cli.3.33.33.33 (#52)
Browse files Browse the repository at this point in the history
Release DynamicsCrm.DevKit.Cli.3.33.33.33
  • Loading branch information
phuocle authored Dec 31, 2023
1 parent 2d14794 commit 0c4960a
Show file tree
Hide file tree
Showing 9,994 changed files with 3,146,489 additions and 3,597 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ ClientBin/
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
!*.pfx
!PL.DynamicsCrm.DevKit.pfx
!DynamicsCrm.DevKit.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
Expand Down Expand Up @@ -274,3 +275,6 @@ __pycache__/
/v2/DynamicsCrm.DevKit.Tool/Nuget/nuget.exe
/v2/Published/2.1.1/DynamicsCrm.DevKit.Cli.exe
/v2/Published/2.1.1/DynamicsCrm.DevKit.Tool.exe
/test/v.3.00.00/TestExistingReports/2.after/Dev.DevKit.Report/TEL_WO_ReportDefinitions

*.exe
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# DynamicsCrm.DevKit contains:
* [14 Visual Studio projects template.](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/Projects-Template)
* [16 Visual Studio projects template.](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/Projects-Template)
* [14 Visual Studio items template.](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/Items-Template)
* [Integrated with Visual Studio](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/Integrated-with-Visual-Studio) for deploy WebResources, Reports.
* [DynamicsCrm.DevKit.Cli](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/DynamicsCrm-DevKit-Cli) for deploy plugins, workflows, custom actions, custom apis, data providers, webresources, download webresources, download reports.
* [DynamicsCrm.DevKit.Cli](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/DynamicsCrm-DevKit-Cli) for deploy plugins, dependent assembly plugins, workflows, custom actions, custom apis, data providers, webresources, download webresources, download reports.

# How to
* [Install DynamicsCrm.DevKit](https://github.com/phuocle/Dynamics-Crm-DevKit/wiki/Install-DynamicsCrm-DevKit)
Expand Down
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions test/3.33.33.33/Dev.DevKit.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {478EE8F5-54E1-431D-BEC8-72AC05F5AF8C}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="AuthType" value="ClientSecret" />
<add key="Url" value="https://dev2-devkit.crm5.dynamics.com" />
<add key="ClientId" value="e31fc7d6-4dce-46e3-8677-04ab0a2968e3" />
<add key="ClientSecret" value="?-iwRSB0te8o]pHX_yVQLJnUqziB1E0h" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.8.0" newVersion="5.2.8.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Configuration;
using Microsoft.Xrm.Tooling.Connector;

namespace Dev.DevKit.Console
{
public static class AppSettings
{
private static CrmServiceClient _Service = null;
public static CrmServiceClient Service
{
get
{
if (_Service != null) return _Service;
CrmServiceClient.MaxConnectionTimeout = new TimeSpan(1, 0, 0);
_Service = new CrmServiceClient(ConnectionString);
return _Service;
}
}
private static string AuthType { get { return ConfigurationManager.AppSettings["AuthType"]; } }
private static string Url { get { return ConfigurationManager.AppSettings["Url"]; } }
private static string UserName { get { return ConfigurationManager.AppSettings["ClientId"]; } }
private static string Password { get { return ConfigurationManager.AppSettings["ClientSecret"]; } }
private static string ConnectionString
{
get
{
if (AuthType == "ClientSecret")
return $"AuthType=ClientSecret;Url={Url};ClientId={UserName};ClientSecret={Password};";
if (AuthType == "OAuth")
return $"AuthType=OAuth;Url={Url};Username={UserName};Password={Password};AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Auto";
var arr = UserName.Split("\\".ToCharArray());
if (arr.Length != 2) throw new Exception("Please enter UserName like: contoso\\jsmith");
return $"AuthType=AD;Url={Url};Domain={arr[0]};Username={arr[1]};Password={Password};";
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dev.DevKit.Console
{
internal class DEVKIT1002
{
private void Test1()
{
var fetchXml = $@"
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='account'>
<all-attributes/>
</entity>
</fetch>
";
}

private void Test2()
{
var account = AppSettings.Service.Retrieve("account", Guid.NewGuid(), new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Messages;

namespace Dev.DevKit.Console
{
internal class DEVKIT1004
{
private void Test1()
{
var request = new AddProductToKitRequest();
var response = (AddProductToKitResponse)AppSettings.Service.Execute(request);
var response2 = AppSettings.Service.Execute(request) as AddProductToKitResponse;
var update = new UpdateRequest();
var response3 = (UpdateResponse)AppSettings.Service.Execute(update);
if (response != null && response2 != null)
{
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Extensions;
using Microsoft.Xrm.Sdk.PluginTelemetry;
using Microsoft.Xrm.Tooling.Connector;
using NSubstitute;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;

namespace Dev.DevKit.Console.Debug
{
public static class Helper
{
private static RemoteExecutionContext DeserializeRemoteExecutionContext(string jsonString)
{
var settings = new DataContractJsonSerializerSettings() { DateTimeFormat = new DateTimeFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'") };
var obj = Activator.CreateInstance<RemoteExecutionContext>();
MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(jsonString));
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType(), settings);
obj = (RemoteExecutionContext)serializer.ReadObject(ms);
ms.Close();
return obj;
}

public static IServiceProvider GetServiceProvider(string json, CrmServiceClient service)
{
var pluginExecutionContext = DeserializeRemoteExecutionContext(json);
FixDataAfterDeserialize(pluginExecutionContext);
var serviceProvider = Substitute.For<IServiceProvider>();
serviceProvider.Get<IPluginExecutionContext>().Returns(pluginExecutionContext);
serviceProvider.Get<IServiceEndpointNotificationService>().Returns(Substitute.For<IServiceEndpointNotificationService>());
serviceProvider.Get<IExecutionContext>().Returns(Substitute.For<IExecutionContext>());
serviceProvider.Get<ITracingService>().Returns(Substitute.For<TracingServiceFake>());
serviceProvider.Get<ILogger>().Returns(Substitute.For<ILogger>());
var factory = Substitute.For<IOrganizationServiceFactory>();
factory.CreateOrganizationService(Arg.Any<Guid?>()).Returns((param) =>
{
var userId = param.ArgAt<Guid?>(0);
if (userId != null) service.CallerId = userId.GetValueOrDefault();
return service;
});
serviceProvider.Get<IOrganizationServiceFactory>().Returns(factory);
return serviceProvider;
}

private static void FixDataAfterDeserialize(RemoteExecutionContext pluginExecutionContext)
{
var entities = new List<Entity>();
entities.AddRange(pluginExecutionContext.InputParameters.Where(x => x.Value is Entity).Select(x => (Entity)x.Value).ToList());
entities.AddRange(pluginExecutionContext.SharedVariables.Where(x => x.Value is Entity).Select(x => (Entity)x.Value).ToList());
entities.AddRange(pluginExecutionContext.OutputParameters.Where(x => x.Value is Entity).Select(x => (Entity)x.Value).ToList());
entities.AddRange(pluginExecutionContext.PostEntityImages.Select(x => (Entity)x.Value).ToList());
entities.AddRange(pluginExecutionContext.PreEntityImages.Select(x => (Entity)x.Value).ToList());
FixedDateTime(entities);
FixedOptionSetValueCollection(entities);
}

private static void FixedOptionSetValueCollection(List<Entity> entities)
{
foreach (var entity in entities)
{
foreach (var key in entity.Attributes.Keys.ToList())
{
try
{
var array = entity.GetAttributeValue<object[]>(key);
if (array != null)
{
var collection = new OptionSetValueCollection();
foreach (var item in array)
collection.Add(item as OptionSetValue);
entity.Attributes[key] = collection;
}
}
catch { }
}
}
}

private static void FixedDateTime(List<Entity> entities)
{
foreach (var entity in entities)
{
foreach (var key in entity.Attributes.Keys.ToList())
{
try
{
var str = entity.GetAttributeValue<string>(key);
if (str != null && DateTime.TryParse(str, out var dateTime))
{
entity.Attributes[key] = dateTime;
}
}
catch { }
}
}
}

public static string Decompress(string compressedString)
{
byte[] decompressedBytes;
var compressedStream = new MemoryStream(Convert.FromBase64String(compressedString));
using (var decompressorStream = new DeflateStream(compressedStream, CompressionMode.Decompress))
{
using (var decompressedStream = new MemoryStream())
{
decompressorStream.CopyTo(decompressedStream);
decompressedBytes = decompressedStream.ToArray();
}
}
return Encoding.UTF8.GetString(decompressedBytes);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.Xrm.Sdk;

namespace Dev.DevKit.Console.Debug
{
public class TracingServiceFake : ITracingService
{
public ITracingService crmTracingService;

public void Trace(string format, params object[] args)
{
if (crmTracingService == null)
{
try
{
System.Console.Write(format, args);
System.Console.WriteLine();
}
catch
{
System.Console.Write(format);
System.Console.WriteLine();
}
}
else
{
crmTracingService.Trace(format, args);
}
}
}
}
Loading

0 comments on commit 0c4960a

Please sign in to comment.