Subversion Repositories DevTools

Rev

Rev 119 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 119 Rev 133
Line 1... Line 1...
1
Option Explicit
1
Option Explicit
2
'=====================================================
2
'=====================================================
3
'        Name: 	common_subs.vbs
3
'        Name:   common_subs.vbs
4
' Description:	Contains list of common subs and functions
4
' Description:   Contains list of common subs and functions
5
'=====================================================
5
'=====================================================
6
'-----------------------------------------------------------------------------------------------------------------
6
'-----------------------------------------------------------------------------------------------------------------
7
' NOTE: This is NOT USED
7
' NOTE: This is NOT USED
8
' It is here only to satisfy Application variable in asp which VBS don't know about
8
' It is here only to satisfy Application variable in asp which VBS don't know about
9
Function Application( sParam )
9
Function Application( sParam )
10
	If sParam = "TNS_NAME" Then
10
   If sParam = "TNS_NAME" Then
11
		Application = ""
11
      Application = ""
12
	ElseIf sParam = "RELEASE_MANAGER_LOGIN" Then
12
   ElseIf sParam = "RELEASE_MANAGER_LOGIN" Then
13
		Application = ""
13
      Application = ""
14
	End If
14
   End If
15
End Function
15
End Function
16
'-----------------------------------------------------------------------------------------------------------------
16
'-----------------------------------------------------------------------------------------------------------------
17
Function ReadFile( SSpath )
17
Function ReadFile( SSpath )
18
	Dim filesys, rfile
18
   Dim filesys, rfile
19
	Set filesys = CreateObject("Scripting.FileSystemObject")
19
   Set filesys = CreateObject("Scripting.FileSystemObject")
20
	
20
 
21
	On Error Resume Next
21
   On Error Resume Next
22
	If filesys.FileExists ( SSpath ) Then
22
   If filesys.FileExists ( SSpath ) Then
23
    	Set rfile = filesys.OpenTextFile( SSpath, 1, false)
23
       Set rfile = filesys.OpenTextFile( SSpath, 1, false)
24
    	ReadFile = rfile.ReadAll
24
       ReadFile = rfile.ReadAll
25
    	rfile.close
25
       rfile.close
26
    Else
26
    Else
27
        Call Raise_Event ( enumEVENT_ERROR, "[sub:ReadFile]", _
27
        Call Raise_Event ( enumEVENT_ERROR, "[sub:ReadFile]", _
28
											"File: "& SSpath, _
28
                           "File: "& SSpath, _
29
						   					"File not found!", enum_RELEASE_NOTES_FAILED )
29
                           "File not found!", enum_RELEASE_NOTES_FAILED )
30
    End If
30
    End If
31
	
31
 
32
	Call ErrorCheck ( "[sub:ReadFile]", NULL )
32
   Call ErrorCheck ( "[sub:ReadFile]", NULL )
33
	
33
 
34
	Set filesys = nothing
34
   Set filesys = nothing
35
End Function
35
End Function
36
'-----------------------------------------------------------------------------------------------------------------
36
'-----------------------------------------------------------------------------------------------------------------
37
Sub SaveFile( SSpath, SSfilename, SScontent )
37
Sub SaveFile( SSpath, SSfilename, SScontent )
38
	Dim filesys, filetxt
38
   Dim filesys, filetxt
39
	Set filesys = CreateObject("Scripting.FileSystemObject")
39
   Set filesys = CreateObject("Scripting.FileSystemObject")
40
    WScript.Echo "Saving file "& SSpath &"\"& SSfilename &" ..."
40
   WScript.Echo "Saving file "& SSpath &"\"& SSfilename &" ..."
41
    
41
 
42
	On Error Resume Next
42
   On Error Resume Next
