Subversion Repositories DevTools

Rev

Rev 6827 | 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
'-----------------------------------------------------------------------------------------------------------------------------
6921 dpurdie 505
'   Note: Some OraDatabase.Parameters may be in use when this function is called
506
'         Attempt to use unqiue names to avaid issues
507
'
119 ghuddy 508
Sub Log_Action ( nPvId, sActionTypeName, sComments )
129 ghuddy 509
 
6921 dpurdie 510
   OraDatabase.Parameters.Add "LA_PV_ID",            nPvId,                   ORAPARM_INPUT, ORATYPE_NUMBER
511
   OraDatabase.Parameters.Add "LA_USER_ID",          objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
512
   OraDatabase.Parameters.Add "LA_ACTION_TYPE_NAME", sActionTypeName,         ORAPARM_INPUT, ORATYPE_VARCHAR2
513
   OraDatabase.Parameters.Add "LA_COMMENTS",         sComments,               ORAPARM_INPUT, ORATYPE_VARCHAR2
129 ghuddy 514
 
515
   objEH.TryORA ( OraSession )
516
   On Error Resume Next
517
 
518
   OraDatabase.ExecuteSQL _
6921 dpurdie 519
   "BEGIN  Log_Action ( :LA_PV_ID, :LA_ACTION_TYPE_NAME, :LA_USER_ID, :LA_COMMENTS );  END;"
129 ghuddy 520
 
521
   objEH.CatchORA ( OraSession )
522
 
6921 dpurdie 523
   OraDatabase.Parameters.Remove "LA_PV_ID"
524
   OraDatabase.Parameters.Remove "LA_USER_ID"
525
   OraDatabase.Parameters.Remove "LA_ACTION_TYPE_NAME"
526
   OraDatabase.Parameters.Remove "LA_COMMENTS"
119 ghuddy 527
End Sub
528
'-----------------------------------------------------------------------------------------------------------------------------
529
Function GetUsername ( nUser_id )
129 ghuddy 530
   Dim rsQry, sQuery
119 ghuddy 531
 
129 ghuddy 532
   OraDatabase.Parameters.Add "USER_ID", nUser_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
533
   sQuery = "SELECT full_name FROM users WHERE user_id = :USER_ID"
534
   Set rsQry = OraDatabase.DbCreateDynaset( sQuery, cint(0))
119 ghuddy 535
 
129 ghuddy 536
   If rsQry.RecordCount = 1 Then
537
      GetUsername = rsQry.Fields("full_name").Value
538
   Else
539
      GetUsername = nothing
540
   End If
119 ghuddy 541
 
129 ghuddy 542
   OraDatabase.Parameters.remove "USER_ID"
543
   rsQry.Close
544
   Set rsQry = nothing
119 ghuddy 545
End Function
546
'-----------------------------------------------------------------------------------------------------------------------------
547
Function GetUserEmail ( nUser_id )
129 ghuddy 548
   Dim rsQry, sQuery
119 ghuddy 549
 
129 ghuddy 550
   OraDatabase.Parameters.Add "USER_ID", nUser_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
551
   sQuery = "SELECT user_email FROM users WHERE user_id = :USER_ID"
552
   Set rsQry = OraDatabase.DbCreateDynaset( sQuery, cint(0))
119 ghuddy 553
 
129 ghuddy 554
   If rsQry.RecordCount = 1 Then
555
      GetUserEmail = rsQry.Fields("user_email").Value
556
   Else
557
      GetUserEmail = nothing
558
   End If
119 ghuddy 559
 
129 ghuddy 560
   OraDatabase.Parameters.remove "USER_ID"
561
   rsQry.Close
562
   Set rsQry = nothing
119 ghuddy 563
End Function
129 ghuddy 564
'---------------------------------------------------------------------------------------------------------------------
565
Sub SetIgnoreWarnings (dpvId, pvId, rtagId)
566
 
567
   Dim Query_String, rsTemp
568
 
569
   OraDatabase.Parameters.Add "RTAG_ID",        rtagId,                  ORAPARM_INPUT, ORATYPE_NUMBER
570
   OraDatabase.Parameters.Add "PV_ID",          pvId,                    ORAPARM_INPUT, ORATYPE_NUMBER
571
   OraDatabase.Parameters.Add "USER_ID",        objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
