| 4807 |
dpurdie |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
| 5958 |
dpurdie |
4 |
' Download a BOM attachment
|
| 4807 |
dpurdie |
5 |
'=====================================================
|
|
|
6 |
%>
|
|
|
7 |
<%
|
|
|
8 |
Option explicit
|
|
|
9 |
' Good idea to set when using redirect
|
| 5958 |
dpurdie |
10 |
Response.Expires = 0 ' always load the page, dont store
|
| 4807 |
dpurdie |
11 |
%>
|
|
|
12 |
|
|
|
13 |
<!--#include file="common/config.asp"-->
|
|
|
14 |
<!--#include file="common/globals.asp"-->
|
|
|
15 |
<!--#include file="common/formating.asp"-->
|
|
|
16 |
<!--#include file="common/qstr.asp"-->
|
|
|
17 |
<!--#include file="common/common_subs.asp"-->
|
|
|
18 |
<!--#include file="common/common_dbedit.asp"-->
|
|
|
19 |
<%
|
|
|
20 |
' Set rfile parameter. This is a return page after Login
|
|
|
21 |
Call objPMod.StoreParameter ( "rfile", "Bom_Home.asp" )
|
|
|
22 |
'------------ ACCESS CONTROL ------------------
|
|
|
23 |
%>
|
|
|
24 |
<!--#include file="_access_control_general.asp"-->
|
|
|
25 |
<%
|
|
|
26 |
'------------ Variable Definition -------------
|
|
|
27 |
Dim sFileName
|
|
|
28 |
Dim sPath
|
|
|
29 |
Dim newID
|
|
|
30 |
Dim retErrCode
|
|
|
31 |
'------------ Constants Declaration -----------
|
|
|
32 |
'------------ Variable Init -------------------
|
|
|
33 |
parBom_id = Request("bom_id")
|
|
|
34 |
'----------------------------------------------
|
|
|
35 |
%>
|
|
|
36 |
<%
|
|
|
37 |
'----------------------- MAIN LINE ---------------------------
|
|
|
38 |
|
|
|
39 |
'--- Process submition ---
|
|
|
40 |
|
|
|
41 |
If (parBom_id <> "") Then
|
| 5958 |
dpurdie |
42 |
|
| 4807 |
dpurdie |
43 |
Dim sName
|
|
|
44 |
Dim OraParameters
|
|
|
45 |
Set OraParameters = OraDatabase.Parameters
|
|
|
46 |
|
|
|
47 |
OraParameters.Add "Name" , Empty,ORAPARM_OUTPUT, ORATYPE_VARCHAR2
|
|
|
48 |
OraParameters.Add "ContentType" , Empty,ORAPARM_OUTPUT, ORATYPE_VARCHAR2
|
|
|
49 |
OraParameters.Add "PartImage" , Empty,ORAPARM_OUTPUT, ORATYPE_BLOB
|
|
|
50 |
|
|
|
51 |
Dim blobSql
|
|
|
52 |
blobSql = "BEGIN select DATA, NAME, CONTENTTYPE INTO :PartImage, :Name, :ContentType from BOM_ATTACHMENTS where BOM_ID=" & parBom_id & "; END;"
|
|
|
53 |
' Response.write "Sql:" & blobSql
|
|
|
54 |
OraDatabase.ExecuteSQL (blobSql)
|
|
|
55 |
|
|
|
56 |
' Response.write "<br>Name:" & OraParameters("Name").Value
|
|
|
57 |
|
|
|
58 |
'Get OraBlob from OraDynaset
|
|
|
59 |
Dim PartImage
|
|
|
60 |
set PartImage = OraDatabase.Parameters("PARTIMAGE").Value
|
|
|
61 |
|
|
|
62 |
'Set Offset and PollingAmount property for piecewise Read operation
|
|
|
63 |
PartImage.offset = 1
|
|
|
64 |
PartImage.PollingAmount = PartImage.Size
|
|
|
65 |
chunksize = 50000
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
'Do the first read on PartImage, buffer must be a variant
|
|
|
69 |
Dim AmountRead
|
|
|
70 |
Dim chunksize
|
|
|
71 |
Dim buffer
|
|
|
72 |
AmountRead = PartImage.Read(buffer, chunksize)
|
|
|
73 |
'Response.write "<br>DataType:" & TypeName(buffer)
|
|
|
74 |
'Response.write "<br>Data:" & AmountRead '& ":" & buffer
|
|
|
75 |
Response.Buffer = true
|
|
|
76 |
Response.Clear
|
|
|
77 |
Response.ContentType = OraParameters("ContentType").Value
|
|
|
78 |
Response.AddHeader "Content-Disposition", "attachment; filename=""" & OraParameters("Name").Value & """"
|
|
|
79 |
Response.Flush
|
| 5958 |
dpurdie |
80 |
Response.BinaryWrite buffer
|
| 4807 |
dpurdie |
81 |
|
|
|
82 |
' Check for the Status property for polling read operation
|
|
|
83 |
While PartImage.Status = ORALOB_NEED_DATA
|
|
|
84 |
AmountRead = PartImage.Read(buffer, chunksize)
|
| 5958 |
dpurdie |
85 |
'Response.write "<br>Data:" & AmountRead '& ":" & buffer
|
|
|
86 |
Response.BinaryWrite buffer
|
| 4807 |
dpurdie |
87 |
Wend
|
|
|
88 |
Response.Flush
|
| 5958 |
dpurdie |
89 |
Call Destroy_All_Objects
|
|
|
90 |
Response.End
|
| 4807 |
dpurdie |
91 |
|
|
|
92 |
Else
|
| 5958 |
dpurdie |
93 |
Response.write "Some mendatory parameters are missing!" & "<br>" 'TODO
|
|
|
94 |
Response.write QSTR_All
|
|
|
95 |
|
| 4807 |
dpurdie |
96 |
End If
|
| 5958 |
dpurdie |
97 |
Call Destroy_All_Objects
|
| 4807 |
dpurdie |
98 |
%>
|
|
|
99 |
|