-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release DynamicsCrm.DevKit.Cli.3.33.33.33 (#52)
Release DynamicsCrm.DevKit.Cli.3.33.33.33
- Loading branch information
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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
32 changes: 32 additions & 0 deletions
32
test/3.33.33.33/DynamicsCrm.DevKit.Analyzers/ClientSecret/Dev.DevKit.Console/App.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
38 changes: 38 additions & 0 deletions
38
test/3.33.33.33/DynamicsCrm.DevKit.Analyzers/ClientSecret/Dev.DevKit.Console/AppSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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};"; | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
test/3.33.33.33/DynamicsCrm.DevKit.Analyzers/ClientSecret/Dev.DevKit.Console/DEVKIT1002.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
test/3.33.33.33/DynamicsCrm.DevKit.Analyzers/ClientSecret/Dev.DevKit.Console/DEVKIT1004.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
test/3.33.33.33/DynamicsCrm.DevKit.Analyzers/ClientSecret/Dev.DevKit.Console/Debug/Helper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../DynamicsCrm.DevKit.Analyzers/ClientSecret/Dev.DevKit.Console/Debug/TracingServiceFake.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.