public async Task <string> RestoreAsync(DbBackupRestore model)
        {
            string strResult = await DbHelper.RestoreAsync(SystemConfigModel.Instance.MasterDbConnStr
                                                           , SystemConfigModel.Instance.DbName
                                                           , model.BackupPath.ToMapPath());

            if (strResult == ConstantHelper.Ok)
            {
                DbContextHelper.Init();

                //Restore Db will kill the sysprocesses.
                ResetDbContext();

                if (!await ExistByIdAsync <DbBackupRestore>(model.Id))
                {
                    model.Id = 0;
                }

                model.RestoreCount = model.RestoreCount + 1;
                model.RestoreTime  = DateTime.Now;
                await SaveAsync(model);
            }

            return(strResult);
        }
        public async Task <string> BackUpAsync()
        {
            string strFilePath = ($"{SystemConfigModel.Instance.BackUpDbName}_{DateTime.Now.ToFormat("yyyyMMddhhmmss")}")
                                 .GetPath("Database", "bak");
            string strResult = await DbHelper.BackUpAsync(SystemConfigModel.Instance.MasterDbConnStr
                                                          , SystemConfigModel.Instance.DbName
                                                          , strFilePath.ToMapPath());

            if (strResult == ConstantHelper.Ok)
            {
                DbBackupRestore model = new DbBackupRestore
                {
                    BackupPath = strFilePath
                };
                await SaveAsync(model);
            }

            return(strResult);
        }
        public async Task <string> RestoreAsync(int id)
        {
            DbBackupRestore model = await GetByIdAsync <DbBackupRestore>(id);

            return(await RestoreAsync(model));
        }