 |
Attachment_2019_01Insert_Attachment Method |
Inserts the specified attachment into EPIC
Namespace:
ASI.TAM.API.Web.EpicSDK.Attachment
Assembly:
ASI.TAM.API.Web.EpicSDK (in ASI.TAM.API.Web.EpicSDK.dll) Version: 2020.1.0.1
Syntaxint[] Insert_Attachment(
Attachment AttachmentObject
)
Function Insert_Attachment (
AttachmentObject As Attachment
) As Integer()
Dim instance As Attachment_2019_01
Dim AttachmentObject As Attachment
Dim returnValue As Integer()
returnValue = instance.Insert_Attachment(AttachmentObject)
Parameters
- AttachmentObject
- Type: ASI.TAM.API.Data.UI.AttachmentAttachment
The attachment to be inserted
Return Value
Type:
Int32A unique AttachmentID identifying the newly inserted attachment
Remarks
To use this with a new file first you need to call Upload_Attachment_File which will upload the physical file
to the EPIC file server and return you a ticket ID. You then use that ticket ID to populate the FileItem property of
the Attachment object to be inserted which will create an EPIC attachment containing the file.
An error message will be thrown if try to insert attachment to the folder that is not accessible by the associated account type.
Examples 1
2
3
4
5
6
7Try
8 Dim oService As New EpicSDK_2018_01Client
9 Dim oHeader As New SDK2009_07.MessageHeader
10
11 Dim oClient As New EpicSDK_2018_01Client("ServiceBinding_2016_01")
12 Dim oStreamingClient As New EpicSDKFileTransferClient("FileTransferServiceBinding")
13
14
15
16 oHeader.DatabaseName = DATABASE
17 oHeader.AuthenticationKey = AUTHENTICATION_KEY
18
19 oHeader.UserCode = USER_CODE
20 oHeader.IntegrationKey = "eaa8b2df-94c0-4bac-a403-1a1b749b8e06"
21
22 Dim sFilePath As String = "C:\src\Epic\Ftr\SDKDFCT\ASI.Tools\API\Documentation\SampleCode\Files\TestAttachment.txt"
23 Dim oFileInfo As New System.IO.FileInfo(sFilePath)
24 Dim iFileLength As Integer = CInt(oFileInfo.Length)
25
26
27 Dim abFileData(iFileLength - 1) As Byte
28 Dim rdrFile As System.IO.FileStream = oFileInfo.OpenRead
29 rdrFile.Read(abFileData, 0, iFileLength)
30 Dim memStream As New IO.MemoryStream(abFileData)
31 rdrFile.Close()
32
33 Dim oFileDetail As New SDK2009_07._account._attachment.FileDetailItem
34
35
36
37 oFileDetail.TicketName = oStreamingClient.Upload_Attachment_File(oHeader, memStream)
38 oFileDetail.Extension = oFileInfo.Extension
39 oFileDetail.Length = iFileLength
40 oFileDetail.FileName = oFileInfo.Name
41
42 Dim oAttachedTos As New SDK2009_07._account._attachment.AttachedToItems
43 Dim oAttachedToItem As New SDK2009_07._account._attachment.AttachedToItem
44
45 With oAttachedToItem
46 .AttachedToID = 113168
47
48 .AttachedToType = "Account"
49 End With
50
51 oAttachedTos.Add(oAttachedToItem)
52
53 Dim oAttachFiles As New SDK2009_07._account._attachment.FileDetailItems
54 oAttachFiles.Add(oFileDetail)
55
56
57 Dim oAttachment As SDK2009_07._account.Attachment = New SDK2009_07._account.Attachment
58 With oAttachment
59
60 .AccountID = 113168
61 .Files = oAttachFiles
62 .AttachedTos = oAttachedTos
63
64 .Description = oFileInfo.Name
65
66 .Folder = "Documents"
67 .SubFolder1 = "Letters"
68 .ReceivedDate = New Date(2010, 12, 12)
69
70 .Comments = "Test Attachment"
71
72 .SecurityAccessLevelCode = "Public"
73
74 End With
75
76 Dim lstAttachment As List(Of Integer) = Nothing
77
78 Try
79
80 lstAttachment = oService.Insert_Attachment(oHeader, oAttachment)
81
82
83 oService.Close()
84
85 Catch ex As Exception
86 oService.Abort()
87 Throw
88 End Try
89
90
91 Console.WriteLine("New Attachment inserted with ID: " & lstAttachment.Item(0).ToString)
92
93Catch ex As Exception
94 Console.WriteLine("Error: " & ex.Detail.Description)
95 Console.WriteLine("Press any key to exit...")
96 Console.ReadLine()
97End Try
See Also