Subversion Repositories DevTools

Rev

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