Subversion Repositories DevTools

Rev

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