Inbound scenario sample using CSharp console app (#26)
This commit is contained in:
Родитель
4980af9e76
Коммит
2c69559f68
|
@ -196,3 +196,4 @@ ModelManifest.xml
|
|||
/ServiceSamples/packages
|
||||
/FileBasedIntegrationSamples/LogicAppSamples/.vs/config
|
||||
/DIXFSamples/packages
|
||||
/FileBasedIntegrationSamples/ConsoleAppSamples/DataPackageHandler/packages
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -0,0 +1,34 @@
|
|||
using Microsoft.IdentityModel.Clients.ActiveDirectory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AuthorizationHelper
|
||||
{
|
||||
public class AuthorizationHelper
|
||||
{
|
||||
const string aadTenant = "https://login.windows.net/<your-tenant>";
|
||||
public const string aadResource = "https://<yourAOS>.cloudax.dynamics.com";
|
||||
const string aadClientAppId = "<client id>";
|
||||
const string aadClientAppSecret = "<client secret>";
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an authentication header from the service.
|
||||
/// </summary>
|
||||
/// <returns>The authentication header for the Web API call.</returns>
|
||||
public static string GetAuthenticationHeader()
|
||||
{
|
||||
AuthenticationContext authenticationContext = new AuthenticationContext(aadTenant);
|
||||
AuthenticationResult authenticationResult;
|
||||
|
||||
var creadential = new ClientCredential(aadClientAppId, aadClientAppSecret);
|
||||
authenticationResult = authenticationContext.AcquireTokenAsync(aadResource, creadential).Result;
|
||||
|
||||
// Create and get JWT token
|
||||
return authenticationResult.CreateAuthorizationHeader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6206B3DF-4475-4A6B-9F06-DA966827903B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AuthorizationHelper</RootNamespace>
|
||||
<AssemblyName>AuthorizationHelper</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.14.0.8, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.14.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.14.0.8, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.14.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AuthorizationHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AuthorizationHelper")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AuthorizationHelper")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("6206b3df-4475-4a6b-9f06-da966827903b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.14.0" targetFramework="net452" />
|
||||
</packages>
|
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{FF96F510-362A-4054-9BD1-7517898425C5}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>DataPackageHandler</RootNamespace>
|
||||
<AssemblyName>DataPackageHandler</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Edm, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Data.Edm.5.8.2\lib\net40\Microsoft.Data.Edm.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.OData, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Data.OData.5.8.2\lib\net40\Microsoft.Data.OData.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Services.Client, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Data.Services.Client.5.8.2\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.14.0.8, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.14.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.14.0.8, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.14.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OData.Client, Version=6.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.OData.Client.6.17.0\lib\net40\Microsoft.OData.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OData.Core, Version=6.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.OData.Core.6.17.0\lib\portable-net45+win+wpa81\Microsoft.OData.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OData.Edm, Version=6.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.OData.Edm.6.17.0\lib\portable-net45+win+wpa81\Microsoft.OData.Edm.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Spatial, Version=6.17.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Spatial.6.17.0\lib\portable-net45+win+wpa81\Microsoft.Spatial.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAzure.Storage, Version=8.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\WindowsAzure.Storage.8.1.4\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Spatial, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\System.Spatial.5.8.2\lib\net40\System.Spatial.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PackageImporter.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="SampleData\usmf_asset-major-types-01.zip">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ODataClient\ODataClient.csproj">
|
||||
<Project>{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}</Project>
|
||||
<Name>ODataClient</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="AuthorizationHelper\AuthorizationHelper.csproj">
|
||||
<Project>{6206b3df-4475-4a6b-9f06-da966827903b}</Project>
|
||||
<Name>AuthorizationHelper</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataPackageHandler", "DataPackageHandler.csproj", "{FF96F510-362A-4054-9BD1-7517898425C5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODataClient", "..\ODataClient\ODataClient.csproj", "{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthorizationHelper", "AuthorizationHelper\AuthorizationHelper.csproj", "{6206B3DF-4475-4A6B-9F06-DA966827903B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FF96F510-362A-4054-9BD1-7517898425C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FF96F510-362A-4054-9BD1-7517898425C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FF96F510-362A-4054-9BD1-7517898425C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FF96F510-362A-4054-9BD1-7517898425C5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6206B3DF-4475-4A6B-9F06-DA966827903B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6206B3DF-4475-4A6B-9F06-DA966827903B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6206B3DF-4475-4A6B-9F06-DA966827903B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6206B3DF-4475-4A6B-9F06-DA966827903B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,77 @@
|
|||
using Microsoft.WindowsAzure.Storage.Blob;
|
||||
using Newtonsoft.Json;
|
||||
using ODataClient.Microsoft.Dynamics.DataEntities;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace DataPackageHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Showcases data package import using the DataManagementDefinitionGroups APIs.
|
||||
/// </summary>
|
||||
class PackageImporter
|
||||
{
|
||||
public static void ImportPackage(Resources d365Client, string filePath)
|
||||
{
|
||||
// 1. Get writable Url from Dynamics 365 for Operations
|
||||
var azureWritableUrlOutput = d365Client.DataManagementDefinitionGroups.GetAzureWriteUrl(new Guid().ToString()).GetValue();
|
||||
var azureWriteUrl = JsonConvert.DeserializeObject<AzureUrlResult>(azureWritableUrlOutput);
|
||||
|
||||
Console.WriteLine("Received azure writable url.");
|
||||
|
||||
// 2. Upload the file to Dynamics 365 for Operations
|
||||
using (FileStream stream = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
var blob = new CloudBlockBlob(new Uri(azureWriteUrl.BlobUrl));
|
||||
blob.UploadFromStream(stream);
|
||||
}
|
||||
|
||||
Console.WriteLine("Uploaded file to blob storage");
|
||||
|
||||
// 3. Import the data package
|
||||
var executionId = d365Client.DataManagementDefinitionGroups.ImportFromPackage(
|
||||
packageUrl: azureWriteUrl.BlobUrl,
|
||||
definitionGroupId: "Integration-data-project-01",
|
||||
executionId: string.Empty,
|
||||
execute: true,
|
||||
overwrite: true,
|
||||
legalEntityId: "USMF").GetValue();
|
||||
|
||||
Console.WriteLine("Package execution initiated.");
|
||||
|
||||
// 4. Check for status
|
||||
DMFExecutionSummaryStatus? output;
|
||||
int maxLoop = 100;
|
||||
|
||||
do
|
||||
{
|
||||
Console.WriteLine("Waiting for package to execution to complete");
|
||||
|
||||
Thread.Sleep(5000);
|
||||
maxLoop--;
|
||||
|
||||
if (maxLoop <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine("Checking status");
|
||||
|
||||
output = d365Client.DataManagementDefinitionGroups.GetExecutionSummaryStatus(executionId).GetValue();
|
||||
|
||||
Console.WriteLine("Status of import is " + output.Value);
|
||||
|
||||
}
|
||||
while (output == DMFExecutionSummaryStatus.NotRun || output == DMFExecutionSummaryStatus.Executing);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class AzureUrlResult
|
||||
{
|
||||
public string BlobId { get; set; }
|
||||
|
||||
public string BlobUrl { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
using ODataClient.Microsoft.Dynamics.DataEntities;
|
||||
using System;
|
||||
|
||||
namespace DataPackageHandler
|
||||
{
|
||||
using AuthorizationHelper;
|
||||
using Microsoft.OData.Client;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string ODataEntityPath = AuthorizationHelper.aadResource + "/data";
|
||||
Uri oDataUri = new Uri(ODataEntityPath, UriKind.Absolute);
|
||||
|
||||
var d365Client = new Resources(oDataUri);
|
||||
d365Client.SendingRequest2 += new EventHandler<SendingRequest2EventArgs>(delegate (object sender, SendingRequest2EventArgs e)
|
||||
{
|
||||
var authenticationHeader = AuthorizationHelper.GetAuthenticationHeader();
|
||||
e.RequestMessage.SetHeader("Authorization", authenticationHeader);
|
||||
});
|
||||
|
||||
PackageImporter.ImportPackage(d365Client, @"..\debug\SampleData\usmf_asset-major-types-01.zip");
|
||||
|
||||
Console.WriteLine("Press enter to quit...");
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("DataPackageHandler")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DataPackageHandler")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ff96f510-362a-4054-9bd1-7517898425c5")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
Двоичные данные
FileBasedIntegrationSamples/ConsoleAppSamples/DataPackageHandler/SampleData/usmf_asset-major-types-01.zip
Normal file
Двоичные данные
FileBasedIntegrationSamples/ConsoleAppSamples/DataPackageHandler/SampleData/usmf_asset-major-types-01.zip
Normal file
Двоичный файл не отображается.
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net452" />
|
||||
<package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net452" />
|
||||
<package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net452" />
|
||||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.14.0" targetFramework="net452" />
|
||||
<package id="Microsoft.OData.Client" version="6.17.0" targetFramework="net452" />
|
||||
<package id="Microsoft.OData.Core" version="6.17.0" targetFramework="net452" />
|
||||
<package id="Microsoft.OData.Edm" version="6.17.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Spatial" version="6.17.0" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
|
||||
<package id="System.ComponentModel.EventBasedAsync" version="4.0.11" targetFramework="net452" />
|
||||
<package id="System.Dynamic.Runtime" version="4.0.0" targetFramework="net452" />
|
||||
<package id="System.Linq.Queryable" version="4.0.0" targetFramework="net452" />
|
||||
<package id="System.Net.Requests" version="4.0.11" targetFramework="net452" />
|
||||
<package id="System.Spatial" version="5.8.2" targetFramework="net452" />
|
||||
<package id="WindowsAzure.Storage" version="8.1.4" targetFramework="net452" />
|
||||
</packages>
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5813E6A9-1ACB-4DB5-B020-3C3E0BBD9D19}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ODataClient</RootNamespace>
|
||||
<AssemblyName>ODataClient</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.OData.Client, Version=6.13.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\DataPackageHandler\packages\Microsoft.OData.Client.6.13.0\lib\net40\Microsoft.OData.Client.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OData.Core, Version=6.13.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\DataPackageHandler\packages\Microsoft.OData.Core.6.13.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OData.Edm, Version=6.13.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\DataPackageHandler\packages\Microsoft.OData.Edm.6.13.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Edm.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Spatial, Version=6.13.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\DataPackageHandler\packages\Microsoft.Spatial.6.13.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ODataClient.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>ODataClient.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="ODataClient.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>ODataClient.cs</LastGenOutput>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ODataClient.ttinclude" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,75 @@
|
|||
<#@ include file="ODataClient.ttinclude" #>
|
||||
<#+
|
||||
public static class Configuration
|
||||
{
|
||||
// The URI of the metadata document. The value must be set to a valid service document URI or a local file path
|
||||
// eg : "http://services.odata.org/V4/OData/OData.svc/", "File:///C:/Odata.edmx", or @"C:\Odata.edmx"
|
||||
// ### Notice ### If the OData service requires authentication for accessing the metadata document, the value of
|
||||
// MetadataDocumentUri has to be set to a local file path, or the client code generation process will fail.
|
||||
public const string MetadataDocumentUri = "https://retail1611pu6c4dd29587c42e289devaos.cloudax.dynamics.com/data/$metadata";
|
||||
|
||||
// The use of DataServiceCollection enables entity and property tracking. The value must be set to true or false.
|
||||
public const bool UseDataServiceCollection = true;
|
||||
|
||||
// The namespace of the client code generated. It replaces the original namespace in the metadata document,
|
||||
// unless the model has several namespaces.
|
||||
public const string NamespacePrefix = "ODataClient";
|
||||
|
||||
// The target language of the generated client code. The value must be set to "CSharp" or "VB".
|
||||
public const string TargetLanguage = "CSharp";
|
||||
|
||||
// This flag indicates whether to enable naming alias. The value must be set to true or false.
|
||||
public const bool EnableNamingAlias = true;
|
||||
|
||||
// This flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate
|
||||
// the client code if any. The value must be set to true or false.
|
||||
public const bool IgnoreUnexpectedElementsAndAttributes = true;
|
||||
}
|
||||
|
||||
public static class Customization
|
||||
{
|
||||
/// <summary>
|
||||
/// Changes the text to use upper camel case, which upper case for the first character.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to convert.</param>
|
||||
/// <returns>The converted text in upper camel case</returns>
|
||||
internal static string CustomizeNaming(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
if (text.Length == 1)
|
||||
{
|
||||
return Char.ToUpperInvariant(text[0]).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
return Char.ToUpperInvariant(text[0]) + text.Substring(1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the namespace to use upper camel case, which upper case for the first character of all segments.
|
||||
/// </summary>
|
||||
/// <param name="fullNamespace">Namespace to convert.</param>
|
||||
/// <returns>The converted namespace in upper camel case</returns>
|
||||
internal static string CustomizeNamespace(string fullNamespace)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fullNamespace))
|
||||
{
|
||||
return fullNamespace;
|
||||
}
|
||||
|
||||
string[] segs = fullNamespace.Split('.');
|
||||
string upperNamespace = string.Empty;
|
||||
int n = segs.Length;
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
upperNamespace += Customization.CustomizeNaming(segs[i]);
|
||||
upperNamespace += (i == n - 1 ? string.Empty : ".");
|
||||
}
|
||||
|
||||
return upperNamespace;
|
||||
}
|
||||
}
|
||||
#>
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ODataClient")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ODataClient")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5813e6a9-1acb-4db5-b020-3c3e0bbd9d19")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.OData.Client" version="6.13.0" targetFramework="net452" />
|
||||
<package id="Microsoft.OData.Core" version="6.13.0" targetFramework="net452" />
|
||||
<package id="Microsoft.OData.Edm" version="6.13.0" targetFramework="net452" />
|
||||
<package id="Microsoft.Spatial" version="6.13.0" targetFramework="net452" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче