示例#1
0
 private void NotifyIcon_MouseMove(object sender, MouseEventArgs e)
 {
     try
     {
         BackupTask backupTask = viewModel.BackupTask;
         if (backupTask != null && !backupTask.Result.HasValue)
         {
             notifyIcon.Text = "Is Backuping";
         }
         else
         {
             BackupConfig config = viewModel.Config;
             if (config == null || config.NextScheduledBackup == DateTime.MaxValue || !config.IsBackupEnabled)
             {
                 notifyIcon.Text = "No Backup scheduled";
             }
             else
             {
                 TimeSpan timeUntilNextBackup = config.NextScheduledBackup - DateTime.Now;
                 notifyIcon.Text = ConvertTimeSpanToStringLong(timeUntilNextBackup);
             }
         }
     }
     catch (Exception exc)
     {
         DebugEvent.SaveText("NotifyIcon_MouseMove", exc);
     }
 }
        /// <summary>
        /// Gets the scheduled backups for newly registered client.
        /// </summary>
        /// <param name="sourceClientInfo">The source client information.</param>
        /// <returns>List of scheduled backups.</returns>
        private IEnumerable <ScheduledBackup> GetScheduledBackupsForNewlyRegisteredClient(ClientInfo sourceClientInfo)
        {
            var scheduledBackups = new List <ScheduledBackup>();

            var destinationFolder             = sourceClientInfo.ClientIpAddress;
            var destinationPath               = Path.Combine("serverSharedFolder", destinationFolder);
            var destinationRegistrationHelper = new ClientRegistrationHelper(
                "ServerUser",
                "1q2w3e",
                destinationPath);
            var destinationClientInfo = destinationRegistrationHelper.ClientInfo;

            var backupConfig = new BackupConfig
            {
                ClientIpAddress       = destinationClientInfo.ClientIpAddress,
                DestinationCredential = destinationClientInfo.CredentialInfo,
                DestinationFolderPath = destinationClientInfo.SharedFolderPath,
                SourceCredential      = sourceClientInfo.CredentialInfo,
                SourceFolderPath      = sourceClientInfo.SharedFolderPath
            };

            var lastScheduled = DateTime.UtcNow;

            for (int i = 0; i < 10; i++)
            {
                var scheduledBackup = new ScheduledBackup(lastScheduled, backupConfig);
                scheduledBackups.Add(scheduledBackup);
                lastScheduled = lastScheduled.AddHours(1);
            }

            return(scheduledBackups);
        }
示例#3
0
        public MainForm()
        {
            InitializeComponent();

            this.felica = new Felica();

            if (!this.felica.ConnectReader())
            {
                MessageBox.Show(
                    "リーダーが接続されていません。プログラムを終了します。",
                    "起動エラー",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                Program.Exit();
            }

            this.felica.SetCallback(new FelicaGetUidDelegate(this.PollingCallback));
            this.felica.BeginPolling();

            // バックアップ
            this.backupConfig = new BackupConfig();
            this.backupConfig.Load();

            //this.backupConfig.Interval = 10 * 60 * 1000;
            //this.backupConfig.Save();

            this.backup = new Backup(this.backupConfig, this.db);
            this.backup.StartBackup();

            this.dormitoryForm.Show(RobotClub.DormitoryReport.DomitoryReportData.Empty);
            this.dormitoryForm.Show();
            this.dormitoryForm.Visible = false;
        }
示例#4
0
        private void GetBackupInfo(object sender, SelectionChangedEventArgs e)
        {
            if (Backups.SelectedIndex == 0)
            {
                return;
            }
            BackupConfig = new BackupConfig();
            if (File.Exists(exe + "\\BBBUBackups\\" + Backups.SelectedValue + "\\Backup.json"))
            {
                BackupConfig = JsonSerializer.Deserialize <BackupConfig>(File.ReadAllText(exe + "\\BBBUBackups\\" + Backups.SelectedValue + "\\Backup.json"));
            }

            if (BackupConfig.BackupType == 0)
            {
                RAPK.Visibility = Visibility.Hidden;
                RAPK.IsChecked  = false;
                ChangeImage("BBBU5_A.png");
            }
            else
            {
                RAPK.Visibility = Visibility.Visible;
                RAPK.IsChecked  = true;
                ChangeImage("BBBU5_B.png");
            }
        }
        public async Task <long> Handle(CreateOrUpdateBackupSettingsTemplateCommand request, CancellationToken cancellationToken)
        {
            BackupConfig backupSettingsTemplate;

            if (request.Id > 0)
            {
                backupSettingsTemplate = await _context.Set <BackupConfig>()
                                         .FirstOrDefaultAsync(x => x.IsTemplate && x.Id == request.Id, cancellationToken);

                if (backupSettingsTemplate == null)
                {
                    throw new EntityNotFoundException(nameof(BackupConfig), request.Id);
                }
            }
            else
            {
                backupSettingsTemplate = new BackupConfig()
                {
                    IsTemplate = true
                };
                _context.Set <BackupConfig>().Add(backupSettingsTemplate);
            }

            Mapper.Map(request, backupSettingsTemplate);

            await _context.SaveChangesAsync(cancellationToken);

            return(backupSettingsTemplate.Id);
        }
示例#6
0
        public static void InitM()
        {
            MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            GlobalSettings gs = GlobalSettings.GetGlobals();

            InitMednafen();

            // check whether bypassconfig is set
            if (gs.bypassConfig == false)
            {
                //ask to import configs
                MessageBoxResult result = MessageBox.Show("Do you want to import data from any Mednafen config files in this directory?\n(This will overwrite any config data stored in MedLaunch)\n\nYou will only be prompted once for this, but you can control automatic import of mednafen config files from the SETTINGS tab.", "Config Import", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    ConfigImport ci = new ConfigImport();
                    ci.ImportAll(null);

                    // set bypassconfig to 1
                    gs.bypassConfig = true;
                    GlobalSettings.SetGlobals(gs);
                }

                else
                {
                    gs.bypassConfig = true;
                    GlobalSettings.SetGlobals(gs);
                }
            }

            // if option is selected make a backup of the mednafen config file
            BackupConfig.BackupMain();
            // mednafen versions
            mw.UpdateCheckMednafen();
        }
        public void DoBackup_SavesTestDataToTempDestination()
        {
            // Arrange
            var crh          = new ClientRegistrationHelper("ShareUser", "1q2w3e", "sharedFolder");
            var logger       = new ConsoleLogger();
            var backupConfig = new BackupConfig
            {
                SourceFolderPath      = crh.ClientInfo.SharedFolderPath,
                SourceCredential      = crh.ClientInfo.CredentialInfo,
                DestinationFolderPath = DestinationPath,
                DestinationCredential = crh.ClientInfo.CredentialInfo
            };
            var backupStrategy = new BackupStrategyCopyFiles(logger);

            // Act
            backupStrategy.DoWork(backupConfig);

            // Assert
            var filesInSource = Directory.EnumerateFiles(backupConfig.SourceFolderPath);

            Assert.IsNotNull(filesInSource);
            var filesInDestination = Directory.EnumerateFiles(backupConfig.DestinationFolderPath);

            Assert.IsNotNull(filesInDestination);
            foreach (var fileName in filesInSource.Select(Path.GetFileName))
            {
                Assert.IsTrue(filesInDestination.Any(f => f.Contains(fileName)));
            }
        }
示例#8
0
        /// <summary>
        /// バックアップクラスを初期化します。
        /// </summary>
        /// <param name="config">バックアップの設定</param>
        public Backup(BackupConfig config, Database database)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            this.Config = config;
            this.Database = database;
            this.Timer = null;
            this.IsTimerStarted = false;
        }
