The ArchiveAPI can be used to add archiving rules to a profile, as seen in the examples below.
using Bluethread.SharePoint.StoragePoint;
using Bluethread.SharePoint.StoragePoint.ArchiveAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ProfileAPI profile = new ProfileAPI("CDB-1111"); //Creates a APIProfile based on existent profile name.
profile.ArchivingSettings.Enabled = true; //To enable the Archiving
MetadataRuleTest(profile); //Calls to MetadataRules
AgeRuleTest(profile); //Calls to AgeRuleTest
profile.Save(); //Needed to save changes to the profile
//Creates AgeRuleTest with only one condition
private static void AgeRuleTest(ProfileAPI profile)
{
AgeRuleAPI ageRule = new AgeRuleAPI(profile, "EP1", "cdb:74d30558-d550-4678-8f5c-b75b97855e0f/s:50777858-f8e3-417a-8ca6-973ac0a47209/w:728c538c-8275-43c0-a6c6-5067c6279b7a");
AgeRuleFormatAPI ageRuleInput = new AgeRuleFormatAPI();
ageRuleInput.DateProperty = "Created";
ageRuleInput.Duration = 5;
ageRuleInput.Interval = "Day";
ageRuleInput.DestinationEndpointName = "EP2";
ageRuleInput.Property = "Name";
ageRuleInput.Operator = "Contains";
ageRuleInput.Value = "metalogix";
bool isValidAge = ageRule.Validate(ageRuleInput.GetArchiveRule());
ageRule.Save();
}
//Creates MetadataRuleTest with only one condition
private static void MetadataRuleTest(ProfileAPI profile)
{
MetadataRuleAPI metadata = new MetadataRuleAPI(profile, "EP2", "cdb:74d30558-d550-4678-8f5c-b75b97855e0f/s:50777858-f8e3-417a-8ca6-973ac0a47209/w:728c538c-8275-43c0-a6c6-5067c6279b7a");
MetadataRuleFormatAPI metadataInput = new MetadataRuleFormatAPI();
metadataInput.Property = "Name";
metadataInput.Operator = "Begins";
metadataInput.Value = "metalogix";
metadataInput.DestinationEndpointName = "EP1";
bool isValid = metadata.Validate(metadataInput.GetArchiveRule());
metadata.Save();
}
}
}
Example Two
using Bluethread.SharePoint.StoragePoint;
using Bluethread.SharePoint.StoragePoint.ArchiveAPI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StoragePointAPI
{
class ArchiveExamples
{
public static void EnableArchiving()
{
// enable the Archive in the profile
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.ArchivingSettings.Enabled = true;
profileInstance.Save();
}
public static void CreateAgeRulewithMetadata()
{
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
AgeRuleFormatAPI ageRuleinput = new AgeRuleFormatAPI();
ageRuleinput.DateProperty = "created"; // it can be : created , modified
ageRuleinput.DestinationEndpointName = "EP1"; // endpoint Name
ageRuleinput.Duration = 15; // duration of the age rule
ageRuleinput.Interval = "day"; // it can be : day,month, year
// metadata section
ageRuleinput.Property = "Name"; //metadata property name
ageRuleinput.Operator = "=" ; // operator it depends of the Metadata Name
ageRuleinput.Value = "Document"; //metadata value
AgeRuleAPI ageRuleAPI = new AgeRuleAPI(profileInstance, "EP1", "wa:ec8d5b10-ccc6-4fea-9fad-7e42bd362ab1");
ageRuleAPI.Validate(ageRuleinput.GetArchiveRule()); // this validate the rule and check it if the any other rule exists for the same scope
ageRuleAPI.Save(); // it save the rule
}
public static void CreateAgeRuleWithoutMetadata()
{
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
AgeRuleFormatAPI ageRuleinput = new AgeRuleFormatAPI();
ageRuleinput.DateProperty = "modified"; // it can be : created , modified
ageRuleinput.DestinationEndpointName = "EP1"; // endpoint Name destination
ageRuleinput.Duration = 2; // duration of the age rule
ageRuleinput.Interval = "month"; // it can be : day,month, year
// metadata section
ageRuleinput.Property = "None"; //metadata property name
ageRuleinput.Operator = "None"; // operator it depends of the Metadata Name
ageRuleinput.Value = "None"; //metadata value
AgeRuleAPI metadataRule = new AgeRuleAPI(profileInstance, "EP1", "wa:ec8d5b10-ccc6-4fea-9fad-7e42bd362ab1/cdb:b3589d08-70da-4081-a31c-ab52552df86f");
metadataRule.Validate(ageRuleinput.GetArchiveRule()); // this validate the rule and check it if the any other rule exists for the same scope
metadataRule.Save(); // it save the rule
}
public static void CreateAgeRuleWithManyConditions()
{
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
AgeRuleFormatAPI ageRuleinput = new AgeRuleFormatAPI();
ageRuleinput.DateProperty = "modified"; // it can be : created , modified
ageRuleinput.DestinationEndpointName = "EP1"; // endpoint Name destination
ageRuleinput.Duration = 2; // duration of the age rule
ageRuleinput.Interval = "month"; // it can be : day,month, year
// metadata section
ageRuleinput.Property = "None"; //metadata property name
ageRuleinput.Operator = "None"; // operator it depends of the Metadata Name
ageRuleinput.Value = "None"; //metadata value
AgeRuleFormatAPI ageRuleinputWithMetadata = new AgeRuleFormatAPI();
ageRuleinputWithMetadata.DateProperty = "modified"; // it can be : created , modified
ageRuleinputWithMetadata.DestinationEndpointName = "EP3"; // endpoint Name destination
ageRuleinputWithMetadata.Duration = 2; // duration of the age rule
ageRuleinputWithMetadata.Interval = "month"; // it can be : day,month, year
// metadata section
ageRuleinputWithMetadata.Property = "Name"; //metadata property name
ageRuleinputWithMetadata.Operator = "begins"; // operator it depends of the Metadata Name
ageRuleinputWithMetadata.Value = "important"; //metadata value
AgeRuleAPI metadataRule = new AgeRuleAPI(profileInstance, "EP1,EP3", "wa:ec8d5b10-ccc6-4fea-9fad-7e42bd362ab1/cdb:b3589d08-70da-4081-a31c-ab52552df86f");
metadataRule.Validate(ageRuleinput.GetArchiveRule() + "?" + ageRuleinputWithMetadata.GetArchiveRule()); // this validate the rule and check it if the any other rule exists for the same scope
metadataRule.Save(); // it saves the rule
}
public static void CreateMetadataRule()
{
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
MetadataRuleFormatAPI metadataFormatAPI = new MetadataRuleFormatAPI();
metadataFormatAPI.DestinationEndpointName = "EP1";
metadataFormatAPI.Operator = "=";
metadataFormatAPI.Property = "Modified";
metadataFormatAPI.Value = "12/10/2015";
MetadataRuleAPI metadataInstance = new MetadataRuleAPI(profileInstance, "EP1", "wa:ec8d5b10-ccc6-4fea-9fad-7e42bd362ab1");
metadataInstance.Validate(metadataFormatAPI.GetArchiveRule());
metadataInstance.Save();
}
public static void CreateMetadataRuleWithManyConditions()
{
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
MetadataRuleFormatAPI metadataFirstAPI = new MetadataRuleFormatAPI();
metadataFirstAPI.DestinationEndpointName = "EP1";
metadataFirstAPI.Operator = "=";
metadataFirstAPI.Property = "Select";
metadataFirstAPI.Value = "James";
MetadataRuleFormatAPI metadataSecondtAPI = new MetadataRuleFormatAPI();
metadataSecondtAPI.DestinationEndpointName = "EP3";
metadataSecondtAPI.Operator = "=";
metadataSecondtAPI.Property = "Title";
metadataSecondtAPI.Value = "head first";
MetadataRuleAPI metadataInstance = new MetadataRuleAPI(profileInstance, "EP1,EP3", "wa:ec8d5b10-ccc6-4fea-9fad-7e42bd362ab1/cdb:b3589d08-70da-4081-a31c-ab52552df86f");
metadataInstance.Validate(metadataFirstAPI.GetArchiveRule() + '?' + metadataSecondtAPI.GetArchiveRule());
metadataInstance.Save();
}
}
}
The TimerJobAPI object allows for the configuration of timer jobs and for scheduling and running the jobs. It also has commands for monitoring timer jobs and getting statuses.
The TimerJobAPI classes can be used to configure StoragePoint timer jobs.
Methods
Method Name |
Description |
public static ContentMigratorJobSettings GetInstance(string server) |
|
public void RunJob(string server, string webRole, int NumberOfThreads, bool emailDefault, string NotificationEmailOther, string includeLargeFiles, string workers) |
Used for running the timer job. |
public void SetThreads(int numberOfThreads) |
Set the number of threads for a job. |
public void SetIncludeLargeFiles(string includeLargeFilesOption) |
Set whether or not the timer job should include the processing of Large File Uploads. |
public void Suspend() |
Suspend a currently running job. |
public void Abort() |
Abort a currently running job. |
public void Resume() |
Resume a suspended job. |
Properties
Use these to pull current information about configured jobs. TimeJobStatusAPI
Property name |
public DateTime Started { get; } |
public DateTime Stopped { get; } |
public DateTime HeartBeat { get; } |
public int ThreadCount { get; } |
public string Status { get; } |
public string LastErr { get; } |
Below is a listing of the profile timer jobs set up with variations on schedule and options.
using Bluethread.SharePoint.StoragePoint;
using Microsoft.SharePoint.Administration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StoragePointAPI
{
public class TimerJobExamples
{
public static void BLOBHealthAnalyzerExample()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateBLOBRefScanJob(oneTimeSchedule, true, "5", true, "othermail@gmail.com", false);
}
public static void BLOBHealthAnalyzerWithServerExample()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateBLOBRefScanJob(oneTimeSchedule, true, "5", true, "othermail@gmail.com", false, SPServer.Local);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateBLOBRefScanJob(dailySchedule, true, "5", true, "othermail@gmail.com", false);
}
public static void UnusedBLOBCleanupExample()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateUnusedBlobCleanupJob(oneTimeSchedule, true, "othermail@gmail.com", true, SPServer.Local, false);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateUnusedBlobCleanupJob(dailySchedule, true, "othermail@gmail.com", true, SPServer.Local, false);
}
public static void BLOBExternalizationExample()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateBLOBExternalizationJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateBLOBExternalizationJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void BLOBRecallJobExample()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateBLOBRecallJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateBLOBRecallJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void BLOBMigrateJobExample()
{
// get the endpoint source and endpoint target'
EndpointAPI source = new EndpointAPI("EP1");
EndpointAPI target = new EndpointAPI("EP3");
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateBLOBMigrateJob(oneTimeSchedule, "5", source, target, true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateBLOBMigrateJob(oneTimeSchedule, "5", source, target, true, "othermail@gmail.com", true, "s:4dd13983-aac1-4a98-8e83-a0abf61d11e1", "include");
}
public static void ArchivingAgingJob()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateAgingJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateAgingJob(dailySchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void ArchivingMetadataJob()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateMetadataJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateMetadataJob(dailySchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void ArchivingVersioningJob()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateVersionsJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateVersionsJob(dailySchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void BLOBMigrateRecordsJob()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateMigrateRecordsJob(oneTimeSchedule, true, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateMigrateRecordsJob(dailySchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void BLOBMigrateHoldJob()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateMigrateHoldsJob(oneTimeSchedule, true, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateMigrateHoldsJob(dailySchedule, true, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
public static void BLOBBackupSyncJob()
{
//create one-time scheduled job to run immediately.
Microsoft.SharePoint.SPOneTimeSchedule oneTimeSchedule = new Microsoft.SharePoint.SPOneTimeSchedule(DateTime.Now);
ProfileAPI profileInstance = new ProfileAPI("SharePoint-15548");
profileInstance.CreateBackupSyncJob(oneTimeSchedule, "5", true, "othermail@gmail.com", true);
// create daily scheduled job definition
Microsoft.SharePoint.SPDailySchedule dailySchedule = new Microsoft.SharePoint.SPDailySchedule();
dailySchedule.BeginHour = 13;
dailySchedule.EndHour = 18;
dailySchedule.BeginMinute = 10;
dailySchedule.EndMinute = 50;
profileInstance.CreateBackupSyncJob(dailySchedule, "5", true, "othermail@gmail.com", true, SPServer.Local);
}
}
}
© ALL RIGHTS RESERVED. 이용 약관 개인정보 보호정책 Cookie Preference Center