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
'-----------------------------------------------------------------------------------------------------------------------------
457
Function GetIssueNumber ( nIssDB, nIssId )
129 ghuddy 458
   Dim rsQry
155 ghuddy 459
   GetIssueNumber = ""
129 ghuddy 460
 
461
   Set rsQry = Server.CreateObject("ADODB.Recordset")
462
   rsQry.ActiveConnection = CQ_conn
463
 
464
   If CInt(nIssDB) = enumCLEARQUEST_DEVI_ID Then
159 ghuddy 465
      rsQry.Source = "EXEC cq_devi.dbo.sp_RM_getIssueDetails "& nIssId &";"
129 ghuddy 466
   End If
467
 
468
   rsQry.CursorType = 0
469
   rsQry.CursorLocation = 2
470
   rsQry.LockType = 3
471
 
472
   On Error Resume Next
473
 
474
   rsQry.Open()
475
 
476
   If (NOT rsQry.BOF) AND (NOT rsQry.EOF)  Then
477
      GetIssueNumber = rsQry("iss_num")
478
   End If
479
 
480
   rsQry.Close
481
   Set rsQry = nothing
119 ghuddy 482
End Function
483
'-----------------------------------------------------------------------------------------------------------------------------
484
Sub LoadFieldRules ( sFieldList, ByRef outobjForm )
129 ghuddy 485
   Dim rsQry, query
486
 
487
   query = _
488
   "   SELECT FIELD_NAME, "&_
489
   "         IS_REQUIRED, "&_
490
   "         IS_NUMERIC, "&_
491
   "         MIN_NUMERIC_VALUE, "&_
492
   "         MAX_NUMERIC_VALUE, "&_
493
   "         IS_DATE, "&_
494
   "         START_DATE, "&_
495
   "         END_DATE, "&_
496
   "         MIN_STRING_LENGTH, "&_
497
   "          MAX_STRING_LENGTH, "&_
498
   "         REGEXP, "&_
499
   "         REGEXP_DESCRIPTION "&_
500
   "     FROM VALIDATION_RULES"&_
501
   "    WHERE field_name IN ("& sFieldList &")"
502
 
503
 
504
   Set rsQry = OraDatabase.DbCreateDynaset( query , ORADYN_DEFAULT )
505
   If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
506
      outobjForm.LoadFieldRules rsQry.GetRows()
507
 
508
   End If
509
 
510
   rsQry.Close
511
   Set rsQry = Nothing
119 ghuddy 512
End Sub
513
'-----------------------------------------------------------------------------------------------------------------------------
514
Sub Log_Action ( nPvId, sActionTypeName, sComments )
129 ghuddy 515
 
516
   OraDatabase.Parameters.Add "PV_ID",            nPvId,                   ORAPARM_INPUT, ORATYPE_NUMBER
517
   OraDatabase.Parameters.Add "USER_ID",          objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
518
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sActionTypeName,         ORAPARM_INPUT, ORATYPE_VARCHAR2
519
   OraDatabase.Parameters.Add "COMMENTS",         sComments,               ORAPARM_INPUT, ORATYPE_VARCHAR2
520
 
521
   objEH.TryORA ( OraSession )
522
   On Error Resume Next
523
 
524
   OraDatabase.ExecuteSQL _
525
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
526
 
527
   objEH.CatchORA ( OraSession )
528
 
529
   OraDatabase.Parameters.Remove "PV_ID"
530
   OraDatabase.Parameters.Remove "USER_ID"
531
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
532
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 533
End Sub
534
'-----------------------------------------------------------------------------------------------------------------------------
535
Function GetUsername ( nUser_id )
129 ghuddy 536
   Dim rsQry, sQuery
119 ghuddy 537
 
129 ghuddy 538
   OraDatabase.Parameters.Add "USER_ID", nUser_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
539
   sQuery = "SELECT full_name FROM users WHERE user_id = :USER_ID"
540
   Set rsQry = OraDatabase.DbCreateDynaset( sQuery, cint(0))
119 ghuddy 541
 
129 ghuddy 542
   If rsQry.RecordCount = 1 Then
543
      GetUsername = rsQry.Fields("full_name").Value
544
   Else