572
   OraDatabase.Parameters.Add "IGNORE_ID_LIST", dpvId,                   ORAPARM_INPUT, ORATYPE_VARCHAR2
573
 
574
   On Error Resume Next
575
 
576
   objEH.TryORA ( OraSession )
577
   OraDatabase.ExecuteSQL _
578
   "BEGIN "&_
579
   " Ignore_Dependency_Warnings( :RTAG_ID, :PV_ID, :IGNORE_ID_LIST, FALSE, :USER_ID ); "&_
580
   "END; "
581
   objEH.CatchORA ( OraSession )
582
 
583
   OraDatabase.Parameters.Remove "USER_ID"
584
   OraDatabase.Parameters.Remove "IGNORE_ID_LIST"
585
 
586
   If objEH.LastOraFailed = FALSE Then
587
      ' DEVI-051154 has prompted the removal of the code to call touch_release from the
588
      ' Ignore_Dependency_Warnings stored procedure, and re-locate it here in the website code, since
589
      ' Ignore_Dependency_Warnings is called internally by other SQL code in the database where
590
      ' we do not want to touch_release. This is what Ignore_Dependency_Warnings used to do:
591
      '     IF PK_ENVIRONMENT.GET_PACKAGE_AREA ( nPvId, nRtagId ) = 2 THEN
592
      '        Touch_Release (nRtagId);
593
      '     END IF;
594
      ' Doing the same in the website code is a bit  more verbose, and we shouldn't do it if it
595
      ' is not necessary.
596
 
597
      ' Get the tab in which the package version resides (0=wip, 1=planned, 2=released)
598
      OraDatabase.Parameters.Add "ENVTAB",  NULL, ORAPARM_OUT, ORATYPE_NUMBER
599
      OraDatabase.ExecuteSQL _
600
      "BEGIN "&_
601
      " :ENVTAB = PK_ENVIRONMENT.GET_PACKAGE_AREA ( :PV_ID, :RTAG_ID ); "&_
602
      "END; "
603
 
604
      ' only need to touch release if it is not already in touched state. The purpose of this is to prevent the
605
      ' code inside the body of this "if-statement" from executing during the period of time when the database schema
606
      ' has yet to be updated to remove the intenral call to touch_release. Once the database schema is updated,
607
      ' the Rebuild_Environment_Necessary call is no longer necessary since it will always return FALSE at this
608
      ' point. Leaving the statement in place post the database schema update will do no harm though.
609
      If Rebuild_Environment_Necessary(rtagId) = FALSE Then
610
         ' If the package version is 'Released' then allow the rebuild of the environment so that the states
611
         ' of higher level packages can be re-evaluated
612
         If OraDatabase.Parameters("ENVTAB").Value = 2 Then
613
            objEH.TryORA ( OraSession )
614
            OraDatabase.ExecuteSQL _
615
            "BEGIN "&_
616
            " Touch_Release ( :RTAG_ID ); "&_
617
            "END; "
618
            objEH.CatchORA ( OraSession )
619
         End If
620
      End If
621
 
622
      OraDatabase.Parameters.Remove "ENVTAB"
623
   End If
624
 
625
   OraDatabase.Parameters.Remove "RTAG_ID"
626
   OraDatabase.Parameters.Remove "PV_ID"
627
End Sub
119 ghuddy 628
'------------------------------------------------------------------------------------------------------------------
151 ghuddy 629
Sub UpdateChangeType (nPvId, nChangeType)
630
   Dim rsTemp, Query_String
631
 
632
   On Error Resume Next
633
   If (NOT IsNull(nChangeType)) AND (nChangeType <> "") AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
634
 
635
      OraDatabase.Parameters.Add "PV_ID",       nPvId,       ORAPARM_INPUT, ORATYPE_NUMBER
636
      OraDatabase.Parameters.Add "CHANGE_TYPE", nChangeType, ORAPARM_INPUT, ORATYPE_CHAR
637
 
638
      objEH.TryORA ( OraSession )
639
      On Error Resume Next
640
 
6921 dpurdie 641
      OraDatabase.ExecuteSQL "UPDATE package_versions pv SET pv.change_type = :CHANGE_TYPE WHERE pv.pv_id = :PV_ID"
151 ghuddy 642
 
643
      objEH.CatchORA ( OraSession )
644
 
