Subversion Repositories DevTools

Rev

Rev 6647 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<%
2
'=====================================================
129 ghuddy 3
'                COMMON DB EDIT
119 ghuddy 4
'=====================================================
5
%>
6
<%
7
Sub Update_Pkg_Category ( SSrtag_id, SSpv_id, SSbase_view_id )
129 ghuddy 8
 
9
   OraDatabase.Parameters.Add "PV_ID",   SSpv_id,        ORAPARM_INPUT, ORATYPE_NUMBER
10
   OraDatabase.Parameters.Add "RTAG_ID", SSrtag_id,      ORAPARM_INPUT, ORATYPE_NUMBER
11
   OraDatabase.Parameters.Add "VIEW_ID", SSbase_view_id, ORAPARM_INPUT, ORATYPE_NUMBER
12
 
13
   objEH.TryORA ( OraSession )
14
   On Error Resume Next
15
   OraDatabase.ExecuteSQL _
16
   "BEGIN PK_ENVIRONMENT.CHANGE_PACKAGE_VIEW ( :PV_ID, :RTAG_ID, :VIEW_ID );  END;"
17
   objEH.CatchORA ( OraSession )
18
 
19
   OraDatabase.Parameters.Remove "PV_ID"
20
   OraDatabase.Parameters.Remove "RTAG_ID"
21
   OraDatabase.Parameters.Remove "VIEW_ID"
22
 
119 ghuddy 23
End Sub
24
'-----------------------------------------------------------------------------------------------------------------------------
25
Sub Seed_Package_Names_Versions ( ARRdep, NNretPV_ID )
129 ghuddy 26
   Dim i
27
   OraDatabase.Parameters.Add "retPV_ID", 0, ORAPARM_OUTPUT, ORATYPE_NUMBER
28
   objEH.TryORA ( OraSession )
29
   On Error Resume Next
30
 
31
   For i = 0 To UBound( ARRdep, 2 )
32
      OraDatabase.ExecuteSQL "BEGIN Seed_Package_Names_Versions ('"& ARRdep(0,i) &"','"& ARRdep(1,i) &"', "& objAccessControl.UserId &", :retPV_ID); END;"
33
   Next
34
   objEH.CatchORA ( OraSession )
35
   OraDatabase.Parameters.Remove "retPV_ID"
119 ghuddy 36
End Sub
37
'-----------------------------------------------------------------------------------------------------------------------------
38
Function IsExtention ( SSstr )
129 ghuddy 39
   Dim objRegEx, Match, Matches, StrReturnStr
40
   Set objRegEx = New RegExp
41
 
42
   objRegEx.IgnoreCase = True
43
   objRegEx.Pattern = "[A-Za-z]+"
44
 
45
   Set Matches = objRegEx.Execute( SSstr )
46
   For Each Match in Matches
47
      IsExtention = true
48
   Next
119 ghuddy 49
End Function
50
'-----------------------------------------------------------------------------------------------------------------------------
51
Function Get_Pkg_Base_View_ID ( NNpv_id, NNrtag_id )
129 ghuddy 52
   Dim rsTemp, Query_String
53
 
54
   If Request("rtag_id") = "" Then
55
      Get_Pkg_Base_View_ID = -1
56
      Exit Function
57
   End If
58
 
59
   Query_String = _
60
   " SELECT rc.base_view_id"&_
61
   "  FROM release_content rc"&_
62
   " WHERE rc.rtag_id = "& NNrtag_id &_
63
   "   AND rc.pv_id = "& NNpv_id
64
 
65
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
66
 
67
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
68
      Get_Pkg_Base_View_ID = CInt( rsTemp("base_view_id") )
69
   Else
70
      Get_Pkg_Base_View_ID = NULL
71
   End If
72
 
73
   rsTemp.Close
74
   Set rsTemp = nothing
119 ghuddy 75
End Function
76
'-----------------------------------------------------------------------------------------------------------------------------
77
Function Get_V_EXT ( SSversion )
129 ghuddy 78
   Dim v_ext
79
   v_ext = Right(SSversion, Len(SSversion) - InStrRev( SSversion, "." ))
80
 
81
   If IsExtention ( v_ext ) Then
82
      Get_V_EXT = v_ext
83
   Else
84
      Get_V_EXT = NULL
85
   End If
86
 
119 ghuddy 87
End Function
88
'-----------------------------------------------------------------------------------------------------------------------------
89
Sub Touch_Package ( NNpv_id )
129 ghuddy 90
   If NNpv_id = "" Then Exit Sub
91
 
92
   objEH.TryORA ( OraSession )
93
   On Error Resume Next
94
   OraDatabase.ExecuteSQL " UPDATE package_versions "&_
95
                          " SET modified_stamp = "& ORA_SYSDATETIME  &", modifier_id = "& objAccessControl.UserId &_
96
                          " WHERE pv_id = "& NNpv_id
97
   objEH.CatchORA ( OraSession )
119 ghuddy 98
End Sub
99
'-----------------------------------------------------------------------------------------------------------------------------
129 ghuddy 100
Function Rebuild_Environment_Necessary(NNrtag_id)
101
   Dim Query_String, rsTemp
102
 
103
   Rebuild_Environment_Necessary = FALSE
104
 
105
   If IsNull(NNrtag_id) OR NNrtag_id = "" Then Exit Function     ' Exit if rtag_id is not supplied
106
 
107
   ' Find if rebuild is required
108
   Query_String = "SELECT rebuild_env FROM release_tags WHERE rtag_id = "& NNrtag_id
109
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
110
   If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
111
      If rsTemp("rebuild_env") = "Y" Then
112
         Rebuild_Environment_Necessary = TRUE
113
      End If
114
   End If
115
   rsTemp.Close
116
   Set rsTemp = nothing
117
End Function
118
 
119
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 120
Sub Rebuild_Environment ( NNrtag_id )
129 ghuddy 121
   If Rebuild_Environment_Necessary(NNrtag_id) Then
5176 dpurdie 122
       Call Rebuild_Environment_Body(NNrtag_id, FALSE)
123
   End If
124
End Sub
129 ghuddy 125
 
5176 dpurdie 126
'-----------------------------------------------------------------------------------------------------------------------------
127
Sub Rebuild_Environment_Body ( NNrtag_id , BallStates)
128
    On Error Resume Next
129 ghuddy 129
 
5176 dpurdie 130
    ' It is important to set the flag rebuild_env = 'N' first, 
131
    ' to stop multiple processes doing the same thing
132
    objEH.TryORA ( OraSession )
133
    OraDatabase.ExecuteSQL " UPDATE release_tags "&_
134
                         " SET rebuild_env = 'N'"&_
135
                         " WHERE rtag_id = "& NNrtag_id
136
    objEH.CatchORA ( OraSession )
129 ghuddy 137
 
5176 dpurdie 138
    ' Only proceed if the last update succeeded
139
    If objEH.LastOraFailed = FALSE Then
140
        ' Now rebuild environment
141
        objEH.TryORA ( OraSession )
142
        OraDatabase.ExecuteSQL " BEGIN Rebuild_Environment( "& NNrtag_id &" ); END;"
143
        objEH.CatchORA ( OraSession )
144
    End If
145
 
146
    If BallStates Then
147
        objEH.TryORA ( OraSession )
148
        OraDatabase.ExecuteSQL " BEGIN REBUILD_DEPRECATE_STATE( "& NNrtag_id &" ); END;"
149
        objEH.CatchORA ( OraSession )
150
    End If
151
 
129 ghuddy 152
End Sub
5176 dpurdie 153
 
119 ghuddy 154
'-----------------------------------------------------------------------------------------------------------------------------
6827 dpurdie 155
Sub Rebuild_Release_Metrics ( NNrtag_id )
156
    On Error Resume Next
157
 
158
    objEH.TryORA ( OraSession )
159
    OraDatabase.ExecuteSQL "BEGIN PK_RMAPI.UPDATE_RELEASE_METRICS( "& NNrtag_id &" ); END;"
160
    objEH.CatchORA ( OraSession )
161
 
162
End Sub
163
 
164
'-----------------------------------------------------------------------------------------------------------------------------
119 ghuddy 165
Sub CheckRequirements ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters, sQuery )
129 ghuddy 166
   Dim rsErr, Query_String
167
   Query_String = sQuery
168
 
169
 
170
   ' --------- SQL PARAMETERS ------------
171
   OraDatabase.Parameters.Add "RTAG_ID",                nRtag_id,               ORAPARM_INPUT, ORATYPE_NUMBER
172
   OraDatabase.Parameters.Add "PV_ID",                  nPv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
173
   OraDatabase.Parameters.Add "enumPKG_STATE_OK",       enumPKG_STATE_OK,       ORAPARM_INPUT, ORATYPE_NUMBER
174
   OraDatabase.Parameters.Add "enumISSUES_STATE_FIXED", enumISSUES_STATE_FIXED, ORAPARM_INPUT, ORATYPE_NUMBER
175
   ' -------------------------------------
176
   Set rsErr = OraDatabase.DbCreateDynaset( Query_String, cint(0))
177
 
178
   returnERRmsg = NULL
179
   returnALRTmsg = NULL
180
 
181
   If ( nPkgType = enumBASE_VIEW_PRODUCTS ) Then
182
      ' Check Requirement for products
5898 dpurdie 183
       Do While ((NOT rsErr.BOF) AND (NOT rsErr.EOF))
184
          If Not IsNull(rsErr("err_message")) Then
185
             returnERRmsg = rsErr("err_message")
186
             returnALRTmsg = rsErr("products_msg")
187
             returnParameters = "_make_released.asp" &"|"
188
             If returnALRTmsg = "ERROR" Then