545
      GetUsername = nothing
546
   End If
119 ghuddy 547
 
129 ghuddy 548
   OraDatabase.Parameters.remove "USER_ID"
549
   rsQry.Close
550
   Set rsQry = nothing
119 ghuddy 551
End Function
552
'-----------------------------------------------------------------------------------------------------------------------------
553
Function GetUserEmail ( nUser_id )
129 ghuddy 554
   Dim rsQry, sQuery
119 ghuddy 555
 
129 ghuddy 556
   OraDatabase.Parameters.Add "USER_ID", nUser_id, ORAPARM_INPUT, ORATYPE_VARCHAR2
557
   sQuery = "SELECT user_email FROM users WHERE user_id = :USER_ID"
558
   Set rsQry = OraDatabase.DbCreateDynaset( sQuery, cint(0))
119 ghuddy 559
 
129 ghuddy 560
   If rsQry.RecordCount = 1 Then
561
      GetUserEmail = rsQry.Fields("user_email").Value
562
   Else
563
      GetUserEmail = nothing
564
   End If
119 ghuddy 565
 
129 ghuddy 566
   OraDatabase.Parameters.remove "USER_ID"
567
   rsQry.Close
568
   Set rsQry = nothing
119 ghuddy 569
End Function
129 ghuddy 570
'---------------------------------------------------------------------------------------------------------------------
571
Sub SetIgnoreWarnings (dpvId, pvId, rtagId)
572
 
573
   Dim Query_String, rsTemp
574
 
575
   OraDatabase.Parameters.Add "RTAG_ID",        rtagId,                  ORAPARM_INPUT, ORATYPE_NUMBER
576
   OraDatabase.Parameters.Add "PV_ID",          pvId,                    ORAPARM_INPUT, ORATYPE_NUMBER
577
   OraDatabase.Parameters.Add "USER_ID",        objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
578
   OraDatabase.Parameters.Add "IGNORE_ID_LIST", dpvId,                   ORAPARM_INPUT, ORATYPE_VARCHAR2
579
 
580
   On Error Resume Next
581
 
582
   objEH.TryORA ( OraSession )
583
   OraDatabase.ExecuteSQL _
584
   "BEGIN "&_
585
   " Ignore_Dependency_Warnings( :RTAG_ID, :PV_ID, :IGNORE_ID_LIST, FALSE, :USER_ID ); "&_
586
   "END; "
587
   objEH.CatchORA ( OraSession )
588
 
589
   OraDatabase.Parameters.Remove "USER_ID"
590
   OraDatabase.Parameters.Remove "IGNORE_ID_LIST"
591
 
592
   If objEH.LastOraFailed = FALSE Then
593
      ' DEVI-051154 has prompted the removal of the code to call touch_release from the
594
      ' Ignore_Dependency_Warnings stored procedure, and re-locate it here in the website code, since
595
      ' Ignore_Dependency_Warnings is called internally by other SQL code in the database where
596
      ' we do not want to touch_release. This is what Ignore_Dependency_Warnings used to do:
597
      '     IF PK_ENVIRONMENT.GET_PACKAGE_AREA ( nPvId, nRtagId ) = 2 THEN
598
      '        Touch_Release (nRtagId);
599
      '     END IF;
600
      ' Doing the same in the website code is a bit  more verbose, and we shouldn't do it if it
601
      ' is not necessary.
602
 
603
      ' Get the tab in which the package version resides (0=wip, 1=planned, 2=released)
604
      OraDatabase.Parameters.Add "ENVTAB",  NULL, ORAPARM_OUT, ORATYPE_NUMBER
605
      OraDatabase.ExecuteSQL _
606
      "BEGIN "&_
607
      " :ENVTAB = PK_ENVIRONMENT.GET_PACKAGE_AREA ( :PV_ID, :RTAG_ID ); "&_
608
      "END; "
609
 
610
      ' only need to touch release if it is not already in touched state. The purpose of this is to prevent the
611
      ' code inside the body of this "if-statement" from executing during the period of time when the database schema
612
      ' has yet to be updated to remove the intenral call to touch_release. Once the database schema is updated,
613
      ' the Rebuild_Environment_Necessary call is no longer necessary since it will always return FALSE at this
