private Boolean isValidDocument(JournalNoteDocumentRequestModel document) { var regx = new Regex(@"([a-zA-Z0-9\s_\\.\-\(\)])+(.doc|.docx|.pdf|.txt|.htm|.html|.msg)$", RegexOptions.IgnoreCase); if (!regx.IsMatch(document.Name)) { Log.ForContext("CorrelationId", _correlationId) .ForContext("ClientId", _clientId) .Error("Invalid document type: " + document.Name); return(false); } return(true); }
private static void CreateJournalNote(CommandLineConfig config) { JournalNoteDocumentRequestModel journalNoteDocumentRequestModel = new JournalNoteDocumentRequestModel() { Content = config.Content, ContentType = config.ContentType, Name = config.Name, }; IList <JournalNoteDocumentRequestModel> GetReadOnlyValues() { List <JournalNoteDocumentRequestModel> journalNoteDocumentRequestModelList = new List <JournalNoteDocumentRequestModel>() { journalNoteDocumentRequestModel, }; return(journalNoteDocumentRequestModelList.AsReadOnly()); } JournalNoteRequestModel journalNoteRequestModel = new JournalNoteRequestModel() { Body = config.Body, Cpr = config.Cpr, Documents = GetReadOnlyValues(), Title = config.Title, Type = config.Type, }; if (journalNoteRequestModel == null) { Log.Information("One or more JournalNoteDocumentRequestModel property is not mentioned", config.TaskId); throw new System.Exception("You must specify a properties of JournalNoteDocumentRequestModel "); } if (string.IsNullOrEmpty(config.CitizenId)) { Log.Information("CitizenId is not mentioned", config.CitizenId); throw new System.Exception("You must specify a CitizenId"); } var client = GetApi(config); var response = client.CreateJournalNote(journalNoteRequestModel, config.CitizenId); Log.Information("Created a Journal Note with attachment", response); }