Scheduled Backup Settings

Hello,

I was working on some SDK documentation when I realized that programmatically setting the schedule for the backup of project server entities would be difficult without reading the source code. So I have created a simple example that duplicates the PWA Schedule Backup UI:

image

The example that I have written is a simple Win32 application that duplicates the functionality (minus the project retention policy):

image 

In order to set the schedule, you need to work with the Archive Web Service. Like other PSI Web Services, it follows the CRUD (Create, Read, Update and Delete) model. It is very simple to read and update the schedule; you just need to call ReadArchiveSchedule() to get the current schedule and UpdateArchiveSchedule(...) with and updated data set to update the schedule. The part that I needed to read the source code to figure out, was how to set entities to be scheduled to be backed up or not and how to set the time for when the backup should occur.

Each entity has a data column in the Archive Schedule data table that stores the scheduled time in ticks:

  • WADMIN_CATEGORY_GROUP -
  • WADMIN_ENTERPRISE_CUSTOM_FIELDS
  • WADMIN_ENTERPRISE_GLOBAL
  • WADMIN_ENTERPRISE_RESOURCE_POOL
  • WADMIN_PROJECTS
  • WADMIN_SYSTEM_SETTINGS
  • WADMIN_VIEW_DEFINITIONS

To schedule the entity for backup, you need to calculate the number of ticks. To do this, you are going to want to to add the hours and minutes to the today's date and then convert that to ticks. I did that with the following line of code:

 dT = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, hours, minutes, 0);
                   
row[itemDBCols[i]] = dT.Ticks;

To set it to never backup the entity, simply set the number of ticks to 0.

Once you have the ticks calculated, just set the appropriate data column in the Archive Schedule data table and return the data set to the server using the UpdateArchiveSchedule(...) method.

See the full source code attached,

Chris Boyd

BackupSettings.zip