Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
123 ghuddy 1
<%
2
'=====================================================
3
'               COMMON MAKE RELEASE BUTTON SUBs
4
'=====================================================
5
'
6
' Conventions within this code
7
'
8
'   1) Where a paramter list contains both RTAG_ID and PV_ID, the RTAG_ID will precede the PV_ID parameter
9
'   2) Functions/Subs that are not used externally, are name decorated PRIVATE_
10
'   3) Functions/Subs that are used extennally, are name decorated PUBLIC_
11
'
12
'
13
'
14
%>
15
<%
16
Dim AutoBuildPermissionDenied
17
Dim ManualBuildPermissionDenied
18
 
19
AutoBuildPermissionDenied   = FALSE
20
ManualBuildPermissionDenied = FALSE
21
 
22
 
23
'-----------------------------------------------------------------------------------------------------------------------------
24
' This is the pattern for approval determination. If the release is in open mode, permission is given. If the release is
25
' in restrictive/ccb mode, permission is given dependent on the accessControlObjectName being granted for the user.
26
'
27
Function PRIVATE_Is_Allowed_To(NNrtag_id, accessControlObjectName)
28
   Dim ReleaseMode
29
 
30
   ReleaseMode = GetReleaseMode ( NNrtag_id )
31
 
32
   PRIVATE_Is_Allowed_To = FALSE
33
 
34
   If ReleaseMode <> enumDB_RELEASE_IN_CLOSED_MODE AND ReleaseMode <> enumDB_RELEASE_IN_ARCHIVE_MODE Then
35
      If ( ReleaseMode = enumDB_RELEASE_IN_OPEN_MODE ) Then
36
         PRIVATE_Is_Allowed_To = TRUE
37
      Else
38
         If objAccessControl.IsActive(accessControlObjectName) Then
39
            PRIVATE_Is_Allowed_To = TRUE
40
         End If
41
      End If
42
   End If
43
End Function
44
'-----------------------------------------------------------------------------------------------------------------------------
45
Function PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id)
46
 
47
   PRIVATE_Is_Allowed_To_Approve_Merge = PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForAutoBuild") _
48
                                      OR PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForManualBuild")
49
End Function
50
'----------------------------------------------------------------------------------------------------------------------------------------
51
Function PRIVATE_Is_Allowed_To_Approve_ManualBuild(NNrtag_id)
52
 
53
   PRIVATE_Is_Allowed_To_Approve_ManualBuild = PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForManualBuild")
54
End Function
55
'----------------------------------------------------------------------------------------------------------------------------------------
56
Function PRIVATE_Is_Allowed_To_Approve_AutoBuild(NNrtag_id)
57
 
58
   PRIVATE_Is_Allowed_To_Approve_AutoBuild = PRIVATE_Is_Allowed_To(NNrtag_id, "ApproveForAutoBuild")
59
End Function
60
 
61
 
62
'=============================================================================================================================
63
' APPROVING PENDING MERGE OPERATIONS - Used from _approve_merge.asp as well as from within this file itself
64
'
65
' All functions in this section originally came from _approve_merge.asp and were placed here to support their use in more
66
' than the original singular context. Being relocated here allows them to be used in the additional "Bulk Release" context.
67
'=============================================================================================================================
68
 
69
'-----------------------------------------------------------------------------------------------------------------------------
70
' USED to approve a pending merge operation. Used internally by the bulk release operation
71
Sub PRIVATE_ApproveMerge ( NNrtag_id, NNpv_id )
72
   On Error Resume Next
73
   objEH.ErrorRedirect = TRUE
74
 
75
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
76
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,  ORAPARM_INPUT, ORATYPE_NUMBER
77
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId,   ORAPARM_INPUT, ORATYPE_NUMBER
78
 
79
   objEH.TryORA ( OraSession )
80
 
81
   OraSession.BeginTrans
82
 
83
   OraDatabase.ExecuteSQL _
84
      "BEGIN "&_
85
      " PK_ENVIRONMENT.APPROVE_MERGE ( :PV_ID, :RTAG_ID, :USER_ID );"&_
86
      "END; "
87
 
88
   OraSession.CommitTrans
89
 
90
   objEH.CatchORA ( OraSession )
91
 
92
   OraDatabase.Parameters.Remove "PV_ID"
93
   OraDatabase.Parameters.Remove "RTAG_ID"
94
   OraDatabase.Parameters.Remove "USER_ID"
95
End Sub
96
 
97
'-----------------------------------------------------------------------------------------------------------------------------
98
' USED to approve a pending merge operation. Used externally from the _approve_merge.asp file, loaded when the btnApproveMerge
99
' action button is pressed.
100
Sub PUBLIC_ApproveMerge ( NNrtag_id, NNpv_id )
101
   ' validate before carrying out the merge
102
   If PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, NNpv_id, "A") OR PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, NNpv_id, "S") Then
103
      If PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id) Then
104
         Call PRIVATE_ApproveMerge(parRtag_id, NNpv_id)
105
      End If
106
   End If
107
End Sub
108
 
109
'-----------------------------------------------------------------------------------------------------------------------------
110
' USED to validate an attempt to approve a pending merge operation
111
Function PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, NNpv_id, op)
112
   Dim rsQry
113
 
114
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,   ORAPARM_INPUT, ORATYPE_NUMBER
115
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id, ORAPARM_INPUT, ORATYPE_NUMBER
116
 
117
   Set rsQry = OraDatabase.DbCreateDynaset( GetQuery("PlannedPackageVersionDetails.sql"), cint(0))
118
 
119
   If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
120
      ' Does the actual operation field in the database match that specified as a parameter?
121
      If (rsQry.Fields("operation") = op) Then
122
         PRIVATE_Is_A_Valid_Pending_Merge = TRUE
123
		Else
124
         PRIVATE_Is_A_Valid_Pending_Merge = FALSE
125
		End If
126
   Else
127
      PRIVATE_Is_A_Valid_Pending_Merge = FALSE
128
   End If
129
 
130
   OraDatabase.Parameters.Remove "PV_ID"
131
   OraDatabase.Parameters.Remove "RTAG_ID"
132
 
133
   rsQry.Close()
134
   Set rsQry = Nothing
135
End Function
136
 
137
 
138
'=============================================================================================================================
139
' APPROVING MANUAL BUILD PENDING VERSIONS - Used from _make_released.asp as well as from within this file itself
140
'
141
' All functions in this section originally came from _make_released.asp and were placed here to support their use in more
142
' than the original singular context. Being relocated here allows them to be used in the additional "Bulk Release" context.
143
'=============================================================================================================================
144
 
145
 
146
'----------------------------------------------------------------------------------------------------------------------------------------
147
' This function came from _make_released.asp and is very similar to the PRIVATE_NotifyInterestAutoBuild, except the subject/body
148
' text is different. Unlike its auto-build counterpart, this one is called during the process of making a manual build release
149
' official.
150
' One question arises... can we not harmonize the email notification code somewhat, between manual and autobuild releases?
151
'
152
' Currently, the function is called internally as part of the bulk release operation, and from _generate_release_notes.asp,
153
' loaded by _make_released.asp which in turn is loaded when a user presses the btnMakeReleased action button for manual
154
' built pending versions.
155
Sub PUBLIC_NotifyInterestManualBuild( NNrtag_id, NNpv_id )
156
   Err.Clear
157
   On Error Resume Next
158
   Dim Query_String, rsQry, myMail
159
 
160
   Query_String = _
161
   "   SELECT * FROM PACKAGE_INTEREST PI, PACKAGES PKG, PACKAGE_VERSIONS PV, USERS U,"&_
162
   "   RELEASE_TAGS RT, PROJECTS PRJ WHERE PKG.PKG_ID = PI.PKG_ID AND "&_
163
   "   RT.RTAG_ID = "& NNrtag_id &""&_
164
   "   AND PV.PV_ID = "& NNpv_id &" AND PV.PKG_ID = PKG.PKG_ID AND "&_
165
   "   PRJ.PROJ_ID = RT.PROJ_ID AND PRJ.PROJ_ID = PI.PROJ_ID AND U.USER_ID = PI.USER_ID"
166
 
167
   Set rsQry = OraDatabase.DbCreateDynaset( Query_String , cint(0) )
168
 
169
   If rsQry.RecordCount <> "" Then
170
      While ((NOT rsQry.BOF) AND (NOT rsQry.EOF))
171
         Set myMail=Server.CreateObject("Persits.MailSender")
172
         If Err.Number <> 0 Then
173
            myMail.Host = SMTP_HOST
174
            myMail.Subject="Version "& rsQry("pkg_version") &" of Package "& rsQry("pkg_name") &" in Project " & rsQry("proj_name") &" on Release Branch " & rsQry("rtag_name") &" has been released."
175
            myMail.Body = "You have received this email as a result of your interest in this package. If you do not wish to receive further emails then remove your package interest from the notifications area in Release Manager."
176
            myMail.From=ADMIN_EMAIL
177
            myMail.AddAddress rsQry("user_email")
178
 
179
            myMail.Send
180
            set myMail=nothing
181
         Else
182
            Call RaiseMsg( enum_MSG_ERROR, "Failed to send notification email of release - possible problem on server with SMTP service or permission to use the service. Error Number = " + CStr(Err.Number) )
183
         End If
184
         rsQry.MoveNext
185
      Wend
186
 
187
   End If
188
 
189
   rsQry.Close()
190
   set rsQry = nothing
191
End Sub
192
 
