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
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
 
5961 dpurdie 55
	    On Error Resume Next
19 rsolanki 56
		OraDatabase.Parameters.Add "BOM_ID", 	Request("bom_id"), 			ORAPARM_INPUT, ORATYPE_NUMBER
57
		OraDatabase.Parameters.Add "USER_ID", 	objAccessControl.UserId, 	ORAPARM_INPUT, ORATYPE_NUMBER 
58
 
59
		objEH.TryORA ( OraSession )
60
 
61
		OraDatabase.ExecuteSQL _
62
		"BEGIN   pk_Bom.Log_Bom_Trail ( :BOM_ID, 'NODE SPECS FILE GENERATED', :USER_ID, NULL );   END;"
63
		objEH.CatchORA ( OraSession )
64
 
65
		OraDatabase.Parameters.Remove "BOM_ID"
66
		OraDatabase.Parameters.Remove "USER_ID"	
5961 dpurdie 67
	    On Error GoTo 0
19 rsolanki 68
 
4214 dpurdie 69
        ' Create a sane path name for the output file
70
        ' Need to use the same rules as NodesSpecRelease.wsf to allow for BOM versions with a '/' in the name
71
        '
4476 dpurdie 72
		Dim LocalPath, ZipFile, filesys, eMsg, zCount
4214 dpurdie 73
    	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))
74
		LocalPath = Request.ServerVariables("APPL_PHYSICAL_PATH") &_
75
                    "deployment_manager\nodespecfiles\"&_
76
                    NicePath(rsQry("branch_name")) & "\" &_
77
                    NicePath(rsQry("version")) & "\"&_
78
                    DateReversed(Date)
79
        ZipFile = LocalPath &".zip"
80
 
81
	    Set filesys = CreateObject("Scripting.FileSystemObject")
82
	    If NOT filesys.FolderExists ( LocalPath ) Then
83
		    Response.write "<br>Internal Error: Folder Not Found"
84
		    Response.write "<br>LocalPath: "&LocalPath
85
		    Response.write "<br>Branch: "&rsQry("branch_name")
86
		    Response.write "<br>Version: "&rsQry("version")
87
		    Response.write "<br>"
88
	        generated = false
89
        Else
90
		    Dim objZIPObject
4476 dpurdie 91
    		Set objZIPObject = Server.CreateObject("XStandard.Zip")
92
 
93
            If filesys.FileExists(ZipFile) Then
94
           	    filesys.DeleteFile ZipFile, TRUE
95
            End If
96
 
97
            objZIPObject.Pack LocalPath &"\*.*", ZipFile
98
            eMsg = objZIPObject.ErrorDescription
99
            zCount = objZIPObject.Contents(ZipFile).Count
100
            'objZIPObject = Nothing
4214 dpurdie 101
 
4476 dpurdie 102
    		Response.Write "Files Zipped=" & zCount 
103
            If eMsg <> "" Then
104
    		    Response.Write " with Error="& eMsg
105
            End If
106
 
5517 dpurdie 107
    		Response.write "<br>Node Spec Files Generated for: "&objAccessControl.UserEmail
108
            Response.Write "<br>"            
4214 dpurdie 109
    	    If NOT filesys.FileExists ( ZipFile ) Then
110
    		    Response.write "<br>Internal Error: File Not Found"
111
    		    Response.write "<br>LocalPath: " & ZipFile & "<br>"
112
    	        generated = false
113
            Else
5517 dpurdie 114
                Response.Write "<br>Emailing using: " & SMTP_HOST
4214 dpurdie 115
                Dim myMail
116
    		    Set myMail=Server.CreateObject("Persits.MailSender")
117
        		myMail.Host = SMTP_HOST
118
        		myMail.Subject="NODESPEC FILES Generated from Deployment Manager"
119
        		myMail.From="releasem@erggroup.com"
120
        		myMail.AddAddress objAccessControl.UserEmail
121
        		' Attach the file
122
        		myMail.AddAttachment LocalPath &".zip"
123
        		myMail.Body = "Your requested node spec files .." 
124
        		myMail.Send
125
    		    set myMail = nothing
126
            End If
127
        End If
19 rsolanki 128
 
129
		set objWSH = nothing
4214 dpurdie 130
	    Set filesys = nothing
19 rsolanki 131
		rsQry.Close
132
		Set rsQry = nothing
133
	Else	
134
	generated = false
4214 dpurdie 135
		Response.write "<br>Node spec filenames not found in the BOM!!!"
19 rsolanki 136
 
137
	End If	
138
 
15 rsolanki 139
Else
140
	Response.write "Please specify bom_id. <br>Example:<br> "& SCRIPT_NAME &"?bom_id=1234"
141
End If
142
 
143
'**********************************************************************
19 rsolanki 144
If generated Then
15 rsolanki 145
%>
19 rsolanki 146
<script language="Javascript">
147
alert("You will be emailed shortly with the NodeSpec files generated. Click OK to Redirect to Previous Page...")
148
history.back()
149
</script>
5958 dpurdie 150
<%Else%>
19 rsolanki 151
<script language="Javascript">
152
alert("Click OK to Redirect to Previous Page...")
153
history.back()
154
</script>
5958 dpurdie 155
<%End If%>
156
<%Call Destroy_All_Objects%>