189
                returnParameters = rsErr("rfile") &"|"& rsErr("anchor")
190
                Exit Do
191
             End If
192
          End If
129 ghuddy 193
 
5898 dpurdie 194
          rsErr.MoveNext
129 ghuddy 195
      Loop
196
 
197
   Else
198
      ' Check Requirements for other packages
5898 dpurdie 199
 
129 ghuddy 200
      Do While ((NOT rsErr.BOF) AND (NOT rsErr.EOF))
201
         If Not IsNull(rsErr("err_message")) Then
202
            returnERRmsg = rsErr("err_message")
203
            returnParameters = rsErr("rfile") &"|"& rsErr("anchor")
204
            Exit Do
205
         End If
206
 
207
         rsErr.MoveNext
208
      Loop
209
 
210
   End If
211
 
212
   rsErr.Close
213
   Set rsErr = nothing
214
   OraDatabase.Parameters.Remove "RTAG_ID"
215
   OraDatabase.Parameters.Remove "PV_ID"
216
   OraDatabase.Parameters.Remove "enumPKG_STATE_OK"
217
   OraDatabase.Parameters.Remove "enumISSUES_STATE_FIXED"
119 ghuddy 218
End Sub
219
'-----------------------------------------------------------------------------------------------------------------------------
220
Sub CheckRequirementsForMakeRelease ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters )
129 ghuddy 221
   Dim QueryString, rsQry
222
   QueryString = "SELECT pv.IS_PATCH FROM PACKAGE_VERSIONS pv WHERE pv.PV_ID = "& nPv_id
223
   Set rsQry = OraDatabase.DbCreateDynaset( QueryString, cint(0))
224
 
225
   If IsNull(rsQry("is_patch")) Then
226
      ' For Package
1376 dpurdie 227
      Call CheckRequirements ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters, ReadFile( rootPath & "queries\req_make_official.sql" ) )
129 ghuddy 228
   Else
229
      ' For Patch
1376 dpurdie 230
      Call CheckRequirements ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters, ReadFile( rootPath & "queries\req_make_official_patch.sql" ) )
129 ghuddy 231
   End If
232
 
233
   rsQry.Close()
234
   Set rsQry = nothing
235
 
119 ghuddy 236
End Sub
237
'-----------------------------------------------------------------------------------------------------------------------------
238
Sub CheckRequirementsForMakePending ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters )
1376 dpurdie 239
    Call CheckRequirements ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters, ReadFile( rootPath & "queries\req_make_pending.sql" ) )
119 ghuddy 240
End Sub
241
'-----------------------------------------------------------------------------------------------------------------------------
242
Sub CheckRequirementsForMakeApproved ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters )
129 ghuddy 243
   Call CheckRequirements ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters, ReadFile( rootPath & "queries\req_make_approved.sql" ) )
119 ghuddy 244
End Sub
245
'-----------------------------------------------------------------------------------------------------------------------------
129 ghuddy 246
Sub CheckRequirementsForMakeDeployable ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters )
247
   Call CheckRequirements ( nPv_id, nRtag_id, nPkgType, returnERRmsg, returnALRTmsg, returnParameters, ReadFile( rootPath & "queries\req_make_deployable.sql" ) )
119 ghuddy 248
End Sub
249
'-----------------------------------------------------------------------------------------------------------------------------
250
Sub Notify ( NNrtag_id )
129 ghuddy 251
   Dim Query_String, Location_SQL, rsNotify, emailBody, readyPv_id_list, SentTODict, releaseSTR
252
   Dim httpRef, URL_root, headerSTR, footerSTR, oAttachmentsDict
253
 
254
   Set SentTODict = CreateObject("Scripting.Dictionary")
255
   Set oAttachmentsDict = CreateObject("Scripting.Dictionary")
256
 
257
   On Error Resume Next
258
   objEH.TryORA ( OraSession )
259
 
260
   Query_String = ReadFile( rootPath & "queries\to_notify.sql" )
261
   Query_String = Replace( Query_String, "/*PKG_STATE_MAJOR_READY*/", enumPKG_STATE_MAJOR_READY)
262
   Query_String = Replace( Query_String, "/*PKG_STATE_MINOR_READY*/", enumPKG_STATE_MINOR_READY)
263
   Query_String = Replace( Query_String, "/*PKG_STATE_OK*/", enumPKG_STATE_OK)
264
   Query_String = Replace( Query_String, "/*ORA_SYSDATETIME*/", ORA_SYSDATETIME)
265
 
266
   ' --------- SQL PARAMETERS ------------
267
   OraDatabase.Parameters.Add "RTAG_ID", NNrtag_id, ORAPARM_INPUT
268
   OraDatabase.Parameters("RTAG_ID").ServerType = ORATYPE_NUMBER
269
 
270
   OraDatabase.Parameters.Add "CURRENT_USER", objAccessControl.UserId, ORAPARM_INPUT
271
   OraDatabase.Parameters("CURRENT_USER").ServerType = ORATYPE_NUMBER
272
   ' -------------------------------------
273
   'Response.write Query_String
274
   Set rsNotify = OraDatabase.DbCreateDynaset( Query_String, cint(0))
275
 
276
   readyPv_id_list = "-1"
277
   emailBody = ""
278
 
279
   '---- Get notification list ----
280
   If ((NOT rsNotify.BOF) AND (NOT rsNotify.EOF)) Then
281
      httpRef = Request.ServerVariables("HTTP_REFERER")
282
      URL_root = Left( httpRef, InStrRev(httpRef, "/") )
283
 
284
      emailBody = emailBody & "<tr>"
285
      emailBody = emailBody & "<td nowrap bgcolor='#CAC5B8'><font size='1' face='tahoma,sans-serif'><b>Owner</b></font></td>"
286
      emailBody = emailBody & "<td nowrap bgcolor='#CAC5B8'><font size='1' face='tahoma,sans-serif'><b>Package Name</b></font></td>"
287
      emailBody = emailBody & "<td nowrap bgcolor='#CAC5B8'><font size='1' face='tahoma,sans-serif'><b>Version</b></font></td>"
288
      emailBody = emailBody & "</tr>"
289
 
290
      While ((NOT rsNotify.BOF) AND (NOT rsNotify.EOF))
3959 dpurdie 291
         emailBody = emailBody & "<tr>"
129 ghuddy 292
         emailBody = emailBody & "<td nowrap><font size='1' face='tahoma,sans-serif'>"& rsNotify("full_name") &"</font></td>"
293
         emailBody = emailBody & "<td nowrap><font size='1' face='tahoma,sans-serif'><a href='"& URL_root &"dependencies.asp?pv_id="& rsNotify("pv_id") &"&rtag_id="& NNrtag_id &"'>"& rsNotify("pkg_name") &"</a></font></td>"
294
         emailBody = emailBody & "<td nowrap><font size='1' face='tahoma,sans-serif'>"& rsNotify("pkg_version") &"</font></td>"
295
         emailBody = emailBody & "</tr>"
296
 
297
         readyPv_id_list = readyPv_id_list &","& rsNotify("pv_id")
298
 
299
         If NOT SentTODict.Exists (Cstr(rsNotify("user_email"))) Then SentTODict.Add Cstr(rsNotify("user_email")), Cstr(rsNotify("full_name"))
300
 
301
         rsNotify.MoveNext
302
      WEnd
303
 
304
      emailBody = "<table width='50%' border='1' cellspacing='0' cellpadding='1'>" & emailBody & "</table>"
305
 
306
   End If
307
 
308
   rsNotify.Close
309
   Set rsNotify = nothing
310
 
311
 
312
   If readyPv_id_list <> "-1" Then
313
      '---- Header ----
314
      headerSTR = _
315
      "<table width='50%' border='0' cellspacing='0' cellpadding='0'>"&_
316
      "   <tr>"&_
317
      "     <td valign='bottom'><img src='cid:RM-Envelop' width='60' height='30'></td>"&_
318
      "     <td valign='bottom' align='right'><font size='3' face='tahoma,sans-serif'><b>release</b>manager Notifications</font></td>"&_
319
      "   </tr>"&_
320
      "   <tr> "&_
321
      "     <td bgcolor='#003399'></td>"&_
322
      "     <td bgcolor='#003399'></td>"&_
323
      "   </tr>"&_
324
      "</table><br><br>"
325
 
326
      '---- Footer ----
327
      footerSTR = _
328
      "<br><br>"&_
329
      "<table width='50%' border='0' cellspacing='0' cellpadding='0'>"&_
330
      "  <tr>"&_
331
      "    <td colspan='2'><hr size='1' noshade color='#003399'></td>"&_
332
      "  </tr>"&_
333
      "  <tr>"&_
6647 dpurdie 334
      "    <td><img src='cid:RM-MASSlogo' width='22' height='17' hspace='5' align='absmiddle'><font size='1' face='tahoma,sans-serif'>&nbsp;<a href='http://mass.vixtechnology.com'>mass</a></font></td>"&_
129 ghuddy 335
      "    <td nowrap align='right'><font size='1' face='tahoma,sans-serif'>ERG Confidential &copy; ERG</font></td>"&_
336
      "  </tr>"&_
337
      "</table>"
338
 
339
 
340
      '---- Get Release loction ----
341
      Location_SQL = _
342
      " SELECT proj.proj_name, rt.rtag_name"&_
343
      "  FROM release_tags rt,"&_
344
      "       projects proj"&_
345
      " WHERE rt.proj_id = proj.proj_id"&_
346
      "   AND rt.rtag_id = :RTAG_ID"
347
 
348
      Set rsNotify = OraDatabase.DbCreateDynaset( Location_SQL, cint(0))
349
      If ((NOT rsNotify.BOF) AND (NOT rsNotify.EOF)) Then
350
      releaseSTR = rsNotify("proj_name")  &" > "& rsNotify("rtag_name")
351
      emailBody = "<font size='1' face='tahoma,sans-serif'>"&_
352
                  "Following packages are ready to build.<br><br>"&_
353
                  rsNotify("proj_name") &" &gt; "& rsNotify("rtag_name") &"<br>"&_
354
                  "<a href='"& URL_root &"dependencies.asp?rtag_id="& NNrtag_id &"'>"& URL_root &"dependencies.asp?rtag_id="& NNrtag_id  &"</a>"&_
355
                  "</font>"&_
356
                  emailBody
357
      End If
358
      rsNotify.Close
359
      Set rsNotify = nothing
360
 
361
      emailBody = headerSTR & emailBody & footerSTR
362
 
363
      '---- Remove pkg from notification history ----
364
      OraDatabase.ExecuteSQL " DELETE FROM notification_history WHERE rtag_id = :RTAG_ID AND pv_id IN ( "& readyPv_id_list &" )"
365
 
366
 
367
      '---- Insert into notification history ----
368
      OraDatabase.ExecuteSQL "INSERT INTO notification_history (rtag_id, pv_id, user_id, date_time_stamp) "&_
369
                             " SELECT ins.rtag_id, ins.pv_id, ins.user_id, ins.date_time_stamp"&_
370
                             "   FROM ("&_
371
                             Query_String &_
372
                             "      ) ins"
373
 
374
   End If
375
 
376
   objEH.CatchORA ( OraSession )
377
 
378
   '================= Send Email ==========================
5357 dpurdie 379
   'Call Send_Email ( "Release Manager Notifications", ADMIN_EMAIL, ADMIN_EMAIL, "Your package is ready to build at "& releaseSTR, emailBody, oAttachmentsDict )
129 ghuddy 380
 
381
   ' ---------- Attachments -------------
382
   oAttachmentsDict.Add "images\i_mail.gif",       "RM-Envelop"
383
   oAttachmentsDict.Add "images\s_masslogo_w.gif", "RM-MASSlogo"
384
 
5357 dpurdie 385
   Call Send_Email ( "Release Manager Notifications", ADMIN_EMAIL, SentTODict, "Your package is ready to build at "& releaseSTR, emailBody, oAttachmentsDict )
129 ghuddy 386
 
387
   OraDatabase.Parameters.Remove "RTAG_ID"
388
   OraDatabase.Parameters.Remove "CURRENT_USER"
389
 
119 ghuddy 390
End Sub
391
'-----------------------------------------------------------------------------------------------------------------------------
392
Function NeedSync ( nPv_id, nRtag_id )
129 ghuddy 393
   Dim rsTemp, Query_String
394
   Query_String = ReadFile( rootPath & "queries\sync_check.sql" )
395
 
396
   ' --------- SQL PARAMETERS ------------
397
   OraDatabase.Parameters.Add "RTAG_ID", nRtag_id, ORAPARM_INPUT, ORATYPE_NUMBER
398
   OraDatabase.Parameters.Add "PV_ID",   nPv_id,   ORAPARM_INPUT, ORATYPE_NUMBER
399
   ' -------------------------------------
400
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
401
 
402
   If rsTemp.RecordCount > 0 Then
403
      NeedSync = TRUE
404
   Else
405
      NeedSync = FALSE
406
   End If
407
 
408
   rsTemp.Close
409
   Set rsTemp = nothing
410
   OraDatabase.Parameters.Remove "RTAG_ID"
411
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 412
End Function
413
'-----------------------------------------------------------------------------------------------------------------------------
414
Function Lookup_Document ( sDocNum, outDocTitle, outDoc_id, outDoc_version, outDoc_created  )
129 ghuddy 415
   Dim rsDocReg
416
 
417
   outDocTitle = NULL
418
   outDoc_id = NULL
419
   outDoc_version = NULL
420
   outDoc_created = NULL
421
 
422
   Set rsDocReg = Server.CreateObject("ADODB.Recordset")
423
   rsDocReg.ActiveConnection = DOCREP_conn
424
 
425
   rsDocReg.Source = "EXEC docregister.dbo.sp_RM_getDocumentFiles '"& sDocNum &"';"
426
   rsDocReg.CursorType = 0
427
   rsDocReg.CursorLocation = 2
428
   rsDocReg.LockType = 3
429
 
430
   On Error Resume Next
431
 
432
   rsDocReg.Open()
433
 
434
   If (NOT rsDocReg.BOF) AND (NOT rsDocReg.EOF)  Then
435
      outDocTitle = rsDocReg("title")
436
      outDoc_id = rsDocReg("id")
437
      outDoc_version = rsDocReg("version")
438
      outDoc_created = rsDocReg("created")
439
   End If
440
 
441
   rsDocReg.Close
442
 
443
   Lookup_Document = Err.Number   ' Return Error number
444
 
445
   Set rsDocReg = nothing
