Subversion Repositories DevTools

Rev

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