public IQueryable <TEntity> GenerateGetDataQuery <TEntity>(DataServiceModel oDSM, bool recoredLevelControl) where TEntity : class { #region Get data var DALContainer = new EFDALContainer(); //IQueryable<TEntity> query = LVHubsHelper.GetDataInHubs<TEntity>(DALContainer.Repository); //if(query == null) IQueryable <TEntity> query = DALContainer.Repository.GetQuery <TEntity>(oDSM.TableInclue); if (!String.IsNullOrWhiteSpace(oDSM.PredicateFavorite)) { query = query.Where(oDSM.PredicateFavorite); } if (!String.IsNullOrWhiteSpace(oDSM.Predicate)) { if (oDSM.Predicate.IndexOf("Nullable_") >= 0) { Guid nullGuid = Guid.Parse(oDSM.DataValue[0].ToString()); query = query.Where(oDSM.Predicate.Replace("Nullable_", "") + ".Value.Equals(@0)", nullGuid); } else { query = query.Where(oDSM.Predicate, oDSM.DataValue); } } if (!String.IsNullOrWhiteSpace(oDSM.PredicateQuickSearch) && oDSM.DataValueQuick != null) { query = query.Where(oDSM.PredicateQuickSearch, oDSM.DataValueQuick); } if (oDSM.Predicates != null && oDSM.DataValues != null) { for (int i = 0; i < oDSM.Predicates.Count; i++) { object[] oDataValue = null; if (oDSM.DataValues.Count > i) { oDataValue = oDSM.DataValues[i]; } query = query.Where(oDSM.Predicates[i], oDataValue); } } #endregion return(query); }
public async Task <object[]> GetDataPagingLogicAsync <TEntity>(DataServiceModel oDSM) where TEntity : class { TEntity[] listData = new TEntity[0]; string entityName = typeof(TEntity).Name; IQueryable <TEntity> query = GenerateGetDataQuery <TEntity>(oDSM, false); query = GenerateSortOrder(query, oDSM.SortColumns, oDSM.SortDirections); int total = query.Distinct().Count(); query = System.Linq.Queryable.Skip(query, oDSM.PageNum); query = System.Linq.Queryable.Take(query, oDSM.PageSize); Task <TEntity[]> task = query.Distinct().ToArrayAsync(); listData = await task; EFDALContainer d = new EFDALContainer(); return(new object[] { listData, total }); }
private string LoginUserLogic(string username, string password, out DatabaseInfo dbInfo, out LVLoginUser user) { dbInfo = null; user = null; try { EFDALContainer dal = new EFDALContainer(); dbInfo = dal.CreateDefaultDatabase(); var dalSchema = new EFDALContainer(dbInfo); string AccountNameEmailAddress = username; string AccountPwd = password; var objName = new object[] { "AccountNameEmailAddress", "AccountPwd" }; var objValue = new object[] { AccountNameEmailAddress, AccountPwd }; var result = this.Repository.ExecuteStoreScalar("usp_Login", objName, objValue); string ReturnCode = string.Empty; string a = LV.Service.Common.JsonConverter.DataSetToJson(result); var userAccount = new UserAccount(); if (result != null && result.Tables.Count > 0) { foreach (DataRow item in result.Tables[0].Rows) { ReturnCode = item["ReturnCode"].ToString(); if (ReturnCode == "0") { userAccount.AccountNameEmailAddress = item["AccountNameEmailAddress"].ToString(); userAccount.V_AccountType = Convert.ToInt64(item["V_AccountType"].ToString()); userAccount.AccountID = Convert.ToInt64(item["AccountID"].ToString()); userAccount.AccountPwd = item["AccountPwd"].ToString(); userAccount.PersonID = Convert.ToInt64(item["PersonID"].ToString()); userAccount.PrimaryRoleID = item["PrimaryRoleID"] == null ? 0 : Convert.ToInt64(item["PrimaryRoleID"].ToString()); userAccount.RoleName = item["RoleName"] == null ? "" : item["RoleName"].ToString(); } else { return(item["ReturnCode"].ToString()); } } } var obj = new object[1] { userAccount.AccountID }; if (userAccount != null) { user = new LVLoginUser(); //if (userAccount.V_AccountType == 7303 || userAccount.V_AccountType == 7302 ) //{ long V_PersonType = 0; if (userAccount.V_AccountType == 7303) { V_PersonType = 5200; } else if (userAccount.V_AccountType == 7302) { V_PersonType = 5201; } else if (userAccount.V_AccountType == 7301) { V_PersonType = 5200; } var objparam = new object[] { "PersonID", "V_PersonType" }; var objvalue = new object[] { userAccount.PersonID, V_PersonType.ToString() }; var Employees = this.Repository.ExecuteStoreScalar("usp_GetInforPerson", objparam, objvalue); var Employee = new Employee(); if (Employees.Tables.Count > 0) { foreach (DataRow item in Employees.Tables[0].Rows) { user.account = userAccount; user.PersName = item["PersName"] == null ? "" : item["PersName"].ToString(); user.FirstName = item["FirstName"] == null? "": item["FirstName"].ToString(); user.ProfilePhoto = item["ProfilePhoto"] == null? "" : item["ProfilePhoto"].ToString(); user.Email = username; user.UserCode = item["EmpCode"] == null ? "": item["EmpCode"].ToString(); user.EmpID = item["EmpID"] == null ? "" : item["EmpID"].ToString(); user.PersonID = item["PersonID"] == null ? "" : item["PersonID"].ToString(); user.Type = userAccount.V_AccountType.ToString(); } } //} user.DatabaseInfo = dbInfo; } return(ReturnCode); } catch (Exception ex) { log.Error(ex.Message); return("4"); } }