193
'----------------------------------------------------------------------------------------------------------------------------------------
194
' Currently, this function is called internally as part of the bulk release operation, and from _generate_release_notes.asp,
195
' loaded by _make_released.asp which in turn is loaded when a user presses the btnMakeReleased action button for manual
196
' built pending versions. It initiates the execution of the windows script file that performs additional database updates
197
' that are needed to make official a package version that has already been built and published into dpkg_archive. This includes
198
' collecting info on all files that were published to dpkg_archive, and inserting that info into the RELEASED_COMPONENTS table.
199
Sub PUBLIC_Run_onMakeOfficial ( nRtag_id, nPv_id )
200
 
201
   Dim objWSH, proj_id, Qry, sRtagName
202
   Set objWSH = Server.CreateObject("WScript.Shell")
203
 
204
   OraSession.BeginTrans
205
   OraDatabase.ExecuteSQL " UPDATE package_versions "&_
206
                          " SET release_notes_info = '"& enum_RELEASE_NOTES_GENERATING &"'"&_
207
                          " WHERE pv_id = "& nPv_id
208
 
209
   OraSession.CommitTrans
210
 
211
   'Used for getting the package name and package version
212
   OraDatabase.Parameters.Add "RTAG_ID", nRtag_id, ORAPARM_INPUT, ORATYPE_NUMBER
213
 
214
   Set Qry = OraDatabase.DbCreateDynaset( "SELECT * FROM RELEASE_TAGS WHERE RTAG_ID = :RTAG_ID", 0 )
215
 
216
   proj_id = Qry("proj_id")
217
   sRtagName = UCase( Qry("rtag_name") )
218
 
219
   Qry.Close()
220
   Set Qry = Nothing
221
 
222
   OraDatabase.Parameters.Remove "RTAG_ID"
223
 
224
   'If proj_id = 281 Or proj_id = 221 Then
225
   '  objWSH.Run   "cmd.exe /c cscript.exe //B //NoLogo "& rootPath & SCRIPTS_FOLDER_STEP &"\on_Make_Official.wsf //job:GetComponents //job:GenerateReleaseNotes //job:PostRun "&_
226
   '                 "/pv_id:"& nPv_id , _
227
   '                 0, False
228
   'Else
229
      objWSH.Run   "cmd.exe /c cscript.exe //B //NoLogo "& rootPath & SCRIPTS_FOLDER &"\on_Make_Official.wsf //job:GetComponents //job:GenerateReleaseNotes //job:PostRun "&_
230
                  "/pv_id:"& nPv_id & " /proj_id:"& proj_id &" /rtag_name:"""&sRtagName&"", _
231
                  0, False
232
   'End If
233
   Set objWSH = nothing
234
 
235
End Sub
236
 
237
'-----------------------------------------------------------------------------------------------------------------------------
238
' This sub is used from _make_released.asp, loaded when a user presses the btnMakeReleased action button, as well as from
239
' internally within this file as part of the bulk release operation.
240
' This function basically removes the PV_ID entry from the WIP/PLANNED table, and adds it to the RELEASE_CONTENT table.
241
Sub PUBLIC_MakeRelease ( NNrtag_id, NNpv_id  )
242
 
243
   On Error Resume Next
244
   objEH.ErrorRedirect = TRUE
245
 
246
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
247
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,               ORAPARM_INPUT, ORATYPE_NUMBER
248
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
249
 
250
   objEH.TryORA ( OraSession )
251
 
252
   OraSession.BeginTrans
253
 
254
   OraDatabase.ExecuteSQL _
255
     "BEGIN "&_
256
     " PK_ENVIRONMENT.MAKE_RELEASE ( :PV_ID, :RTAG_ID, :USER_ID );"&_
257
     "END; "
258
 
259
   OraSession.CommitTrans
260
 
261
   objEH.CatchORA ( OraSession )
262
 
263
   OraDatabase.Parameters.Remove "PV_ID"
264
   OraDatabase.Parameters.Remove "RTAG_ID"
265
   OraDatabase.Parameters.Remove "USER_ID"
266
End Sub
267
 
268
 
269
'=============================================================================================================================
270
' APPROVING AUTO/MANUAL BUILD PENDING VERSIONS - Used from _make_approved.asp as well as from within this file itself
271
'
272
' All functions in this section originally came from _make_approved.asp and were placed here to support their use in more
273
' than the original singular context. Being relocated here allows them to be used in the additional "Bulk Release" context.
274
'=============================================================================================================================
275
 
276
'----------------------------------------------------------------------------------------------------------------------------------------
277
Function PRIVATE_Get_CQ_Issues ( SSsql, OOrsCQ )
278
   'On Error Resume Next
279
   OOrsCQ.ActiveConnection = CQ_conn
280
   OOrsCQ.Source = SSsql
281
   OOrsCQ.CursorType = 0
282
   OOrsCQ.CursorLocation = 2
283
   OOrsCQ.LockType = 3
284
   OOrsCQ.Open()
285
   PRIVATE_Get_CQ_Issues = Err.Number
286
End Function
287
'------------------------------------------------------------------------------------------------------------------------------------------
288
' Currently, this function does not seem to be used. The call to it was commented out in the _make_approved.asp file from where it was
289
' originally called from.
290
'
291
Sub PRIVATE_NotifyInterestAutoBuild( NNrtag_id, NNpv_id )
292
   On Error Resume Next
293
   Dim Query_String, rsQry, myMail
294
 
295
   Query_String = _
296
   "   SELECT * FROM PACKAGE_INTEREST PI, PACKAGES PKG, PACKAGE_VERSIONS PV, USERS U,"&_
297
   "   RELEASE_TAGS RT, PROJECTS PRJ WHERE PKG.PKG_ID = PI.PKG_ID AND "&_
298
   "   RT.RTAG_ID = "& NNrtag_id &""&_
299
   "   AND PV.PV_ID = "& NNpv_id &" AND PV.PKG_ID = PKG.PKG_ID AND "&_
300
   "   PRJ.PROJ_ID = RT.PROJ_ID AND PRJ.PROJ_ID = PI.PROJ_ID AND U.USER_ID = PI.USER_ID"
301
 
302
   Set rsQry = OraDatabase.DbCreateDynaset( Query_String , cint(0) )
303
 
304
   If rsQry.RecordCount <> "" Then
305
      While ((NOT rsQry.BOF) AND (NOT rsQry.EOF))
306
         Set myMail=Server.CreateObject("Persits.MailSender")
307
         myMail.Host = SMTP_HOST
308
         myMail.Subject="New Version of Package "& rsQry("pkg_name") &" in Project " & rsQry("proj_name") &" on Release Branch " & rsQry("rtag_name") &" would be autobuild soon."
309
         myMail.From=ADMIN_EMAIL
310
         myMail.AddAddress rsQry("user_email")
311
         myMail.Send
312
         set myMail=nothing
313
         rsQry.MoveNext
314
      Wend
315
   End If
316
 
317
   rsQry.Close()
318
   set rsQry = nothing
319
End Sub
320
'-------------------------------------------------------------------------------------
321
Sub PRIVATE_Get_Package_Issues(NNpv_id, SSsql)
322
   Dim sqlstr, rsTemp, DEVIiss, TDSEiss, VT5DMiss, VTSUPiss
323
 
324
   sqlstr = "SELECT iss_db, iss_id, iss_state, notes FROM CQ_ISSUES WHERE pv_id="& NNpv_id &"  AND iss_state = 1"
325
 
326
   Set rsTemp = OraDatabase.DbCreateDynaset( sqlstr, cint(0))
327
 
328
   DEVIiss = "-1"
329
   TDSEiss  = "-1"
330
   VT5DMiss = "-1"
331
   VTSUPiss = "-1"
332
 
333
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
334
      If CInt(rsTemp("iss_db")) = CInt(enumCLEARQUEST_DEVI_ID) Then
335
         DEVIiss = DEVIiss &","& rsTemp("iss_id")
336
      ElseIf CInt(rsTemp("iss_db")) = CInt(enumCLEARQUEST_TDSE_ID) Then
337
         TDSEiss = TDSEiss &","& rsTemp("iss_id")
338
      ElseIf CInt(rsTemp("iss_db")) = CInt(enumCLEARQUEST_VT5DM_ID) Then
339
         VT5DMiss = VT5DMiss &","& rsTemp("iss_id")
340
      ElseIf CInt(rsTemp("iss_db")) = CInt(enumCLEARQUEST_VTSUP_ID) Then
341
         VTSUPiss = VTSUPiss &","& rsTemp("iss_id")
342
      End If
343
 
344
      rsTemp.MoveNext
345
   WEnd
346
 
347
   ' Construct SQL statement for CQ database
348
   If Len(DEVIiss) <> 1 OR Len(TDSEiss) <> 1 Then
349
      SSsql = ReadFile( rootPath & "queries\cq_issues.sql" )
350
      SSsql = Replace( SSsql, "/*enumCLEARQUEST_DEVI_ID*/", enumCLEARQUEST_DEVI_ID)
351
      SSsql = Replace( SSsql, "/*enumCLEARQUEST_TDSE_ID*/", enumCLEARQUEST_TDSE_ID)
352
      SSsql = Replace( SSsql, "/*enumCLEARQUEST_VT5DM_ID*/", enumCLEARQUEST_VT5DM_ID)
353
      SSsql = Replace( SSsql, "/*enumCLEARQUEST_VTSUP_ID*/", enumCLEARQUEST_VTSUP_ID)
