/// <summary> /// Clears all settings, and makes the setting object reflect the schedule /// </summary> /// <param name="schedule">The schedule to reflect</param> public void ReflectSchedule(Datamodel.Schedule schedule) { MainAction action = this.PrimayAction; System.Data.LightDatamodel.IDataFetcherWithRelations connection = this.DataConnection; m_settings.Clear(); this.ScheduleID = schedule.ID; this.ScheduleName = schedule.Name; this.SchedulePath = schedule.Path; this.SourcePath = schedule.Task.SourcePath; this.EncodedFilterXml = schedule.Task.FilterXml; this.BackupPassword = schedule.Task.Encryptionkey; this.Backend = schedule.Task.Service; this.BackendSettings = new Dictionary <string, string>(schedule.Task.BackendSettingsLookup); this.BackupTimeOffset = schedule.When; this.RepeatInterval = schedule.Repeat; this.AllowedWeekdays = schedule.AllowedWeekdays; this.FullBackupInterval = schedule.Task.FullAfter; this.MaxFullBackups = (int)schedule.Task.KeepFull; this.BackupExpireInterval = schedule.Task.KeepTime; this.UploadSpeedLimit = schedule.Task.Extensions.UploadBandwidth; this.DownloadSpeedLimit = schedule.Task.Extensions.DownloadBandwidth; this.BackupSizeLimit = schedule.Task.Extensions.MaxUploadSize; this.VolumeSize = schedule.Task.Extensions.VolumeSize; this.ThreadPriority = schedule.Task.Extensions.ThreadPriority; this.AsyncTransfer = schedule.Task.Extensions.AsyncTransfer; this.EncryptionModule = schedule.Task.EncryptionModule; this.IncludeSetup = schedule.Task.IncludeSetup; this.IgnoreFileTimestamps = schedule.Task.Extensions.IgnoreTimestamps; this.FileSizeLimit = schedule.Task.Extensions.FileSizeLimit; this.DisableAESFallbackEncryption = schedule.Task.Extensions.DisableAESFallbackDecryption; //Handle the "Select Files" portion this.SelectFilesUI.Version = schedule.Task.Extensions.SelectFiles_Version; this.SelectFilesUI.UseSimpleMode = schedule.Task.Extensions.SelectFiles_UseSimpleMode; this.SelectFilesUI.IncludeDocuments = schedule.Task.Extensions.SelectFiles_IncludeDocuments; this.SelectFilesUI.IncludeDesktop = schedule.Task.Extensions.SelectFiles_IncludeDesktop; this.SelectFilesUI.IncludeMusic = schedule.Task.Extensions.SelectFiles_IncludeMusic; this.SelectFilesUI.IncludeImages = schedule.Task.Extensions.SelectFiles_IncludeImages; this.SelectFilesUI.IncludeSettings = schedule.Task.Extensions.SelectFiles_IncludeAppData; this.SelectWhenUI.HasWarnedNoSchedule = schedule.Task.Extensions.SelectWhen_WarnedNoSchedule; this.SelectWhenUI.HasWarnedTooManyIncremental = schedule.Task.Extensions.SelectWhen_WarnedTooManyIncrementals; this.SelectWhenUI.HasWarnedNoIncrementals = schedule.Task.Extensions.SelectWhen_WarnedNoIncrementals; this.PasswordSettingsUI.WarnedNoPassword = schedule.Task.Extensions.PasswordSettings_WarnedNoPassword; this.CleanupSettingsUI.HasWarnedClean = schedule.Task.Extensions.CleanupSettings_WarnedNoCleanup; this.Overrides = new Dictionary <string, string>(schedule.Task.TaskOverridesLookup); this.EncryptionSettings = new Dictionary <string, string>(schedule.Task.EncryptionSettingsLookup); this.CompressionSettings = new Dictionary <string, string>(schedule.Task.CompressionSettingsLookup); this.ApplicationSettings = ApplicationSetup.GetApplicationSettings(schedule.DataParent); this.PrimayAction = action; this.DataConnection = connection; }
/// <summary> /// The purpose of this function is to set the default /// settings on the new backup. /// </summary> public void SetupDefaults() { m_settings.Clear(); ApplicationSettings appset = new ApplicationSettings(Program.DataConnection); if (appset.UseCommonPassword) { this.BackupPassword = appset.CommonPassword; this.EncryptionModule = appset.CommonPasswordEncryptionModule; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program), "Backup defaults.xml")); System.Xml.XmlNode root = doc.SelectSingleNode("settings"); List <System.Xml.XmlNode> nodes = new List <System.Xml.XmlNode>(); if (root != null) { foreach (System.Xml.XmlNode n in root.ChildNodes) { nodes.Add(n); } } //Load user supplied settings, if any string filename = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "Backup defaults.xml"); if (System.IO.File.Exists(filename)) { doc.Load(filename); root = doc.SelectSingleNode("settings"); if (root != null) { foreach (System.Xml.XmlNode n in root.ChildNodes) { nodes.Add(n); } } } foreach (System.Xml.XmlNode n in nodes) { if (n.NodeType == System.Xml.XmlNodeType.Element) { System.Reflection.PropertyInfo pi = this.GetType().GetProperty(n.Name); if (pi != null && pi.CanWrite) { if (pi.PropertyType == typeof(DateTime)) { pi.SetValue(this, Library.Utility.Timeparser.ParseTimeInterval(n.InnerText, DateTime.Now.Date), null); } else { pi.SetValue(this, Convert.ChangeType(n.InnerText, pi.PropertyType), null); } } } } this.ApplicationSettings = ApplicationSetup.GetApplicationSettings(Program.DataConnection); }