|
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.LR_Desktop;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using System;
- using Hangfire;
-
- namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2019-06-26 15:35
- /// 描 述:数据库备份设置
- /// </summary>
- public class Sys_DataBaseBackupSetController : MvcControllerBase
- {
- private Sys_DataBaseBackupSetIBLL sys_DataBaseBackupSetIBLL = new Sys_DataBaseBackupSetBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = sys_DataBaseBackupSetIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var Sys_DataBaseBackupSetData = sys_DataBaseBackupSetIBLL.GetSys_DataBaseBackupSetEntity(keyValue);
- var jsonData = new
- {
- Sys_DataBaseBackupSet = Sys_DataBaseBackupSetData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- try
- {
- RecurringJob.RemoveIfExists(keyValue);
- sys_DataBaseBackupSetIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- catch (Exception e)
- {
- return Success("删除成功!");
- }
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- try
- {
- var loginUserInfo = LoginUserInfo.Get();
- Sys_DataBaseBackupSetEntity entity = strEntity.ToObject<Sys_DataBaseBackupSetEntity>();
- entity.CreateUserId = loginUserInfo.userId;
- entity.CreateUserName = loginUserInfo.realName;
- entity.CreateTime = DateTime.Now;
- if (sys_DataBaseBackupSetIBLL.GetRecordCount() <= 1)
- {
- sys_DataBaseBackupSetIBLL.SaveEntity(keyValue, entity);
- RecurringJob.RemoveIfExists(entity.Id);
- if (entity.EnabledMark == 1)
- {
- if (entity.BackupType == 0)
- {
- RecurringJob.AddOrUpdate(entity.Id,
- () => sys_DataBaseBackupSetIBLL.AutoBackUp(),
- Cron.Daily(Convert.ToInt32(entity.Time.Split(':')[0]), Convert.ToInt32(entity.Time.Split(':')[1])), TimeZoneInfo.Local);
- }
- if (entity.BackupType == 1)
- {
- Enum.TryParse(entity.Week.ToString(), out DayOfWeek dayOfWeek);
- RecurringJob.AddOrUpdate(entity.Id,
- () => sys_DataBaseBackupSetIBLL.AutoBackUp(),
- Cron.Weekly(dayOfWeek, Convert.ToInt32(entity.Time.Split(':')[0]), Convert.ToInt32(entity.Time.Split(':')[1])),TimeZoneInfo.Local);
- }
- }
- return Success("保存成功!");
- }
- else
- {
- return Fail("已设置备份方式,只能设置一种备份方式!");
- }
- }
- catch (Exception e)
- {
- return Success("保存成功!");
- }
- }
- #endregion
-
- #region 扩展数据
-
- /// <summary>
- /// 获取周
- /// </summary>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetWeek()
- {
- var data = WebHelper.GenerateWeek();
- return Success(data);
- }
-
- #endregion
-
- }
- }
|