119 ghuddy 446
End Function
447
'-----------------------------------------------------------------------------------------------------------------------------
448
Function Short_Document_Details ( nDocId, outDocTitle, outDoc_version, outDoc_created  )
129 ghuddy 449
   Dim rsDocReg
450
 
451
   outDocTitle = NULL
452
   outDoc_version = NULL
453
   outDoc_created = NULL
454
 
455
   Set rsDocReg = Server.CreateObject("ADODB.Recordset")
456
   rsDocReg.ActiveConnection = DOCREP_conn
457
 
458
   rsDocReg.Source = "EXEC docregister.dbo.sp_RM_getFileDetails "& nDocId &";"
459
   rsDocReg.CursorType = 0
460
   rsDocReg.CursorLocation = 2
461
   rsDocReg.LockType = 3
462
 
463
   On Error Resume Next
464
 
465
   rsDocReg.Open()
466
 
467
   If (NOT rsDocReg.BOF) AND (NOT rsDocReg.EOF)  Then
468
      outDocTitle = rsDocReg("title")
469
      outDoc_version = rsDocReg("version")
470
      outDoc_created = rsDocReg("created")
471
   End If
472
 
473
   rsDocReg.Close
474
 
475
   Short_Document_Details = Err.Number   ' Return Error number
476
 
477
   Set rsDocReg = nothing
119 ghuddy 478
End Function
479
'-----------------------------------------------------------------------------------------------------------------------------
4553 dpurdie 480
'   ClearQuest Interface
481
'   Convert is CQ Issue number into a DEVI Number
482
'
119 ghuddy 483
Function GetIssueNumber ( nIssDB, nIssId )
4553 dpurdie 484
   Dim rsQry, rsSQL
155 ghuddy 485
   GetIssueNumber = ""
129 ghuddy 486
 
487
   If CInt(nIssDB) = enumCLEARQUEST_DEVI_ID Then
4553 dpurdie 488
    rsSQL = "SELECT dbid AS iss_id, new_num AS iss_num " &_
489
	        "  FROM release_manager.cq_software_issue si" &_
490
	        "  WHERE si.dbid = " & nIssId
129 ghuddy 491
 
4553 dpurdie 492
    On Error Resume Next
493
    Set rsQry = OraDatabase.DbCreateDynaset( rsSQL, cint(0))
129 ghuddy 494
 
4553 dpurdie 495
    If (NOT rsQry.BOF) AND (NOT rsQry.EOF)  Then
496
      GetIssueNumber = rsQry("iss_num")
497
    End If
129 ghuddy 498
 
4553 dpurdie 499
    rsQry.Close
500
    Set rsQry = nothing
129 ghuddy 501
 
502
   End If
119 ghuddy 503
End Function
504
'-----------------------------------------------------------------------------------------------------------------------------
505
Sub Log_Action ( nPvId, sActionTypeName, sComments )
129 ghuddy 506
 
507
   OraDatabase.Parameters.Add "PV_ID",            nPvId,                   ORAPARM_INPUT, ORATYPE_NUMBER
508
   OraDatabase.Parameters.Add "USER_ID",          objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
509
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sActionTypeName,         ORAPARM_INPUT, ORATYPE_VARCHAR2
510
   OraDatabase.Parameters.Add "COMMENTS",         sComments,               ORAPARM_INPUT, ORATYPE_VARCHAR2
511
 
512
   objEH.TryORA ( OraSession )
513
   On Error Resume Next
514
 
515
   OraDatabase.ExecuteSQL _
516
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
517
 
518
   objEH.CatchORA ( OraSession )
519
 
520
   OraDatabase.Parameters.Remove "PV_ID"
521
   OraDatabase.Parameters.Remove "USER_ID"
522
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
523
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 524
End Sub
525
'-----------------------------------------------------------------------------------------------------------------------------
526
Function GetUsername ( nUser_id )
129 ghuddy 527
   Dim rsQry, sQuery
119 ghuddy 528
 
129 ghuddy 529
   OraDatabase.Parameters.Add "USER_ID", nUser_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
530
   sQuery = "SELECT full_name FROM users WHERE user_id = :USER_ID"
531
   Set rsQry = OraDatabase.DbCreateDynaset( sQuery, cint(0))
119 ghuddy 532
 
129 ghuddy 533
   If rsQry.RecordCount = 1 Then
534
      GetUsername = rsQry.Fields("full_name").Value
535
   Else
536
      GetUsername = nothing
537
   End If
119 ghuddy 538
 
129 ghuddy 539
   OraDatabase.Parameters.remove "USER_ID"
540
   rsQry.Close
541
   Set rsQry = nothing
119 ghuddy 542
End Function
543
'-----------------------------------------------------------------------------------------------------------------------------
544
Function GetUserEmail ( nUser_id )
129 ghuddy 545
   Dim rsQry, sQuery
119 ghuddy 546
 
