public ApiResultObject <List <ViewModuleRole> > GetViewResult(AasModuleRoleViewFilter filter) { ApiResultObject <List <ViewModuleRole> > result = null; try { bool valid = true; valid = valid && IsNotNull(param); valid = valid && IsNotNull(filter); List <ViewModuleRole> resultData = null; if (valid) { resultData = new ModuleRoleGet(param).GetView(filter); } result = this.PackResult(resultData); this.FailLog(result.Success, filter, result.Data); } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; result = null; } return(result); }
internal List <ViewModuleRole> GetView(AasModuleRoleViewFilter filter) { try { StringBuilder sb = new StringBuilder().Append("SELECT * FROM \"ViewModuleRole\""); string query = this.GetFilterQuery(filter); if (String.IsNullOrWhiteSpace(query)) { sb.Append(String.Format(" WHERE {0}", query)); } if (!String.IsNullOrWhiteSpace(filter.OrderDirection) && !String.IsNullOrWhiteSpace(filter.OrderField)) { sb.Append(String.Format(" ORDER BY \"{0}\" {1}", filter.OrderField, filter.OrderDirection)); if (param.Limit.HasValue && param.Start.HasValue) { sb.Append(String.Format(" LIMIT {0} OFFSET {1}", param.Limit.Value, param.Start.Value)); } } string sqlQuery = sb.ToString(); return(DAOWorker.SqlDAO.GetSql <ViewModuleRole>(sqlQuery)); } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; return(null); } }
public List <ViewModuleRole> GetView(AasModuleRoleViewFilter filter) { List <ViewModuleRole> result = null; try { result = new ModuleRoleGet(param).GetView(filter); } catch (Exception ex) { LogSystem.Error(ex); param.HasException = true; result = null; } return(result); }
private string GetFilterQuery(AasModuleRoleViewFilter filter) { StringBuilder sbFilter = new StringBuilder(); bool addAnd = false; if (filter.Id.HasValue) { sbFilter.Append(String.Format(" \"ID\" = {0}", filter.Id.Value)); addAnd = true; } if (filter.IsActive.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"IsActive\" = {0}", filter.IsActive.Value)); } else { sbFilter.Append(String.Format(" \"IsActive\" = {0}", filter.IsActive.Value)); addAnd = true; } } if (filter.ApplicationId.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ApplicationId\" = {0}", filter.ApplicationId.Value)); } else { sbFilter.Append(String.Format(" \"ApplicationId\" = {0}", filter.ApplicationId.Value)); addAnd = true; } } if (filter.RoleId.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"RoleId\" = {0}", filter.RoleId.Value)); } else { sbFilter.Append(String.Format(" \"RoleId\" = {0}", filter.RoleId.Value)); addAnd = true; } } if (filter.CreateTimeFrom.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"CreateTime\" >= {0}", filter.CreateTimeFrom.Value)); } else { sbFilter.Append(String.Format(" \"CreateTime\" >= {0}", filter.CreateTimeFrom.Value)); addAnd = true; } } if (filter.CreateTimeTo.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"CreateTime\" <= {0}", filter.CreateTimeTo.Value)); } else { sbFilter.Append(String.Format(" \"CreateTime\" <= {0}", filter.CreateTimeTo.Value)); addAnd = true; } } if (filter.CreateTimeFromGreater.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"CreateTime\" > {0}", filter.CreateTimeFromGreater.Value)); } else { sbFilter.Append(String.Format(" \"CreateTime\" > {0}", filter.CreateTimeFromGreater.Value)); addAnd = true; } } if (filter.CreateTimeToLess.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"CreateTime\" < {0}", filter.CreateTimeToLess.Value)); } else { sbFilter.Append(String.Format(" \"CreateTime\" < {0}", filter.CreateTimeToLess.Value)); addAnd = true; } } if (!String.IsNullOrWhiteSpace(filter.Creator)) { if (addAnd) { sbFilter.Append(String.Format(" AND \"Creator\" = {0}", filter.Creator)); } else { sbFilter.Append(String.Format(" \"Creator\" = {0}", filter.Creator)); addAnd = true; } } if (!String.IsNullOrWhiteSpace(filter.Modifier)) { if (addAnd) { sbFilter.Append(String.Format(" AND \"Modifier\" = {0}", filter.Modifier)); } else { sbFilter.Append(String.Format(" \"Modifier\" = {0}", filter.Modifier)); addAnd = true; } } if (filter.ModifyTimeFrom.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ModifyTime\" >= {0}", filter.ModifyTimeFrom.Value)); } else { sbFilter.Append(String.Format(" \"ModifyTime\" >= {0}", filter.ModifyTimeFrom.Value)); addAnd = true; } } if (filter.ModifyTimeTo.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ModifyTime\" <= {0}", filter.ModifyTimeTo.Value)); } else { sbFilter.Append(String.Format(" \"ModifyTime\" <= {0}", filter.ModifyTimeTo.Value)); addAnd = true; } } if (filter.ModifyTimeFromGreater.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ModifyTime\" = {0}", filter.ModifyTimeFromGreater.Value)); } else { sbFilter.Append(String.Format(" \"ModifyTime\" = {0}", filter.ModifyTimeFromGreater.Value)); addAnd = true; } } if (filter.ModifyTimeToLess.HasValue) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ModifyTime\" < {0}", filter.ModifyTimeToLess.Value)); } else { sbFilter.Append(String.Format(" \"ModifyTime\" < {0}", filter.ModifyTimeToLess.Value)); addAnd = true; } } if (filter.ApplicationIds != null) { string addIn = DAOWorker.SqlDAO.AddInClause(filter.ApplicationIds, " {IN_CLAUSE}", "\"ApplicationId\""); if (addAnd) { sbFilter.Append(String.Format(" AND {0}", addIn)); } else { sbFilter.Append(String.Format(" {0}", addIn)); addAnd = true; } } if (filter.Ids != null) { string addIn = DAOWorker.SqlDAO.AddInClause(filter.Ids, " {IN_CLAUSE}", "\"Id\""); if (addAnd) { sbFilter.Append(String.Format(" AND {0}", addIn)); } else { sbFilter.Append(String.Format(" {0}", addIn)); addAnd = true; } } if (filter.RoleIds != null) { string addIn = DAOWorker.SqlDAO.AddInClause(filter.RoleIds, " {IN_CLAUSE}", "\"RoleId\""); if (addAnd) { sbFilter.Append(String.Format(" AND {0}", addIn)); } else { sbFilter.Append(String.Format(" {0}", addIn)); addAnd = true; } } if (!String.IsNullOrWhiteSpace(filter.ModuleCodeExact)) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ModuleCode\" = '{0}'", filter.ModuleCodeExact)); } else { sbFilter.Append(String.Format(" \"ModuleCode\" = '{0}'", filter.ModuleCodeExact)); addAnd = true; } } if (!String.IsNullOrWhiteSpace(filter.ApplicationCodeExact)) { if (addAnd) { sbFilter.Append(String.Format(" AND \"ApplicationCode\" = '{0}'", filter.ApplicationCodeExact)); } else { sbFilter.Append(String.Format(" \"ApplicationCode\" = '{0}'", filter.ApplicationCodeExact)); addAnd = true; } } if (!String.IsNullOrWhiteSpace(filter.RoleCodeExact)) { if (addAnd) { sbFilter.Append(String.Format(" AND \"RoleCode\" = '{0}'", filter.RoleCodeExact)); } else { sbFilter.Append(String.Format(" \"RoleCode\" = '{0}'", filter.RoleCodeExact)); addAnd = true; } } if (!String.IsNullOrWhiteSpace(filter.KeyWord)) { string key = filter.KeyWord.Trim(); if (addAnd) { sbFilter.Append(String.Format(" AND ( \"Creator\" ILIKE '%{0}'", key)) .Append(String.Format(" OR \"Modifier\" ILIKE '%{0}'", key)) .Append(String.Format(" OR \"ApplicationCode\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"ApplicationName\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"ModuleCode\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"ModuleName\" ILIKE '%{0}%' )", key)) .Append(String.Format(" OR \"RoleCode\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"RoleName\" ILIKE '%{0}%' )", key)); } else { sbFilter.Append(String.Format(" ( \"Creator\" ILIKE '%{0}'", key)) .Append(String.Format(" OR \"Modifier\" ILIKE '%{0}'", key)) .Append(String.Format(" OR \"ApplicationCode\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"ApplicationName\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"ModuleCode\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"ModuleName\" ILIKE '%{0}%' )", key)) .Append(String.Format(" OR \"RoleCode\" ILIKE '%{0}%'", key)) .Append(String.Format(" OR \"RoleName\" ILIKE '%{0}%' )", key)); } } return(sbFilter.ToString()); }