Ejemplo n.º 1
0
 public void DeleteBackup()
 {
     FileIOHelper.DeleteSingleFile(SelectedBackup.FullName);
     BackupList.Remove(SelectedBackup);
     SelectedBackup = null;
     NotifyOfPropertyChange(() => BackupList);
     NotifyOfPropertyChange(() => SelectedBackup);
 }
Ejemplo n.º 2
0
        private async Task RefreshBackupList()
        {
            // Získání souborů
            List <OneDriveFileInfo> files = new List <OneDriveFileInfo>();

            if (IsLoggedIn)
            {
                // Získání složky
                string folderId = await LiveConnectHelper.SearchFolderIdAsync(BackupFolderName);

                // Získání seznamu souborů se zálohami
                if (folderId != null)
                {
                    files = await LiveConnectHelper.GetFilesInfoAsync(folderId, BackupFileExtension);
                }
            }

            // Vytvoření seznamu
            List <RestoreListPickerItem> list = new List <RestoreListPickerItem>();

            foreach (OneDriveFileInfo fileInfo in files)
            {
                string fileName = fileInfo.Name.Replace(BackupFileExtension, "");

                try
                {
                    DateTime createdDate = DateTimeExtensions.FromFileName(fileName);
                    list.Add(new RestoreListPickerItem(createdDate.ToString(), fileInfo, createdDate));
                }
                catch (FormatException)
                {
                    // Při parsování datumu, takže
                }
            }

            // Seřazení podle vytvoření
            list.Sort((f1, f2) =>
            {
                return(f2.Value2.CompareTo(f1.Value2));
            });

            if (list.Count > _maxBackupsInList)
            {
                list.RemoveRange(_maxBackupsInList, list.Count - _maxBackupsInList);
            }

            // Naplnění pickeru
            if (list.Count > 0)
            {
                list[0].Label += string.Format(" ({0})", AppResources.BackupLatest);
                BackupList     = new ObservableCollection <RestoreListPickerItem>(list);
            }
            else
            {
                BackupList.Clear();
                BackupList.Add(new RestoreListPickerItem(AppResources.NoBackups, null, DateTime.MinValue));
            }
        }
Ejemplo n.º 3
0
        public void CreateBackup()
        {
            string source = Settings.DatabasePath;
            string target = $"{Settings.BackupPath}{BackupName}.db";

            if (CopyDatabase(source, target))
            {
                BackupName = "";
                FileInfo targetFile = new FileInfo(target);
                BackupList.Add(targetFile);
                NotifyOfPropertyChange(BackupName);
            }
        }
Ejemplo n.º 4
0
        public void DeleteActiveDatabase()
        {
            // Make a safety backup for the active database
            string source = Settings.DatabasePath;
            string guid   = Guid.NewGuid().ToString();
            string target = $"{Settings.BackupPath}Delete backup {guid}.db";

            if (CopyDatabase(source, target))
            {
                FileInfo targetFile = new FileInfo(target);
                BackupList.Add(targetFile);
                FileIOHelper.DeleteSingleFile(source);
                NotifyOfPropertyChange(() => CanDeleteActiveDatabase);
                NotifyOfPropertyChange(() => CanCreateDatabase);
            }
        }
Ejemplo n.º 5
0
        private void ZOpenMenu(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Point Pointer = Cursor.Position;

            Pointer     = BackupList.PointToClient(Pointer);
            MenuStripID = BackupList.IndexFromPoint(Pointer);

            bool ItemSelected = MenuStripID >= 0;

            ZAbrir.Visible  = ItemSelected;
            ZDelete.Visible = ItemSelected;

            if (!ItemSelected && !Engine.DebugMode)
            {
                e.Cancel = true;
            }
        }