示例#9
0
        /// <summary>
        /// Performs the required work.
        /// </summary>
        /// <param name="config">The configuration.</param>
        public void DoWork(BackupConfig config)
        {
            _logger.LogInfo(
                $"Copying files started. \n Source: {config.SourceFolderPath} \n Destination: {config.DestinationFolderPath} \n");

            try
            {
                CopyFilesImpersonated(config);
            }
            catch (Exception e)
            {
                _logger.LogException(e);
            }

            _logger.LogInfo(
                $"Copying files finished. \n Source: {config.SourceFolderPath} \n Destination: {config.DestinationFolderPath} \n");
        }
示例#10
0
        private async Task CheckForBackup()
        {
            DebugEvent.SaveText("CheckForBackup", "NextBackup: " + viewModel.Config.NextScheduledBackup);

            BackupConfig config = viewModel.Config;

            if (config == null || config.NextScheduledBackup > DateTime.Now)
            {
                return;
            }

            BackupTask backupTask = viewModel.BackupTask;

            if (config.IsBackupEnabled && (backupTask == null || backupTask.Result.HasValue))
            {
                await BackupAsync();
            }
        }
示例#11
0
        /// <summary>
        /// Backups the file.
        /// </summary>
        /// <param name="backupConfig">The backup configuration.</param>
        private void CopyFilesImpersonated(BackupConfig backupConfig)
        {
            var sourceImpersonationToken      = backupConfig.SourceCredential.GetImpersonationToken(isCurrentSystemLogon: true);
            var destinationImpersonationToken = backupConfig.DestinationCredential.GetImpersonationToken(isCurrentSystemLogon: false);

            using (sourceImpersonationToken)
            {
                // Use the token handle for the user of the source machine.
                using (WindowsIdentity.Impersonate(sourceImpersonationToken.DangerousGetHandle()))
                {
                    using (destinationImpersonationToken)
                    {
                        // Use the token handle for the user of the destination machine.
                        using (WindowsIdentity.Impersonate(destinationImpersonationToken.DangerousGetHandle()))
                        {
                            FilesManagementHelper.DirectoryCopy(backupConfig);
                        }
                    }
                }
            }
        }
示例#12
0
        private async Task <Account> CreateTemplate(CreateOrUpdateGeneralTemplateCommand command, CancellationToken cancellationToken)
        {
            var accountTemplate = new Account()
            {
                IsTemplate = true
            };

            Mapper.Map(command, accountTemplate);

            var instanceSettingsTemplate = new MachineConfig()
            {
                IsTemplate = true
            };

            Mapper.Map(command, instanceSettingsTemplate);
            accountTemplate.MachineConfig = instanceSettingsTemplate;

            var licenseTemplate = new LicenseConfig()
            {
                IsTemplate = true
            };

            Mapper.Map(command, licenseTemplate);
            accountTemplate.LicenseConfig = licenseTemplate;

            var backupSettingsTemplate = new BackupConfig()
            {
                IsTemplate = true
            };

            Mapper.Map(command, backupSettingsTemplate);
            accountTemplate.BackupConfig = backupSettingsTemplate;

            _context.Set <Account>().Add(accountTemplate);
            return(accountTemplate);
        }
        /// <summary>
        /// バックアップ設定のダイアログを初期化する。
        /// </summary>
        /// <param name="config">バックアップの設定</param>
        public BackupConfigForm(BackupConfig config)
        {
            InitializeComponent();

            this.Config = config;
        }
示例#14
0
 public UiMain()
 {
     InitializeComponent();
     _config = BackupConfig.Load();
 }
示例#15
0
 public UiMain()
 {
     InitializeComponent();
     _config = BackupConfig.Load();
 }
