Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
23 rsolanki 40
 
13 rsolanki 41
	Set objWSH = Server.CreateObject("WScript.Shell")
42
	objWSH.Run   "cmd.exe /c cscript.exe //B //NoLogo "& APP_ROOT &"\jobs\PostBOMRelease.wsf /bom_id:"& Request("bom_id") , 0, True 
43
 
15 rsolanki 44
	OraDatabase.Parameters.Add "BOM_ID", 	Request("bom_id"), 			ORAPARM_INPUT, ORATYPE_NUMBER
45
	OraDatabase.Parameters.Add "USER_ID", 	objAccessControl.UserId, 	ORAPARM_INPUT, ORATYPE_NUMBER 
13 rsolanki 46
 
15 rsolanki 47
	objEH.TryORA ( OraSession )
48
 
49
	OraDatabase.ExecuteSQL _
50
	"BEGIN   pk_Bom.Log_Bom_Trail ( :BOM_ID, 'XML BOM GENERATED', :USER_ID, NULL );   END;"
51
 
52
	objEH.CatchORA ( OraSession )
53
 
54
	OraDatabase.Parameters.Remove "BOM_ID"
55
	OraDatabase.Parameters.Remove "USER_ID"	
56
 
57
	Dim rsQry, objZIPObject
4476 dpurdie 58
    Dim LocalPath, ZipFile, filesys, eMsg, zCount
59
 
15 rsolanki 60
	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))
61
 
4476 dpurdie 62
    LocalPath = Request.ServerVariables("APPL_PHYSICAL_PATH") &_
63
                "deployment_manager\downloads\"&_
64
                NicePath(rsQry("branch_name")) & "\" &_
65
                NicePath(rsQry("version")) & "\"&_
66
                DateReversed(Date)
67
    ZipFile = LocalPath &".zip"
15 rsolanki 68
 
4476 dpurdie 69
    Set filesys = CreateObject("Scripting.FileSystemObject")
70
    Set objZIPObject = Server.CreateObject("XStandard.Zip")
71
 
72
    If filesys.FileExists(ZipFile) Then
73
        filesys.DeleteFile ZipFile, TRUE
74
    End If
75
 
76
    objZIPObject.Pack LocalPath &"\*.*", ZipFile
77
    eMsg = objZIPObject.ErrorDescription
78
    zCount = objZIPObject.Contents(ZipFile).Count
79
 
80
    Response.Write "Files Zipped=" & zCount 
81
    If eMsg <> "" Then
82
        Response.Write " with Error=" & eMsg
83
    End If
84
	'Response.Write("" & ZipFile)
85
 
86
    'objZIPObject = Nothing
87
    Set filesys = Nothing
15 rsolanki 88
 
4476 dpurdie 89
	Dim myMail
15 rsolanki 90
	Set myMail=Server.CreateObject("Persits.MailSender")
91
 
92
	myMail.Host = SMTP_HOST
25 rsolanki 93
 
94
	Dim rsTemp
95
 
96
	Set rsTemp = OraDatabase.DbCreateDynaset( "SELECT * FROM BOMS WHERE BOM_ID = "& Request("bom_id"), cint(0))
97
 
98
	If rsTemp("is_readonly") = "Y" Then
99
		myMail.Subject="OFFICIAL XML BOMS Generated from Deployment Manager"
100
	Else
101
		myMail.Subject="THESE ARE NOT OFFICIAL XML BOMS!!!"
102
	End If
15 rsolanki 103
	myMail.From="releasem@erggroup.com"
104
	myMail.AddAddress objAccessControl.UserEmail
105
	' Attach the file
4476 dpurdie 106
	myMail.AddAttachment ZipFile
15 rsolanki 107
	myMail.Body = "Your requested xml files .." 
108
	myMail.Send
109
 
19 rsolanki 110
	set myMail = nothing
111
	set objWSH = nothing
15 rsolanki 112
 
25 rsolanki 113
	rsTemp.Close()
114
	Set rsTemp = Nothing
115
	rsQry.Close()
15 rsolanki 116
	Set rsQry = nothing
117
 
118
	'Response.write "<br>You will be emailed shortly with the XML files generated.<br>"
119
	'Response.write "Go to <a href='\\auperaweb08\wwwTRD\manager_suite_DEVELOPMENT\deployment_manager\downloads'>\\auperaweb08\wwwTRD\manager_suite_DEVELOPMENT\deployment_manager\downloads</a>"
120
 
13 rsolanki 121
Else
122
	Response.write "Please specify bom_id. <br>Example:<br> "& SCRIPT_NAME &"?bom_id=1234"
123
End If
124
 
125
'**********************************************************************
126
%>
15 rsolanki 127
<script language="Javascript">
128
alert("You will be emailed shortly with the XML files generated. Click OK to Redirect to Previous Page...")
129
history.back()
130
</script>
13 rsolanki 131
<%
132
'------------ RUN AFTER CODE RUN --------------
133
'----------------------------------------------
134
%><!--#include file="common/globals_destructor.asp"-->