Subversion Repositories DevTools

Rev

Rev 6643 | 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))
6643 dpurdie 74
		LocalPath = Server.MapPath("nodespecfiles") & "\" &_
4214 dpurdie 75
                    NicePath(rsQry("branch_name")) & "\" &_
76
                    NicePath(rsQry("version")) & "\"&_
77
                    DateReversed(Date)
78
        ZipFile = LocalPath &".zip"
79
 
80
	    Set filesys = CreateObject("Scripting.FileSystemObject")
81
	    If NOT filesys.FolderExists ( LocalPath ) Then
82
		    Response.write "<br>Internal Error: Folder Not Found"
83
		    Response.write "<br>LocalPath: "&LocalPath
84
		    Response.write "<br>Branch: "&rsQry("branch_name")
85
		    Response.write "<br>Version: "&rsQry("version")
86
		    Response.write "<br>"
87
	        generated = false
88
        Else
89
		    Dim objZIPObject
4476 dpurdie 90
    		Set objZIPObject = Server.CreateObject("XStandard.Zip")
91
 
92
            If filesys.FileExists(ZipFile) Then
93
           	    filesys.DeleteFile ZipFile, TRUE
94
            End If
95
 
96
            objZIPObject.Pack LocalPath &"\*.*", ZipFile
97
            eMsg = objZIPObject.ErrorDescription
98
            zCount = objZIPObject.Contents(ZipFile).Count
99
            'objZIPObject = Nothing
4214 dpurdie 100
 
4476 dpurdie 101
    		Response.Write "Files Zipped=" & zCount 
102
            If eMsg <> "" Then
103
    		    Response.Write " with Error="& eMsg
104
            End If
105
 
5517 dpurdie 106
    		Response.write "<br>Node Spec Files Generated for: "&objAccessControl.UserEmail
107
            Response.Write "<br>"            
4214 dpurdie 108
    	    If NOT filesys.FileExists ( ZipFile ) Then
109
    		    Response.write "<br>Internal Error: File Not Found"
110
    		    Response.write "<br>LocalPath: " & ZipFile & "<br>"
111
    	        generated = false
112
            Else
5517 dpurdie 113
                Response.Write "<br>Emailing using: " & SMTP_HOST
4214 dpurdie 114
                Dim myMail
115
    		    Set myMail=Server.CreateObject("Persits.MailSender")
116
        		myMail.Host = SMTP_HOST
117
        		myMail.Subject="NODESPEC FILES Generated from Deployment Manager"
6646 dpurdie 118
        		myMail.From="releasem@vixtechnology.com"
4214 dpurdie 119
        		myMail.AddAddress objAccessControl.UserEmail
120
        		' Attach the file
121
        		myMail.AddAttachment LocalPath &".zip"
122
        		myMail.Body = "Your requested node spec files .." 
123
        		myMail.Send
124
    		    set myMail = nothing
125
            End If
126
        End If
19 rsolanki 127
 
128
		set objWSH = nothing
4214 dpurdie 129
	    Set filesys = nothing
19 rsolanki 130
		rsQry.Close
131
		Set rsQry = nothing
132
	Else	
133
	generated = false
4214 dpurdie 134
		Response.write "<br>Node spec filenames not found in the BOM!!!"
19 rsolanki 135
 
136
	End If	
137
 
15 rsolanki 138
Else
139
	Response.write "Please specify bom_id. <br>Example:<br> "& SCRIPT_NAME &"?bom_id=1234"
140
End If
141
 
142
'**********************************************************************
19 rsolanki 143
If generated Then
15 rsolanki 144
%>
19 rsolanki 145
<script language="Javascript">
146
alert("You will be emailed shortly with the NodeSpec files generated. Click OK to Redirect to Previous Page...")
147
history.back()
148
</script>
5958 dpurdie 149
<%Else%>
19 rsolanki 150
<script language="Javascript">
151
alert("Click OK to Redirect to Previous Page...")
152
history.back()
153
</script>
5958 dpurdie 154
<%End If%>
155
<%Call Destroy_All_Objects%>