示例#16
0
        private async Task <Account> UpdateTemplate(CreateOrUpdateGeneralTemplateCommand command, CancellationToken cancellationToken)
        {
            var accountTemplate = await _context.Set <Account>()
                                  .Include(x => x.Billing)
                                  .Include(x => x.Contact)
                                  .Include(x => x.LicenseConfig)
                                  .Include(x => x.MachineConfig)
                                  .Include(x => x.BackupConfig)
                                  .FirstOrDefaultAsync(x => x.IsTemplate && x.Id == command.Id, cancellationToken);

            if (accountTemplate == null)
            {
                throw new EntityNotFoundException(nameof(Account), command.Id);
            }

            var instanceSettingsTemplate = accountTemplate.MachineConfig;

            if (instanceSettingsTemplate != null)
            {
                Mapper.Map(command, instanceSettingsTemplate);
            }
            else
            {
                instanceSettingsTemplate = new MachineConfig()
                {
                    IsTemplate = true
                };
                Mapper.Map(command, instanceSettingsTemplate);
                accountTemplate.MachineConfig = instanceSettingsTemplate;
            }

            var licenseTemplate = accountTemplate.LicenseConfig;

            if (licenseTemplate != null)
            {
                Mapper.Map(command, licenseTemplate);
            }
            else
            {
                licenseTemplate = new LicenseConfig()
                {
                    IsTemplate = true
                };
                Mapper.Map(command, licenseTemplate);
                accountTemplate.LicenseConfig = licenseTemplate;
            }

            var backupSettingsTemplate = accountTemplate.BackupConfig;

            if (backupSettingsTemplate != null)
            {
                Mapper.Map(command, backupSettingsTemplate);
            }
            else
            {
                backupSettingsTemplate = new BackupConfig()
                {
                    IsTemplate = true
                };
                Mapper.Map(command, backupSettingsTemplate);
                accountTemplate.BackupConfig = backupSettingsTemplate;
            }

            Mapper.Map(command, accountTemplate);

            return(accountTemplate);
        }
