private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DataFilePath?.Equals("") == true)//没有设置数据目录,则压缩默认数据目录的数据文件
            {
                if (Directory.Exists(Model.AppPath.XmlDataDirPath))
                {
                    fileNames.AddRange(Directory.GetFiles(Model.AppPath.XmlDataDirPath));
                }
                fileNames.Add(Model.AppPath.RootPath + "\\AppData\\DSJLDB.mdb");
            }
            else
            {
                if (!Directory.Exists(DataFilePath))
                {
                    MessageBoxTool.ShowConfirmMsgBox("未找到数据文件目录!");
                    this.Close();
                }
                else
                {
                    fileNames.AddRange(Directory.GetFiles(DataFilePath));
                }
            }
            pbCompression.Maximum = fileNames.Count;

            Thread t = new Thread(new ThreadStart(CompressionThread));

            t.Start();
        }
Beispiel #2
0
        //登录
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBoxTool.ShowConfirmMsgBox("用户名不能为空!");
                return;
            }
            if (txtPwd.Password == "")
            {
                MessageBoxTool.ShowConfirmMsgBox("密码不能为空!");

                return;
            }
            if (adminInfoBLL.GetModelList("AdminName='" + txtName.Text.Trim() + "' and AdminPwd='" + txtPwd.Password.Trim() + "'").Count > 0)
            {
                mainWindow = new MainWindow();
                Application.Current.MainWindow = mainWindow;
                this.Close();
                mainWindow.Show();
            }
            else
            {
                MessageBoxTool.ShowConfirmMsgBox("用户名或密码输入错误,请重新输入!!");
            }
        }
Beispiel #3
0
        //部分备份
        private void btnBackupProject_Click(object sender, RoutedEventArgs e)
        {
            if (txtBackupName.Text.Trim() == "")
            {
                MessageBoxTool.ShowConfirmMsgBox("备份名称不能为空,请重新输入!");
                return;
            }
            BackupProjectWindow backupProjectWindow = new BackupProjectWindow();

            backupProjectWindow.BackupName = txtBackupName.Text.Trim();
            backupProjectWindow.ShowDialog();
        }
Beispiel #4
0
        private void btnBackup_Click(object sender, RoutedEventArgs e)
        {
            backupTask = new Task(() =>
            {
                try
                {
                    //创建temp 目录
                    CreateDir(AppPath.TempDirPath);
                    //1、读取选择的项目的测试数据,包括人员信息和测试数据
                    List <TB_TestManager> checkedTestManager = testManagerList.FindAll(x => x.IsChecked == true);
                    Converter <TB_TestManager, int> testManagerIDConverter = new Converter <TB_TestManager, int>((TB_TestManager manager) =>
                    {
                        return(manager.ID);
                    });
                    int[] checkedTestManagerIDs   = checkedTestManager.ConvertAll <int>(testManagerIDConverter).ToArray();
                    string testManagerIDs         = string.Join(",", checkedTestManagerIDs);
                    List <TB_AthleteInfo> athList = (new BLL.TB_AthleteInfo()).GetModelList(string.Format("ath_testid in ({0})", testManagerIDs));
                    Converter <TB_AthleteInfo, int> athIDConverter = new Converter <TB_AthleteInfo, int>((TB_AthleteInfo ath) =>
                    {
                        return(ath.ID);
                    });
                    string athIDs = string.Join(",", athList.ConvertAll <int>(athIDConverter).ToArray());
                    List <TB_TestInfo> testInfoList = (new BLL.TB_TestInfo()).GetModelList(string.Format("ath_id in ({0})", athIDs));
                    //2、复制空数据库文件,复制数据xml文件
                    File.Copy(AppPath.DataPath + AppPath.EmptyDBName, AppPath.TempDirPath + AppPath.DBName);
                    //3、往空数据库文件中写入数据
                    DBUtility.DbHelperOleDb.SetDBPath(AppPath.TempDirPath + AppPath.DBName);//------------------

                    //4、创建压缩窗口,设置DataFilePath属性,并启动,Invoke
                    this.Dispatcher.Invoke(new Action(() => {
                        CompressProgress compress = new CompressProgress();
                        compress.DataFilePath     = AppPath.TempDirPath;
                        compress.OutputPath       = backFileName;
                        if (compress.ShowDialog() == true)
                        {
                            //删除temp目录
                            DeleteTempDir();
                            MessageBoxTool.ShowConfirmMsgBox("备份成功!");
                            this.Close();
                        }
                    }));
                }
                catch (Exception ee)
                {
                    MessageBoxTool.ShowConfirmMsgBox(string.Format("备份出现错误!\r\n异常类型:{0}\r\n异常信息:{1}", ee.GetType().ToString(), ee.Message));
                }
            });
            backupTask.Start();
            btnBackup.IsEnabled = btnChangeFolder.IsEnabled = false;
            btnCancle.IsEnabled = true;
        }
Beispiel #5
0
        //备份
        private void btnBackup_Click(object sender, RoutedEventArgs e)
        {
            if (txtBackupName.Text.Trim() == "")
            {
                MessageBoxTool.ShowConfirmMsgBox("备份名称不能为空,请重新输入!");
                return;
            }
            string fileName = txtBackupName.Text.Trim() + "-" + DateTime.Now.ToString("yyyyMMdd");

            SaveFileDialog ofd = new SaveFileDialog();

            ofd.Title           = "请选择保存文件的路径";
            ofd.DefaultExt      = "zip";
            ofd.FileName        = fileName;
            ofd.OverwritePrompt = true;
            ofd.AddExtension    = true;
            ofd.Filter          = "等速肌力数据库备份文件(*.zip)|*.zip";
            if (ofd.ShowDialog() == true)
            {
                string path = ofd.FileName;
                try
                {
                    CompressProgress progressWindow = new CompressProgress();
                    progressWindow.OutputPath = path;
                    progressWindow.Owner      = Application.Current.MainWindow;
                    progressWindow.ShowDialog();

                    Model.TB_BackupInfo backInfo = new Model.TB_BackupInfo();
                    backInfo.BackupDate = DateTime.Now.ToString("yyyy-MM-dd");
                    backInfo.BackupName = txtBackupName.Text.Trim();
                    backInfo.BackupPath = path;
                    backInfoBLL.Add(backInfo);
                    ReloadData();
                    txtBackupName.Text = "";

                    MessageBoxTool.ShowConfirmMsgBox("备份成功!");
                }
                catch (Exception ee)
                {
                    MessageBoxTool.ShowErrorMsgBox("备份出错,请稍候重试!\r\n" + ee.Message);
                }
            }
        }
Beispiel #6
0
        //还原
        private void btnRestore_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBoxTool.ShowAskMsgBox("还原数据库会把现有的数据库删除,且不可恢复,确定要还原吗?") == MessageBoxResult.Yes)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Title  = "还原数据库";
                ofd.Filter = "压缩文件(*.zip)|*.zip";
                if (ofd.ShowDialog() == true)
                {
                    ExtractProgressWindow extractWindow = new ExtractProgressWindow();
                    extractWindow.BackupFile = ofd.FileName;
                    extractWindow.Owner      = Application.Current.MainWindow;
                    extractWindow.ShowDialog();

                    ReloadData();
                    DSJL.Tools.DBUpgrade.Upgrade();
                    MessageBoxTool.ShowConfirmMsgBox("还原成功!");
                }
            }
        }