public ExecResult DelDict(DictQuery query) { ExecResult execResult = new ExecResult(); IDictService service = ServiceContainer.Instance.Container.Resolve<IDictService>(); IList<Int64> dictIDs = query.DictIDs.ToList(); if (dictIDs == null) { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "没有删除任何数据!"; return execResult; } string msg = string.Empty; IList<Int64> list = service.BatchDeleteDict(dictIDs); if (list == null || list.Count < dictIDs.Count) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "删除数据字典成功!"; if (list != null && list.Count > 0) execResult.msg += string.Format("部分编号[{0}]由于存在数据字典值,请先删除", string.Join(",", list)); } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "删除数据字典失败!"; } return execResult; }
public ActionResult Delete(Int64[] dictIDs) { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); DictQuery query = new DictQuery(); query.JournalID = CurAuthor.JournalID; query.DictIDs = dictIDs; ExecResult result = service.DelDict(query); return Json(new { result = result.result, msg = result.msg }); }
public ActionResult GetDictPageList(DictQuery query) { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); query.JournalID = CurAuthor.JournalID; query.CurrentPage = Convert.ToInt32(Request.Params["page"]); query.PageSize = Convert.ToInt32(Request.Params["pagesize"]); Pager<DictEntity> pager = service.GetDictPageList(query); return Json(new { Rows = pager.ItemList, Total = pager.TotalRecords }); }
public ActionResult Create(Int64 dictId = 0) { DictEntity model=null; if (dictId > 0) { DictQuery query = new DictQuery(); query.JournalID = CurAuthor.JournalID; query.DictID = dictId; ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model = service.GetDictModel(query); } if (model == null) model = new DictEntity(); return View(model); }
/// <summary> /// 获取所有符合查询条件的数据 /// </summary> /// <param name="dictQuery">DictQuery查询实体对象</param> /// <returns>List<DictEntity></returns> public List<DictEntity> GetDictList(DictQuery dictQuery) { return DictDataAccess.Instance.GetDictList(dictQuery); }
public DictEntity GetDictModel(DictQuery query) { IDictService service = ServiceContainer.Instance.Container.Resolve<IDictService>(); DictEntity model = service.GetDict(query.DictID); return model; }
public Pager<DictEntity> GetDictPageList(DictQuery query) { IDictService service = ServiceContainer.Instance.Container.Resolve<IDictService>(); Pager<DictEntity> pager = service.GetDictPageList(query); return pager; }
public DictEntity GetDictModelByKey(DictQuery query) { IDictService service = ServiceContainer.Instance.Container.Resolve<IDictService>(); DictEntity model = service.GetDictByKey(query.DictKey,query.JournalID); return model; }
/// <summary> /// 分页获取符合查询条件的数据 /// </summary> /// <param name="dictQuery">DictQuery查询实体对象</param> /// <returns>Pager<DictEntity></returns> public Pager<DictEntity> GetDictPageList(DictQuery dictQuery) { Pager<DictEntity> pager = DictBusProvider.GetDictPageList(dictQuery); if (pager != null) pager.ItemList = GetDictList(pager.ItemList.ToList(), dictQuery); return pager; }
public List<DictEntity> GetDictList(DictQuery query) { List<DictEntity> list = new List<DictEntity>(); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("SELECT DictID,JournalID,DictKey,Note,InUserID,EditUserID,EditDate,AddDate FROM dbo.Dict WITH(NOLOCK)"); string whereSQL = DictQueryToSQLWhere(query); string orderBy=DictQueryToSQLOrder(query); if(!string.IsNullOrEmpty(whereSQL)) sqlCommandText.Append(" WHERE " + whereSQL); if(!string.IsNullOrEmpty(orderBy)) sqlCommandText.Append(" ORDER BY " + orderBy); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); using(IDataReader dr = db.ExecuteReader(cmd)) { list = MakeDictList(dr); } return list; }
/// <summary> /// 将查询实体转换为Where语句 /// <param name="query">查询实体</param> /// <returns>获取Where语句,不包含Where</returns> /// </summary> public string DictQueryToSQLWhere(DictQuery query) { if (query.JournalID > 0) return " JournalID=" + query.JournalID; return string.Empty; }
/// <summary> /// 将查询实体转换为Order语句 /// <param name="query">查询实体</param> /// <returns>获取Order语句,不包含Order</returns> /// </summary> public string DictQueryToSQLOrder(DictQuery query) { return " DictID DESC"; }
/// <summary> /// 删除数据字典 /// </summary> /// <param name="query"></param> /// <returns></returns> public ExecResult DelDict(DictQuery query) { HttpClientHelper clientHelper = new HttpClientHelper(); ExecResult result = clientHelper.Post<ExecResult, DictQuery>(GetAPIUrl(APIConstant.DICT_DELETE), query); return result; }
/// <summary> /// 获取数据字典分页数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public Pager<DictEntity> GetDictPageList(DictQuery query) { HttpClientHelper clientHelper = new HttpClientHelper(); Pager<DictEntity> pager = clientHelper.Post<Pager<DictEntity>, DictQuery>(GetAPIUrl(APIConstant.DICT_GETPAGELIST), query); return pager; }
public DictEntity GetDictModelByKey(DictQuery query) { HttpClientHelper clientHelper = new HttpClientHelper(); DictEntity model = clientHelper.Post<DictEntity, DictQuery>(GetAPIUrl(APIConstant.DICT_GETMODELBYKEY), query); return model; }
/// <summary> /// 组装数据 /// </summary> /// <param name="list"></param> /// <returns></returns> private List<DictEntity> GetDictList(List<DictEntity> list, DictQuery dictQuery) { if (list == null || list.Count == 0) return list; AuthorInfoService service = new AuthorInfoService(); AuthorInfoQuery query=new AuthorInfoQuery(); query.JournalID=dictQuery.JournalID; var dict = service.AuthorInfoBusProvider.GetAuthorDict(query); foreach (var mode in list) { mode.InUserName = dict.GetValue(mode.InUserID, mode.InUserID.ToString()); } return list; }
public Pager<DictEntity> GetDictPageList(DictQuery query) { string strSql = "SELECT DictID,JournalID,DictKey,Note,InUserID,EditUserID,EditDate,AddDate,ROW_NUMBER() OVER(ORDER BY DictID DESC) AS ROW_ID FROM dbo.Dict with(nolock)", sumStr="SELECT RecordCount=COUNT(1) FROM dbo.Dict with(nolock)"; string whereSQL=DictQueryToSQLWhere(query); if(!string.IsNullOrWhiteSpace(whereSQL)) { strSql+=" WHERE "+whereSQL; sumStr+=" WHERE "+whereSQL; } return db.GetPageList<DictEntity>(string.Format(SQL_Page_Select, strSql, query.StartIndex, query.EndIndex) , sumStr , query.CurrentPage, query.PageSize , (dr, pager) => { pager.TotalRecords = TypeParse.ToLong(dr["RecordCount"]); } , MakeDictList); }
/// <summary> /// 获取所有符合查询条件的数据 /// </summary> /// <param name="dictQuery">DictQuery查询实体对象</param> /// <returns>List<DictEntity></returns> public List<DictEntity> GetDictList(DictQuery dictQuery) { return GetDictList(DictBusProvider.GetDictList(dictQuery), dictQuery); }