using learun.iapplication; using learun.util; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; namespace learun.application { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.11.01 /// 描 述:任务计划模板信息 /// public class TSSchemeService : ServiceBase { #region 获取数据 /// /// 获取页面显示列表数据 /// /// 分页参数 /// 查询参数 /// public Task> GetPageList(Pagination pagination, string queryJson) { var strSql = new StringBuilder(); strSql.Append(@" SELECT t.F_Id, t.F_Name, t.F_Description, t.F_IsActive, t.F_BeginTime, t.F_EndType, t.F_EndTime FROM LR_TS_SchemeInfo t "); strSql.Append(" WHERE 1=1 "); var queryParam = queryJson.ToJObject(); string keyWord = ""; if (!queryParam["keyWord"].IsEmpty()) { keyWord = "%" + queryParam["keyWord"].ToString() + "%"; strSql.Append(" AND t.F_Name like @keyWord "); } return this.BaseRepository().FindList(strSql.ToString(), new { keyWord }, pagination); } /// /// 获取所有启用的任务 /// /// public Task> GetList() { var strSql = new StringBuilder(); strSql.Append(@" SELECT t.F_Id, t.F_Name, t.F_IsActive, t.F_BeginTime, t.F_EndType, t.F_EndTime, t.F_Description, t.F_Scheme FROM LR_TS_SchemeInfo t "); strSql.Append(" WHERE t.F_IsActive = 1 "); return this.BaseRepository().FindList(strSql.ToString()); } /// /// 获取表实体数据 /// /// 主键 /// public Task GetSchemeInfoEntity(string keyValue) { return this.BaseRepository().FindEntityByKey(keyValue); } #endregion 获取数据 #region 提交数据 /// /// 删除实体数据 /// /// 主键 /// public async Task DeleteEntity(string keyValue) { await this.BaseRepository().DeleteAny(new { F_Id = keyValue }); } /// /// 保存实体数据(新增、修改) /// /// 主键 /// 实体数据 /// public async Task SaveEntity(string keyValue, TSSchemeInfoEntity entity) { TSSchemeModel model = entity.F_Scheme.ToObject(); if (model.startType == 1) { entity.F_BeginTime = DateTime.Now; } else { entity.F_BeginTime = model.startTime; } entity.F_EndType = model.endType; if (model.endType == 1) { entity.F_EndTime = DateTime.MaxValue.AddDays(-1); } else { entity.F_EndTime = model.endTime; } if (!string.IsNullOrEmpty(keyValue)) { entity.F_Id = keyValue; await this.BaseRepository().Update(entity); } else { entity.F_Id = Guid.NewGuid().ToString(); entity.F_IsActive = 1; await this.BaseRepository().Insert(entity); } } /// /// 更新实体数据 /// /// /// /// public async Task UpdateEntity(string keyValue, TSSchemeInfoEntity entity) { entity.F_Id = keyValue; await this.BaseRepository().Update(entity); } #endregion 提交数据 #region 执行sql语句和存储过程 /// /// 执行sql语句 /// /// 数据库编码 /// sql语句 /// public async Task ExecuteBySql(string code, string sql) { await this.BaseRepository(code).ExecuteSql(sql); } /// /// 执行存储过程 /// /// 数据库编码 /// 名称 /// public async Task ExecuteProc(string code, string name) { await this.BaseRepository(code).ExecuteProc(name); } #endregion 执行sql语句和存储过程 } }