| 13 |
rsolanki |
1 |
<%@LANGUAGE="VBSCRIPT"%>
|
|
|
2 |
<%
|
|
|
3 |
'=====================================================
|
|
|
4 |
'| |
|
|
|
5 |
'| XML BOM Gen |
|
|
|
6 |
'| |
|
|
|
7 |
'=====================================================
|
|
|
8 |
%>
|
|
|
9 |
<%
|
|
|
10 |
Option explicit
|
|
|
11 |
Response.Expires = 0 ' always load the page, dont store
|
|
|
12 |
%>
|
|
|
13 |
<!--#include file="common/globals.asp"-->
|
|
|
14 |
<!--#include file="common/config.asp"-->
|
|
|
15 |
<!--#include file="common/common_subs.asp"-->
|
|
|
16 |
<!--#include file="common/_popup_window_common.asp"-->
|
|
|
17 |
|
|
|
18 |
<%
|
|
|
19 |
'------------ VARIABLE DEFINITION -------------
|
|
|
20 |
Dim objWSH
|
|
|
21 |
'------------ CONSTANTS DECLARATION -----------
|
|
|
22 |
'------------ VARIABLE INIT -------------------
|
|
|
23 |
'------------ CONDITIONS ----------------------
|
|
|
24 |
'----------------------------------------------
|
|
|
25 |
%>
|
|
|
26 |
<%
|
|
|
27 |
'--------------------------------------------------------------------------------------------------------------------------
|
|
|
28 |
|
|
|
29 |
'--------------------------------------------------------------------------------------------------------------------------
|
|
|
30 |
%>
|
|
|
31 |
<%
|
| 15 |
rsolanki |
32 |
Function DateReversed ( dDate )
|
|
|
33 |
' Ensures Reverse Date format YYYY-MM-DD
|
|
|
34 |
If IsNull(dDate) Then Exit Function
|
|
|
35 |
DateReversed = Year(dDate) &"-"& Month(dDate) &"-"& Day(dDate)
|
|
|
36 |
End Function
|
| 13 |
rsolanki |
37 |
'**************************** M A I N ******************************
|
|
|
38 |
|
|
|
39 |
If Request("bom_id") <> "" Then
|
|
|
40 |
Set objWSH = Server.CreateObject("WScript.Shell")
|
|
|
41 |
objWSH.Run "cmd.exe /c cscript.exe //B //NoLogo "& APP_ROOT &"\jobs\PostBOMRelease.wsf /bom_id:"& Request("bom_id") , 0, True
|
|
|
42 |
|
| 15 |
rsolanki |
43 |
OraDatabase.Parameters.Add "BOM_ID", Request("bom_id"), ORAPARM_INPUT, ORATYPE_NUMBER
|
|
|
44 |
OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
|
| 13 |
rsolanki |
45 |
|
| 15 |
rsolanki |
46 |
objEH.TryORA ( OraSession )
|
|
|
47 |
|
|
|
48 |
OraDatabase.ExecuteSQL _
|
|
|
49 |
"BEGIN pk_Bom.Log_Bom_Trail ( :BOM_ID, 'XML BOM GENERATED', :USER_ID, NULL ); END;"
|
|
|
50 |
|
|
|
51 |
objEH.CatchORA ( OraSession )
|
|
|
52 |
|
|
|
53 |
OraDatabase.Parameters.Remove "BOM_ID"
|
|
|
54 |
OraDatabase.Parameters.Remove "USER_ID"
|
|
|
55 |
|
|
|
56 |
Dim rsQry, objZIPObject
|
|
|
57 |
Set rsQry = OraDatabase.DbCreateDynaset( "SELECT bn.BOM_NAME, br.BRANCH_NAME, bn.BOM_NAME ||''|| b.BOM_VERSION ||'.'|| b.BOM_LIFECYCLE AS VERSION FROM BOMS B, BRANCHES BR, BOM_NAMES BN WHERE B.BOM_ID = "& Request("bom_id") &" AND B.BRANCH_ID = BR.BRANCH_ID AND B.BOM_NAME_ID = BN.BOM_NAME_ID", cint(0))
|
|
|
58 |
|
|
|
59 |
Set objZIPObject = Server.CreateObject("aspZip.EasyZIP")
|
|
|
60 |
|
|
|
61 |
objZIPObject.ZipFileName = ""& Request.ServerVariables("APPL_PHYSICAL_PATH") &"deployment_manager\downloads\"& rsQry("branch_name") &"\"& rsQry("version") &"\"& DateReversed(Date) &".zip"
|
|
|
62 |
objZIPObject.ArgsClear
|
|
|
63 |
objZIPObject.ArgsAdd(""& Request.ServerVariables("APPL_PHYSICAL_PATH") &"deployment_manager\downloads\"& rsQry("branch_name") &"\"& rsQry("version") &"\"& DateReversed(Date) &"\*.*")
|
|
|
64 |
objZIPObject.Zip
|
|
|
65 |
|
|
|
66 |
Response.Write "Files Zipped=" & objZIPObject.SuccessCNT & " with Error="& objZIPObject.Error
|
|
|
67 |
'Response.Write(""& Request.ServerVariables("APPL_PHYSICAL_PATH") &"deployment_manager\downloads\"& rsQry("bom_name") &"\"& rsQry("version") &"\"& DateReversed(Date) &".zip")
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
Dim myMail, LocalPath
|
|
|
72 |
Set myMail=Server.CreateObject("Persits.MailSender")
|
|
|
73 |
LocalPath = ""& Request.ServerVariables("APPL_PHYSICAL_PATH") &"deployment_manager\downloads\"& rsQry("branch_name") &"\"& rsQry("version") &"\"& DateReversed(Date) &".zip"
|
|
|
74 |
|
|
|
75 |
myMail.Host = SMTP_HOST
|
|
|
76 |
myMail.Subject="XML BOM Generated from Deployment Manager"
|
|
|
77 |
myMail.From="releasem@erggroup.com"
|
|
|
78 |
myMail.AddAddress objAccessControl.UserEmail
|
|
|
79 |
' Attach the file
|
|
|
80 |
myMail.AddAttachment LocalPath
|
|
|
81 |
myMail.Body = "Your requested xml files .."
|
|
|
82 |
myMail.Send
|
|
|
83 |
|
|
|
84 |
set myMail=nothing
|
|
|
85 |
|
|
|
86 |
rsQry.Close
|
|
|
87 |
Set rsQry = nothing
|
|
|
88 |
|
|
|
89 |
'Response.write "<br>You will be emailed shortly with the XML files generated.<br>"
|
|
|
90 |
'Response.write "Go to <a href='\\auperaweb08\wwwTRD\manager_suite_DEVELOPMENT\deployment_manager\downloads'>\\auperaweb08\wwwTRD\manager_suite_DEVELOPMENT\deployment_manager\downloads</a>"
|
|
|
91 |
|
| 13 |
rsolanki |
92 |
Else
|
|
|
93 |
Response.write "Please specify bom_id. <br>Example:<br> "& SCRIPT_NAME &"?bom_id=1234"
|
|
|
94 |
End If
|
|
|
95 |
|
|
|
96 |
'**********************************************************************
|
|
|
97 |
%>
|
| 15 |
rsolanki |
98 |
<script language="Javascript">
|
|
|
99 |
alert("You will be emailed shortly with the XML files generated. Click OK to Redirect to Previous Page...")
|
|
|
100 |
history.back()
|
|
|
101 |
</script>
|
| 13 |
rsolanki |
102 |
<%
|
|
|
103 |
'------------ RUN AFTER CODE RUN --------------
|
|
|
104 |
'----------------------------------------------
|
|
|
105 |
%><!--#include file="common/globals_destructor.asp"-->
|