354
      SSsql = Replace( SSsql, "/*DEVIiss*/", DEVIiss)
355
      SSsql = Replace( SSsql, "/*TDSEiss*/", TDSEiss)
356
      SSsql = Replace( SSsql, "/*VT5DMiss*/", VT5DMiss)
357
      SSsql = Replace( SSsql, "/*VTSUPiss*/", VTSUPiss)
358
   End If
359
 
360
   rsTemp.Close
361
   Set rsTemp = nothing
362
 
363
End Sub
364
'-------------------------------------------------------------------------------------
365
Sub PRIVATE_SendOwnerEmail (NNrtag_id, NNpv_id, EmailBody)
366
   Dim myMail, rsQry, EmailAutoBuild, comments, release, package
367
 
368
   EmailAutoBuild = ReadFile( rootPath & "queries\EmailAutoBuild.sql" )
369
   EmailAutoBuild = Replace( EmailAutoBuild, ":PV_ID", NNpv_id)
370
   EmailAutoBuild = Replace( EmailAutoBuild, ":RTAG_ID", NNrtag_id)
371
 
372
   Set rsQry = OraDatabase.DbCreateDynaset( EmailAutoBuild , cint(0))
373
   If rsQry("comments") <> "" Then
374
      comments = comments & "<table width='100%' border='0' cellspacing='0' cellpadding='1'>"
375
      comments = comments & "<tr>"
376
      comments = comments & "<td background='#CAC5B8' nowrap class='form_field'><font size='2' face='tahoma,sans-serif'><b>Reason&nbsp;For&nbsp;Release</b></font></td>"
377
      comments = comments & "</tr>"
378
      comments = comments & "<tr>"
379
      comments = comments & "<td background='#CAC5B8' nowrap class='form_item'><font size='1' face='tahoma,sans-serif'>"&NewLine_To_BR((rsQry("comments")))&"</font></td>"
380
      comments = comments & "</tr>"
381
      comments = comments & "</table>"
382
      comments = comments & "<br>"
383
   End If
384
 
385
   Err.Clear
386
   On Error Resume Next
387
   Set myMail=Server.CreateObject("Persits.MailSender")
388
   If Err.Number <> 0 Then
389
      If rsQry("owner_email") <> "" Then
390
         myMail.Host = SMTP_HOST
391
         myMail.Subject="Build required for package "& rsQry("pkg_name") &" in Project " & rsQry("proj_name") &" on Release Branch " & rsQry("rtag_name")
392
         release = release & "<table width='100%' border='0' cellspacing='0' cellpadding='1'>"
393
         release = release & "<tr>"
394
         release = release & "<td background='#CAC5B8' nowrap class='form_field'><font size='2' face='tahoma,sans-serif'><b>Release</b></font></td>"
395
         release = release & "</tr>"
396
         release = release & "<tr>"
397
         release = release & "<td background='#CAC5B8' nowrap class='form_item'><a href='http://erg:8002/ManagerSuite/Release_Manager/dependencies.asp?rtag_id="_
398
                           & NNrtag_id  & "'><font size='1' face='tahoma,sans-serif'>"&rsQry("rtag_name")&"</font></a></td>"
399
         release = release & "</tr>"
400
         release = release & "</table>"
401
         release = release & "<br>"
402
 
403
         package = package & "<table width='100%' border='0' cellspacing='0' cellpadding='1'>"
404
         package = package & "<tr>"
405
         package = package & "<td background='#CAC5B8' nowrap class='form_field'><font size='2' face='tahoma,sans-serif'><b>Package</b></font></td>"
406
         package = package & "</tr>"
407
         package = package & "<tr>"
408
         package = package & "<td background='#CAC5B8' nowrap class='form_item'><a href='http://erg:8002/ManagerSuite/Release_Manager/fixed_issues.asp?pv_id=" _
409
                           & NNpv_id  & "&rtag_id=" & NNrtag_id & "'><font size='1' face='tahoma,sans-serif'>"&rsQry("pkg_name")&" "&rsQry("pkg_version")&"</font></a></td>"
410
         package = package & "</tr>"
411
         package = package & "</table>"
412
         package = package & "<br>"
413
 
414
         EmailBody =  release & package & comments & EmailBody
415
         myMail.IsHTML = True
416
         myMail.Body = EmailBody
417
         myMail.From=ADMIN_EMAIL
418
 
419
         ' if before 8AM or after 5PM then send to owners personal email address else send to their work email address
420
         If Timer < 28800 OR Timer > 61200 Then
421
            If rsQry("owner_personal_email") <> "" Then
422
               myMail.AddAddress rsQry("owner_personal_email")
423
            Else
424
               myMail.AddAddress rsQry("owner_email")
425
            End If
426
         Else
427
            myMail.AddAddress rsQry("owner_email")
428
         End If
429
 
