public void TestGetPrimaryMetadataForEveryone() { // Blow away excessive nychanis data. FastDAO <NycDatum> dataDao = new FastDAO <NycDatum>("PDP.Data", "NYCHANIS"); DaoCriteria crit = new DaoCriteria(); crit.Expressions.Add(new EqualExpression("IndicatorId", 201, false)); crit.Expressions.Add(new GreaterExpression("IndicatorId", 10)); dataDao.Delete(crit); // And also excessive PDB data. PdbTwoTableHelper helper = new PdbTwoTableHelper(Config.GetConfig("PDP.Data"), "Properties", PdbEntityType.Properties); DictionaryDao primaryPdbDao = new DictionaryDao( dataDao.ConnDesc, helper.GetClassMapForPrimaryTable(new SecurityRole[] { SecurityRole.@public })); FastDAO <PdbSecondaryTableProperty> secondaryPdbDao = new FastDAO <PdbSecondaryTableProperty>( dataDao.ConnDesc, helper.GetClassMapForSecondaryTable()); crit.Expressions.Clear(); crit.Expressions.Add(new GreaterExpression("UID", 100630)); primaryPdbDao.Delete(crit); crit.Expressions.Clear(); crit.Expressions.Add(new GreaterExpression("ForeignKey", 100630)); secondaryPdbDao.Delete(crit); }
protected override void InternalGET(System.Web.HttpContext context, HandlerTimedCache cache) { IList <SecurityRole> roles = UserHelper.GetUserRoles(context.User.Identity.Name); IList <IExpression> expressions = PropertiesHandler.ParseExpressions(context); PdbTwoTableHelper dataHelper = new PdbTwoTableHelper(Config.GetConfig("PDP.Data"), "Properties", PdbEntityType.Properties); // x and y are expected in web mercator. PdbResultLocations list = dataHelper.QueryForLocations(expressions, roles, WebUtil.ParseDoubleParam(context, "minx"), WebUtil.ParseDoubleParam(context, "maxx"), WebUtil.ParseDoubleParam(context, "miny"), WebUtil.ParseDoubleParam(context, "maxy"), WebUtil.ParseDoubleParam(context, "minBx"), WebUtil.ParseDoubleParam(context, "maxBx"), WebUtil.ParseDoubleParam(context, "minBy"), WebUtil.ParseDoubleParam(context, "maxBy")); context.Response.Write(WebUtil.ObjectToJson(list)); }
protected override void InternalGET(System.Web.HttpContext context, HandlerTimedCache cache) { var roles = UserHelper.GetUserRoles(context.User.Identity.Name); var dataHelper = new PdbTwoTableHelper(Config.GetConfig("PDP.Data"), "Properties"); var ids = new List <string>(); var id = WebUtil.GetParam(context, "id", true); if (id != null) { ids.Add(id); } else { var idList = WebUtil.GetParam(context, "ids", false); ids.AddRange(idList.Split(',')); } var list = dataHelper.Query(ids, roles); context.Response.Write(WebUtil.ObjectToJson(list)); }
protected override void InternalGET(HttpContext context, HandlerTimedCache cache) { IList <SecurityRole> roles = UserHelper.GetUserRoles(context.User.Identity.Name); //Get the paging parameters... int page = WebUtil.ParseIntParam(context, "page"); int pageSize = WebUtil.ParseIntParam(context, "pageSize"); // Check to see if this is a csv export request. Runs the normal query (with no paging). bool csv = false; WebUtil.ParseOptionalBoolParam(context, "csv", ref csv); // If this is csv, we want all data - override any paging if (csv) { page = -1; pageSize = -1; } IList <IExpression> expressions = ParseExpressions(context); // Now get the ordering parameters, if specified. int sortCol = -1; WebUtil.ParseOptionalIntParam(context, "sortBy", ref sortCol); SortType?sortDir = null; if (sortCol >= 0) { // Default is ascending sort, passing false means descending. bool ascending = true; WebUtil.ParseOptionalBoolParam(context, "sortasc", ref ascending); sortDir = ascending ? SortType.Asc : SortType.Desc; } PdbTwoTableHelper dataHelper = new PdbTwoTableHelper(Config.GetConfig("PDP.Data"), "Properties", PdbEntityType.Properties); // Now get the grouping parameters, if specified. IList <string> groupBys = WebUtil.GetJsonStringArrayParam(context, "groupby", true); PdbResultsWithMetadata list; if ((groupBys != null) && (groupBys.Count > 0)) { list = dataHelper.GroupedQuery(expressions, groupBys, sortCol, sortDir, roles, pageSize, page); } else { list = dataHelper.Query(expressions, sortCol, sortDir, roles, pageSize, page); } // If this was a csv request, format it and return it instead if (csv) { // Generate actual csv data, determine if this is groupby'd or not string export = dataHelper.ResultsAsCsv(list, ((groupBys != null) && (groupBys.Count > 0))); // Setup the response to handle this type of request context.Response.AddHeader("Content-Disposition", "attachment;filename=Furman_Center_SHIP_Properties.csv"); context.Response.ContentType = "text/csv"; context.Response.Write(export); return; } context.Response.Write(WebUtil.ObjectToJson(list)); }