private static ParaEntityList <T> RetrieveAllEntities <T>(ParaCredentials pc, ParaEntityQuery query) where T : ParaEntity, new() { ApiCallResponse ar; var entityList = new ParaEntityList <T>(); ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; var continueCalling = true; while (continueCalling) { if (entityList.TotalItems > entityList.Data.Count) { // We still need to pull data // Getting next page's data query.PageNumber = query.PageNumber + 1; ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { var objectlist = ParaEntityParser.FillList <T>(ar.XmlReceived); entityList.Data.AddRange(objectlist.Data); entityList.ResultsReturned = entityList.Data.Count; entityList.PageNumber = query.PageNumber; } else { // There is an error processing request entityList.ApiCallResponse = ar; continueCalling = false; } } else { // That is it, pulled all the items. continueCalling = false; entityList.ApiCallResponse = ar; } } return(entityList); }
/// <summary> /// Fills a main module's list object. /// </summary> internal static ParaEntityList <T> ApiGetEntityList <T>(ParaCredentials pc, ParaEntityQuery query) where T : ParaEntity, new() { var entityList = new ParaEntityList <T>(); // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { entityList = RetrieveAllEntities <T>(pc, query); } else { var ar = ApiCallFactory.ObjectGetList <T>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; } return(entityList); }