129 ghuddy 547
   OraDatabase.Parameters.Add "USER_ID", nUser_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
548
   sQuery = "SELECT user_email FROM users WHERE user_id = :USER_ID"
549
   Set rsQry = OraDatabase.DbCreateDynaset( sQuery, cint(0))
119 ghuddy 550
 
129 ghuddy 551
   If rsQry.RecordCount = 1 Then
552
      GetUserEmail = rsQry.Fields("user_email").Value
553
   Else
554
      GetUserEmail = nothing
555
   End If
119 ghuddy 556
 
129 ghuddy 557
   OraDatabase.Parameters.remove "USER_ID"
558
   rsQry.Close
559
   Set rsQry = nothing
119 ghuddy 560
End Function
129 ghuddy 561
'---------------------------------------------------------------------------------------------------------------------
562
Sub SetIgnoreWarnings (dpvId, pvId, rtagId)
563
 
564
   Dim Query_String, rsTemp
565
 
566
   OraDatabase.Parameters.Add "RTAG_ID",        rtagId,                  ORAPARM_INPUT, ORATYPE_NUMBER
567
   OraDatabase.Parameters.Add "PV_ID",          pvId,                    ORAPARM_INPUT, ORATYPE_NUMBER
568
   OraDatabase.Parameters.Add "USER_ID",        objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
569
   OraDatabase.Parameters.Add "IGNORE_ID_LIST", dpvId,                   ORAPARM_INPUT, ORATYPE_VARCHAR2
570
 
571
   On Error Resume Next
572
 
573
   objEH.TryORA ( OraSession )
574
   OraDatabase.ExecuteSQL _
575
   "BEGIN "&_
576
   " Ignore_Dependency_Warnings( :RTAG_ID, :PV_ID, :IGNORE_ID_LIST, FALSE, :USER_ID ); "&_
577
   "END; "
578
   objEH.CatchORA ( OraSession )
579
 
580
   OraDatabase.Parameters.Remove "USER_ID"
581
   OraDatabase.Parameters.Remove "IGNORE_ID_LIST"
582
 
583
   If objEH.LastOraFailed = FALSE Then
584
      ' DEVI-051154 has prompted the removal of the code to call touch_release from the
585
      ' Ignore_Dependency_Warnings stored procedure, and re-locate it here in the website code, since
586
      ' Ignore_Dependency_Warnings is called internally by other SQL code in the database where
587
      ' we do not want to touch_release. This is what Ignore_Dependency_Warnings used to do:
588
      '     IF PK_ENVIRONMENT.GET_PACKAGE_AREA ( nPvId, nRtagId ) = 2 THEN
589
      '        Touch_Release (nRtagId);
590
      '     END IF;
591
      ' Doing the same in the website code is a bit  more verbose, and we shouldn't do it if it
592
      ' is not necessary.
593
 
594
      ' Get the tab in which the package version resides (0=wip, 1=planned, 2=released)
595
      OraDatabase.Parameters.Add "ENVTAB",  NULL, ORAPARM_OUT, ORATYPE_NUMBER
596
      OraDatabase.ExecuteSQL _
597
      "BEGIN "&_
598
      " :ENVTAB = PK_ENVIRONMENT.GET_PACKAGE_AREA ( :PV_ID, :RTAG_ID ); "&_
599
      "END; "
600
 
601
      ' only need to touch release if it is not already in touched state. The purpose of this is to prevent the
602
      ' code inside the body of this "if-statement" from executing during the period of time when the database schema
603
      ' has yet to be updated to remove the intenral call to touch_release. Once the database schema is updated,
604
      ' the Rebuild_Environment_Necessary call is no longer necessary since it will always return FALSE at this
605
      ' point. Leaving the statement in place post the database schema update will do no harm though.
606
      If Rebuild_Environment_Necessary(rtagId) = FALSE Then
607
         ' If the package version is 'Released' then allow the rebuild of the environment so that the states
608
         ' of higher level packages can be re-evaluated
609
         If OraDatabase.Parameters("ENVTAB").Value = 2 Then
610
            objEH.TryORA ( OraSession )
611
            OraDatabase.ExecuteSQL _
612
            "BEGIN "&_
613
            " Touch_Release ( :RTAG_ID ); "&_
614
            "END; "
615
            objEH.CatchORA ( OraSession )
616
         End If
617
      End If
618
 
619
      OraDatabase.Parameters.Remove "ENVTAB"
620
   End If
621
 
622
   OraDatabase.Parameters.Remove "RTAG_ID"
623
   OraDatabase.Parameters.Remove "PV_ID"
624
End Sub
119 ghuddy 625
'------------------------------------------------------------------------------------------------------------------
151 ghuddy 626
Sub UpdateChangeType (nPvId, nChangeType)
627
   Dim rsTemp, Query_String
628
 
629
   On Error Resume Next
630
   If (NOT IsNull(nChangeType)) AND (nChangeType <> "") AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
631
 
