示例#1
0
        public static void LoadBackupStatus(MyBackup backup)
        {
            var MyIni      = new IniFile("BackupStatus.ini");
            var StrIndexes = MyIni.ReadString("Configuration", "Indexes#" + backup.MyIndex, "");

            int[] Indexes = StrIndexes.Split(',').Select(x => int.TryParse(x, out var i) ? i : 0).ToArray();

            foreach (var i in Indexes)
            {
                string Section = "Status#" + backup.MyIndex + "#" + i.ToString();
                int    MyIndex = MyIni.ReadInt32(Section, "MyIndex", 0);
                if (MyIndex > 0)
                {
                    var state = new BackupState()
                    {
                        StateIndex            = MyIndex,
                        backup                = backup,
                        FullPath              = MyIni.ReadString(Section, "FullPath"),
                        BackupDateTime        = MyIni.ReadInt64(Section, "BackupDateTime"),
                        DefaultBackupDateTime = MyIni.ReadInt64(Section, "DefaultBackupDateTime"),
                        Warning               = MyIni.ReadBoolean(Section, "Warning"),
                        WarningMessage        = MyIni.ReadString(Section, "WarningMessage"),
                        FullWarning           = MyIni.ReadString(Section, "FullWarning"),
                        Read = MyIni.ReadBoolean(Section, "Read"),
                    };

                    backup.BackupStatus.Add(state);
                }
            }
        }
示例#2
0
        public static void SaveBackup(MyBackup backup)
        {
            var MyIni   = new IniFile("Configuration.ini");
            var Section = "Configuration#";

            if (backup.MyIndex == 0)
            {
                var MaxIndex = MyIni.ReadInt32("Configuration", "MaxIndex", 0) + 1;
                backup.MyIndex = MaxIndex;
                Section       += MaxIndex.ToString();

                MyIni.Write("Configuration", "MaxIndex", MaxIndex);
            }
            else
            {
                Section += backup.MyIndex.ToString();
            }


            MyIni.Write(Section, "MyIndex", backup.MyIndex);
            MyIni.Write(Section, "IsEnabled", backup.IsEnabled);
            MyIni.Write(Section, "BackupName", backup.BackupName);
            MyIni.Write(Section, "Host", backup.Host);
            MyIni.Write(Section, "Database", backup.Database);
            MyIni.Write(Section, "Authentication", backup.Authentication);
            MyIni.Write(Section, "Username", backup.Username);
            MyIni.Write(Section, "Password", backup.Password);
            MyIni.Write(Section, "SavePassword", backup.SavePassword);
            MyIni.Write(Section, "BackupPath", backup.BackupPath);
            MyIni.Write(Section, "Repeat", backup.Repeat);
            MyIni.Write(Section, "Time", backup.Time);
            MyIni.Write(Section, "Sat", backup.Sat);
            MyIni.Write(Section, "Sun", backup.Sun);
            MyIni.Write(Section, "Mon", backup.Mon);
            MyIni.Write(Section, "Tue", backup.Tue);
            MyIni.Write(Section, "Wed", backup.Wed);
            MyIni.Write(Section, "Thu", backup.Thu);
            MyIni.Write(Section, "Fri", backup.Fri);
            MyIni.Write(Section, "Specific", backup.Specific);
            MyIni.Write(Section, "Every", backup.Every);
            MyIni.Write(Section, "SpecificType", (int)backup.SpecificType);
            MyIni.Write(Section, "LastBackup", backup.LastBackup);

            if (!MyBackups.Contains(backup))
            {
                MyBackups.Add(backup);
            }
        }
示例#3
0
        public static void LoadBackups(MainMenu mainMenu)
        {
            var MyIni    = new IniFile("Configuration.ini");
            var MaxIndex = MyIni.ReadInt32("Configuration", "MaxIndex", 0);

            for (int i = 0; i < MaxIndex; i++)
            {
                var Section = "Configuration#" + (i + 1).ToString();
                var MyIndex = MyIni.ReadInt32(Section, "MyIndex", 0);
                if (MyIndex > 0)
                {
                    var backup = new MyBackup()
                    {
                        MyIndex        = MyIndex,
                        IsEnabled      = MyIni.ReadBoolean(Section, "IsEnabled"),
                        BackupName     = MyIni.ReadString(Section, "BackupName"),
                        Host           = MyIni.ReadString(Section, "Host"),
                        Database       = MyIni.ReadString(Section, "Database"),
                        Authentication = MyIni.ReadBoolean(Section, "Authentication"),
                        Username       = MyIni.ReadString(Section, "Username"),
                        Password       = MyIni.ReadString(Section, "Password"),
                        SavePassword   = MyIni.ReadBoolean(Section, "SavePassword"),
                        BackupPath     = MyIni.ReadString(Section, "BackupPath"),
                        Repeat         = MyIni.ReadBoolean(Section, "Repeat"),
                        Time           = MyIni.ReadInt64(Section, "Time"),
                        Sat            = MyIni.ReadBoolean(Section, "Sat"),
                        Sun            = MyIni.ReadBoolean(Section, "Sun"),
                        Mon            = MyIni.ReadBoolean(Section, "Mon"),
                        Tue            = MyIni.ReadBoolean(Section, "Tue"),
                        Wed            = MyIni.ReadBoolean(Section, "Wed"),
                        Thu            = MyIni.ReadBoolean(Section, "Thu"),
                        Fri            = MyIni.ReadBoolean(Section, "Fri"),
                        Specific       = MyIni.ReadBoolean(Section, "Specific"),
                        Every          = MyIni.ReadDecimal(Section, "Every"),
                        SpecificType   = (SpecificTypes)MyIni.ReadInt32(Section, "SpecificType"),
                        LastBackup     = MyIni.ReadInt64(Section, "LastBackup"),
                    };

                    MyBackups.Add(backup);
                    LoadBackupStatus(backup);
                }
            }

            mainMenu.BackupsLoaded();
        }
示例#4
0
        public static void DeleteBackup(MyBackup backup)
        {
            while (backup.BackupStatus.Count > 0)
            {
                DeleteBackupState(backup.BackupStatus[0]);
            }

            IniFile MyIni = new IniFile("Configuration.ini");

            MyIni.DeleteSection("Configuration#" + backup.MyIndex);
            MyBackups.Remove(backup);
            int MaxIndex;

            if (MyBackups.Count == 0)
            {
                MaxIndex = 0;
            }
            else
            {
                MaxIndex = MyBackups.Max(x => x.MyIndex);
            }
            MyIni.Write("Configuration", "MaxIndex", MaxIndex.ToString());
        }