Skip to content

Commit 7541a9d

Browse files
committed
Aspose.Diagram Cloud .NET Examples
1 parent f164cf3 commit 7541a9d

File tree

6 files changed

+273
-0
lines changed

6 files changed

+273
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25123.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspose.Diagram Cloud APIs Examples", "Aspose.Diagram Cloud APIs Examples\Aspose.Diagram Cloud APIs Examples.csproj", "{797B97E2-C308-4416-9A5B-B95E7AC5B9A3}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{797B97E2-C308-4416-9A5B-B95E7AC5B9A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{797B97E2-C308-4416-9A5B-B95E7AC5B9A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{797B97E2-C308-4416-9A5B-B95E7AC5B9A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{797B97E2-C308-4416-9A5B-B95E7AC5B9A3}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
14+
</configuration>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{797B97E2-C308-4416-9A5B-B95E7AC5B9A3}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Aspose.Diagram_Cloud_APIs_Examples</RootNamespace>
11+
<AssemblyName>Aspose.Diagram Cloud APIs Examples</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Aspose.Diagram.Cloud.SDK, Version=18.10.0.0, Culture=neutral, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Aspose.Diagram-Cloud.18.10.0\lib\net4.5\Aspose.Diagram.Cloud.SDK.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
40+
<Reference Include="Aspose.Storage.Cloud.Sdk, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>..\packages\Aspose.Storage-Cloud.18.3.0\lib\net20\Aspose.Storage.Cloud.Sdk.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
45+
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="RestSharp, Version=105.1.0.0, Culture=neutral, processorArchitecture=MSIL">
49+
<HintPath>..\packages\RestSharp.105.1.0\lib\net452\RestSharp.dll</HintPath>
50+
<Private>True</Private>
51+
</Reference>
52+
<Reference Include="System" />
53+
<Reference Include="System.Core" />
54+
<Reference Include="System.Xml.Linq" />
55+
<Reference Include="System.Data.DataSetExtensions" />
56+
<Reference Include="Microsoft.CSharp" />
57+
<Reference Include="System.Data" />
58+
<Reference Include="System.Net.Http" />
59+
<Reference Include="System.Xml" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="DiagramExamples.cs" />
63+
<Compile Include="Properties\AssemblyInfo.cs" />
64+
</ItemGroup>
65+
<ItemGroup>
66+
<None Include="App.config" />
67+
<None Include="packages.config" />
68+
</ItemGroup>
69+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
70+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
71+
Other similar extension points exist, see Microsoft.Common.targets.
72+
<Target Name="BeforeBuild">
73+
</Target>
74+
<Target Name="AfterBuild">
75+
</Target>
76+
-->
77+
</Project>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
using Aspose.Diagram.Cloud.SDK.Api;
2+
using Aspose.Diagram.Cloud.SDK.Client;
3+
using Aspose.Diagram.Cloud.SDK.Model;
4+
using Aspose.Storage.Cloud.Sdk.Api;
5+
using Aspose.Storage.Cloud.Sdk.Model.Requests;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.IO;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
13+
namespace Aspose.Diagram_Cloud_APIs_Examples
14+
{
15+
class DiagramExamples
16+
{
17+
protected ApiClient client;
18+
protected Configuration config;
19+
protected static OAuthApi oauth2 = null;
20+
protected string grantType = "client_credentials";
21+
protected string clientId = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
22+
protected string clientSecret = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
23+
protected static string accesstoken;
24+
protected string refreshtoken;
25+
26+
static void Main(string[] args)
27+
{
28+
DiagramExamples diagramExamples = new DiagramExamples();
29+
// Get Diagram Document Information
30+
diagramExamples.GetDiagram();
31+
// Convert Diagram File to Another Format
32+
diagramExamples.PostSaveAsTest();
33+
// Create Diagram File
34+
diagramExamples.PutCreateTest();
35+
// Upload Diagram File
36+
diagramExamples.PutUploadTest();
37+
}
38+
39+
// Get Diagram Document Information
40+
private void GetDiagram()
41+
{
42+
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
43+
44+
string name = "file_get_1.vdx";
45+
string folder = null;
46+
UpdateDataFile(name);
47+
var response = instance.DiagramFileGetDiagram(name, "pdf", folder);
48+
int i = 5;
49+
}
50+
51+
// Convert Diagram File to Another Format
52+
private void PostSaveAsTest()
53+
{
54+
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
55+
56+
string name = "file_get_1.vdx";
57+
bool isOverwrite = true;
58+
string folder = null;
59+
60+
FileFormatRequest format = new FileFormatRequest() { Format = "pdf" };
61+
string newfilename = "file_saveas_1.pdf";
62+
63+
UpdateDataFile(name);
64+
var response = instance.DiagramFilePostSaveAs(name, format, newfilename, folder, isOverwrite);
65+
}
66+
67+
// Create Diagram File
68+
private void PutCreateTest()
69+
{
70+
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
71+
72+
string name = "file_get_1.vdx";
73+
bool isOverwrite = true;
74+
string folder = null;
75+
76+
var response = instance.DiagramFilePutCreate(name, folder, isOverwrite);
77+
}
78+
79+
// Upload Diagram File
80+
private void PutUploadTest()
81+
{
82+
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
83+
84+
string name = "123.vsd";
85+
bool isOverwrite = true;
86+
string folder = null;
87+
88+
string localFilePath = @"c:\Data\123.vsd";
89+
var response = instance.DiagramFilePutUpload(localFilePath, name, folder, isOverwrite);
90+
}
91+
92+
protected void UpdateDataFile(string filename)
93+
{
94+
StorageApi StorageApi = new StorageApi(clientSecret, clientId);
95+
96+
// Upload document to Cloud Storage
97+
PutCreateRequest request = new PutCreateRequest(filename, File.OpenRead(@"c:\Data\" + filename), null, null);
98+
StorageApi.PutCreate(request);
99+
}
100+
101+
protected Configuration GetConfiguration()
102+
{
103+
if (oauth2 == null)
104+
{
105+
oauth2 = new OAuthApi("https://api.aspose.cloud");
106+
var oauth2response = oauth2.OAuthPost(grantType, clientId, clientSecret);
107+
accesstoken = oauth2response.AccessToken;
108+
refreshtoken = oauth2response.RefreshToken;
109+
}
110+
Dictionary<string, string> headerParameters = new Dictionary<string, string>();
111+
headerParameters.Add("Authorization", "Bearer " + accesstoken);
112+
client = new ApiClient();
113+
config = new Configuration(client, headerParameters);
114+
return config;
115+
}
116+
}
117+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Aspose.Diagram Cloud APIs Examples")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Aspose.Diagram Cloud APIs Examples")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("797b97e2-c308-4416-9a5b-b95e7ac5b9a3")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Aspose.Diagram-Cloud" version="18.10.0" targetFramework="net452" />
4+
<package id="Aspose.Storage-Cloud" version="18.3.0" targetFramework="net452" />
5+
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
6+
<package id="RestSharp" version="105.1.0" targetFramework="net452" />
7+
</packages>

0 commit comments

Comments
 (0)