using Learun.Application.Base.SystemModule;
using Learun.Util;
using System.Web.Mvc;
namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2017.04.01
/// 描 述:数据源管理
///
public class DataSourceController : MvcControllerBase
{
DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
#region 获取视图
///
/// 管理页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 表单页面
///
///
[HttpGet]
public ActionResult Form()
{
return View();
}
///
/// 测试页面
///
///
[HttpGet]
public ActionResult TestForm()
{
return View();
}
///
/// 选择页面
///
///
[HttpGet]
public ActionResult SelectForm()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取分页数据
///
/// 分页参数
/// 关键字
///
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string keyword)
{
Pagination paginationobj = pagination.ToObject();
var data = dataSourceIBLL.GetPageList(paginationobj, keyword);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records,
};
return JsonResult(jsonData);
}
///
/// 获取所有数据源数据列表
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetList()
{
var data = dataSourceIBLL.GetList();
return JsonResult(data);
}
///
/// 获取所有数据源实体根据编号
///
/// 编号
///
[HttpGet]
[AjaxOnly]
public ActionResult GetEntityByCode(string keyValue)
{
if (string.IsNullOrEmpty(keyValue))
{
return Success("");
}
else
{
var data = dataSourceIBLL.GetEntityByCode(keyValue.Split(',')[0]);
return JsonResult(data);
}
}
///
/// 获取所有数据源实体根据编号
///
/// 编号
///
[HttpGet]
[AjaxOnly]
public ActionResult GetNameByCode(string keyValue)
{
if (string.IsNullOrEmpty(keyValue))
{
return SuccessString("");
}
else
{
var data = dataSourceIBLL.GetEntityByCode(keyValue.Split(',')[0]);
if (data != null)
{
return SuccessString(data.F_Name);
}
else
{
return SuccessString("");
}
}
}
#endregion
#region 提交数据
///
/// 保存表单数据
///
/// 主键
/// 实体
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, DataSourceEntity entity)
{
bool res = dataSourceIBLL.SaveEntity(keyValue, entity);
if (res)
{
return Success("保存成功!");
}
else
{
return Fail("保存失败,编码重复!");
}
}
///
/// 删除表单数据
///
/// 主键
///
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
dataSourceIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
#endregion
#region 扩展方法
///
/// 获取数据源数据
///
/// 数据源编号
/// sql查询条件语句
/// 数据源请求条件字串
///
[HttpGet]
[AjaxOnly]
public ActionResult GetDataTable(string code, string strWhere, string queryJson)
{
var data = dataSourceIBLL.GetDataTable(code, strWhere, queryJson);
return JsonResult(data);
}
///
/// 获取数据源数据
///
/// 分页参数
/// 数据源编号
/// sql查询条件语句
/// 数据源请求条件字串
///
[HttpGet]
[AjaxOnly]
public ActionResult GetDataTablePage(string pagination, string code, string strWhere, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = dataSourceIBLL.GetDataTable(code, paginationobj, strWhere, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records,
};
return JsonResult(jsonData);
}
///
/// 获取数据源列名
///
/// 数据源编码
///
[HttpGet]
[AjaxOnly]
public ActionResult GetDataColName(string code)
{
var data = dataSourceIBLL.GetDataColName(code);
return JsonResult(data);
}
///
/// 获取数据源数据
///
/// 数据源编号
/// sql查询条件语句
/// 数据源请求条件字串
///
[HttpGet]
[AjaxOnly]
public ActionResult GetMap(string code, string ver)
{
var data = dataSourceIBLL.GetDataTable(code, "");
string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
if (md5 == ver)
{
return Success("no update");
}
else
{
var jsondata = new
{
data = data,
ver = md5
};
return JsonResult(jsondata);
}
}
///
/// 获取表单数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetTree(string code, string parentId, string Id, string showId)
{
var data = dataSourceIBLL.GetTree(code, parentId, Id, showId);
return JsonResult(data);
}
#endregion
}
}