Ejemplo n.º 6
0
        void SelectBackupVersion_PageLeave(object sender, PageChangedArgs args)
        {
            if (args.Direction == PageChangedDirection.Back)
            {
                BackupList.Abort();
                return;
            }

            if (BackupList.SelectedItem.Ticks == 0)
            {
                MessageBox.Show(this, Strings.SelectBackupVersion.NoBackupSelectedError, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                args.Cancel = true;
                return;
            }

            m_selectedDate = new DateTime();
            m_selectedDate = BackupList.SelectedItem;

            m_wrapper.RestoreTime = m_selectedDate;
            args.NextPage         = new TargetFolder();
        }
        private void ToolDiffDebugSelectForm_Shown(object sender, EventArgs e)
        {
            using (InputFormRef.AutoPleaseWait wait = new InputFormRef.AutoPleaseWait())
            {
                this.FindBackup = new FindBackup();
                this.FindBackup.AppendOrignalROMToBackupList(); //末尾にバックアップROMを追加.

                this.PrefixTextBox.Text   = this.FindBackup.Prefix;
                this.OrignalFilename.Text = this.FindBackup.OrignalFilename;

                BackupList.Items.Clear();
                BackupList.BeginUpdate();
                for (int i = 0; i < this.FindBackup.Files.Count; i++)
                {
                    string filename = Path.GetFileName(this.FindBackup.Files[i].FilePath);
                    string text     = R._("{0} //{1}", filename, this.FindBackup.Files[i].Date.ToLocalTime());
                    BackupList.Items.Add(text);
                }
                BackupList.EndUpdate();
            }
        }
Ejemplo n.º 8
0
        void SelectBackup_PageEnter(object sender, PageChangedArgs args)
        {
            BackupList.Setup(Program.DataConnection, true, false);
            m_wrapper = new WizardSettingsWrapper(m_settings);

            if (m_action != null)
            {
                m_wrapper.PrimayAction = m_action.Value;
            }

            if (m_wrapper.PrimayAction == WizardSettingsWrapper.MainAction.RunNow && m_wrapper.DataConnection == null)
            {
                m_wrapper.DataConnection = Program.DataConnection;
            }

            if (m_wrapper.ScheduleID > 0)
            {
                BackupList.SelectedBackup = (m_wrapper.DataConnection ?? Program.DataConnection).GetObjectById <Schedule>(m_wrapper.ScheduleID);
            }

            if (m_wrapper.PrimayAction == WizardSettingsWrapper.MainAction.Restore)
            {
                topLabel.Visible       = false;
                RestoreOptions.Visible = true;
            }
            else
            {
                topLabel.Visible          = true;
                RestoreOptions.Visible    = false;
                ShowAdvancedPanel.Visible = false;
                topLabel.Text             = this.Title;
            }

            if (m_valuesAutoLoaded)
            {
                m_skipFirstEvent = true;
            }

            args.TreatAsLast = false;
        }
Ejemplo n.º 9
0
        protected void LoadConfig(string Configuration, SplashForm Splash)
        {
            string ConfigStr = Configuration;

            if (ConfigStr != null)
            {
                Utility.Debug(ConfigStr);

                using (StringReader sr = new StringReader(ConfigStr))
                    MainList = Serializer.Deserialize(sr) as BackupList;

                foreach (BackupProject bp in MainList.Projects)
                {
                    if (Splash != null)
                    {
                        Splash.Status = "Loading Backup Project '" + bp.Name + "'...";
                    }

                    bp.AfterXmlLoad();
                    try
                    {
                        bp.Refresh();
                    }
                    catch (Exception)
                    {
                        // If we can't load one of the projects, continue anyway and it will get flagged in red... I think.
                    }
                }

                if (Splash != null)
                {
                    Splash.Status = "Almost done loading configuration...";
                }
            }
            else
            {
                MainList = BackupList.CreateDefault();
            }
        }
Ejemplo n.º 10
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (IsPostBack && Validators.Count == 0)
     {
         Response.Redirect(Request.Url.ToString());
     }
     try
     {
         BackupList.DataSource = from f in C1Directory.GetFiles(BackupDirectory, "*.zip")
                                 orderby f
                                 select new
         {
             Filename    = Path.GetFileName(f),
             DateCreated = C1File.GetCreationTime(f),
             Filepath    = string.Format("?{0}={1}", BackupFilename, Path.GetFileName(f)),
             Filesize    = ((int)((new C1FileInfo(f).Length) / 1000)).ToString("N0")
         };
         BackupList.DataBind();
     }
     catch
     {
     }
 }
Ejemplo n.º 11
0
        public void RestoreBackup()
        {
            // Make a safetybackup for the active database
            string source = Settings.DatabasePath;
            string guid   = Guid.NewGuid().ToString();
            string target = $"{Settings.BackupPath}Restore backup {guid}.db";

            if (File.Exists(source))
            {
                if (CopyDatabase(source, target))
                {
                    FileInfo targetFile = new FileInfo(target);
                    BackupList.Add(targetFile);
                    FileIOHelper.DeleteSingleFile(source);
                    CopyDatabase(SelectedBackup.FullName, source);
                }
            }
            else
            {
                // no active database for any reason ..
                CopyDatabase(SelectedBackup.FullName, source);
                NotifyOfPropertyChange(() => CanDeleteActiveDatabase);
            }
        }
Ejemplo n.º 12
0
 void SelectBackupVersion_PageEnter(object sender, PageChangedArgs args)
 {
     m_wrapper = new WizardSettingsWrapper(m_settings);
     m_wrapper.UpdateSchedule(m_wrapper.DataConnection.GetObjectById <Schedule>(m_wrapper.ScheduleID));
     BackupList.Setup(m_wrapper.DataConnection.GetObjectById <Schedule>(m_wrapper.ScheduleID));
 }