Exemplo n.º 1
0
        private DataManagerCodes ActualBackup(
            string srcPath,
            string destPath,
            ref string destination)
        {
            Logger.Info("In Actual Backup");
            int num = new Random().Next(0, 2147483646);

            DateTime.Now.ToString();
            string path2   = string.Format("BlueStacksBackup_{0}", (object)num);
            string dirPath = Path.Combine(destPath, path2);

            destination = dirPath;
            try
            {
                this.BackupFullBluestacksData(srcPath, dirPath);
                if (this.bgBackupThread.CancellationPending)
                {
                    return(DataManagerCodes.BACKUP_CANCELLED_DURING_PROCESS);
                }
                if (this.BackUpUserInfo(dirPath) != 0)
                {
                    Backup.DeleteBackup(dirPath);
                    DataManagerUtils.ShowErrorMsg(LocaleStrings.GetLocalizedString("STRING_BACKUP_FAILED", ""), LocaleStrings.GetLocalizedString("STRING_BACKUP_FAILURE", ""), this.progress);
                    return(DataManagerCodes.ERROR_IN_CREATING_USERINFO_FILE_WHILE_BACKUP);
                }
                if (this.bgBackupThread.CancellationPending)
                {
                    return(DataManagerCodes.BACKUP_CANCELLED_DURING_PROCESS);
                }
                this.ExportRegistry(dirPath);
                this.progress.Dispatcher.Invoke((Delegate)(() => this.progress.mProgressText.Text = string.Format("{0} {1}", (object)LocaleStrings.GetLocalizedString("STRING_BACKUP_SUCCESSFUL", ""), (object)dirPath)));
                this.bgBackupThread.ReportProgress(100);
                Thread.Sleep(2000);
                if (this.bgBackupThread.CancellationPending)
                {
                    return(DataManagerCodes.BACKUP_CANCELLED_DURING_PROCESS);
                }
                Logger.Info("Backup successfully taken");
                Stats.SendMiscellaneousStatsSync("BackupAndRestoreStats", nameof(Backup), RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, RegistryManager.Instance.Version, "Backup Completed", (string)null, (string)null, (string)null, (string)null, 15000);
                return(DataManagerCodes.SUCCESS);
            }
            catch (Exception ex)
            {
                Logger.Error("Error in taking Backup " + ex.ToString());
                DataManagerUtils.ShowErrorMsg(LocaleStrings.GetLocalizedString("STRING_BACKUP_FAILED", ""), LocaleStrings.GetLocalizedString("STRING_BACKUP_FAILURE", ""), this.progress);
                Backup.DeleteDirectory(dirPath);
                return(DataManagerCodes.EXCEPTION_IN_BACKUP);
            }
        }
 public static void ShowErrorMsg(string message, string captionTitle, ProgressWindow progress)
 {
     Logger.Info("Showing Error Message prompt");
     if (!App.sOpt.s)
     {
         progress.Dispatcher.Invoke((Delegate)(() =>
         {
             CustomMessageWindow customMessageWindow = new CustomMessageWindow();
             customMessageWindow.TitleTextBlock.Text = LocaleStrings.GetLocalizedString(captionTitle, "");
             customMessageWindow.BodyTextBlock.Text = LocaleStrings.GetLocalizedString(message, "");
             customMessageWindow.AddButton(ButtonColors.Blue, "STRING_EXIT", new EventHandler(DataManagerUtils.DataManagerUtils_ExitBtnHandler), (string)null, false, (object)null, true);
             customMessageWindow.CloseButtonHandle(new EventHandler(DataManagerUtils.DataManagerUtils_ExitBtnHandler), (object)null);
             customMessageWindow.Owner = (Window)progress;
             customMessageWindow.ShowInTaskbar = true;
             customMessageWindow.Title = Strings.ProductDisplayName;
             progress.Hide();
             customMessageWindow.ShowDialog();
         }));
     }
     else
     {
         DataManagerUtils.DataManagerUtils_ExitBtnHandler((object)null, (EventArgs)null);
     }
 }