430
         myMail.Send
431
         set myMail=nothing
432
      End If
433
   Else
434
      Call RaiseMsg( enum_MSG_ERROR, "Failed to send notification email of release - possible problem on server with SMTP service or permission to use the service. Error Number = " + CStr(Err.Number) )
435
   End If
436
End Sub
437
'-------------------------------------------------------------------------------------
438
Sub PRIVATE_MakeApproved (NNrtag_id, NNpv_id)
439
 
440
   OraDatabase.Parameters.Add "PV_ID",   NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
441
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id,               ORAPARM_INPUT, ORATYPE_NUMBER
442
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
443
 
444
   OraSession.BeginTrans
445
 
446
   OraDatabase.ExecuteSQL _
447
   "BEGIN "&_
448
   "   PK_ENVIRONMENT.MAKE_APPROVED ( :PV_ID, :RTAG_ID, :USER_ID ); "&_
449
   "END; "
450
 
451
   OraSession.CommitTrans
452
 
453
   OraDatabase.Parameters.Remove "PV_ID"
454
   OraDatabase.Parameters.Remove "RTAG_ID"
455
   OraDatabase.Parameters.Remove "USER_ID"
456
End Sub
457
'-------------------------------------------------------------------------------------
458
Function PRIVATE_Get_EmailBody(NNrtag_id, NNpv_id)
459
 
460
   Dim SSsql, rsCQ
461
 
462
   PRIVATE_Get_EmailBody = ""
463
 
464
   Set rsCQ = Server.CreateObject("ADODB.Recordset")
465
   ' All Requirements OK
466
   'COMPLETE THE REQUEST...
467
   Call PRIVATE_Get_Package_Issues(NNpv_id, SSsql)
468
 
469
   If PRIVATE_Get_CQ_Issues ( SSsql, rsCQ )  = 0 Then
470
      Dim EmailBody
471
 
472
      EmailBody =             "<font size='2' face='tahoma,sans-serif'><b>Fixed Issues</b></font>"
473
      EmailBody = EmailBody & "<table width='100%' border='1' cellspacing='0' cellpadding='1'>"
474
      EmailBody = EmailBody & "<tr>"
475
      EmailBody = EmailBody & "<td background='#CAC5B8' nowrap class='form_field'><font size='1' face='tahoma,sans-serif'>Issue&nbsp;Id&nbsp;</font></td>"
476
 
477
      EmailBody = EmailBody & "<td background='#CAC5B8' nowrap class='form_field'><font size='1' face='tahoma,sans-serif'>Summary</font></td>"
478
      EmailBody = EmailBody & "<td background='#CAC5B8' nowrap class='form_field'><font size='1' face='tahoma,sans-serif'>Issue&nbsp;Type&nbsp;</font></td>"
479
      EmailBody = EmailBody & "<td background='#CAC5B8' nowrap class='form_field'><font size='1' face='tahoma,sans-serif'>Priority</font></td>"
480
      EmailBody = EmailBody & "<td background='#CAC5B8' nowrap class='form_field'><font size='1' face='tahoma,sans-serif'>Status</font></td>"
481
 
482
      EmailBody = EmailBody & "</tr>"
483
      If ((NOT rsCQ.BOF) AND (NOT rsCQ.EOF)) Then
484
         While ((NOT rsCQ.BOF) AND (NOT rsCQ.EOF))
485
            EmailBody = EmailBody & "<tr>"
486
            EmailBody = EmailBody & "<td background='#CAC5B8' nowrap class='form_item'><font size='1' face='tahoma,sans-serif'>"&rsCQ("iss_num")&"</font></td>"
487
            EmailBody = EmailBody & "<td background='#CAC5B8' class='form_item'><font size='1' face='tahoma,sans-serif'>"&NewLine_To_BR ( To_HTML ( rsCQ("summary") ) )&"</font></td>"
488
            EmailBody = EmailBody & "<td nowrap background='#CAC5B8' class='form_item'><font size='1' face='tahoma,sans-serif'>"&rsCQ("issue_type")&"</font></td>"
489
            EmailBody = EmailBody & "<td nowrap background='#CAC5B8' class='form_item'><font size='1' face='tahoma,sans-serif'>"&rsCQ("priority")&"</font></td>"
490
            EmailBody = EmailBody & "<td nowrap background='#CAC5B8' class='form_item'><font size='1' face='tahoma,sans-serif'>"&rsCQ("Status")&"</font></td>"
491
            EmailBody = EmailBody & "</tr>"
492
            rsCQ.MoveNext
493
         WEnd
494
         rsCQ.Close
495
      Else
496
         EmailBody = EmailBody & "<tr>"
497
         EmailBody = EmailBody & "<td background='#CAC5B8' nowrap></td>"
498
         EmailBody = EmailBody & "<td background='#CAC5B8' class='form_item'></td>"