632
      OraDatabase.Parameters.Add "PV_ID",       nPvId,       ORAPARM_INPUT, ORATYPE_NUMBER
633
      OraDatabase.Parameters.Add "CHANGE_TYPE", nChangeType, ORAPARM_INPUT, ORATYPE_CHAR
634
 
635
      objEH.TryORA ( OraSession )
636
      On Error Resume Next
637
 
638
      OraDatabase.ExecuteSQL _
639
      "UPDATE package_versions pv SET pv.change_type = '"& nChangeType &"' WHERE pv.pv_id = "& nPvId
640
 
641
      objEH.CatchORA ( OraSession )
642
 
643
      OraDatabase.Parameters.Remove "PV_ID"
644
      OraDatabase.Parameters.Remove "CHANGE_TYPE"
645
 
646
      If objEH.LastOraFailed = FALSE Then
647
         '/* Log Action */
648
         If nChangeType = "M" Then
649
            Call Log_Action ( nPvId, "change_type_update", "Major Change" )
650
 
651
         ElseIf nChangeType = "N" Then
652
            Call Log_Action ( nPvId, "change_type_update", "Minor Change" )
653
 
654
         ElseIf nChangeType = "P" Then
655
            Call Log_Action ( nPvId, "change_type_update", "Patch Change" )
656
 
657
         End If
658
      End If
659
   End If
660
End Sub
661
'------------------------------------------------------------------------------------------------------------------
662
Sub UpdateReasonForVersion (nPvId, nReason)
663
   Dim rsTemp, Query_String
664
 
665
   On Error Resume Next
666
   If (NOT IsNull(nReason)) AND (nReason <> "") AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
667
 
668
      OraDatabase.Parameters.Add "PV_ID",    nPvId,   ORAPARM_INPUT, ORATYPE_NUMBER
669
      OraDatabase.Parameters.Add "COMMENTS", nReason, ORAPARM_INPUT, ORATYPE_VARCHAR2
670
 
671
      objEH.TryORA ( OraSession )
672
      On Error Resume Next
673
 
674
      OraDatabase.ExecuteSQL _
155 ghuddy 675
      "UPDATE package_versions pv SET pv.comments = '"& SQLstring(nReason) &"' WHERE pv.pv_id = "& nPvId
151 ghuddy 676
 
677
      objEH.CatchORA ( OraSession )
678
 
679
      OraDatabase.Parameters.Remove "PV_ID"
680
      OraDatabase.Parameters.Remove "COMMENTS"
681
 
682
      If objEH.LastOraFailed = FALSE Then
683
         '/* Log Action */
684
         Call Log_Action ( nPvId, "reason_for_release", nReason )
685
      End If
686
   End If
687
End Sub
5338 dpurdie 688
 
151 ghuddy 689
'------------------------------------------------------------------------------------------------------------------
5338 dpurdie 690
' Currently used to specify non-vix licence when creating the first veersion of a new package
691
' Negative nLicence iis used to indicate that the user selected 100% vix. This is not stored. It is assumed
692
Sub UpdateLicenceInfo (nPvId, nLicence)
693
   Dim rsTemp, logMsg
151 ghuddy 694
 
5338 dpurdie 695
   On Error Resume Next
696
   If (NOT IsNull(nLicence)) AND (nLicence <> "") AND (nLicence > 0) AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
697
 
698
      OraDatabase.Parameters.Add "PV_ID",    nPvId,     ORAPARM_INPUT, ORATYPE_NUMBER
699
      OraDatabase.Parameters.Add "LICENCE", nLicence,   ORAPARM_INPUT, ORATYPE_NUMBER
700
 
701
      objEH.TryORA ( OraSession )
702
      On Error Resume Next
703
 
704
      OraDatabase.ExecuteSQL "insert into licencing (pv_id,licence ) values (:PV_ID,:LICENCE)"
705
 
706
      objEH.CatchORA ( OraSession )
707
 
708
      OraDatabase.Parameters.Remove "PV_ID"
709
      OraDatabase.Parameters.Remove "LICENCE"
710
 
711
      If objEH.LastOraFailed = FALSE Then
712
        OraDatabase.Parameters.Add "LICENCE", nLicence,   ORAPARM_INPUT, ORATYPE_NUMBER
713
        Set rsTemp = OraDatabase.DbCreateDynaset("select name from licences where licence = :LICENCE", cint(0))
714
        If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
715
            logMsg = "Set to " & rsTemp("name")
716
        Else
717
            logMsg = "Set to unknown(" & nPvId & ")"
718
        End If
719
        rsTemp.Close()
720
        Set rsTemp = nothing
721
        OraDatabase.Parameters.Remove "LICENCE"
722
 
723
        '/* Log Action */
724
        Call Log_Action ( nPvId, "software_licence", logMsg )
725
      End If
726
 
727
   End If
728
End Sub
729
 
730
'------------------------------------------------------------------------------------------------------------------
731
 
129 ghuddy 732
%>