private static Dictionary <string, CleanupTask> LoadTasks() { lock (s_lock) { string[] cleanupUsers = Settings.Store.CleanupUsers; Dictionary <string, CleanupTask> tasks = new Dictionary <string, CleanupTask>(); foreach (string item in cleanupUsers) { try { CleanupTask task = CleanupTask.FromRegString(item); tasks.Add(task.UserName, task); } catch (Exception e) { m_logger.ErrorFormat("Unable to parse registry entry! {0}", e); throw; } } return(tasks); } }
public static CleanupTask FromRegString(string regString) { string[] parts = regString.Split(new string[] { DELIMITER }, StringSplitOptions.RemoveEmptyEntries); string uname = parts[0]; DateTime timestamp = DateTime.FromBinary(long.Parse(parts[1])); CleanupAction action; // This check is for backward compatibility. If there happens to be stuff left over // from older versions of pGina, there will not be a third part in the string, in // which case we choose based on the settings; if (parts.Length > 2) { action = (CleanupAction)Enum.Parse(typeof(CleanupAction), parts[2]); } else { bool deleteProfiles = Settings.Store.RemoveProfiles; if (deleteProfiles) { action = CleanupAction.DELETE_PROFILE; } else { action = CleanupAction.SCRAMBLE_PASSWORD; } } CleanupTask task = new CleanupTask(uname, action); task.m_time = timestamp; return(task); }
public static CleanupTask FromRegString(string regString) { string[] parts = regString.Split(new string[] { DELIMITER }, StringSplitOptions.RemoveEmptyEntries); string uname = parts[0]; DateTime timestamp = DateTime.FromBinary(long.Parse(parts[1])); CleanupAction action; // This check is for backward compatibility. If there happens to be stuff left over // from older versions of pGina, there will not be a third part in the string, in // which case we choose based on the settings; if (parts.Length > 2) { action = (CleanupAction)Enum.Parse(typeof(CleanupAction), parts[2]); } else { bool deleteProfiles = Settings.Store.RemoveProfiles; if (deleteProfiles) action = CleanupAction.DELETE_PROFILE; else action = CleanupAction.SCRAMBLE_PASSWORD; } CleanupTask task = new CleanupTask(uname, action); task.m_time = timestamp; return task; }
public static void AddTask(CleanupTask newTask) { lock (s_lock) { Dictionary <string, CleanupTask> tasks = CleanupTasks.LoadTasks(); if (tasks.ContainsKey(newTask.UserName)) { // We already have a task for this user... get it. CleanupTask currentTask = tasks[newTask.UserName]; // We only need to change the action if it is not "DELETE_PROFILE" because if // it is "DELETE_PROFILE" then we want to do both actions (delete and scramble), // in which case it is pointless to do the scramble. if (currentTask.Action != CleanupAction.DELETE_PROFILE) { // Current task action must be SCRAMBLE, so we only change if the new // task is not SCRAMBLE (i.e. delete). if (currentTask.Action != newTask.Action) { tasks[newTask.UserName] = newTask; } } } else { tasks.Add(newTask.UserName, newTask); } CleanupTasks.SaveTasks(tasks); } }
public static void AddTask(CleanupTask newTask) { lock (s_lock) { Dictionary<string, CleanupTask> tasks = CleanupTasks.LoadTasks(); if (tasks.ContainsKey(newTask.UserName)) { // We already have a task for this user... get it. CleanupTask currentTask = tasks[newTask.UserName]; // We only need to change the action if it is not "DELETE_PROFILE" because if // it is "DELETE_PROFILE" then we want to do both actions (delete and scramble), // in which case it is pointless to do the scramble. if (currentTask.Action != CleanupAction.DELETE_PROFILE) { // Current task action must be SCRAMBLE, so we only change if the new // task is not SCRAMBLE (i.e. delete). if (currentTask.Action != newTask.Action) { tasks[newTask.UserName] = newTask; } } } else { tasks.Add(newTask.UserName, newTask); } CleanupTasks.SaveTasks(tasks); } }