Beispiel #1
0
        public JsonResult AddBackups(string txt_dbName, string txt_fileName, string txt_backupType, string txt_remark)
        {
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
            Common.Json json      = new Common.Json();
            B_Backups   b_backup  = new B_Backups();
            B_Manager   b_manager = new B_Manager();

            txt_fileName += ".bak";
            var filePath = Server.MapPath("~/Resource/DbBackup/" + txt_fileName);

            //把文件备份成功
            b_backup.BackupDB(txt_dbName, filePath, Convert.ToInt32(txt_backupType));
            Domain.Backups m_backup = new Domain.Backups();
            m_backup.dbName   = txt_dbName;
            m_backup.fileName = txt_fileName;
            m_backup.filePath = "/Resource/DbBackup/" + txt_fileName;
            if (Convert.ToInt32(txt_backupType) == Convert.ToInt32(EnumBase.BackupType.完整备份))
            {
                m_backup.backupType = EnumBase.BackupType.完整备份.Description();
            }
            else if (Convert.ToInt32(txt_backupType) == Convert.ToInt32(EnumBase.BackupType.差异备份))
            {
                m_backup.backupType = EnumBase.BackupType.差异备份.Description();
            }
            else
            {
                m_backup.backupType = EnumBase.BackupType.完整备份.Description();
            }
            m_backup.fileSize   = FileHelper.ToFileSize(FileHelper.GetFileSize(filePath));
            m_backup.addTime    = DateTime.Now;
            m_backup.addManager = b_manager.Get(Convert.ToInt32(base.User.Identity.Name));
            m_backup.remark     = txt_remark;
            m_backup.delManager = new Domain.Manager();//这里给个空对象,否则外键关联会出错的
            var res = b_backup.Save(m_backup);

            if (res > 0)
            {
                json.msg = "备份成功!";
            }
            else
            {
                json.msg    = "备份失败!";
                json.status = -1;
            }
            return(Json(json));
        }
Beispiel #2
0
 public void Update(Domain.Backups model)
 {
     dal.Update(model);
 }
Beispiel #3
0
 public int Save(Domain.Backups model)
 {
     return(Convert.ToInt32(dal.Save(model)));
 }