Subversion Repositories DevTools

Rev

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