This seems to work:
[assembly: RegisterCustomClass("MyNameSpace.CheckInAllObjects", typeof(CheckInAllObjects))]
namespace MyNameSpace
{
public class CheckInAllObjects : ITask
{
public string EventLogCode = "Check All Objects In";
private string _scheduledTaskSuccess = "Successfully checked all applicable objects in";
/// <summary>
/// Main execution of task
/// </summary>
/// <param name="oTask"></param>
/// <returns></returns>
public string Execute(TaskInfo oTask)
{
var result = "";
try
{
var transformations = TransformationInfoProvider.GetTransformations();
foreach (var transformation in transformations)
{
if (transformation.ObjectSettings.ObjectCheckedOutByUserID != 0)
{
TransformationInfo tempTransformation;
tempTransformation = transformation;
tempTransformation.ObjectSettings.ObjectCheckedOutByUserID = 0;
tempTransformation.ObjectSettings.ObjectCheckedOutVersionHistoryID = 0;
tempTransformation.ObjectSettings.SetValue("IsCheckedOut", false);
tempTransformation.ObjectSettings.SetValue("IsCheckedOutByUserID", 0);
TransformationInfoProvider.SetTransformation(tempTransformation);
}
}
var templates = PageTemplateInfoProvider.GetTemplates();
foreach (var template in templates)
{
if (template.ObjectSettings.ObjectCheckedOutByUserID != 0)
{
PageTemplateInfo temptemp;
temptemp = template;
temptemp.ObjectSettings.ObjectCheckedOutByUserID = 0;
temptemp.ObjectSettings.ObjectCheckedOutVersionHistoryID = 0;
temptemp.ObjectSettings.SetValue("IsCheckedOut", false);
temptemp.ObjectSettings.SetValue("IsCheckedOutByUserID", 0);
PageTemplateInfoProvider.SetPageTemplateInfo(temptemp);
}
}
result = _scheduledTaskSuccess;
}
catch (Exception ex)
{
result = ex.Message;
}
// then restart the application so the objects show checked in status in admin cp
CMS.Helpers.SystemHelper.RestartApplication();
return result;
}
}
}
Add that into a cs code file then create a new scheduled task and select it as an assembly