614
      ' point. Leaving the statement in place post the database schema update will do no harm though.
615
      If Rebuild_Environment_Necessary(rtagId) = FALSE Then
616
         ' If the package version is 'Released' then allow the rebuild of the environment so that the states
617
         ' of higher level packages can be re-evaluated
618
         If OraDatabase.Parameters("ENVTAB").Value = 2 Then
619
            objEH.TryORA ( OraSession )
620
            OraDatabase.ExecuteSQL _
621
            "BEGIN "&_
622
            " Touch_Release ( :RTAG_ID ); "&_
623
            "END; "
624
            objEH.CatchORA ( OraSession )
625
         End If
626
      End If
627
 
628
      OraDatabase.Parameters.Remove "ENVTAB"
629
   End If
630
 
631
   OraDatabase.Parameters.Remove "RTAG_ID"
632
   OraDatabase.Parameters.Remove "PV_ID"
633
End Sub
119 ghuddy 634
'------------------------------------------------------------------------------------------------------------------
151 ghuddy 635
Sub UpdateChangeType (nPvId, nChangeType)
636
   Dim rsTemp, Query_String
637
 
638
   On Error Resume Next
639
   If (NOT IsNull(nChangeType)) AND (nChangeType <> "") AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
640
 
641
      OraDatabase.Parameters.Add "PV_ID",       nPvId,       ORAPARM_INPUT, ORATYPE_NUMBER
642
      OraDatabase.Parameters.Add "CHANGE_TYPE", nChangeType, ORAPARM_INPUT, ORATYPE_CHAR
643
 
644
      objEH.TryORA ( OraSession )
645
      On Error Resume Next
646
 
647
      OraDatabase.ExecuteSQL _
648
      "UPDATE package_versions pv SET pv.change_type = '"& nChangeType &"' WHERE pv.pv_id = "& nPvId
649
 
650
      objEH.CatchORA ( OraSession )
651
 
652
      OraDatabase.Parameters.Remove "PV_ID"
653
      OraDatabase.Parameters.Remove "CHANGE_TYPE"
654
 
655
      If objEH.LastOraFailed = FALSE Then
656
         '/* Log Action */
657
         If nChangeType = "M" Then
658
            Call Log_Action ( nPvId, "change_type_update", "Major Change" )
659
 
660
         ElseIf nChangeType = "N" Then
661
            Call Log_Action ( nPvId, "change_type_update", "Minor Change" )
662
 
663
         ElseIf nChangeType = "P" Then
664
            Call Log_Action ( nPvId, "change_type_update", "Patch Change" )
665
 
666
         End If
667
      End If
668
   End If
669
End Sub
670
'------------------------------------------------------------------------------------------------------------------
671
Sub UpdateReasonForVersion (nPvId, nReason)
672
   Dim rsTemp, Query_String
673
 
674
   On Error Resume Next
675
   If (NOT IsNull(nReason)) AND (nReason <> "") AND (NOT IsNull(nPvId)) AND (nPvId <> "") Then
676
 
677
      OraDatabase.Parameters.Add "PV_ID",    nPvId,   ORAPARM_INPUT, ORATYPE_NUMBER
678
      OraDatabase.Parameters.Add "COMMENTS", nReason, ORAPARM_INPUT, ORATYPE_VARCHAR2
679
 
680
      objEH.TryORA ( OraSession )
681
      On Error Resume Next
682
 
683
      OraDatabase.ExecuteSQL _
155 ghuddy 684
      "UPDATE package_versions pv SET pv.comments = '"& SQLstring(nReason) &"' WHERE pv.pv_id = "& nPvId
151 ghuddy 685
 
686
      objEH.CatchORA ( OraSession )
687
 
688
      OraDatabase.Parameters.Remove "PV_ID"
689
      OraDatabase.Parameters.Remove "COMMENTS"
690
 
691
      If objEH.LastOraFailed = FALSE Then
692
         '/* Log Action */
693
         Call Log_Action ( nPvId, "reason_for_release", nReason )
694
      End If
695
   End If
696
End Sub
697
'------------------------------------------------------------------------------------------------------------------
698
 
129 ghuddy 699
%>