Exemplo n.º 3
0
        private void BackupThread_DoWork(
            object sender,
            DoWorkEventArgs e,
            string dataDir,
            string path,
            ref string destination)
        {
            Logger.Info("In Do Work");
            string           dirPath = path;
            DataManagerCodes flag    = DataManagerCodes.DEFAULT;

            if (path == null)
            {
                this.progress.Dispatcher.Invoke((Delegate)(() =>
                {
                    this.progress.mLastRow.Height = new GridLength(20.0, GridUnitType.Star);
                    this.progress.mProgressHeader.Text = LocaleStrings.GetLocalizedString("STRING_CREATING_BACKUP", "");
                    this.progress.mProgressText.Text = LocaleStrings.GetLocalizedString("STRING_BACKUP_PLEASE_WAIT", "");
                    flag = this.SelectBackupFolder(ref dirPath);
                    if (flag != DataManagerCodes.CANCEL)
                    {
                        return;
                    }
                    e.Result = (object)flag;
                }));
                try
                {
                    if (new DriveInfo(Path.GetPathRoot(dirPath)).AvailableFreeSpace < 5368709120L)
                    {
                        this.progress.Dispatcher.Invoke((Delegate)(() =>
                        {
                            CustomMessageWindow customMessageWindow = new CustomMessageWindow();
                            customMessageWindow.TitleTextBlock.Text = LocaleStrings.GetLocalizedString("STRING_INSUFFICIENT_SPACE", "");
                            customMessageWindow.AddAboveBodyWarning(LocaleStrings.GetLocalizedString("STRING_BACKUP_DISK_SPACE_FULL_WARNING", ""));
                            customMessageWindow.BodyTextBlock.Text = LocaleStrings.GetLocalizedString("STRING_BACKUP_DISK_SPACE_FULL_MESSAGE", "");
                            customMessageWindow.AboveBodyWarningTextBlock.Visibility = Visibility.Visible;
                            customMessageWindow.AddButton(ButtonColors.Blue, "STRING_CHANGE_LOCATION", (EventHandler)((obj, e1) =>
                            {
                                flag = this.SelectBackupFolder(ref dirPath);
                                if (flag != DataManagerCodes.CANCEL)
                                {
                                    return;
                                }
                                e.Result = (object)flag;
                            }), (string)null, false, (object)null, true);
                            customMessageWindow.AddButton(ButtonColors.White, "STRING_CONTINUE", (EventHandler)null, (string)null, false, (object)null, true);
                            customMessageWindow.Owner = (Window)this.progress;
                            customMessageWindow.ShowInTaskbar = true;
                            customMessageWindow.Title = Strings.ProductDisplayName;
                            customMessageWindow.ShowDialog();
                        }));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Warning("Exception while checking available space in the backup directory: " + ex.ToString());
                    throw;
                }
            }
            if (!string.IsNullOrEmpty(dirPath))
            {
                if (this.CheckForValidBackupPath(dirPath))
                {
                    Stats.SendMiscellaneousStatsAsync("BackupAndRestoreStats", nameof(Backup), RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, RegistryManager.Instance.Version, "Backup Started", (string)null, (string)null, (string)null, "Android", 0);
                    e.Result = (object)this.ActualBackup(dataDir, dirPath, ref destination);
                    if ((int)e.Result != -4)
                    {
                        return;
                    }
                    e.Cancel = true;
                }
                else
                {
                    Logger.Error("Invalid Path selected path = " + dirPath);
                    DataManagerUtils.ShowErrorMsg(LocaleStrings.GetLocalizedString("STRING_BACKUP_ERROR_INVALID_PATH_SELECTED", ""), LocaleStrings.GetLocalizedString("STRING_BACKUP_FAILURE", ""), this.progress);
                    e.Result = (object)DataManagerCodes.ERROR_IN_CREATING_BACKUP_INVALID_PATH_SELECTED;
                }
            }
            else
            {
                Logger.Error("Path is empty");
                DataManagerUtils.ShowErrorMsg(LocaleStrings.GetLocalizedString("STRING_BACKUP_ERROR_INVALID_PATH_SELECTED", ""), LocaleStrings.GetLocalizedString("STRING_BACKUP_FAILURE", ""), this.progress);
                e.Result = (object)DataManagerCodes.NO_PATH_CHOSEN;
            }
        }