Subversion Repositories DevTools

Rev

Rev 5517 | Rev 5961 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15 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
19 rsolanki 21
Dim rsQry
22
Dim generated
15 rsolanki 23
'------------ CONSTANTS DECLARATION -----------
24
'------------ VARIABLE INIT -------------------
25
'------------ CONDITIONS ----------------------
26
'----------------------------------------------
27
%>
28
<%
19 rsolanki 29
Function DateReversed ( dDate )
30
	' Ensures Reverse Date format YYYY-MM-DD
31
	If IsNull(dDate) Then Exit Function
32
	DateReversed = Year(dDate) &"-"&  Month(dDate) &"-"& Day(dDate)
33
End Function
15 rsolanki 34
'--------------------------------------------------------------------------------------------------------------------------
35
 
36
'--------------------------------------------------------------------------------------------------------------------------
37
%>
38
<%
39
'**************************** M  A  I  N ******************************
40
 
41
If Request("bom_id") <> "" Then
42
 
19 rsolanki 43
	OraDatabase.Parameters.Add "BOM_ID",	Request("bom_id"),	ORAPARM_INPUT, ORATYPE_NUMBER 
44
	Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("NodesSpecFileNames.sql"), cint(0))
45
	OraDatabase.Parameters.Remove "BOM_ID"
15 rsolanki 46
 
19 rsolanki 47
	If rsQry.RecordCount <> 0 Then 
48
 
49
		generated = true
50
 
5517 dpurdie 51
		Set objWSH = createWscriptShell()
52
 
19 rsolanki 53
		objWSH.Run   "cmd.exe /c cscript.exe //B //NoLogo "& APP_ROOT &"\jobs\NodesSpecRelease.wsf /bom_id:"& Request("bom_id") , 0, True 
54
 
55
		OraDatabase.Parameters.Add "BOM_ID", 	Request("bom_id"), 			ORAPARM_INPUT, ORATYPE_NUMBER
56
		OraDatabase.Parameters.Add "USER_ID", 	objAccessControl.UserId, 	ORAPARM_INPUT, ORATYPE_NUMBER 
57
 
58
		objEH.TryORA ( OraSession )
59
 
60
		OraDatabase.ExecuteSQL _
61
		"BEGIN   pk_Bom.Log_Bom_Trail ( :BOM_ID, 'NODE SPECS FILE GENERATED', :USER_ID, NULL );   END;"
62
		objEH.CatchORA ( OraSession )
63
 
64
		OraDatabase.Parameters.Remove "BOM_ID"
65
		OraDatabase.Parameters.Remove "USER_ID"	
66
 
4214 dpurdie 67
        ' Create a sane path name for the output file
68
        ' Need to use the same rules as NodesSpecRelease.wsf to allow for BOM versions with a '/' in the name
69
        '
4476 dpurdie 70
		Dim LocalPath, ZipFile, filesys, eMsg, zCount
4214 dpurdie 71
    	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))
72
		LocalPath = Request.ServerVariables("APPL_PHYSICAL_PATH") &_
73
                    "deployment_manager\nodespecfiles\"&_
74
                    NicePath(rsQry("branch_name")) & "\" &_
75
                    NicePath(rsQry("version")) & "\"&_
76
                    DateReversed(Date)
77
        ZipFile = LocalPath &".zip"
78
 
79
	    Set filesys = CreateObject("Scripting.FileSystemObject")
80
	    If NOT filesys.FolderExists ( LocalPath ) Then
81
		    Response.write "<br>Internal Error: Folder Not Found"
82
		    Response.write "<br>LocalPath: "&LocalPath
83
		    Response.write "<br>Branch: "&rsQry("branch_name")
84
		    Response.write "<br>Version: "&rsQry("version")
85
		    Response.write "<br>"
86
	        generated = false
87
        Else
88
		    Dim objZIPObject
4476 dpurdie 89
    		Set objZIPObject = Server.CreateObject("XStandard.Zip")
90
 
91
            If filesys.FileExists(ZipFile) Then
92
           	    filesys.DeleteFile ZipFile, TRUE
93
            End If
94
 
95
            objZIPObject.Pack LocalPath &"\*.*", ZipFile
96
            eMsg = objZIPObject.ErrorDescription
97
            zCount = objZIPObject.Contents(ZipFile).Count
98
            'objZIPObject = Nothing
4214 dpurdie 99
 
4476 dpurdie 100
    		Response.Write "Files Zipped=" & zCount 
101
            If eMsg <> "" Then
102
    		    Response.Write " with Error="& eMsg
103
            End If
104
 
5517 dpurdie 105
    		Response.write "<br>Node Spec Files Generated for: "&objAccessControl.UserEmail
106
            Response.Write "<br>"            
4214 dpurdie 107
    	    If NOT filesys.FileExists ( ZipFile ) Then
108
    		    Response.write "<br>Internal Error: File Not Found"
109
    		    Response.write "<br>LocalPath: " & ZipFile & "<br>"
110
    	        generated = false
111
            Else
5517 dpurdie 112
                Response.Write "<br>Emailing using: " & SMTP_HOST
4214 dpurdie 113
                Dim myMail
114
    		    Set myMail=Server.CreateObject("Persits.MailSender")
115
        		myMail.Host = SMTP_HOST
116
        		myMail.Subject="NODESPEC FILES Generated from Deployment Manager"
117
        		myMail.From="releasem@erggroup.com"
118
        		myMail.AddAddress objAccessControl.UserEmail
119
        		' Attach the file
120
        		myMail.AddAttachment LocalPath &".zip"
121
        		myMail.Body = "Your requested node spec files .." 
122
        		myMail.Send
123
    		    set myMail = nothing
124
            End If
125
        End If
19 rsolanki 126
 
127
		set objWSH = nothing
4214 dpurdie 128
	    Set filesys = nothing
19 rsolanki 129
		rsQry.Close
130
		Set rsQry = nothing
131
	Else	
132
	generated = false
4214 dpurdie 133
		Response.write "<br>Node spec filenames not found in the BOM!!!"
19 rsolanki 134
 
135
	End If	
136
 
15 rsolanki 137
Else
138
	Response.write "Please specify bom_id. <br>Example:<br> "& SCRIPT_NAME &"?bom_id=1234"
139
End If
140
 
141
'**********************************************************************
19 rsolanki 142
If generated Then
15 rsolanki 143
%>
19 rsolanki 144
<script language="Javascript">
145
alert("You will be emailed shortly with the NodeSpec files generated. Click OK to Redirect to Previous Page...")
146
history.back()
147
</script>
5958 dpurdie 148
<%Else%>
19 rsolanki 149
<script language="Javascript">
150
alert("Click OK to Redirect to Previous Page...")
151
history.back()
152
</script>
5958 dpurdie 153
<%End If%>
154
<%Call Destroy_All_Objects%>