示例#17
0
        public void StartBackup(String BackupName, Boolean Advanced)
        {
            StartBMBF();
            if (running)
            {
                running = false;
                return;
            }
            running = true;

            if (BackupName != "")
            {
                BName.Text = Name;
            }

            //Check Quest IP
            if (!MainWindow.iPUtils.CheckIP(Quest))
            {
                txtbox.AppendText("\n\n" + MainWindow.globalLanguage.global.ipInvalid);
                running = false;
                return;
            }
            Version version = new Version(MainWindow.config.GameVersion);

            try
            {
                WebClient c      = new WebClient();
                BMBFC     config = BMBFUtils.GetBMBFConfig();
                version = new Version(config.BeatSaberVersion);
            } catch { }
            BackupConfig.BSVersion = version;
            if (Advanced)
            {
                MessageBoxResult r = MessageBox.Show(MainWindow.globalLanguage.bBBU.code.advancedBackupWarning, "BMBF Manager - BMBF Beat Saber Backup Utility", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                switch (r)
                {
                case MessageBoxResult.No:
                    txtbox.AppendText("\n\n" + MainWindow.globalLanguage.bBBU.code.backupAborted);
                    running = false;
                    return;
                }
            }

            MainWindow.DCRPM.SetActivity(MainWindow.globalLanguage.dCRP.creatingBBBUBackup);

            //Create all Backup Folders
            if (!BackupFSet())
            {
                txtbox.AppendText("\n\n" + MainWindow.globalLanguage.bBBU.code.backupExists);
                running = false;
                return;
            }

            BackupConfig = new BackupConfig();

            //Scores
            txtbox.AppendText("\n\n" + MainWindow.globalLanguage.bBBU.code.backingUpScores);
            MainWindow.aDBI.adb("pull /sdcard/Android/data/com.beatgames.beatsaber/files/LocalDailyLeaderboards.dat \"" + Scores + "\"", txtbox);
            MainWindow.aDBI.adb("pull /sdcard/Android/data/com.beatgames.beatsaber/files/LocalLeaderboards.dat \"" + Scores + "\"", txtbox);
            MainWindow.aDBI.adb("pull /sdcard/Android/data/com.beatgames.beatsaber/files/PlayerData.dat \"" + Scores + "\"", txtbox);
            MainWindow.aDBI.adb("pull /sdcard/Android/data/com.beatgames.beatsaber/files/AvatarData.dat \"" + Scores + "\"", txtbox);
            MainWindow.aDBI.adb("pull /sdcard/Android/data/com.beatgames.beatsaber/files/settings.cfg \"" + Scores + "\"", txtbox);
            txtbox.AppendText("\n" + MainWindow.globalLanguage.bBBU.code.backedUpScores + "\n");
            txtbox.ScrollToEnd();

            //Songs (now in ModData)

            //QSE();
            //MainWindow.aDBI.adb("pull /sdcard/BMBFData/CustomSongs \"" + BackupF + "\"");

            //Playlists

            PlaylistB();
            MainWindow.aDBI.adb("pull /sdcard/BMBFData/Playlists/ \"" + Playlists + "\"", txtbox);
            txtbox.ScrollToEnd();

            //ModData

            txtbox.AppendText("\n\n" + MainWindow.globalLanguage.bBBU.code.backingUpModData);
            MainWindow.aDBI.adb("pull /sdcard/ModData/com.beatgames.beatsaber \"" + BackupF + "\"", txtbox);
            txtbox.AppendText("\n" + MainWindow.globalLanguage.bBBU.code.backedUpModData + "\n");
            txtbox.ScrollToEnd();

            //Mods

            MainWindow.aDBI.adb("pull /sdcard/BMBFData/Mods \"" + BackupF + "\"", txtbox);

            if (Advanced)
            {
                BackupAPK();
                if (!BackupConfig.BMBFBackup)
                {
                    MessageBox.Show(MainWindow.globalLanguage.bBBU.code.bMBFAPKBackupFailed, "BMBF Manager - BMBF Beat Saber Backup Utility", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                if (!BackupConfig.BSBackup)
                {
                    MessageBox.Show(MainWindow.globalLanguage.bBBU.code.bSAPKBackupFailed, "BMBF Manager - BMBF Beat Saber Backup Utility", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

            if (Advanced)
            {
                BackupConfig.BackupType = 1;
            }
            else
            {
                BackupConfig.BackupType = 0;
            }
            File.WriteAllText(BackupF + "\\Backup.json", JsonSerializer.Serialize(BackupConfig));

            txtbox.AppendText("\n\n\n" + MainWindow.globalLanguage.bBBU.code.backupMade);
            txtbox.ScrollToEnd();
            running = false;
        }
示例#18
0
        public void SetBackupConfig(BackupConfig objBackupConfig)
        {
            idTxtServerName.Text = objBackupConfig.ServerCredentials.ServerName;
            idTxtUserId.Text     = objBackupConfig.ServerCredentials.UserId;
            idTxtPassword.Text   = objBackupConfig.ServerCredentials.Password;

            idListDatabase.DataSource = objBackupConfig.BackupDatabase.DatabaseName;

            if (objBackupConfig.BackupSchedule.Sunday == Helper.AppConstants.Full)
            {
                idRdbSundayF.Checked = true;
            }
            else
            {
                idRdbSundayD.Checked = true;
            }


            if (objBackupConfig.BackupSchedule.Monday == Helper.AppConstants.Full)
            {
                idRdbMondayF.Checked = true;
            }
            else
            {
                idRdbMondayD.Checked = true;
            }

            if (objBackupConfig.BackupSchedule.Tuesday == Helper.AppConstants.Full)
            {
                idRdbTuesdayF.Checked = true;
            }
            else
            {
                idRdbTuesdayD.Checked = true;
            }

            if (objBackupConfig.BackupSchedule.Wednesday == Helper.AppConstants.Full)
            {
                idRdbWednesdayF.Checked = true;
            }
            else
            {
                idRdbWednesdayD.Checked = true;
            }

            if (objBackupConfig.BackupSchedule.Thursday == Helper.AppConstants.Full)
            {
                idRdbThursdayF.Checked = true;
            }
            else
            {
                idRdbThursdayD.Checked = true;
            }

            if (objBackupConfig.BackupSchedule.Friday == Helper.AppConstants.Full)
            {
                idRdbFridayF.Checked = true;
            }
            else
            {
                idRdbFridayD.Checked = true;
            }

            if (objBackupConfig.BackupSchedule.Saturday == Helper.AppConstants.Full)
            {
                idRdbSaturdayF.Checked = true;
            }
            else
            {
                idRdbSaturdayD.Checked = true;
            }

            idTxtBackupLocation.Text = objBackupConfig.BackupLocation;
            idDateTimePicker.Text    = objBackupConfig.BackupTime;

            //if (objBackupConfig.BackupType == Helper.AppConstants.BackupFileBak)
            //    idRdbBak.Checked = true;
            //else
            //    idRdbScript.Checked = true;

            idTxtBackupPassword.Text = objBackupConfig.BackupPassword;

            if (!string.IsNullOrEmpty(objBackupConfig.BackupPassword))
            {
                idChkPasswordProtect.Checked = true;
                idTxtBackupPassword.Enabled  = true;
            }
            else
            {
                idTxtBackupPassword.Enabled = false;
            }
        }
示例#19
0
        public BackupConfig GetBackupConfig()
        {
            BackupConfig objBackupConfig = new BackupConfig();

            objBackupConfig.ServerCredentials.ServerName = idTxtServerName.Text;
            objBackupConfig.ServerCredentials.UserId     = idTxtUserId.Text;
            objBackupConfig.ServerCredentials.Password   = idTxtPassword.Text;

            List <string> DatabaseList = new List <string>();

            for (var i = 0; i < idListDatabase.Items.Count; i++)
            {
                DatabaseList.Add(idListDatabase.Items[i].ToString());
            }
            objBackupConfig.BackupDatabase.DatabaseName.AddRange(DatabaseList);

            if (idRdbSundayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Sunday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Sunday = Helper.AppConstants.Differential;
            }

            if (idRdbMondayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Monday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Monday = Helper.AppConstants.Differential;
            }

            if (idRdbTuesdayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Tuesday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Tuesday = Helper.AppConstants.Differential;
            }

            if (idRdbWednesdayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Wednesday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Wednesday = Helper.AppConstants.Differential;
            }

            if (idRdbThursdayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Thursday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Thursday = Helper.AppConstants.Differential;
            }

            if (idRdbFridayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Friday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Friday = Helper.AppConstants.Differential;
            }

            if (idRdbSaturdayF.Checked == true)
            {
                objBackupConfig.BackupSchedule.Saturday = Helper.AppConstants.Full;
            }
            else
            {
                objBackupConfig.BackupSchedule.Saturday = Helper.AppConstants.Differential;
            }

            objBackupConfig.BackupLocation = idTxtBackupLocation.Text;
            objBackupConfig.BackupTime     = idDateTimePicker.Text;

            //if (idRdbBak.Checked == true)
            //    objBackupConfig.BackupType = Helper.AppConstants.BackupFileBak;
            //else
            //    objBackupConfig.BackupType = Helper.AppConstants.BackupFileScript;

            objBackupConfig.BackupPassword = idTxtBackupPassword.Text;

            return(objBackupConfig);
        }
示例#20
0
 /// <summary>
 ///     Directories the copy.
 /// </summary>
 /// <param name="backupConfig">The backup configuration.</param>
 /// <param name="copySubDirs">if set to <c>true</c> [copy sub dirs].</param>
 public static void DirectoryCopy(BackupConfig backupConfig, bool copySubDirs = false)
 {
     DirectoryCopy(backupConfig.SourceFolderPath, backupConfig.DestinationFolderPath, copySubDirs);
 }