I am having a problem logging deletions for pages when a structure group is deleted. The structure group deletion is logged but the pages in the structure group are not logged when the structure group is deleted. I am trying to do this by creating two events; the initiated and the committed but having problems. I am just not sure what to put in the initiated section and how to get the items to be deleted to the committed section Here is my code.
// We are getting all the objects deleted prior to it being deleted
private void StructureGroupPreDeleteAction(StructureGroup subject, DeleteOrganizationalItemEventArgs args, EventPhases phase)
{
StringBuilder deletesg = new StringBuilder();
foreach (var item in args.ItemsToDelete)
{
}
}
// Grab the objects the were collected before deletions and send them to the log.
private void StructureGroupDeleteAction(StructureGroup subject, DeleteOrganizationalItemEventArgs args, EventPhases phase)
{
string logDate = DateTime.Now.ToString("T");
string fileName = String.Format(@"{0}\{1}.{2}.{3}", logFilePath, deleteLogName.ToLower().Replace(" ", "_"), DateTime.Now.ToString("yyyy-MM-dd"), "txt");
TextWriter tw = new StreamWriter(fileName, true);
tw.WriteLine(logDate + "itemsToDelete" );
tw.Close();
}