public override ActionResult GetTreeGridJson(string keyword, string searchFiled, string list, string orderBy = " ORDER BY F_SortCode ") { string[] classnameList = typeof(Mst_PositionInfo).ToString().Split('.'); string condition = ""; if (string.IsNullOrEmpty(list)) { condition = GetKeywordCondition(keyword, searchFiled); } else { condition = GetAdvCondition(JsonConvert.DeserializeObject <List <AdvSearchEntity> >(list)); } TreeInfoEntity entity = new TreeInfoEntity(); entity.F_Condition = string.IsNullOrEmpty(condition) ? string.Empty : " AND " + condition; entity.F_CType = 1; entity.F_KeyFiled = "F_Id"; entity.F_ParentFiled = "F_ParentId"; entity.F_SortCode = orderBy; entity.F_TableName = classnameList[classnameList.Length - 1].Replace("Info", string.Empty); var dt = BLLFactory <AppCommon> .Instance.GetTreeInfo(entity); //baseBLL.Find(condition, orderBy); string dataStr = JsonAppHelper.ToJson(dt); var data = JsonAppHelper.ToList <Mst_PositionInfo>(dataStr); foreach (var item in data) { string name = BLLFactory <Mst_Warehouse> .Instance.FindByID(item.F_WarehouseId).F_FullName; item.F_WarehouseName = string.IsNullOrEmpty(name) ? "" : name; } return(Content(GetTreeGridJsonStr(data))); }
/// <summary> /// 获取分页对象 /// </summary> /// <typeparam name="E">需要返回的集合泛型</typeparam> /// <param name="dt">数据集合datatable</param> /// <param name="recordcount">记录总数</param> /// <param name="pager">分页对象 为空时,不分页返回</param> /// <returns></returns> protected virtual Task <PagerDataEntity <E> > GetPagerDataAysnc <E>(DataTable dt, int recordcount, PagerInfo pager) { return(Task.Run(() => { int total = 0; //总页数 int recordCount = 0; //总记录数 if (pager == null) { //不分页处理 total = -1; recordCount = dt.Rows.Count; } else { //分页处理 total = recordcount / pager.PageSize == 0 ? 1 : (recordcount % pager.PageSize == 0 ? recordcount / pager.PageSize : recordcount / pager.PageSize + 1); recordCount = recordcount; } var data = new PagerDataEntity <E> { rows = JsonAppHelper.ToList <E>(dt), total = total, page = -1, records = recordCount }; return data; })); }
/// <summary> /// 获取分页对象 /// </summary> /// <typeparam name="E">需要返回的集合泛型</typeparam> /// <param name="ds">使用SQL Server分页存储过程后返回的对象</param> /// <param name="pager">分页对象 为空时,不分页返回</param> /// <returns></returns> protected virtual Task <PagerDataEntity <E> > GetPagerDataAsync <E>(DataSet ds, PagerInfo pager) { return(Task.Run(() => { int dataIndex = 0; //数据Index int total = 0; //总页数 int recordCount = 0; //总记录数 if (pager == null) { //不分页处理 total = -1; recordCount = ds.Tables[0].Rows.Count; } else { //分页处理 dataIndex = 1; total = Convert.ToInt32(ds.Tables[2].Rows[0]["pagecount"]); recordCount = Convert.ToInt32(ds.Tables[2].Rows[0]["recordcount"]); } var data = new PagerDataEntity <E> { rows = JsonAppHelper.ToList <E>(ds.Tables[dataIndex]), total = total, page = -1, records = recordCount }; return data; })); }
/// <summary> /// 对用户登录的操作进行验证 /// </summary> /// <param name="username">用户账号</param> /// <param name="password">用户密码</param> /// <returns></returns> private CommonResult CheckUserInfo(string username, string password) { CommonResult result = new CommonResult(); try { if (string.IsNullOrEmpty(username)) { result.Success = false; result.ErrorMessage = "用户名不能为空"; } else { LoginModel model = new LoginModel(); model.Account = username; model.Password = DESEncrypt.Encrypt(password); model.LoginSystem = ""; model.IPAddress = Net.Ip; model.IPAddressName = Net.GetLocation(model.IPAddress); DataSet ds = BLLFactory <Sys_User> .Instance.LoginSystem(model); if (Convert.ToBoolean(ds.Tables[0].Rows[0]["bSuccess"])) { result.Success = true; result.Message = JsonHelper.ToJson(ds); Session["UserInfo"] = JsonAppHelper.ToList <Sys_UserInfo>(JsonAppHelper.ToJson(ds.Tables[0]))[0]; } else { result.Success = false; result.ErrorMessage = ds.Tables[0].Rows[0]["errorMessage"].ToString(); } } } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.ToString(); } return(result); }