| 29 |
jtweddle |
1 |
<?xml version="1.0" ?>
|
|
|
2 |
<package>
|
|
|
3 |
<comment>
|
|
|
4 |
PrimalCode wizard generated file.
|
|
|
5 |
</comment>
|
|
|
6 |
<job id="CheckForPackageVersions" args="/bom_id:2864" prompt="no">
|
|
|
7 |
<?job error="false" debug="false" ?>
|
|
|
8 |
<runtime>
|
|
|
9 |
<named helpstring="Bom ID" name="bom_id" required="false" type="string"/>
|
|
|
10 |
</runtime>
|
|
|
11 |
<object id="Oracle_Objects_For_OLE" progid="OracleInProcServer.XOraServer" events="true"/>
|
|
|
12 |
<script language="VBScript" src="common_subs.vbs"/>
|
|
|
13 |
<script language="VBScript" src="config.vbs"/>
|
|
|
14 |
|
|
|
15 |
<script language="VBScript" src="pkg_archive.vbs"/>
|
|
|
16 |
<script id="CheckForPackageVersions" language="VBScript">
|
|
|
17 |
<![CDATA[
|
|
|
18 |
Option Explicit
|
|
|
19 |
'=====================================================
|
|
|
20 |
' Name: GetComponents
|
|
|
21 |
' Description: Connects to dpkg_archive and gets the
|
|
|
22 |
' content of folders and files of certain
|
|
|
23 |
' package. It then stores this info into
|
|
|
24 |
' Release Manager database. This info can
|
|
|
25 |
' later be included in release notes Or
|
|
|
26 |
' searched with search engine.
|
|
|
27 |
' INPUT: pkg_name
|
|
|
28 |
' pkg_version
|
|
|
29 |
'=====================================================
|
|
|
30 |
|
|
|
31 |
'== Variable Definition ==============================
|
|
|
32 |
Dim BomId
|
|
|
33 |
Dim CompareBomId
|
|
|
34 |
Dim UserName
|
|
|
35 |
Dim objArgs
|
|
|
36 |
|
|
|
37 |
'== Constants Declaration ============================
|
|
|
38 |
'== Variable Init ====================================
|
|
|
39 |
'=====================================================
|
|
|
40 |
|
|
|
41 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
42 |
Sub CheckForPackageVersions ( nBomId, nCompareBomId, sUserName )
|
|
|
43 |
Dim rsQry, rsTemp, rsDep, aPackages, XMLNode, DateString, objPkgFileSys, sSourcePath, sDestPath, oFileSys
|
|
|
44 |
Dim lastRow, row, MappedDrive, objMessage, strBody, strHTML, isPatch, pkgName
|
|
|
45 |
Dim outUser, outPassword, command, login_details
|
|
|
46 |
Dim ftp, scriptPath, pdfPath
|
|
|
47 |
|
|
|
48 |
scriptPath = "E:\wwwTRD\manager_suite\deployment_manager\jobs\uploadscripts"
|
|
|
49 |
|
|
|
50 |
pdfPath = "E:\wwwTRD\manager_suite\deployment_manager\pdf"
|
|
|
51 |
|
|
|
52 |
Set oFileSys = CreateObject("Scripting.FileSystemObject")
|
|
|
53 |
|
|
|
54 |
OraDatabase.Parameters.Add "BOM_ID", nBomId, ORAPARM_INPUT, ORATYPE_NUMBER
|
|
|
55 |
OraDatabase.Parameters.Add "COMPARE_BOM_ID", nCompareBomId, ORAPARM_INPUT, ORATYPE_NUMBER
|
|
|
56 |
|
|
|
57 |
Set rsTemp = OraDatabase.DbCreateDynaset( GetQuery ("BomLocationDetails.sql"), ORADYN_DEFAULT )
|
|
|
58 |
|
|
|
59 |
Set rsQry = OraDatabase.DbCreateDynaset( GetQuery ("BomCompare.sql"), ORADYN_DEFAULT )
|
|
|
60 |
|
|
|
61 |
OraDatabase.Parameters.Remove "BOM_ID"
|
|
|
62 |
OraDatabase.Parameters.Remove "COMPARE_BOM_ID"
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
Set objPkgFileSys = New PkgArchive
|
|
|
66 |
|
|
|
67 |
objPkgFileSys.Map_Network_Drive UNC_ARCHIVE, MappedDrive ' Map Drive if required
|
|
|
68 |
|
|
|
69 |
objPkgFileSys.Remote_Host = TELNET_MACHINE
|
|
|
70 |
|
|
|
71 |
objPkgFileSys.Archive_Path = TELNET_RELEASES
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
If rsQry.RecordCount > 0 Then
|
|
|
76 |
aPackages = rsQry.GetRows()
|
|
|
77 |
|
|
|
78 |
End If
|
|
|
79 |
|
|
|
80 |
lastRow = UBound( aPackages, 2 )
|
|
|
81 |
DateString = DateReversed( Date )
|
|
|
82 |
|
|
|
83 |
'strBody = NULL
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
For row = 0 To lastRow
|
|
|
89 |
isPatch = aPackages (7, row)
|
|
|
90 |
|
|
|
91 |
If isPatch = "Y" Then
|
|
|
92 |
Set rsDep = OraDatabase.DbCreateDynaset( "select * from package_dependencies pd, package_versions pv where pd.dpv_id = pv.pv_id and pd.pv_id ="&aPackages(0, row), ORADYN_DEFAULT )
|
|
|
93 |
sSourcePath = "\\auperaunx26\releases\"&rsTemp("proj_name")&"\"&rsTemp("branch_name")&"\"&aPackages(1, row)&"\"&rsDep("pkg_version")
|
|
|
94 |
rsDep.Close()
|
|
|
95 |
Set rsDep = nothing
|
|
|
96 |
Else
|
|
|
97 |
sSourcePath = "\\auperaunx26\releases\"&rsTemp("proj_name")&"\"&rsTemp("branch_name")&"\"&aPackages(1, row)&"\"&aPackages(6, row)&"\"&aPackages(2, row)
|
|
|
98 |
|
|
|
99 |
Wscript.Echo sSourcePath
|
|
|
100 |
End If
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
If oFileSys.FolderExists( sSourcePath ) Then
|
|
|
104 |
objPkgFileSys.Make_Zip aPackages(1, row) &"-"& aPackages(2, row) &"-" & aPackages(6, row) &".zip", "/devl/releases/"& rsTemp("proj_name") &"/"& rsTemp("branch_name") &"/"& aPackages(1, row) &"/"& aPackages(6, row) &"/"& aPackages(2, row)&"/"
|
|
|
105 |
ftp = ftp + "mput "&chr(34)&"m:\releases\"&rsTemp("proj_name")&"\"&rsTemp("branch_name")&"\"&aPackages(1, row)&"\"&aPackages(6, row)&"\"&aPackages(2, row)&"\"&aPackages(1, row) &"-"& aPackages(2, row) &"-" & aPackages(6, row) &".zip"&chr(34)&""& VbCrLf
|
|
|
106 |
Else
|
|
|
107 |
'Wscript.Echo pkgName
|
|
|
108 |
If pkgName = aPackages(1, row) Then
|
|
|
109 |
strBody = strBody + "<br>Version: "&aPackages(2, row)
|
|
|
110 |
Else
|
|
|
111 |
strBody = strBody + "<br><br>"
|
|
|
112 |
strBody = strBody + "Project: "&rsTemp("proj_name")
|
|
|
113 |
strBody = strBody + "<br>Branch: "&rsTemp("branch_name")
|
|
|
114 |
strBody = strBody + "<br>Package: "&aPackages(1, row)
|
|
|
115 |
strBody = strBody + "<br>Version: "&aPackages(2, row)
|
|
|
116 |
End If
|
|
|
117 |
End If
|
|
|
118 |
pkgName = aPackages(1, row)
|
|
|
119 |
Next
|
|
|
120 |
|
|
|
121 |
If NOT IsNull( ftp ) Then
|
|
|
122 |
|
|
|
123 |
Dim batch_data, batch_file, txt_data, txt_file, pdf, pdf_data, pdf_file
|
|
|
124 |
|
|
|
125 |
pdf_file = rsTemp("bom_name")&" "&rsTemp("bom_version")&"."&rsTemp("bom_lifecycle")&".txt"
|
|
|
126 |
|
|
|
127 |
pdf = "mput "&chr(34)&pdfPath&"\"&rsTemp("bom_name")&" "&rsTemp("bom_version")&"."&rsTemp("bom_lifecycle")&".pdf"&chr(34)&""& VbCrLf
|
|
|
128 |
|
|
|
129 |
pdf_data = "open peraft01" & VbCrLf
|
|
|
130 |
pdf_data = pdf_data + "releasem" & VbCrLf
|
|
|
131 |
pdf_data = pdf_data + "releasem" & VbCrLf
|
|
|
132 |
pdf_data = pdf_data + "binary" & VbCrLf
|
|
|
133 |
pdf_data = pdf_data + "prompt" & VbCrLf
|
|
|
134 |
pdf_data = pdf_data + pdf & VbCrLf
|
|
|
135 |
pdf_data = pdf_data + "bye"
|
|
|
136 |
|
|
|
137 |
Call SaveBatchFile ( pdfPath, pdf_file, pdf_data )
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
txt_file = rsTemp("branch_name") + "_"&rsTemp("bom_version")&"."&rsTemp("bom_lifecycle")&".txt"
|
|
|
141 |
batch_file = rsTemp("branch_name") + "_"&rsTemp("bom_version")&"."&rsTemp("bom_lifecycle")&".bat"
|
|
|
142 |
|
|
|
143 |
txt_data = "open peraft01" & VbCrLf
|
|
|
144 |
txt_data = txt_data + "releasem" & VbCrLf
|
|
|
145 |
txt_data = txt_data + "releasem" & VbCrLf
|
|
|
146 |
txt_data = txt_data + "binary" & VbCrLf
|
|
|
147 |
txt_data = txt_data + "prompt" & VbCrLf
|
|
|
148 |
txt_data = txt_data + ftp & VbCrLf
|
|
|
149 |
txt_data = txt_data + "bye"
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
Call SaveBatchFile ( scriptPath, txt_file, txt_data )
|
|
|
153 |
|
|
|
154 |
batch_data = "ftp -s:"&chr(34)&pdfPath&"\"&pdf_file&""&chr(34)&""& VBCrLf
|
|
|
155 |
|
|
|
156 |
batch_data = batch_data + "net use m: "&UNC_ARCHIVE&" /USER:ERG\releasem releasem" & VbCrLf
|
|
|
157 |
batch_data = batch_data + "ftp -s:"&chr(34)&scriptPath&"\"&txt_file&""&chr(34)&""& VBCrLf
|
|
|
158 |
|
|
|
159 |
batch_data = batch_data + "net use m: /delete"
|
|
|
160 |
|
|
|
161 |
Call SaveBatchFile ( scriptPath, batch_file, batch_data )
|
|
|
162 |
|
|
|
163 |
Dim sysShell
|
|
|
164 |
|
|
|
165 |
Set sysShell = WScript.CreateObject("WScript.Shell")
|
|
|
166 |
|
|
|
167 |
Wscript.Echo chr(34)&scriptPath&"\"&batch_file&chr(34)
|
|
|
168 |
|
|
|
169 |
sysShell.Run chr(34)&scriptPath&"\"&batch_file&chr(34), 0, False
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
End If
|
|
|
173 |
|
|
|
174 |
If strBody <> "" Then
|
|
|
175 |
|
|
|
176 |
strHTML = "<HTML>"
|
|
|
177 |
strHTML = strHTML & "<HEAD>"
|
|
|
178 |
strHTML = strHTML & "<BODY>"
|
|
|
179 |
strHTML = strHTML & "<b>"&strBody&"</b></br>"
|
|
|
180 |
strHTML = strHTML & "</BODY>"
|
|
|
181 |
strHTML = strHTML & "</HTML>"
|
|
|
182 |
|
|
|
183 |
Set objMessage = CreateObject("CDO.Message")
|
|
|
184 |
objMessage.Subject = "Missing Packages In Releases Area"
|
|
|
185 |
objMessage.From = "releasem@erggroup.com" 'System Administrators
|
|
|
186 |
objMessage.To = sUserName&"@erggroup.com" 'BOM Releasor
|
|
|
187 |
'Wscript.Echo strHTML
|
|
|
188 |
|
|
|
189 |
'The line below shows how to send using HTML included directly in your script
|
|
|
190 |
objMessage.HTMLBody = strHTML
|
|
|
191 |
|
|
|
192 |
objMessage.Configuration.Fields.Item _
|
|
|
193 |
("http://schemas.microsoft.com/cdo/configuration/sendusing")= 2
|
|
|
194 |
|
|
|
195 |
'IP of remote SMTP server for ERG
|
|
|
196 |
objMessage.Configuration.Fields.Item _
|
|
|
197 |
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
|
|
|
198 |
= "aupera03.aupera.erggroup.com"
|
|
|
199 |
|
|
|
200 |
'Server port = 25
|
|
|
201 |
objMessage.Configuration.Fields.Item _
|
|
|
202 |
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
|
|
|
203 |
= 25
|
|
|
204 |
|
|
|
205 |
objMessage.Configuration.Fields.Update
|
|
|
206 |
|
|
|
207 |
objMessage.Send()
|
|
|
208 |
|
|
|
209 |
Set objMessage = Nothing
|
|
|
210 |
|
|
|
211 |
End If
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
Set objPkgFileSys = Nothing
|
|
|
216 |
Set oFileSys = Nothing
|
|
|
217 |
|
|
|
218 |
rsQry.Close()
|
|
|
219 |
rsTemp.Close()
|
|
|
220 |
|
|
|
221 |
Set rsQry = Nothing
|
|
|
222 |
Set rsTemp = Nothing
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
End Sub
|
|
|
229 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
Function FormatFileName ( sFileName )
|
|
|
233 |
Dim sReturn
|
|
|
234 |
|
|
|
235 |
sReturn = Replace ( sFileName, "/", "" )
|
|
|
236 |
sReturn = Replace ( sReturn, "\", "" )
|
|
|
237 |
sReturn = Replace ( sReturn, "&", "And" )
|
|
|
238 |
sReturn = Replace ( sReturn, " ", "_" )
|
|
|
239 |
|
|
|
240 |
FormatFileName = sReturn
|
|
|
241 |
|
|
|
242 |
End Function
|
|
|
243 |
'-----------------------------------------------------------------------------------------------------------------
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
'=================================== MAIN LINE ======================================
|
|
|
249 |
WScript.Echo "==================== job:CheckForPackageVersions ===================="
|
|
|
250 |
|
|
|
251 |
Set objArgs = WScript.Arguments
|
|
|
252 |
|
|
|
253 |
If (objArgs.Unnamed.Count > 0) Then
|
|
|
254 |
Wscript.Echo "ERROR: Unnamed parameters!"
|
|
|
255 |
objArgs.ShowUsage
|
|
|
256 |
WScript.Quit
|
|
|
257 |
|
|
|
258 |
Else
|
|
|
259 |
BomId = objArgs.Named.Item("bom_id")
|
|
|
260 |
CompareBomId = objArgs.Named.Item("compare_bom_id")
|
|
|
261 |
UserName = objArgs.Named.Item("user_name")
|
|
|
262 |
|
|
|
263 |
If ( BomId <> "" ) And (CompareBomId <> "") And (UserName <> "") Then
|
|
|
264 |
'Check if the Package Versions Exists for Tests to be Uploaded.
|
|
|
265 |
Call CheckForPackageVersions( BomId, CompareBomId, UserName )
|
|
|
266 |
Else
|
|
|
267 |
objArgs.ShowUsage
|
|
|
268 |
WScript.Quit
|
|
|
269 |
|
|
|
270 |
End If
|
|
|
271 |
|
|
|
272 |
End If
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
WScript.Echo "Job completed successfully!"
|
|
|
276 |
|
|
|
277 |
'====================================================================================
|
|
|
278 |
|
|
|
279 |
|
|
|
280 |
]]>
|
|
|
281 |
</script>
|
|
|
282 |
</job>
|
|
|
283 |
</package>
|