Subversion Repositories DevTools

Rev

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