Exemple #1
0
        private void DelSqlite(object sender, RoutedEventArgs e)
        {
            Core.pojo.data.SqliteInfo sqliteInfo = vieModel_StartUp.CurrentDatabases[listBox.SelectedIndex];
            string path = sqliteInfo.Path;
            string name = sqliteInfo.Name;

            if (new Msgbox(this, $"{Jvedio.Language.Resources.IsToDelete} {name}?").ShowDialog() == true)
            {
                string dirpath    = DateTime.Now.ToString("yyyyMMddHHmm");
                string backupPath = Path.Combine(GlobalVariable.BackupPath, dirpath);
                FileHelper.TryCreateDir(backupPath);
                if (File.Exists(path))
                {
                    //备份
                    FileHelper.TryCopyFile(path, Path.Combine(backupPath, name + ".sqlite"), true);
                    //删除
                    if (FileHelper.TryDeleteFile(path))
                    {
                        ConfigConnection.Instance.DeleteByIds(new List <int>()
                        {
                            sqliteInfo.ID
                        });
                        vieModel_StartUp.ScanDatabase();
                    }
                }
            }
        }
Exemple #2
0
        private void RenameSqlite(object sender, RoutedEventArgs e)
        {
            Core.pojo.data.SqliteInfo sqliteInfo = vieModel_StartUp.CurrentDatabases[listBox.SelectedIndex];
            string      originName = sqliteInfo.Name;
            string      originPath = sqliteInfo.Path;
            DialogInput input      = new DialogInput(this, Jvedio.Language.Resources.Rename, originName);

            if (input.ShowDialog() == false)
            {
                return;
            }
            string targetName = input.Text;

            if (targetName == originName)
            {
                return;
            }
            if (string.IsNullOrEmpty(targetName) || targetName.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) != -1)
            {
                MessageCard.Show("名称非法!");
                return;
            }
            string targetPath = Path.Combine(GlobalVariable.DataPath, GlobalVariable.CurrentInfoType.ToString(), targetName + ".sqlite");

            if (File.Exists(targetPath))
            {
                MessageCard.Show(Jvedio.Language.Resources.Message_AlreadyExist);
                return;
            }
            sqliteInfo.Name = targetName;
            sqliteInfo.Path = targetPath;
            FileHelper.TryMoveFile(originPath, targetPath);
            ConfigConnection.Instance.UpdateSqliteInfoPath(sqliteInfo);
            vieModel_StartUp.ScanDatabase(); // todo 仅更新重命名的
        }
Exemple #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            SqliteInfo o = obj as SqliteInfo;

            if (o == null)
            {
                return(false);
            }
            return(o.Type == this.Type && o.Name == this.Name && o.Path == this.Path);
        }