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