Subversion Repositories DevTools

Rev

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