499
         EmailBody = EmailBody & "<td background='#CAC5B8' class='form_item'></td>"
500
         EmailBody = EmailBody & "<td background='#CAC5B8' class='form_item'></td>"
501
         EmailBody = EmailBody & "<td background='#CAC5B8' class='form_item'></td>"
502
         EmailBody = EmailBody & "</tr>"
503
      End If
504
 
505
      EmailBody = EmailBody & "</table>"
506
 
507
      PRIVATE_Get_EmailBody = EmailBody
508
   End If
509
End Function
510
 
511
'-------------------------------------------------------------------------------------
512
' This function is called from _make_approved.asp, which is loaded when the btnApprovePackage
513
' action button is pressed. It is also called as part of the bulk release operation.
514
Function PUBLIC_ApproveRelease(NNrtag_id, NNpv_id, ByRef retParameters)
515
 
516
   Dim retERRmsg
517
   Dim retALRTmsg
518
   Dim pkgType
519
 
520
   retParameters = ""
521
   pkgType = 0
522
 
523
   Set pkgInfoHash = CreateObject("Scripting.Dictionary")
524
 
525
   ' default return value
526
   PUBLIC_ApproveRelease = FALSE
527
 
528
   If ( NNrtag_id <> "") AND (NNpv_id <> "") Then
529
 
530
      'Check If There Already Exists A WIP Instance Of The Package In The Release
531
      If Check_Package_WIP_Already_Exists(NNrtag_id, NNpv_id) > 0 Then
532
         Call RaiseMsg ( enum_MSG_PACKAGE_WIP_EXISTS&"?rtag_id="& NNrtag_id & "&pv_id="& NNpv_id & "", NNpv_id )
533
         ' RaiseMsg redirects loaded web page, so no return
534
      Else
535
         '-- Get Package details
536
         Call Get_Pkg_Info ( NNpv_id, NNrtag_id )
537
 
538
         If pkgInfoHash.Item("build_type") = "A" Then
539
            If PRIVATE_Is_Allowed_To_Approve_AutoBuild(NNrtag_id) Then
540
               '-- Approve Automatic-build package
541
               Call CheckRequirementsForMakeApproved ( NNpv_id, NNrtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
542
               If IsNull(retERRmsg) Then
543
                  Dim EmailBody
544
 
545
                  EmailBody = PRIVATE_Get_EmailBody (NNrtag_id, NNpv_id)
546
 
547
                  Call PRIVATE_MakeApproved (NNrtag_id, NNpv_id)
548
 
549
                  Call PRIVATE_SendOwnerEmail(NNrtag_id, NNpv_id, EmailBody)
550
 
551
                  ' indicate success
552
                  PUBLIC_ApproveRelease = TRUE
553
               Else
554
                  Call RaiseMsg ( Eval(retERRmsg), NNrtag_id & "|" & NNpv_id & "|" & retParameters & "|" & "N" )
555
               End If
556
            Else
557
               ' Indicate an auto-build permission problem was detected in the global variable.
558
               ' This is only used within the context of a bulk release.
559
               AutoBuildPermissionDenied = TRUE
560
            End If
561
         Else
562
            If PRIVATE_Is_Allowed_To_Approve_ManualBuild(NNrtag_id) Then
563
               '-- Approve a Manual Build Release
564
               Call CheckRequirementsForMakeRelease ( NNpv_id, NNrtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )
565
               If IsNull(retERRmsg) Then
566
 
567
                  Call PUBLIC_MakeRelease ( NNrtag_id, NNpv_id )
568
                  ' If all went well, initiate the generation of release notes, and email any interested parties
569
 
570
                  If objEH.Finally Then
571
                     Call PUBLIC_Run_onMakeOfficial ( NNrtag_id, NNpv_id )
572
 
573
                     Call PUBLIC_NotifyInterestManualBuild( NNrtag_id, NNpv_id )
574
 
575
                     ' indicate success
576
                     PUBLIC_ApproveRelease = TRUE
577
                  End If
578
               Else
579
                  Call RaiseMsg ( Eval(retERRmsg), NNrtag_id & "|" & NNpv_id & "|" & retParameters & "|" & "N" )
580
               End If
581
            Else
582
               ' Indicate a manual-build permission problem was detected in the global variable
583
               ' This is only used within the context of a bulk release.
584
               ManualBuildPermissionDenied = TRUE
585
            End If
586
         End If
587
      End If
588
   End If
589
End Function
590
'-----------------------------------------------------------------------------------------------------------------------------
591
 
592
 
593
'=============================================================================================================================
594
' MAKING A BULK RELEASE from a list of PV_IDs for a specified release
595
'
596
' This section contains the new "Bulk Release' code. This function is tied to the use of the make bulk release button.
597
'
598
'=============================================================================================================================
599
 
600
'-----------------------------------------------------------------------------------------------------------------------------
601
' This public function is called from the make_bulk_release.asp file, loaded when a user presses the Make Bulk Release
602
' button when viewing items on the Pending Tab of a release area.
603
'
604
' The function processes a list of PV_ID's that cam from the pending tab of a release, formed from each item whose checkbox
605
' was checked. There are 3 different types of item to deal with, and this function will deal with them in the order shown
606
' below:
607
'    1) Subtractive merge operations
608
'    2) Additive merge operations
609
'    3) Manual/Auto build items
610
'
611
' This order was chosen by design to ensure that in the end effect upon a release, the manual and auto build items
612
' take precedence over merge candidates. This occurs naturally if we process manual/auto build items last.
613
'
614
' Parameters:
615
'   NNrtag_id       The release area
616
'   NN_pv_id_list   A list of PV_IDs representing pending items to be approved for release or merge.
617
'
618
Sub PUBLIC_MakeBulkRelease (NNrtag_id, NN_pv_id_list)
619
   Dim initialList         ' holds all items
620
   Dim remainingList1()    ' To hold additive merge items
621
   Dim remainingList2()    ' To hold auto/manual build items
622
   Dim len_remainingList
623
   Dim pvId
624
   Dim retParameters
625
   Dim allowedToApproveMerge
626
 
627
   ' determine in advance if user is allowed to approve merges
628
   allowedToApproveMerge = PRIVATE_Is_Allowed_To_Approve_Merge(NNrtag_id)
629
 
630
   ' ready the remaining list index to extract additive merges and manual/auto build items
631
   len_remainingList = 0
632
 
633
   AutoBuildPermissionDenied   = FALSE
634
   ManualBuildPermissionDenied = FALSE
635
 
636
   ' Remove any spaces and split the pv_id list into a string array
637
   initialList = Split ( Replace(NN_pv_id_list, " ", "" ), "," )
638
 
639
   ' Process each subtractive merge item in the string array.
640
   ' We do these first to cleanup the release somewhat before we start adding new stuff in
641
   For Each pvId In initialList
642
      If IsNumeric(pvId) Then
643
         ' Test to see if this PV_ID represents a pending SUBTRACTIVE merge operation, and proceed with it if permissions allow
644
         If PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, pvId, "S") Then
645
            If allowedToApproveMerge Then
646
               Call PRIVATE_ApproveMerge(NNrtag_id, pvId)
647
            Else
648
               AutoBuildPermissionDenied   = TRUE
649
               ManualBuildPermissionDenied = TRUE
650
            End If
651
         Else
652
            ' add item to the remaining list for the next loop to process
653
            len_remainingList = len_remainingList + 1
654
            ReDim Preserve remainingList1(len_remainingList)
655
            remainingList1(len_remainingList - 1) = pvId
656
         End If
657
      End If
658
   Next
659
 
660
   ' ready the remaining list index to extract manual/auto build items
661
   len_remainingList = 0
662
 
663
   ' Now process each additive merge item in the string array
664
   ' We do these before finally processing any auto/manual build items so that the latter take precedence in their eventual
665
   ' effect upon the release.
666
   For Each pvId In remainingList1
667
      ' Test to see if this PV_ID represents a pending ADDITIVE merge operation, and proceed with it if permissions allow
668
      If PRIVATE_Is_A_Valid_Pending_Merge(NNrtag_id, pvId, "A") Then
669
         If allowedToApproveMerge Then
670
            Call PRIVATE_ApproveMerge(NNrtag_id, pvId)
671
         Else
672
            AutoBuildPermissionDenied   = TRUE
673
            ManualBuildPermissionDenied = TRUE
674
         End If
675
      Else
676
         ' add item to the remaining list for the next loop to process
677
         len_remainingList = len_remainingList + 1
678
         ReDim Preserve remainingList2(len_remainingList)
679
         remainingList2(len_remainingList - 1) = pvId
680
      End If
681
   Next
682
 
683
   ' Now process each new Auto/Manaul build item in the string array
684
   For Each pvId In remainingList2
685
      Call PUBLIC_ApproveRelease(NNrtag_id, pvId, retParameters)
686
   Next
687
 
688
 
689
   ' If any items were not approved for release due to permission errors, issue an alert to the user
690
   If AutoBuildPermissionDenied = TRUE OR ManualBuildPermissionDenied = TRUE Then
691
      Call RaiseMsg( enum_MSG_ERROR, "One of more items could not be approved due to missing permissions (either ApproveForAutoBuild or ApproveForManualBuild).<p>"_
692
                                   & "NOTE : All items that could be approved, have been.</p>" )
693
   End If
694
 
695
End Sub
696
'-----------------------------------------------------------------------------------------------------------------------------
697
 
698
 
699
 
700
 
701
%>