Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active January 23, 2019 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/7dc5932f6637bce774d0b90a9cb10365 to your computer and use it in GitHub Desktop.
Save aspose-cloud/7dc5932f6637bce774d0b90a9cb10365 to your computer and use it in GitHub Desktop.
The GIST contains .NET Examples of Aspose.Diagram REST APIs.
The GIST contains .NET Examples of Aspose.Diagram REST APIs.
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-dotnet
using Aspose.Diagram.Cloud.SDK.Api;
using Aspose.Diagram.Cloud.SDK.Client;
using Aspose.Diagram.Cloud.SDK.Model;
using Aspose.Storage.Cloud.Sdk.Api;
using Aspose.Storage.Cloud.Sdk.Model.Requests;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aspose.Diagram_Cloud_APIs_Examples
{
class DiagramExamples
{
protected ApiClient client;
protected Configuration config;
protected static OAuthApi oauth2 = null;
protected string grantType = "client_credentials";
protected string clientId = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected string clientSecret = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected static string accesstoken;
protected string refreshtoken;
static void Main(string[] args)
{
DiagramExamples diagramExamples = new DiagramExamples();
// Get Diagram Document Information
diagramExamples.GetDiagram();
}
// Get Diagram Document Information
private void GetDiagram()
{
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
string name = "file_get_1.vdx";
string folder = null;
UpdateDataFile(name);
var response = instance.DiagramFileGetDiagram(name, "pdf", folder);
}
private void UpdateDataFile(string filename)
{
StorageApi StorageApi = new StorageApi(clientSecret, clientId);
// Upload document to Cloud Storage
PutCreateRequest request = new PutCreateRequest(filename, File.OpenRead(@"c:\Data\" + filename), null, null);
StorageApi.PutCreate(request);
}
private Configuration GetConfiguration()
{
if (oauth2 == null)
{
oauth2 = new OAuthApi("https://api.aspose.cloud");
var oauth2response = oauth2.OAuthPost(grantType, clientId, clientSecret);
accesstoken = oauth2response.AccessToken;
refreshtoken = oauth2response.RefreshToken;
}
Dictionary<string, string> headerParameters = new Dictionary<string, string>();
headerParameters.Add("Authorization", "Bearer " + accesstoken);
client = new ApiClient();
config = new Configuration(client, headerParameters);
return config;
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-dotnet
using Aspose.Diagram.Cloud.SDK.Api;
using Aspose.Diagram.Cloud.SDK.Client;
using Aspose.Diagram.Cloud.SDK.Model;
using Aspose.Storage.Cloud.Sdk.Api;
using Aspose.Storage.Cloud.Sdk.Model.Requests;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aspose.Diagram_Cloud_APIs_Examples
{
class DiagramExamples
{
protected ApiClient client;
protected Configuration config;
protected static OAuthApi oauth2 = null;
protected string grantType = "client_credentials";
protected string clientId = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected string clientSecret = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected static string accesstoken;
protected string refreshtoken;
static void Main(string[] args)
{
DiagramExamples diagramExamples = new DiagramExamples();
// Convert Diagram File to Another Format
diagramExamples.PostSaveAs();
}
// Convert Diagram File to Another Format
private void PostSaveAs()
{
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
string name = "file_get_1.vdx";
bool isOverwrite = true;
string folder = null;
FileFormatRequest format = new FileFormatRequest() { Format = "pdf" };
string newfilename = "file_saveas_1.pdf";
UpdateDataFile(name);
var response = instance.DiagramFilePostSaveAs(name, format, newfilename, folder, isOverwrite);
}
private void UpdateDataFile(string filename)
{
StorageApi StorageApi = new StorageApi(clientSecret, clientId);
// Upload document to Cloud Storage
PutCreateRequest request = new PutCreateRequest(filename, File.OpenRead(@"c:\Data\" + filename), null, null);
StorageApi.PutCreate(request);
}
private Configuration GetConfiguration()
{
if (oauth2 == null)
{
oauth2 = new OAuthApi("https://api.aspose.cloud");
var oauth2response = oauth2.OAuthPost(grantType, clientId, clientSecret);
accesstoken = oauth2response.AccessToken;
refreshtoken = oauth2response.RefreshToken;
}
Dictionary<string, string> headerParameters = new Dictionary<string, string>();
headerParameters.Add("Authorization", "Bearer " + accesstoken);
client = new ApiClient();
config = new Configuration(client, headerParameters);
return config;
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-dotnet
using Aspose.Diagram.Cloud.SDK.Api;
using Aspose.Diagram.Cloud.SDK.Client;
using Aspose.Diagram.Cloud.SDK.Model;
using Aspose.Storage.Cloud.Sdk.Api;
using Aspose.Storage.Cloud.Sdk.Model.Requests;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aspose.Diagram_Cloud_APIs_Examples
{
class DiagramExamples
{
protected ApiClient client;
protected Configuration config;
protected static OAuthApi oauth2 = null;
protected string grantType = "client_credentials";
protected string clientId = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected string clientSecret = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected static string accesstoken;
protected string refreshtoken;
static void Main(string[] args)
{
DiagramExamples diagramExamples = new DiagramExamples();
// Create Diagram File
diagramExamples.PutCreate();
}
// Create Diagram File
private void PutCreate()
{
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
string name = "file_get_1.vdx";
bool isOverwrite = true;
string folder = null;
var response = instance.DiagramFilePutCreate(name, folder, isOverwrite);
}
private Configuration GetConfiguration()
{
if (oauth2 == null)
{
oauth2 = new OAuthApi("https://api.aspose.cloud");
var oauth2response = oauth2.OAuthPost(grantType, clientId, clientSecret);
accesstoken = oauth2response.AccessToken;
refreshtoken = oauth2response.RefreshToken;
}
Dictionary<string, string> headerParameters = new Dictionary<string, string>();
headerParameters.Add("Authorization", "Bearer " + accesstoken);
client = new ApiClient();
config = new Configuration(client, headerParameters);
return config;
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-diagram-cloud/aspose-diagram-cloud-dotnet
using Aspose.Diagram.Cloud.SDK.Api;
using Aspose.Diagram.Cloud.SDK.Client;
using Aspose.Diagram.Cloud.SDK.Model;
using Aspose.Storage.Cloud.Sdk.Api;
using Aspose.Storage.Cloud.Sdk.Model.Requests;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aspose.Diagram_Cloud_APIs_Examples
{
class DiagramExamples
{
protected ApiClient client;
protected Configuration config;
protected static OAuthApi oauth2 = null;
protected string grantType = "client_credentials";
protected string clientId = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected string clientSecret = ""; // Get App Key and App SID from https://dashboard.aspose.cloud/
protected static string accesstoken;
protected string refreshtoken;
static void Main(string[] args)
{
DiagramExamples diagramExamples = new DiagramExamples();
// Upload Diagram File
diagramExamples.PutUpload();
}
// Upload Diagram File
private void PutUpload()
{
DiagramFileApi instance = new DiagramFileApi(GetConfiguration());
string name = "123.vsd";
bool isOverwrite = true;
string folder = null;
string localFilePath = @"c:\Data\123.vsd";
var response = instance.DiagramFilePutUpload(localFilePath, name, folder, isOverwrite);
}
private Configuration GetConfiguration()
{
if (oauth2 == null)
{
oauth2 = new OAuthApi("https://api.aspose.cloud");
var oauth2response = oauth2.OAuthPost(grantType, clientId, clientSecret);
accesstoken = oauth2response.AccessToken;
refreshtoken = oauth2response.RefreshToken;
}
Dictionary<string, string> headerParameters = new Dictionary<string, string>();
headerParameters.Add("Authorization", "Bearer " + accesstoken);
client = new ApiClient();
config = new Configuration(client, headerParameters);
return config;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment