/// <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> /// /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="entityId"></param> /// <param name="pc"></param> /// <param name="queryString"></param> /// <returns></returns> public TEntity GetDetails <TEntity>(long entityId, ArrayList queryString) where TEntity : ParaEntityBaseProperties, new() { if (typeof(TEntity) != typeof(Folder)) { return(ApiUtils.ApiGetEntity <TEntity>(Credentials, entityId, queryString)); } var folder = new TEntity(); var ar = ApiCallFactory.ObjectGetDetail <TEntity>(Credentials, entityId); if (ar.HasException == false) { folder = ParaEntityParser.EntityFill <TEntity>(ar.XmlReceived); folder.FullyLoaded = true; } else { folder.FullyLoaded = false; folder.Id = 0; } folder.ApiCallResponse = ar; return(folder); }
public static ParaEntityList <TFolder> GetList(XmlDocument listXml) { var downloadFoldersList = ParaEntityParser.FillList <TFolder>(listXml); downloadFoldersList.ApiCallResponse.XmlReceived = listXml; return(downloadFoldersList); }
public static ParaEntityList <TEntity> GetList(XmlDocument listXml) { var list = ParaEntityParser.FillList <TEntity>(listXml); list.ApiCallResponse.XmlReceived = listXml; return(list); }
/// <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 <ParaObjects.Download> GetList(XmlDocument listXml) { var accountsList = ParaEntityParser.FillListDownload(listXml); accountsList.ApiCallResponse.XmlReceived = listXml; return(accountsList); }
public static TFolder GetDetails(XmlDocument xml) { var folder = ParaEntityParser.EntityFill <TFolder>(xml); folder.FullyLoaded = true; folder.ApiCallResponse.XmlReceived = xml; folder.ApiCallResponse.Id = folder.Id; return(folder); }
public static TEntity GetDetails(XmlDocument xml) { var entity = ParaEntityParser.EntityFill <TEntity>(xml); entity.FullyLoaded = true; entity.ApiCallResponse.XmlReceived = xml; entity.ApiCallResponse.Id = entity.Id; entity.IsDirty = false; return(entity); }
internal static ParaEntityList <ParaObjects.Download> ApiGetDownloadEntityList(ParaCredentials pc) { var entityList = new ParaEntityList <ParaObjects.Download>(); var ar = ApiCallFactory.ObjectGetList <ParaObjects.Download>(pc, new ArrayList()); if (ar.HasException == false) { entityList = ParaEntityParser.FillListDownload(ar.XmlReceived); } entityList.ApiCallResponse = ar; return(entityList); }
/// <summary> /// Retrieve the transcript for a particualr chat /// </summary> /// <param name="chatId"></param> /// <param name="paraCredentials"></param> /// <returns>A list of chat messages</returns> public List <ChatMessage> GetChatTranscript(long chatId) { var ar = ApiCallFactory.ChatTranscriptGetDetail(Credentials, chatId); if (ar.HasException == false) { return(ParaEntityParser.EntityFill <ParaObjects.Chat>(ar.XmlReceived).Transcript); } else { throw new Exception(ar.ExceptionDetails); } }
public static TEntity Schema(ParaCredentials pc) { var entity = new TEntity(); var ar = ApiCallFactory.ObjectGetSchema <TEntity>(pc); if (ar.HasException == false) { var purgedSchema = ApiUtils.RemoveStaticFieldsNodes(ar.XmlReceived); entity = ParaEntityParser.EntityFill <TEntity>(purgedSchema); } entity.ApiCallResponse = ar; return(entity); }
/// <summary> /// Create a new entity object. This object is not saved to the server until you call Insert with it. /// </summary> /// <typeparam name="TEntity"></typeparam> /// <returns></returns> public TEntity Create <TEntity>() where TEntity : ParaEntityBaseProperties, new() { var entity = new TEntity(); var ar = ApiCallFactory.ObjectGetSchema <TEntity>(Credentials); if (ar.HasException == false) { var purgedSchema = ApiUtils.RemoveStaticFieldsNodes(ar.XmlReceived); entity = ParaEntityParser.EntityFill <TEntity>(purgedSchema); } entity.ApiCallResponse = ar; return(entity); }
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); }
/// <summary> /// Internal method to attach a file for the Parature entity /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="pc"></param> /// <param name="attachment"></param> /// <returns></returns> internal static Attachment UploadFile <TEntity>(ParaCredentials pc, System.Net.Mail.Attachment attachment) where TEntity : ParaEntity { var postUrlR = ApiCallFactory.FileUploadGetUrl <TEntity>(pc); var uploadUrlDoc = postUrlR.XmlReceived; var postUrl = AttachmentGetUrlToPost(uploadUrlDoc); var upresp = ApiCallFactory.FilePerformUpload(postUrl, attachment); var attaDoc = upresp.XmlReceived; var attach = ParaEntityParser.EntityFill <Attachment>(attaDoc); return(attach); }
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> /// Retrieve the details for a specific Parature module entity with custom query string arguments /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pc"></param> /// <param name="entityId"></param> /// <returns></returns> internal static T ApiGetEntity <T>(ParaCredentials pc, long entityId, ArrayList arl) where T : ParaEntityBaseProperties, new() { var entity = new T(); var req = ApiCallFactory.ObjectGetDetail <T>(pc, entityId, arl); if (req.HasException == false) { entity = ParaEntityParser.EntityFill <T>(req.XmlReceived); entity.FullyLoaded = true; } else { entity.FullyLoaded = false; entity.Id = 0; } entity.ApiCallResponse = req; entity.IsDirty = false; return(entity); }
private static TFolder FillDetails(Int64 folderId, ParaCredentials creds) { var folder = new TFolder(); var ar = ApiCallFactory.ObjectGetDetail <TFolder>(creds, folderId); if (ar.HasException == false) { folder = ParaEntityParser.EntityFill <TFolder>(ar.XmlReceived); folder.FullyLoaded = true; } else { folder.FullyLoaded = false; folder.Id = 0; } folder.ApiCallResponse = ar; return(folder); }
/// <summary> /// Retrieve the details for a specific Parature module entity with custom query string arguments /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pc"></param> /// <param name="entityId"></param> /// <returns></returns> internal static ParaObjects.Download ApiGetDownloadEntity(ParaCredentials pc, long entityId, ArrayList arl) { var entity = new ParaObjects.Download(); var req = ApiCallFactory.ObjectGetDetail <ParaObjects.Download>(pc, entityId, arl); if (req.HasException == false) { entity = ParaEntityParser.EntityFillDownload(req.XmlReceived); entity.FullyLoaded = true; } else { entity.FullyLoaded = false; entity.Id = 0; } entity.ApiCallResponse = req; entity.IsDirty = false; return(entity); }
internal static ParaEntityList <ParaObjects.Download> ApiGetDownloadEntityList(ParaCredentials pc, DownloadQuery query) { var entityList = new ParaEntityList <ParaObjects.Download>(); // Checking if the system needs to recursively call all of the data returned. if (query.RetrieveAllRecords) { entityList = RetrieveAllDownloadEntities(pc, query); } else { var ar = ApiCallFactory.ObjectGetList <ParaObjects.Download>(pc, query.BuildQueryArguments()); if (ar.HasException == false) { entityList = ParaEntityParser.FillListDownload(ar.XmlReceived); } entityList.ApiCallResponse = ar; } return(entityList); }
private static ParaObjects.Chat FillTranscriptDetails(Int64 chatid, ParaCredentials paraCredentials) { //Because chat transcripts return a Chat object with just a list messages, we'll deserialize the transcript into a chat object var chat = new ParaObjects.Chat(); var ar = ApiCallFactory.ChatTranscriptGetDetail(paraCredentials, chatid); if (ar.HasException == false) { chat = ParaEntityParser.EntityFill <ParaObjects.Chat>(ar.XmlReceived); chat.FullyLoaded = true; } else { chat.FullyLoaded = false; chat.Id = 0; } chat.ApiCallResponse = ar; chat.IsDirty = false; return(chat); }
/// <summary> /// Internal method to handle the upload of a file to Parature. /// </summary> internal static Attachment UploadFile <TEntity>(ParaCredentials pc, Byte[] attachment, String contentType, String fileName) where TEntity : ParaEntity { Attachment attach; var postUrl = ""; postUrl = AttachmentGetUrlToPost(ApiCallFactory.FileUploadGetUrl <TEntity>(pc).XmlReceived); if (String.IsNullOrEmpty(postUrl) == false) { var uploadResponse = ApiCallFactory.FilePerformUpload(postUrl, attachment, contentType, fileName) .XmlReceived; attach = new Attachment(); var uploadResult = ParaEntityParser.EntityFill <UploadResult>(uploadResponse); if (!string.IsNullOrEmpty(uploadResult.Error)) { //There was an error uploading attach.HasException = true; attach.Error = uploadResult.Error; } else { attach.Name = uploadResult.Result.File.FileName; attach.Guid = uploadResult.Result.File.Guid; } } else { attach = new Attachment(); } return(attach); }
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); }
public static TEntity GetDetails(XmlDocument xml) { var entity = ParaEntityParser.EntityFill <TEntity>(xml); return(entity); }