AHSerListResult IAuthHisMgtSer.GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, AuthorizedHistoryVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter) { try { //Restore Server Session RetrieveServerSideSession(entity_WCFAuthInfoVM); bool ret = false; List <string> strList_Error = new List <string>(); AHSerListResult returnResult = new AHSerListResult(); CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext(); AuthorizedHistoryRespository entityRepos_AH = new AuthorizedHistoryRespository(dbContext, entity_BaseSession.ID); #region [ Check Privilege ] ret = CheckAccPrivilege(entity_BaseSession.ID, entity_WCFAuthInfoVM.RequestFunKey, entity_WCFAuthInfoVM.RequestFunTypeKey, ref strList_Error); #endregion returnResult.StrList_Error = strList_Error; returnResult.Int_TotalRecordCount = 0; returnResult.EntityList_AuthorizedHistoryVM = new List <AuthorizedHistoryVM>(); if (ret) { int recordCount = 0; List <AuthorizedHistoryVM> vmList = entityRepos_AH.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, (entityList) => { List <AuthorizedHistory> entityList_AuthorizedHistory = new List <AuthorizedHistory>(); if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.LoginName)) { DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext_Temp => { List <LUser> entityList_LUser = dbContext_Temp.LUsers.Where(current => current.LU_Name.IndexOf(entity_SearchCriteria.LoginName) == 0).ToList(); if (entityList_LUser != null && entityList_LUser.Count > 0) { List <Guid> guidList_UserID = entityList_LUser.Select(current => current.ID).ToList(); entityList_AuthorizedHistory = entityList.Where(current => guidList_UserID.Contains(current.AH_UserID) && (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OperationType) ? current.AH_EventType == entity_SearchCriteria.OperationType : true)).ToList(); } }); } else { DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext_Temp => { entityList_AuthorizedHistory = entityList.Where(current => !string.IsNullOrWhiteSpace(entity_SearchCriteria.OperationType) ? current.AH_EventType == entity_SearchCriteria.OperationType : true).ToList(); }); } return(entityList_AuthorizedHistory); }, null, (entityList) => { List <Guid> userIDList = entityList.Select(current => current.LoginUserID).ToList(); List <LUser> entityList_LUser_GetLoginName = new List <LUser>(); DBContextHelper.ExecuteSearchEvent(CoolPrivilegeControlContext.CreateContext(), dbContext_Temp => { entityList_LUser_GetLoginName = dbContext_Temp.LUsers.Where(current => userIDList.Contains(current.ID)).ToList(); }); foreach (var item in entityList) { var item_LUser = entityList_LUser_GetLoginName.Where(current => current.ID == item.LoginUserID).FirstOrDefault(); if (item_LUser != null) { item.LoginName = item_LUser.LU_Name; } if (item.OperationType == OperationType.L.ToString()) { item.OperationTypeName = MultilingualHelper.GetStringFromResource(languageKey, "Login"); } else if (item.OperationType == OperationType.O.ToString()) { item.OperationTypeName = MultilingualHelper.GetStringFromResource(languageKey, "Logout"); } } return(entityList); }); returnResult.EntityList_AuthorizedHistoryVM = vmList; returnResult.Int_TotalRecordCount = recordCount; } return(returnResult); } catch (Exception ex) { throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message); } }