43
	Set filetxt = filesys.CreateTextFile( SSpath &"\"& SSfilename, True )
43
   Set filetxt = filesys.CreateTextFile( SSpath &"\"& SSfilename, True )
44
	filetxt.WriteLine(SScontent)
44
   filetxt.WriteLine(SScontent)
45
	filetxt.Close
45
   filetxt.Close
46
	
46
 
47
	Call ErrorCheck ( "[sub:SaveFile]", NULL )
47
   Call ErrorCheck ( "[sub:SaveFile]", NULL )
48
	
48
 
49
	WScript.Echo "File Saved: "& SSpath &"\"& SSfilename
49
   WScript.Echo "File Saved: "& SSpath &"\"& SSfilename
50
	Set filetxt = nothing
50
   Set filetxt = nothing
51
	Set filesys = nothing
51
   Set filesys = nothing
52
End Sub
52
End Sub
53
'-----------------------------------------------------------------------------------------------------------------
53
'-----------------------------------------------------------------------------------------------------------------
54
Sub DeleteFile( SSpath )
54
Sub DeleteFile( SSpath )
55
	Dim filesys
55
   Dim filesys
56
	Set filesys = CreateObject("Scripting.FileSystemObject")
56
   Set filesys = CreateObject("Scripting.FileSystemObject")
57
	If filesys.FileExists(SSpath) Then
57
   If filesys.FileExists(SSpath) Then
58
   		filesys.DeleteFile SSpath 
58
      filesys.DeleteFile SSpath
59
	End If 
59
   End If
60
	Set filesys = nothing
60
   Set filesys = nothing
61
End Sub
61
End Sub
62
'-----------------------------------------------------------------------------------------------------------------
62
'-----------------------------------------------------------------------------------------------------------------
63
Sub DeleteFolder( SSpath )
63
Sub DeleteFolder( SSpath )
64
	Dim  filesys
64
   Dim  filesys
65
	Set filesys = CreateObject ("Scripting.FileSystemObject")
65
   Set filesys = CreateObject ("Scripting.FileSystemObject")
66
	If filesys.FolderExists( SSpath ) Then
66
   If filesys.FolderExists( SSpath ) Then
67
		filesys.DeleteFolder SSpath, TRUE
67
      filesys.DeleteFolder SSpath, TRUE
68
	End If
68
   End If
69
End Sub
69
End Sub
70
'-----------------------------------------------------------------------------------------------------------------
70
'-----------------------------------------------------------------------------------------------------------------
71
Function Folder_Is_Empty ( sPath )
71
Function Folder_Is_Empty ( sPath )
72
	Dim filesys, oFolder
72
   Dim filesys, oFolder
73
	Set filesys = CreateObject("Scripting.FileSystemObject") 
73
   Set filesys = CreateObject("Scripting.FileSystemObject")
74
	
74
 
75
	If filesys.FolderExists( sPath ) Then
75
   If filesys.FolderExists( sPath ) Then
76
		Set oFolder = filesys.GetFolder( sPath )  
76
      Set oFolder = filesys.GetFolder( sPath )
77
		If ( oFolder.Files.Count + oFolder.SubFolders.Count ) > 0 Then
77
      If ( oFolder.Files.Count + oFolder.SubFolders.Count ) > 0 Then
78
			Folder_Is_Empty = FALSE
78
         Folder_Is_Empty = FALSE
79
		Else
79
      Else
80
			Folder_Is_Empty = TRUE
80
         Folder_Is_Empty = TRUE
81
		End If
81
      End If
82
	Else
82
   Else
83
		Folder_Is_Empty = TRUE
83
      Folder_Is_Empty = TRUE
84
	End If
84
   End If
85
	
85
 
86
End Function
86
End Function
87
'-----------------------------------------------------------------------------------------------------------------
87
'-----------------------------------------------------------------------------------------------------------------
88
Function NVL ( SSvalue )
88
Function NVL ( SSvalue )
89
	If IsNull(SSvalue) Or SSvalue = "" Then
89
   If IsNull(SSvalue) Or SSvalue = "" Then
90
		NVL = " "
90
      NVL = " "
91
	Else
91
   Else
92
		NVL = SSvalue
92
      NVL = SSvalue
93
	End If
93
   End If
94
End Function
94
End Function
95
'-----------------------------------------------------------------------------------------------------------------
95
'-----------------------------------------------------------------------------------------------------------------
96
Function Format_FileName( sPkg_name, sPkg_version, nPv_id )
96
Function Format_FileName( sPkg_name, sPkg_version, nPv_id )
97
	Dim name, version
97
   Dim name, version
98
	name =  Replace( sPkg_name, " ", "_")
98
   name =  Replace( sPkg_name, " ", "_")
99
	version = Replace( sPkg_version, " ", "")
99
   version = Replace( sPkg_version, " ", "")
100
	version = Replace( version, ".", "_")
100
   version = Replace( version, ".", "_")
101
	
101
 
102
	Format_FileName = RELESE_NOTES_PERFIX &"_"& nPv_id &"_"& name &"_"& version &".html"
102
   Format_FileName = RELESE_NOTES_PERFIX &"_"& nPv_id &"_"& name &"_"& version &".html"
103
End Function
103
End Function
104
'-----------------------------------------------------------------------------------------------------------------
104
'-----------------------------------------------------------------------------------------------------------------
105
Function Get_Application_Path ()
105
Function Get_Application_Path ()
106
	Dim tempSTR
106
   Dim tempSTR
107
	tempSTR = WScript.ScriptFullName
107
   tempSTR = WScript.ScriptFullName
108
 
108
 
109
	Get_Application_Path = Left( tempSTR, InStrRev( tempSTR, "\", InStrRev( tempSTR, "\" ) -1 ) )
109
   Get_Application_Path = Left( tempSTR, InStrRev( tempSTR, "\", InStrRev( tempSTR, "\" ) -1 ) )
110
End Function
110
End Function
111
'-----------------------------------------------------------------------------------------------------------------
111
'-----------------------------------------------------------------------------------------------------------------
112
Sub Include_File ( SSFile )
112
Sub Include_File ( SSFile )
113
	Dim myInclude
113
   Dim myInclude
114
	myInclude = ReadFile( SSFile )
114
   myInclude = ReadFile( SSFile )
115
	myInclude = Replace ( myInclude, "<%", "" )		' Remove ASP tags
115
   myInclude = Replace ( myInclude, "<%", "" )      ' Remove ASP tags
116
	myInclude = Replace ( myInclude, "%>", "" )		' Remove ASP tags
116
   myInclude = Replace ( myInclude, "%>", "" )      ' Remove ASP tags
117
	Execute( myInclude )
117
   Execute( myInclude )
118
End Sub
118
End Sub
119
'-----------------------------------------------------------------------------------------------------------------
119
'-----------------------------------------------------------------------------------------------------------------
120
Sub CRC_cksum ( SSfile_name, outCRC, outSize )
120
Sub CRC_cksum ( SSfile_name, outCRC, outSize )
121
	Dim sysShell, crcDump, oExec, outStdErr, outStrOut, crcARR
121
   Dim sysShell, crcDump, oExec, outStdErr, outStrOut, crcARR
122
	Set sysShell = WScript.CreateObject("WScript.Shell")
122
   Set sysShell = WScript.CreateObject("WScript.Shell")
123
	
123
 
124
	
124
 
125
	Set oExec = sysShell.Exec( AppPath & CKSUM_EXE &" """& SSfile_name &"""" )
125
   Set oExec = sysShell.Exec( AppPath & CKSUM_EXE &" """& SSfile_name &"""" )
126
	
126
 
127
	outStdErr = oExec.StdErr.ReadLine
127
   outStdErr = oExec.StdErr.ReadLine
128
	outStrOut = oExec.StdOut.ReadLine
128
   outStrOut = oExec.StdOut.ReadLine
129
	
129
 
130
	If outStdErr = "" Then
130
   If outStdErr = "" Then
131
		crcDump = Trim( outStrOut )
131
      crcDump = Trim( outStrOut )
132
		crcDump = Replace ( crcDump, VBNewLine, "" )		' Remove newline characters
132
      crcDump = Replace ( crcDump, VBNewLine, "" )      ' Remove newline characters
133
		While InStr( crcDump, "  ") > 0
133
      While InStr( crcDump, "  ") > 0
134
			crcDump = Replace ( crcDump, "  ", " " )		' Ensure single space between items
134
         crcDump = Replace ( crcDump, "  ", " " )      ' Ensure single space between items
135
		Wend
135
      Wend
136
	
136
 
137
		crcARR = Split ( crcDump, " " ) 	' Split with space
137
      crcARR = Split ( crcDump, " " )    ' Split with space
138
		outCRC = crcARR(0)
138
      outCRC = crcARR(0)
139
		outSize = crcARR(1)
139
      outSize = crcARR(1)
140
	Else
140
   Else
141
		outCRC = -1		' Error occuerd during cksum. Can be no read permissions
141
      outCRC = -1      ' Error occuerd during cksum. Can be no read permissions
142
		outSize = -1
142
      outSize = -1
143
	End If
143
   End If
144
	
144
 
145
	Set sysShell = nothing
145
   Set sysShell = nothing
146
End Sub
146
End Sub
147
'-----------------------------------------------------------------------------------------------------------------
147
'-----------------------------------------------------------------------------------------------------------------
148
Sub CRC_modcrc ( SSfile_name, SSfile_path, outCRC, outSize )
148
Sub CRC_modcrc ( SSfile_name, SSfile_path, outCRC, outSize )
149
	Dim sysShell, crcDump, oExec, outStdErr, outStrOut, crcARR
149
   Dim sysShell, crcDump, oExec, outStdErr, outStrOut, crcARR
150
	Set sysShell = WScript.CreateObject("WScript.Shell")
150
   Set sysShell = WScript.CreateObject("WScript.Shell")
151
	
151
 
152
	Set oExec = sysShell.Exec( AppPath & MODCRC_EXE &" -m="& SSfile_path & SSfile_name &" -i=thx" )
152
   Set oExec = sysShell.Exec( AppPath & MODCRC_EXE &" -m="& SSfile_path & SSfile_name &" -i=thx" )
153
 
153
 
154
	outStdErr = oExec.StdErr.ReadLine
154
   outStdErr = oExec.StdErr.ReadLine
155
	outStrOut = oExec.StdOut.ReadLine
155
   outStrOut = oExec.StdOut.ReadLine
156
	
156
 
157
	If outStdErr = "" Then
157
   If outStdErr = "" Then
158
		crcDump = Trim( outStrOut )
158
      crcDump = Trim( outStrOut )
159
		crcDump = Replace ( crcDump, VBNewLine, "" )		' Remove newline characters
159
      crcDump = Replace ( crcDump, VBNewLine, "" )      ' Remove newline characters
160
		While InStr( crcDump, "  ") > 0
160
      While InStr( crcDump, "  ") > 0
161
			crcDump = Replace ( crcDump, "  ", " " )		' Ensure single space between items
161
         crcDump = Replace ( crcDump, "  ", " " )      ' Ensure single space between items
162
		Wend
162
      Wend
163
	
163
 
164
		crcARR = Split ( crcDump, " " ) 	' Split with space
164
      crcARR = Split ( crcDump, " " )    ' Split with space
165
		outCRC = crcARR(4)
165
      outCRC = crcARR(4)
166
		outSize = crcARR(6)
166
      outSize = crcARR(6)
167
	Else
167
   Else
168
		outCRC = -1		' Error occuerd during cksum. Can be no read permissions
168
      outCRC = -1      ' Error occuerd during cksum. Can be no read permissions
169
		outSize = -1
169
      outSize = -1
170
	End If
170
   End If
171
	
171
 
172
	Set sysShell = nothing
172
   Set sysShell = nothing
173
End Sub
173
End Sub
174
'-----------------------------------------------------------------------------------------------------------------
174
'-----------------------------------------------------------------------------------------------------------------
175
Sub Raise_Event ( eventType, SSlocation, SSvalues, SSerror_message, sDBmsg )
175
Sub Raise_Event ( eventType, SSlocation, SSvalues, SSerror_message, sDBmsg )
176
	Dim WshShell, WshNetwork, objArgs, i, agrSTR, SSmsg
176
   Dim WshShell, WshNetwork, objArgs, i, agrSTR, SSmsg
177
	Set WshShell = WScript.CreateObject("WScript.Shell")
177
   Set WshShell = WScript.CreateObject("WScript.Shell")
178
    Set WshNetwork = WScript.CreateObject("WScript.Network")
178
   Set WshNetwork = WScript.CreateObject("WScript.Network")
179
    
179
 
180
	Set objArgs = WScript.Arguments
180
   Set objArgs = WScript.Arguments
181
	For i = 0 to objArgs.Count - 1
181
   For i = 0 to objArgs.Count - 1
182
	   agrSTR = agrSTR & objArgs(i) & VBNewLine
182
      agrSTR = agrSTR & objArgs(i) & VBNewLine
183
	Next
183
   Next
184
	
184
 
185
	' Compose Message
185
   ' Compose Message
186
	SSmsg = _
186
   SSmsg = _
187
	"-- Script Info  --"& VBNewLine &_
187
   "-- Script Info  --"& VBNewLine &_
188
	"Host Name: "& WshNetwork.ComputerName & VBNewLine &_
188
   "Host Name: "& WshNetwork.ComputerName & VBNewLine &_
189
	"Script Name: "& WScript.ScriptName & VBNewLine & VBNewLine &_
189
   "Script Name: "& WScript.ScriptName & VBNewLine & VBNewLine &_
190
	"-- Script Parameters --"& VBNewLine &_
190
   "-- Script Parameters --"& VBNewLine &_
191
	agrSTR &_
191
   agrSTR &_
192
	VBNewLine &_
192
   VBNewLine &_
193
	"-- Error Location --"& VBNewLine &_
193
   "-- Error Location --"& VBNewLine &_
194
	SSlocation & VBNewLine &_
194
   SSlocation & VBNewLine &_
195
	VBNewLine &_
195
   VBNewLine &_
196
	"-- Values --"& VBNewLine &_
196
   "-- Values --"& VBNewLine &_
197
	SSvalues & VBNewLine &_
197
   SSvalues & VBNewLine &_
198
	VBNewLine &_
198
   VBNewLine &_
199
	"-- Error Message --"& VBNewLine &_
199
   "-- Error Message --"& VBNewLine &_
200
	SSerror_message & VBNewLine 
200
   SSerror_message & VBNewLine
201
	
201
 
202
	'-- Raise this message at these places...
202
   '-- Raise this message at these places...
203
	Wscript.Echo SSmsg
203
   Wscript.Echo SSmsg
204
	WshShell.LogEvent eventType, SSmsg
204
   WshShell.LogEvent eventType, SSmsg
205
	'Call Alert_Admin ( SSmsg )
205
   'Call Alert_Admin ( SSmsg )
206
	'----------------------------------------
206
   '----------------------------------------
207
	
207
 
208
	Set WshShell = Nothing
208
   Set WshShell = Nothing
209
	
209
 
210
	If Not IsNull(sDBmsg) Then Call Write_To_Release_Notes_Info ( parPv_id, sDBmsg )
210
   If Not IsNull(sDBmsg) Then Call Write_To_Release_Notes_Info ( parPv_id, sDBmsg )
211
	If eventType = enumEVENT_ERROR Then WScript.Quit    ' Only Quit if ERROR
211
   If eventType = enumEVENT_ERROR Then WScript.Quit    ' Only Quit if ERROR
212
	
212
 
213
End Sub
213
End Sub
214
'-----------------------------------------------------------------------------------------------------------------
214
'-----------------------------------------------------------------------------------------------------------------
215
Sub ErrorCheck ( ERRlocation, ERRvals )
215
Sub ErrorCheck ( ERRlocation, ERRvals )
216
	If Err.Number <> 0 Then
216
   If Err.Number <> 0 Then
217
		Call Raise_Event ( enumEVENT_ERROR, ERRlocation, ERRvals, Err.Source &" "& Err.Description, enum_RELEASE_NOTES_FAILED  )
217
      Call Raise_Event ( enumEVENT_ERROR, ERRlocation, ERRvals, Err.Source &" "& Err.Description, enum_RELEASE_NOTES_FAILED  )
218
	End If
218
   End If
219
	Err.Clear
219
   Err.Clear
220
End Sub
220
End Sub
221
'-----------------------------------------------------------------------------------------------------------------
221
'-----------------------------------------------------------------------------------------------------------------
222
Sub Alert_Admin ( SSmsg )
222
Sub Alert_Admin ( SSmsg )
223
	'Call Send_Email ( adminEmail, adminEmail, "Windows Script Alert!", SSmsg )
223
   'Call Send_Email ( adminEmail, adminEmail, "Windows Script Alert!", SSmsg )
224
End Sub
224
End Sub
225
'-----------------------------------------------------------------------------------------------------------------
225
'-----------------------------------------------------------------------------------------------------------------
226
Sub Send_Email ( SSfrom, SSto, SSsubject, SSbody )
226
Sub Send_Email ( SSfrom, SSto, SSsubject, SSbody )
227
	'Dim objCDOMail
227
   'Dim objCDOMail
228
	'Set objCDOMail = CreateObject("CDONTS.NewMail")
228
   'Set objCDOMail = CreateObject("CDONTS.NewMail")
229
	''objCDOMail.From = Request.Form("firstName") & " " & Request.Form("lastName") & " <" & strReturnEmailAddress & ">"
229
   ''objCDOMail.From = Request.Form("firstName") & " " & Request.Form("lastName") & " <" & strReturnEmailAddress & ">"
230
	'objCDOMail.From = SSfrom
230
   'objCDOMail.From = SSfrom
231
	'objCDOMail.To = SSto
231
   'objCDOMail.To = SSto
232
	''objCDOMail.Cc = strCCEmailAddress
232
   ''objCDOMail.Cc = strCCEmailAddress
233
	''objCDOMail.Bcc = strBCCEmailAddress
233
   ''objCDOMail.Bcc = strBCCEmailAddress
234
	'objCDOMail.Subject = SSsubject
234
   'objCDOMail.Subject = SSsubject
235
	'objCDOMail.BodyFormat = 1		 		' 0 = HTML, 1 = Plain
235
   'objCDOMail.BodyFormat = 1             ' 0 = HTML, 1 = Plain
236
	'objCDOMail.MailFormat = 1 				' 0 = MIME, 1 = Text
236
   'objCDOMail.MailFormat = 1             ' 0 = MIME, 1 = Text
237
	'objCDOMail.Importance = 0 				' 0 = High, 1 = Medium, 2 = Low
237
   'objCDOMail.Importance = 0             ' 0 = High, 1 = Medium, 2 = Low
238
	''objCDOMail.attachFile ("c:\images\mypicture.gif") ' you can also attach files 
238
   ''objCDOMail.attachFile ("c:\images\mypicture.gif") ' you can also attach files
239
	'objCDOMail.Body = SSbody
239
   'objCDOMail.Body = SSbody
240
	''objCDOMail.Send
240
   ''objCDOMail.Send
241
	'Set objCDOMail = Nothing
241
   'Set objCDOMail = Nothing
242
End Sub
242
End Sub
243
'-----------------------------------------------------------------------------------------------------------------
243
'-----------------------------------------------------------------------------------------------------------------
244
Sub Get_PV_ID ( SSpkg_name, SSpkg_version, outPV_ID)
244
Sub Get_PV_ID ( SSpkg_name, SSpkg_version, outPV_ID)
245
	Dim Query_String, rsTemp
245
   Dim Query_String, rsTemp
246
	
246
 
247
	If outPV_ID <> "" Then Exit Sub		' PV_ID already assigned
247
   If outPV_ID <> "" Then Exit Sub      ' PV_ID already assigned
248
	
248
 
249
	Query_String = _
249
   Query_String = _
250
	" SELECT pv.pv_id"&_
250
   " SELECT pv.pv_id"&_
251
	" FROM packages pkg,"&_
251
   "   FROM packages pkg,"&_
252
	"      package_versions pv"&_
252
   "        package_versions pv"&_
253
	" WHERE pv.pkg_id = pkg.pkg_id"&_
253
   "  WHERE pv.pkg_id = pkg.pkg_id"&_
254
	"   AND pkg.pkg_name = '"& SSpkg_name &"'"&_
254
   "    AND pkg.pkg_name = '"& SSpkg_name &"'"&_
255
	"   AND pv.pkg_version = '"& SSpkg_version &"'"
255
   "    AND pv.pkg_version = '"& SSpkg_version &"'"
256
	Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
256
   Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
257
	
257
 
258
	If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
258
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
259
		outPV_ID = rsTemp("pv_id")
259
      outPV_ID = rsTemp("pv_id")
260
	Else
260
   Else
261
		Call Raise_Event ( enumEVENT_ERROR, "[sub:Get_PV_ID]", _
261
      Call Raise_Event ( enumEVENT_ERROR, "[sub:Get_PV_ID]", _
262
											"pkg_name: "& SSpkg_name & VBNewLine &_
262
                         "pkg_name: "& SSpkg_name & VBNewLine &_
263
											"pkg_version: "& SSpkg_version , _
263
                         "pkg_version: "& SSpkg_version , _
264
						   					"pkg_name and/or pkg_version not found in Release Manager database!", enum_RELEASE_NOTES_FAILED )
264
                         "pkg_name and/or pkg_version not found in Release Manager database!", enum_RELEASE_NOTES_FAILED )
265
	End If
265
   End If
266
	rsTemp.Close
266
   rsTemp.Close
267
	Set rsTemp = Nothing
267
   Set rsTemp = Nothing
268
End Sub
268
End Sub
269
'-----------------------------------------------------------------------------------------------------------------
269
'-----------------------------------------------------------------------------------------------------------------
270
Function Get_Package_Type ( NNpv_id )
270
Function Get_Package_Type ( NNpv_id )
271
	Dim Query_String, rsTemp
271
   Dim Query_String, rsTemp
272
	
272
 
273
	Query_String = ReadFile( AppPath & QUERIES_FOLDER & "\package_type.sql" )
273
   Query_String = ReadFile( AppPath & QUERIES_FOLDER & "\package_type.sql" )
274
	OraDatabase.Parameters.Add "PV_ID", NNpv_id, ORAPARM_INPUT, ORATYPE_NUMBER
274
   OraDatabase.Parameters.Add "PV_ID", NNpv_id, ORAPARM_INPUT, ORATYPE_NUMBER
275
	OraDatabase.Parameters.Add "enumBASE_VIEW_PRODUCTS", enumBASE_VIEW_PRODUCTS, ORAPARM_INPUT, ORATYPE_NUMBER
275
   OraDatabase.Parameters.Add "enumBASE_VIEW_PRODUCTS", enumBASE_VIEW_PRODUCTS, ORAPARM_INPUT, ORATYPE_NUMBER
276
	Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
276
   Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
277
	
277
 
278
	If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
278
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
279
		If Not IsNull( rsTemp("message") ) Then 
279
      If Not IsNull( rsTemp("message") ) Then
280
			Get_Package_Type = Eval(rsTemp("message"))
280
         Get_Package_Type = Eval(rsTemp("message"))
281
		Else
281
      Else
282
			Get_Package_Type = enumPKG_TYPE_GENERIC_DPKG
282
         Get_Package_Type = enumPKG_TYPE_GENERIC_DPKG
283
		End If
283
      End If
284
	Else
284
   Else
285
		Get_Package_Type = enumPKG_TYPE_GENERIC_DPKG
285
      Get_Package_Type = enumPKG_TYPE_GENERIC_DPKG
286
	End If
286
   End If
287
	
287
 
288
	WScript.Echo "Package Type : "& Get_Package_Type
288
   WScript.Echo "Package Type : "& Get_Package_Type
289
	
289
 
290
	OraDatabase.Parameters.Remove "PV_ID"
290
   OraDatabase.Parameters.Remove "PV_ID"
291
	OraDatabase.Parameters.Remove "enumBASE_VIEW_PRODUCTS"
291
   OraDatabase.Parameters.Remove "enumBASE_VIEW_PRODUCTS"
292
	rsTemp.Close
292
   rsTemp.Close
293
	Set rsTemp = Nothing
293
   Set rsTemp = Nothing
294
End Function
294
End Function
295
'-----------------------------------------------------------------------------------------------------------------
295
'-----------------------------------------------------------------------------------------------------------------
296
Sub Get_Pkg_Name_Version ( NNpv_id, outPkg_name, outPkg_version )
296
Sub Get_Pkg_Name_Version ( NNpv_id, outPkg_name, outPkg_version )
297
	Dim Query_String, rsTemp
297
   Dim Query_String, rsTemp
298
	
298
 
299
	Query_String = _
299
   Query_String = _
300
	" SELECT pkg.pkg_name, pv.pkg_version"&_
300
   " SELECT pkg.pkg_name, pv.pkg_version"&_
301
	" FROM packages pkg,"&_
301
   "   FROM packages pkg,"&_
302
	"      package_versions pv"&_
302
   "        package_versions pv"&_
303
	" WHERE pv.pkg_id = pkg.pkg_id"&_
303
   "  WHERE pv.pkg_id = pkg.pkg_id"&_
304
	"   AND pv.pv_id = "& NNpv_id 
304
   "    AND pv.pv_id = "& NNpv_id
305
	Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
305
   Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
306
	
306
 
307
	If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
307
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
308
		outPkg_name = rsTemp("pkg_name")
308
      outPkg_name = rsTemp("pkg_name")
309
		outPkg_version = rsTemp("pkg_version")
309
      outPkg_version = rsTemp("pkg_version")
310
	Else
310
   Else
311
		Call Raise_Event ( enumEVENT_ERROR, "[sub:Get_Pkg_Name_Version]", _
311
      Call Raise_Event ( enumEVENT_ERROR, "[sub:Get_Pkg_Name_Version]", _
312
											"PV_ID: "& NNpv_id , _
312
                         "PV_ID: "& NNpv_id , _
313
		 								    "PV_ID not found in Release Manager database!", enum_RELEASE_NOTES_FAILED )
313
                         "PV_ID not found in Release Manager database!", enum_RELEASE_NOTES_FAILED )
314
	End If
314
   End If
315
	
315
 
316
	rsTemp.Close
316
   rsTemp.Close
317
	Set rsTemp = Nothing
317
   Set rsTemp = Nothing
318
End Sub
318
End Sub
319
'-----------------------------------------------------------------------------------------------------------------
319
'-----------------------------------------------------------------------------------------------------------------
320
Sub Check_Requirements_To_Proceed ( nPv_id )
320
Sub Check_Requirements_To_Proceed ( nPv_id )
321
	Dim Query_String, rsTemp
321
   Dim Query_String, rsPackageVersions, rsRunLevel, rsReleaseConfig, rsReleaseTags
322
	
322
 
323
	' Exit if Release Notyes Generation is forced
323
   ' Exit if Release Notyes Generation is forced
324
	If objArgs.Named.Item("f") <> "" Then Exit Sub
324
   If objArgs.Named.Item("f") <> "" Then Exit Sub
325
	
-
 
326
	
325
 
327
	Query_String = _
326
   Query_String = _
328
	" SELECT pv.release_notes_info"&_
327
   " SELECT pv.release_notes_info, pv.pkg_id"&_
329
	" FROM package_versions pv"&_
328
   " FROM package_versions pv"&_
330
	" WHERE pv.pv_id = "& nPv_id
329
   " WHERE pv.pv_id = "& nPv_id
331
	
330
 
332
	Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
331
   Set rsPackageVersions = OraDatabase.CreateDynaset( Query_String, cint(0))
333
	
332
 
334
	If rsTemp("release_notes_info") <> enum_RELEASE_NOTES_GENERATING Then
333
   If rsPackageVersions("release_notes_info") <> enum_RELEASE_NOTES_GENERATING Then
335
	    WScript.Echo "Exiting this job. release_notes_info in [PACKAGE_VERSIONS] table is ("& rsTemp("release_notes_info") &")"
334
      WScript.Echo "Exiting this job. release_notes_info in [PACKAGE_VERSIONS] table is ("& rsPackageVersions("release_notes_info") &")"
336
	    WScript.Echo "Expected value is ("& enum_RELEASE_NOTES_GENERATING &")"
335
      WScript.Echo "Expected value is ("& enum_RELEASE_NOTES_GENERATING &")"
337
	    Call Raise_Event ( enumEVENT_ERROR, "[sub:Check_Requirements_To_Proceed]", _
336
      Call Raise_Event ( enumEVENT_ERROR, "[sub:Check_Requirements_To_Proceed]", _
338
											"PV_ID: "& nPv_id , _
337
                         "PV_ID: "& nPv_id , _
339
		 								    "Exiting this job. release_notes_info in [PACKAGE_VERSIONS] table is ("& rsTemp("release_notes_info") &")", NULL )
338
                         "Exiting this job. release_notes_info in [PACKAGE_VERSIONS] table is ("& rsPackageVersions("release_notes_info") &")", NULL )
340
	End If
339
   End If
-
 
340
 
-
 
341
   ' Do not proceed if the build daemon is building a version of the package. This is an attempt to make sure that
-
 
342
   ' release notes generation does not cause a problem for the build daemons, such as might be the case if and when
-
 
343
   ' it manipulates file ownership later on, etc (see DEVI-48682). This is not a foolproof method to prevent the problem,
-
 
344
   ' but it should reduce the likelyhood of it occuring
-
 
345
   Dim mustAbort
-
 
346
   mustAbort = FALSE
-
 
347
 
-
 
348
   Query_String = _
-
 
349
   " SELECT * "&_
-
 
350
   "   FROM run_level rl"&_
-
 
351
   "  WHERE rl.current_pkg_id_being_built = "& rsPackageVersions("pkg_id")
-
 
352
 
-
 
353
   Set rsRunLevel = OraDatabase.CreateDynaset( Query_String, cint(0))
-
 
354
 
-
 
355
   'For each run_level table entry...
-
 
356
   Do While (NOT rsRunLevel.BOF) AND (NOT rsRunLevel.EOF) AND (mustAbort = FALSE)
-
 
357
 
-
 
358
      ' Make sure that the release configuration shows that there is a daemon hostname associated with this
-
 
359
      ' run_level table entry.
-
 
360
      Query_String = _
-
 
361
      " SELECT rtag_id, daemon_hostname"&_
-
 
362
      "   FROM release_config"&_
-
 
363
      "  WHERE rcon_id = "& rsRunLevel("rcon_id")
-
 
364
 
-
 
365
      Set rsReleaseConfig = OraDatabase.CreateDynaset( Query_String, cint(0))
-
 
366
      If (rsReleaseConfig.RecordCount > 0) AND NOT IsNull(rsReleaseConfig("daemon_hostname")) Then
-
 
367
         ' ought to check the validity of the daemon hostname - will have to wait for these to be configured metadata
-
 
368
         ' before we can do that though, unless we hard-code the valid names here somewhere.
-
 
369
         ' Anyway, the hostname is not null so it looks like the run_level entry is one we cannot dis-regard
-
 
370
 
-
 
371
         ' if the run level is ACTIVE (3) then abort
-
 
372
         If rsRunLevel("current_run_level") = 3 Then
-
 
373
            mustAbort = TRUE
-
 
374
         Else
-
 
375
            ' run level must be WAITING, PAUSED, etc, so examine the official state of the release to see if
-
 
376
            ' it is still open in some way
-
 
377
            Query_String = _
-
 
378
            " SELECT official"&_
-
 
379
            "   FROM release_tags"&_
-
 
380
            "  WHERE rtag_id = "& rsReleaseConfig("rtag_id")
-
 
381
 
-
 
382
            Set rsReleaseTags = OraDatabase.CreateDynaset( Query_String, cint(0))
-
 
383
            If (rsReleaseTags.RecordCount > 0) Then
-
 
384
               ' If release is not closed or archived
-
 
385
               If NOT (IsNull(rsReleaseTags("official")) OR (rsReleaseTags("official") = "Y") OR (rsReleaseTags("official") = "A")) Then
-
 
386
                  ' release is still open (OPEN or RESTRICTED, or CCB Mode) so abort
-
 
387
                  mustAbort = TRUE
-
 
388
               End If
-
 
389
            End If
-
 
390
            rsReleaseTags.Close
-
 
391
            Set rsReleaseTags = Nothing
-
 
392
         End If
-
 
393
      End If
-
 
394
 
-
 
395
      rsReleaseConfig.Close
-
 
396
      Set rsReleaseConfig = Nothing
-
 
397
 
-
 
398
      rsRunLevel.MoveNext
-
 
399
   Loop
-
 
400
 
-
 
401
   If (mustAbort) Then
-
 
402
      WScript.Echo "Exiting this job. Build Daemon is currently building this/another version of this package."
-
 
403
      WScript.Echo "Try again later."
-
 
404
      Call Raise_Event ( enumEVENT_ERROR, "[sub:Check_Requirements_To_Proceed]", _
-
 
405
                         "PV_ID: "& nPv_id & VBNewLine & "PKG_ID: "& rsPackageVersions("pkg_id"), _
-
 
406
                         "Exiting this job. Build Daemon is currently building this/another version of this package.", NULL )
-
 
407
   End If
341
	
408
 
342
	rsTemp.Close
409
   rsRunLevel.Close
343
	Set rsTemp = Nothing
410
   Set rsRunLevel = Nothing
-
 
411
 
-
 
412
   rsPackageVersions.Close
-
 
413
   Set rsPackageVersions = Nothing
-
 
414
 
344
End Sub
415
End Sub
345
'-----------------------------------------------------------------------------------------------------------------
416
'-----------------------------------------------------------------------------------------------------------------
346
Sub Write_To_Release_Notes_Info ( nPv_id, sMsg )
417
Sub Write_To_Release_Notes_Info ( nPv_id, sMsg )
347
    WScript.Echo "Writing message to release_notes_info in [PACKAGE_VERSIONS] table."
418
    WScript.Echo "Writing message to release_notes_info in [PACKAGE_VERSIONS] table."
348
    WScript.Echo sMsg
419
    WScript.Echo sMsg
349
    OraSession.BeginTrans
420
    OraSession.BeginTrans
350
	OraDatabase.ExecuteSQL " UPDATE package_versions "&_
421
   OraDatabase.ExecuteSQL " UPDATE package_versions "&_
351
						   " SET release_notes_info = '"& sMsg &"'"&_
422
                          "    SET release_notes_info = '"& sMsg &"'"&_
352
						   " WHERE pv_id = "& nPv_id
423
                          "  WHERE pv_id = "& nPv_id
353
    OraSession.CommitTrans
424
    OraSession.CommitTrans
354
End Sub
425
End Sub
355
'-----------------------------------------------------------------------------------------------------------------
426
'-----------------------------------------------------------------------------------------------------------------
356
Function FormatTextBox ( SSstr ) 
427
Function FormatTextBox ( SSstr )
357
	If SSstr <> "" Or NOT IsNull(SSstr) Then
428
   If SSstr <> "" Or NOT IsNull(SSstr) Then
358
		FormatTextBox = Replace ( SSstr, VBNewLine, "<br>") 
429
      FormatTextBox = Replace ( SSstr, VBNewLine, "<br>")
359
	End If
430
   End If
360
End Function
431
End Function
361
'-----------------------------------------------------------------------------------------------------------------
432
'-----------------------------------------------------------------------------------------------------------------
362
Function HTML_Encode ( sSTR )
433
Function HTML_Encode ( sSTR )
363
    Dim tempSTR
434
    Dim tempSTR
364
    tempSTR = sSTR
435
    tempSTR = sSTR
Line 371... Line 442...
371
        HTML_Encode = tempSTR
442
        HTML_Encode = tempSTR
372
    End If
443
    End If
373
End Function
444
End Function
374
'-----------------------------------------------------------------------------------------------------------------------------
445
'-----------------------------------------------------------------------------------------------------------------------------
375
Function EuroDate ( dDate )
446
Function EuroDate ( dDate )
376
	' Ensures Euro Date format DD/MM/YYYY
447
   ' Ensures Euro Date format DD/MM/YYYY
377
	If IsNull(dDate) Then Exit Function
448
   If IsNull(dDate) Then Exit Function
378
	EuroDate = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate)
449
   EuroDate = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate)
379
End Function
450
End Function
380
'-----------------------------------------------------------------------------------------------------------------------------
451
'-----------------------------------------------------------------------------------------------------------------------------
381
Function EuroDateTime ( dDate )
452
Function EuroDateTime ( dDate )
382
	' Ensures Euro DateTime format DD/MM/YYYY H24:MIN:SS
453
   ' Ensures Euro DateTime format DD/MM/YYYY H24:MIN:SS
383
	If IsNull(dDate) Then Exit Function
454
   If IsNull(dDate) Then Exit Function
384
	EuroDateTime = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate) &" "& FormatDateTime( dDate, 4 )
455
   EuroDateTime = Day(dDate) &"/"& Month(dDate) &"/"& Year(dDate) &" "& FormatDateTime( dDate, 4 )
385
End Function
456
End Function
386
'-----------------------------------------------------------------------------------------------------------------
-
 
387
457
'-----------------------------------------------------------------------------------------------------------------
-
 
458