645
      OraDatabase.Parameters.Remove "PV_ID"
646
      OraDatabase.Parameters.Remove "CHANGE_TYPE"
647
 
648
      If objEH.LastOraFailed = FALSE Then
649
         '/* Log Action */
650
         If nChangeType = "M" Then
651
            Call Log_Action ( nPvId, "change_type_update", "Major Change" )
652
 
653
         ElseIf nChangeType = "N" Then
654
            Call Log_Action ( nPvId, "change_type_update", "Minor Change" )
655
 
656
         ElseIf nChangeType = "P" Then
657
            Call Log_Action ( nPvId, "change_type_update", "Patch Change" )
658
 
659
         End If
660
      End If
661
   End If
662
End Sub
663
'------------------------------------------------------------------------------------------------------------------
664
Sub UpdateReasonForVersion (nPvId, nReason)
665
   Dim rsTemp, Query_String
666
 
667
   On Error Resume Next
668
   If (NOT IsNull(nReason)) AND (nReason <> "") AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
669
 
670
      OraDatabase.Parameters.Add "PV_ID",    nPvId,   ORAPARM_INPUT, ORATYPE_NUMBER
671
      OraDatabase.Parameters.Add "COMMENTS", nReason, ORAPARM_INPUT, ORATYPE_VARCHAR2
672
 
673
      objEH.TryORA ( OraSession )
674
      On Error Resume Next
675
 
676
      OraDatabase.ExecuteSQL _
155 ghuddy 677
      "UPDATE package_versions pv SET pv.comments = '"& SQLstring(nReason) &"' WHERE pv.pv_id = "& nPvId
151 ghuddy 678
 
679
      objEH.CatchORA ( OraSession )
680
 
681
      OraDatabase.Parameters.Remove "PV_ID"
682
      OraDatabase.Parameters.Remove "COMMENTS"
683
 
684
      If objEH.LastOraFailed = FALSE Then
685
         '/* Log Action */
686
         Call Log_Action ( nPvId, "reason_for_release", nReason )
687
      End If
688
   End If
689
End Sub
5338 dpurdie 690
 
151 ghuddy 691
'------------------------------------------------------------------------------------------------------------------
5338 dpurdie 692
' Currently used to specify non-vix licence when creating the first veersion of a new package
693
' Negative nLicence iis used to indicate that the user selected 100% vix. This is not stored. It is assumed
694
Sub UpdateLicenceInfo (nPvId, nLicence)
695
   Dim rsTemp, logMsg
151 ghuddy 696
 
5338 dpurdie 697
   On Error Resume Next
698
   If (NOT IsNull(nLicence)) AND (nLicence <> "") AND (nLicence > 0) AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
699
 
700
      OraDatabase.Parameters.Add "PV_ID",    nPvId,     ORAPARM_INPUT, ORATYPE_NUMBER
701
      OraDatabase.Parameters.Add "LICENCE", nLicence,   ORAPARM_INPUT, ORATYPE_NUMBER
702
 
703
      objEH.TryORA ( OraSession )
704
      On Error Resume Next
705
 
706
      OraDatabase.ExecuteSQL "insert into licencing (pv_id,licence ) values (:PV_ID,:LICENCE)"
707
 
708
      objEH.CatchORA ( OraSession )
709
 
710
      OraDatabase.Parameters.Remove "PV_ID"
711
      OraDatabase.Parameters.Remove "LICENCE"
712
 
713
      If objEH.LastOraFailed = FALSE Then
714
        OraDatabase.Parameters.Add "LICENCE", nLicence,   ORAPARM_INPUT, ORATYPE_NUMBER
715
        Set rsTemp = OraDatabase.DbCreateDynaset("select name from licences where licence = :LICENCE", cint(0))
716
        If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
717
            logMsg = "Set to " & rsTemp("name")
718
        Else
719
            logMsg = "Set to unknown(" & nPvId & ")"
720
        End If
721
        rsTemp.Close()
722
        Set rsTemp = nothing
723
        OraDatabase.Parameters.Remove "LICENCE"
724
 
725
        '/* Log Action */
726
        Call Log_Action ( nPvId, "software_licence", logMsg )
727
      End If
728
 
729
   End If
730
End Sub
731
 
732
'------------------------------------------------------------------------------------------------------------------
733
 
129 ghuddy 734
%>