protected List <Attachment> GetAttachments() { var attachments = new List <Attachment>(); if (!HasAttachments) { return(attachments); } var attachmentSet = new HashSet <string>(); foreach (var subNode in SubNodeDataDto) { var nodeType = NID.GetNodeType(subNode.Key); if (nodeType != NID.NodeType.ATTACHMENT_PC) { continue; } var attachmentPC = new PropertyContext(subNode.Value); var attachment = new Attachment(attachmentPC); if (attachmentSet.Contains(attachment.AttachmentLongFileName)) { var smallGuid = Guid.NewGuid().ToString().Substring(0, 5); attachment.AttachmentLongFileName = $"{smallGuid}-{attachment.AttachmentLongFileName}"; } attachmentSet.Add(attachment.AttachmentLongFileName); attachments.Add(attachment); } return(attachments); }
private List <Attachment> GetAttachments() { var attachments = new List <Attachment>(); if (!HasAttachments) { return(attachments); } var attachmentSet = new HashSet <string>(); foreach (var subNode in SubNodeDataDto) { // fixme start here. this is the node id. If we can figure out that the attachment is embedded // and jump straight to the attachment node id we may have something var nodeType = NID.GetNodeType(subNode.Key); if (nodeType != NID.NodeType.ATTACHMENT_PC) { continue; } var attachmentPC = new PropertyContext(subNode.Value); var attachment = new Attachment(attachmentPC); if (attachmentSet.Contains(attachment.AttachmentLongFileName)) { var smallGuid = Guid.NewGuid().ToString().Substring(0, 5); attachment.AttachmentLongFileName = $"{smallGuid}-{attachment.AttachmentLongFileName}"; } attachmentSet.Add(attachment.AttachmentLongFileName); attachments.Add(attachment); } return(attachments); }