/// <summary> /// Fills a Role list object /// </summary> /// <param name="creds"></param> /// <param name="query"></param> /// <param name="module"></param> /// <param name="entity"></param> /// <returns></returns> internal static ParaEntityList <TEntity> ApiGetEntityList <TModule, TEntity>(ParaCredentials creds, ParaQuery query) where TModule : ParaEntity where TEntity : ParaEntityBaseProperties { var rolesList = new ParaEntityList <TEntity>(); var ar = ApiCallFactory.ObjectSecondLevelGetList <TModule, TEntity>(creds, query.BuildQueryArguments()); if (ar.HasException == false) { //...Customer/status is sending "entities" not "Entities", which breaks the parser. Unwind and fix the XML var xmlStr = ar.XmlReceived.OuterXml; if (xmlStr.Contains("<entities")) { xmlStr = xmlStr.Replace("<entities", "<Entities"); xmlStr = xmlStr.Replace("entities>", "Entities>"); ar.XmlReceived = ParseXmlDoc(xmlStr); } rolesList = ParaEntityParser.FillList <TEntity>(ar.XmlReceived); } rolesList.ApiCallResponse = ar; // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { var continueCalling = true; while (continueCalling) { if (rolesList.TotalItems > rolesList.Data.Count) { // We still need to pull data // Getting next page's data query.PageNumber = query.PageNumber + 1; ar = ApiCallFactory.ObjectSecondLevelGetList <TModule, TEntity>(creds, query.BuildQueryArguments()); var objectlist = ParaEntityParser.FillList <TEntity>(ar.XmlReceived); if (objectlist.Data.Count == 0) { continueCalling = false; } rolesList.Data.AddRange(objectlist.Data); rolesList.ResultsReturned = rolesList.Data.Count; rolesList.PageNumber = query.PageNumber; } else { // That is it, pulled all the items. continueCalling = false; rolesList.ApiCallResponse = ar; } } } return(rolesList); }
/// <summary> /// Returns an view list object from a XML Document. No calls to the APIs are made when calling this method. /// </summary> /// <typeparam name="TEntity">The entity type to return</typeparam> /// <param name="xml">The view List XML; it should follow the exact template of the XML returned by the Parature APIs.</param> /// <returns></returns> public ParaEntityList <TEntity> GetList <TEntity>(XmlDocument xml) where TEntity : ParaEntityBaseProperties, new() { var list = ParaEntityParser.FillList <TEntity>(xml); list.ApiCallResponse.XmlReceived = xml; return(list); }
public static ParaEntityList <TEntity> GetList(XmlDocument listXml) { var list = ParaEntityParser.FillList <TEntity>(listXml); list.ApiCallResponse.XmlReceived = listXml; return(list); }
public static ParaEntityList <TFolder> GetList(XmlDocument listXml) { var downloadFoldersList = ParaEntityParser.FillList <TFolder>(listXml); downloadFoldersList.ApiCallResponse.XmlReceived = listXml; return(downloadFoldersList); }
internal static ParaEntityList <T> ApiGetEntityList <T>(ParaCredentials pc) { var entityList = new ParaEntityList <T>(); var ar = ApiCallFactory.ObjectGetList <T>(pc, new ArrayList()); if (ar.HasException == false) { entityList = ParaEntityParser.FillList <T>(ar.XmlReceived); } entityList.ApiCallResponse = ar; return(entityList); }
public ParaEntityList <TFolder> GetList <TFolder>(FolderQuery query) where TFolder : Folder, new() { var folderList = new ParaEntityList <TFolder>(); var ar = ApiCallFactory.ObjectGetList <TFolder>(Credentials, query.BuildQueryArguments()); if (ar.HasException == false) { folderList = ParaEntityParser.FillList <TFolder>(ar.XmlReceived); } folderList.ApiCallResponse = ar; // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { bool continueCalling = true; while (continueCalling) { if (folderList.TotalItems > folderList.Data.Count) { // We still need to pull data // Getting next page's data query.PageNumber = query.PageNumber + 1; ar = ApiCallFactory.ObjectGetList <TFolder>(Credentials, query.BuildQueryArguments()); var objectlist = ParaEntityParser.FillList <TFolder>(ar.XmlReceived); if (objectlist.Data.Count == 0) { continueCalling = false; } folderList.Data.AddRange(objectlist.Data); folderList.ResultsReturned = folderList.Data.Count; folderList.PageNumber = query.PageNumber; } else { // That is it, pulled all the items. continueCalling = false; folderList.ApiCallResponse = ar; } } } return(folderList); }
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); }
private static ParaEntityList <ParaObjects.Chat> RetrieveAllEntitites(ParaCredentials creds, ChatQuery query) { var chatList = new ParaEntityList <ParaObjects.Chat>(); var ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments()); if (ar.HasException == false) { chatList = ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived); } chatList.ApiCallResponse = ar; bool continueCalling = true; while (continueCalling) { if (chatList.TotalItems > chatList.Data.Count) { // We still need to pull data // Getting next page's data query.PageNumber = query.PageNumber + 1; ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments()); if (ar.HasException == false) { chatList.Data.AddRange(ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived).Data); chatList.ResultsReturned = chatList.Data.Count; chatList.PageNumber = query.PageNumber; } else { continueCalling = false; chatList.ApiCallResponse = ar; break; } } else { // That is it, pulled all the items. continueCalling = false; chatList.ApiCallResponse = ar; } } return(chatList); }
/// <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); }
private static ParaEntityList <ParaObjects.Chat> FillList(ParaCredentials creds, Boolean includeTranscripts, ChatQuery query) { if (query == null) { query = new ChatQuery(); } var chatList = new ParaEntityList <ParaObjects.Chat>(); // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { chatList = RetrieveAllEntitites(creds, query); } else { var ar = ApiCallFactory.ObjectGetList <ParaObjects.Chat>(creds, query.BuildQueryArguments()); if (ar.HasException == false) { chatList = ParaEntityParser.FillList <ParaObjects.Chat>(ar.XmlReceived); } chatList.ApiCallResponse = ar; } if (includeTranscripts) { var service = new ParaService(creds); //Fetch transcripts for each chat. Each request is another API call... foreach (var chat in chatList) { chat.Transcript = service.GetChatTranscript(chat.Id); } } return(chatList); }