Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix odata batch support #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ dotnet/Xrm.Tools.SeverCommonTest/obj
dotnet/Xrm.Tools.WebAPI.NuGet/bin/
dotnet/Xrm.Tools.WebAPI.NuGet/obj
dotnet/Xrm.Tools.WebAPI.NuGet/obj/Debug/**
dotnet/Xrm.Tools.WebAPI.Core/obj/
dotnet/Xrm.Tools.WebAPI.Core/obj
dotnet/Xrm.Tools.WebAPI.Core/bin
dotnet/Xrm.Tools.WebAPI.Core.Test/obj
dotnet/Xrm.Tools.WebAPI.Core.Test/bin

.vs
.nuget
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Xrm.Tools.WebAPI.Test\ActionTests.cs" Link="ActionTests.cs" />
<Compile Include="..\Xrm.Tools.WebAPI.Test\BasicChangeTrackingTests.cs" Link="BasicChangeTrackingTests.cs" />
<Compile Include="..\Xrm.Tools.WebAPI.Test\BasicCRUDTests.cs" Link="BasicCRUDTests.cs" />
<Compile Include="..\Xrm.Tools.WebAPI.Test\BasicMetadataTests.cs" Link="BasicMetadataTests.cs" />
<Compile Include="..\Xrm.Tools.WebAPI.Test\UnitTestBaseClass.cs" Link="UnitTestBaseClass.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Xrm.Tools.WebAPI.Core\Xrm.Tools.WebAPI.Core.csproj" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions dotnet/Xrm.Tools.WebAPI.Core/Xrm.Tools.WebAPI.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>xt.snk</AssemblyOriginatorKeyFile>
<AssemblyName>Xrm.Tools.WebAPI</AssemblyName>
Expand All @@ -26,7 +26,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"System.Runtime.Serialization.Primitives/4.1.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HZ6Du5QrTG8MNJbf4e4qMO3JRAkIboGT5Fk804uZtg3Gq516S7hAqTm2UZKUHa7/6HUGdVy3AqMQKbns06G/cg==",
"sha512": "sha512-uoLAgxKA0qYYdleZTUYCiVykz6S875iBgz0D0Q+OF2Z49MJh6zbKiJ3GZ6nXygdbMLgAuD1Zs0dHWMSRLDrVfA==",
"path": "system.runtime.serialization.primitives/4.1.1",
"hashPath": "system.runtime.serialization.primitives.4.1.1.nupkg.sha512"
}
Expand Down
Binary file modified dotnet/Xrm.Tools.WebAPI.NuGet/NuGet.exe
Binary file not shown.
Binary file modified dotnet/Xrm.Tools.WebAPI.NuGet/NuGet.log
Binary file not shown.
16 changes: 9 additions & 7 deletions dotnet/Xrm.Tools.WebAPI.NuGet/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,25 @@
<group targetFramework="uap10.0">
<dependency id="Newtonsoft.Json" version="8.0.2" />
</group>
<group targetFramework=".NETCoreApp1.0">
<dependency id="Microsoft.NETCore.App" version="1.1.0" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="9.0.1" exclude="Build,Analyzers" />
<group targetFramework=".NETCoreApp2.1">
<dependency id="Microsoft.NETCore.App" version="2.1.0" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="11.0.2" exclude="Build,Analyzers" />
<dependency id="Microsoft.AspNet.WebApi.Client" version="5.2.7" exclude="Build,Analyzers" />
</group>
<group targetFramework="netstandard1.4">
<group targetFramework="netstandard2.0">
<dependency id="System.Reflection" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Reflection.TypeExtensions" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="10.0.2" exclude="Build,Analyzers" />
<dependency id="Microsoft.AspNet.WebApi.Client" version="5.2.7" exclude="Build,Analyzers" />
</group>
</dependencies>
<references></references>
<tags></tags>
</metadata>
<files>
<file src="..\Xrm.Tools.WebAPI\bin\debug\Xrm.Tools.WebAPI.dll" target="lib\net46" />
<file src="..\Xrm.Tools.WebAPI.Core\bin\Debug\netcoreapp1.0\Xrm.Tools.WebAPI.dll" target="lib\netcore" />
<file src="..\Xrm.Tools.WebAPI.Core\bin\Debug\netcoreapp1.0\Xrm.Tools.WebAPI.dll" target="lib\netcoreapp" />
<file src="..\Xrm.Tools.WebAPI.Standard\bin\Debug\netstandard1.4\Xrm.Tools.WebAPI.dll" target="lib\netstandard" />
<file src="..\Xrm.Tools.WebAPI.Core\bin\Debug\netcoreapp2.1\Xrm.Tools.WebAPI.dll" target="lib\netcore" />
<file src="..\Xrm.Tools.WebAPI.Core\bin\Debug\netcoreapp2.1\Xrm.Tools.WebAPI.dll" target="lib\netcoreapp" />
<file src="..\Xrm.Tools.WebAPI.Standard\bin\Debug\netstandard2.0\Xrm.Tools.WebAPI.dll" target="lib\netstandard" />
</files>
</package>
Binary file modified dotnet/Xrm.Tools.WebAPI.NuGet/Xrm.Tools.CRMWebAPI.1.0.24.nupkg
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.4;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>xt.snk</AssemblyOriginatorKeyFile>
<AssemblyName>Xrm.Tools.WebAPI</AssemblyName>
Expand Down Expand Up @@ -31,4 +31,10 @@
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNet.WebApi.Client">
<Version>5.2.7</Version>
</PackageReference>
</ItemGroup>

</Project>
145 changes: 65 additions & 80 deletions dotnet/Xrm.Tools.WebAPI.Test/ActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,103 +10,88 @@ namespace Xrm.Tools.WebAPI.Test
public class ActionTests : UnitTestBaseClass
{
[TestMethod]
public void TestWinOpportunity()
public async Task TestWinOpportunity()
{
var api = GetAPI();

dynamic account = new ExpandoObject();
account.name = "test " + DateTime.Now.ToString();
Guid accountID = await api.Create("accounts", account);

dynamic contact = new ExpandoObject();
contact.firstname = "test " + DateTime.Now.ToString();
contact.lastname = "test " + DateTime.Now.ToString();
Guid contactID = await api.Create("contacts", contact);

dynamic opportunity = new ExpandoObject();
var oppIndexer = opportunity as IDictionary<string, Object>;
opportunity.name = "Test opportunity " + DateTime.Now.ToString();
oppIndexer["customerid_account@odata.bind"] = "/accounts(" + accountID.ToString() + ")";
oppIndexer["parentcontactid@odata.bind"] = "/contacts(" + contactID.ToString() + ")";
Guid oppID = await api.Create("opportunities", opportunity);

dynamic opportClose = new ExpandoObject();
var opportCloseIndexer = opportClose as IDictionary<string, Object>;
opportClose.subject = "Won Opportunity";
opportCloseIndexer["opportunityid@odata.bind"] = "/opportunities(" + oppID.ToString() + ")";
dynamic lostOpportParams = new ExpandoObject();
lostOpportParams.Status = 3;
lostOpportParams.OpportunityClose = opportClose;
await api.ExecuteAction("WinOpportunity", lostOpportParams);

System.Diagnostics.Trace.WriteLine("finished");

Task.Run(async () =>
{
var api = GetAPI();

dynamic account = new ExpandoObject();
account.name = "test " + DateTime.Now.ToString();
Guid accountID = await api.Create("accounts", account);
}
[TestMethod]
public async Task TestLostOpportunity()
{

dynamic contact = new ExpandoObject();
contact.firstname = "test " + DateTime.Now.ToString();
contact.lastname = "test " + DateTime.Now.ToString();
Guid contactID = await api.Create("contacts", contact);
var api = GetAPI();

dynamic opportunity = new ExpandoObject();
var oppIndexer = opportunity as IDictionary<string, Object>;
opportunity.name = "Test opportunity " + DateTime.Now.ToString();
oppIndexer["customerid_account@odata.bind"] = "/accounts(" + accountID.ToString() + ")";
oppIndexer["parentcontactid@odata.bind"] = "/contacts(" + contactID.ToString() + ")";
Guid oppID = await api.Create("opportunities", opportunity);
dynamic account = new ExpandoObject();
account.name = "test " + DateTime.Now.ToString();
Guid accountID = await api.Create("accounts", account);

dynamic opportClose = new ExpandoObject();
var opportCloseIndexer = opportClose as IDictionary<string, Object>;
opportClose.subject = "Won Opportunity";
opportCloseIndexer["opportunityid@odata.bind"] = "/opportunities(" + oppID.ToString() + ")";
dynamic lostOpportParams = new ExpandoObject();
lostOpportParams.Status = 3;
lostOpportParams.OpportunityClose = opportClose;
await api.ExecuteAction("WinOpportunity", lostOpportParams);
dynamic contact = new ExpandoObject();
contact.firstname = "test " + DateTime.Now.ToString();
contact.lastname = "test " + DateTime.Now.ToString();
Guid contactID = await api.Create("contacts", contact);

System.Diagnostics.Trace.WriteLine("finished");
dynamic opportunity = new ExpandoObject();
var oppIndexer = opportunity as IDictionary<string, Object>;
opportunity.name = "Test opportunity " + DateTime.Now.ToString();
oppIndexer["customerid_account@odata.bind"] = "/accounts(" + accountID.ToString() + ")";
oppIndexer["parentcontactid@odata.bind"] = "/contacts(" + contactID.ToString() + ")";
Guid oppID = await api.Create("opportunities", opportunity);

dynamic opportClose = new ExpandoObject();
var opportCloseIndexer = opportClose as IDictionary<string, Object>;
opportClose.subject = "Lost Opportunity";
opportCloseIndexer["opportunityid@odata.bind"] = "/opportunities(" + oppID.ToString() + ")";
dynamic lostOpportParams = new ExpandoObject();
lostOpportParams.Status = 4;
lostOpportParams.OpportunityClose = opportClose;
await api.ExecuteAction("LoseOpportunity", lostOpportParams);

}).Wait();
}
[TestMethod]
public void TestLostOpportunity()
{
System.Diagnostics.Trace.WriteLine("finished");

Task.Run(async () =>
{
var api = GetAPI();

dynamic account = new ExpandoObject();
account.name = "test " + DateTime.Now.ToString();
Guid accountID = await api.Create("accounts", account);

dynamic contact = new ExpandoObject();
contact.firstname = "test " + DateTime.Now.ToString();
contact.lastname = "test " + DateTime.Now.ToString();
Guid contactID = await api.Create("contacts", contact);

dynamic opportunity = new ExpandoObject();
var oppIndexer = opportunity as IDictionary<string, Object>;
opportunity.name = "Test opportunity " + DateTime.Now.ToString();
oppIndexer["customerid_account@odata.bind"] = "/accounts(" + accountID.ToString() + ")";
oppIndexer["parentcontactid@odata.bind"] = "/contacts(" + contactID.ToString() + ")";
Guid oppID = await api.Create("opportunities", opportunity);

dynamic opportClose = new ExpandoObject();
var opportCloseIndexer = opportClose as IDictionary<string, Object>;
opportClose.subject = "Lost Opportunity";
opportCloseIndexer["opportunityid@odata.bind"] = "/opportunities(" + oppID.ToString() +")";
dynamic lostOpportParams = new ExpandoObject();
lostOpportParams.Status = 4;
lostOpportParams.OpportunityClose = opportClose;
await api.ExecuteAction("LoseOpportunity", lostOpportParams);

System.Diagnostics.Trace.WriteLine("finished");


}).Wait();
}

[TestMethod]
public void TestCalculateRollup()
public async Task TestCalculateRollup()
{
var api = GetAPI();

Task.Run(async () =>
{
var api = GetAPI();

dynamic voteCountUpdate = new ExpandoObject();
voteCountUpdate.Target = new ExpandoObject();
var ivote = voteCountUpdate.Target as IDictionary<string, Object>;

ivote["@odata.id"] = "ctccrm_ideas(19dc848b-1c5e-e711-8112-e0071b66aea1)";
voteCountUpdate.FieldName = "ctccrm_votes";
await api.ExecuteFunction("CalculateRollupField", voteCountUpdate);

dynamic voteCountUpdate = new ExpandoObject();
voteCountUpdate.Target = new ExpandoObject();
var ivote = voteCountUpdate.Target as IDictionary<string, Object>;

System.Diagnostics.Trace.WriteLine("finished");
ivote["@odata.id"] = "ctccrm_ideas(19dc848b-1c5e-e711-8112-e0071b66aea1)";
voteCountUpdate.FieldName = "ctccrm_votes";
await api.ExecuteFunction("CalculateRollupField", voteCountUpdate);


}).Wait();
System.Diagnostics.Trace.WriteLine("finished");
}
}
}
Loading