/// <summary> /// Takes the common message format gets the specific fields /// </summary> /// <param name="m"></param> /// <returns></returns> public async Task<Message> GetMessage(Message m) { //Only the URI is required to retrieve the message var theMessage = new Message(); string message = await _dal.GetMessageJSON(m.Links.Self.Href); if (!string.IsNullOrEmpty(message)) { theMessage = Serializer.DeserializeMessage(message); theMessage = AdjustMessage(theMessage); } return theMessage; }
public async Task<Message> GetMessage(string messageid) { //Only the URI is required to retrieve the message var theMessage = new Message(); string requestUrl = String.Format(AppContext.RESTURL, Session.SelectedOrg.OrganizationNumber) + "/" + messageid; string message = await _dal.GetMessageJSON(requestUrl); if (!string.IsNullOrEmpty(message)) { theMessage = Serializer.DeserializeMessage(message); theMessage = AdjustMessage(theMessage); } return theMessage; }
private Message CorrectCorresAttachment(Message theMessage) { try { //Some attachments is missing the file ending if (theMessage.Links.Attachment != null) { if (!string.IsNullOrEmpty(theMessage.Links.Attachment[0].Name)) { string name = theMessage.Links.Attachment[0].Name; if (name.IndexOf('.') > 0) { //string fileEnding = name.Substring (name.IndexOf ('.') + 1); string fileending = name.Substring(name.IndexOf('.') + 1); theMessage.Links.Attachment[0].FileEnding = fileending; if (fileending == "pdf") { theMessage.Links.Attachment[0].Mimetype = "application/pdf"; } else if (fileending == "html") { theMessage.Links.Attachment[0].Mimetype = "text/html"; } else if (fileending == "xml") { theMessage.Links.Attachment[0].Mimetype = "text/xml"; } else { theMessage.Links.Attachment[0].Mimetype = ""; } } else if (name.IndexOf('.') < 0) { //If the file ending is missing we attempt to add "pdf" since in most cases it is. Some tax return attachments are missing the file ending theMessage.Links.Attachment[0].Name += ".pdf"; theMessage.Links.Attachment[0].FileEnding = "pdf"; theMessage.Links.Attachment[0].Mimetype = "application/pdf"; } } } } catch (Exception ex) { Logger.Logg("Failed to adjust corres mime-type: " + ex); } return theMessage; }
public Message AdjustMessage(Message theMessage) { //Set the downloaded flag so we know that it is done theMessage.IsDownloaded = true; //Correct the date from the API per client request if (theMessage.Type == Constants.MessageType.Correspondence.ToString()) { theMessage = CorrectCorresAttachment(theMessage); } //theMessage = CorrectDate (theMessage); return theMessage; }