A simple C# SDK for interacting with the Salesforce Metadata API.
Перейти к файлу
Wade Wegner fe69b8c6b8 Merge branch 'master' of github.com:wadewegner/Salesforce.CSharp.Metadata 2016-06-10 12:08:07 -07:00
src Updated to show unpacking zip 2016-06-10 12:01:13 -07:00
.gitignore Initial commit 2016-06-09 08:34:43 -07:00
LICENSE Initial commit 2016-06-09 08:34:43 -07:00
README.md Added sample for unpacking zip 2016-06-10 12:03:19 -07:00

README.md

Salesforce.CSharp.Metadata

A simple C# SDK for interacting with the Salesforce Metadata API.

Usage

Below you'll find some sample codes for using this library. You can also review the functional tests for cues on usage.

Login

var partnerClient = new PartnerClient();
var loginResult = await partnerClient.Login(Username, Password, ApiVersion);

Describe Metadata

var metadataClient = new MetadataClient(loginResult.MetadataServerUrl, loginResult.SessionId);
var describeMetadataResult = await metadataClient.DescribeMetadata();

List Metadata

var customObjects = await metadataClient.ListMetadata("CustomObject");
var apexClasses = await metadataClient.ListMetadata("ApexClass");
var auraDefinitionBundle = await metadataClient.ListMetadata("AuraDefinitionBundle");

Retrieve Metadata

var retrieveResult = await metadataClient.Retrieve();

Check Retrieve Metadata Status

var checkRetrieveStatusResult = await metadataClient.CheckRetrieveStatus(retrieveResult.Id);

if (checkRetrieveStatusResult.Status == "Succeeded")
{
  var toBytes = Convert.FromBase64String(checkRetrieveStatusResult.ZipFile);
  var fileName = checkRetrieveStatusResult.Id + ".zip";
  var extractPath = checkRetrieveStatusResult.Id;
  
  using (var fs = new FileStream(fileName, FileMode.Create))
  {
    fs.Write(toBytes, 0, toBytes.Length);
  }
  
  ZipFile.ExtractToDirectory(fileName, extractPath);
}