Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
147 ghuddy 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'|                                                   |
5
'|               wAddDaemonInstruction               |
6
'|                                                   |
7
'=====================================================
8
%>
9
<%
10
Option explicit
11
Response.Expires = 0
12
%>
13
<!--#include file="common/conf.asp"-->
14
<!--#include file="common/globals.asp"-->
15
<!--#include file="common/formating.asp"-->
16
<!--#include file="common/qstr.asp"-->
17
<!--#include file="common/common_subs.asp"-->
18
<!--#include file="common/_form_window_common.asp"-->
149 ghuddy 19
<!--#include file="common/common_dbedit.asp"-->
147 ghuddy 20
<!--#include file="common/daemon_instructions.asp"-->
21
<%
22
'------------ ACCESS CONTROL ------------------
23
%>
24
<!--#include file="_access_control_general.asp"-->
25
<!--#include file="_access_control_login.asp"-->
26
<%
27
'------------ VARIABLE DEFINITION -------------
28
Dim sMessage
29
Dim parProj_id
30
Dim parPv_id
31
Dim parOp_code
32
Dim parRepeat
33
Dim parInst_id
34
Dim parSchDateTime
35
Dim parRfile
36
Dim bHideRepeat
149 ghuddy 37
Dim bHidePackages
38
Dim bPreventSubmit
39
Dim parSortOrder
147 ghuddy 40
'------------ CONSTANTS DECLARATION -----------
41
 
42
 
43
'------------ VARIABLE INIT -------------------
44
sMessage = NULL
45
 
149 ghuddy 46
bPreventSubmit = False
47
 
48
' collect all parameters from query string
147 ghuddy 49
parOp_code = Request("op_code")
50
parProj_id = Request("proj_id")
51
parPv_id = Request("pv_id")
52
parRepeat = Request("repeat")
53
parInst_id = Request("inst_id")
54
parSchDateTime = Request("sdt")
55
parRfile = Request("rfile")
56
 
149 ghuddy 57
parSortOrder = Request("sort")
58
If IsNull(parSortOrder) OR parSortOrder = "" Then
59
   parSortOrder = "0"
60
End If
61
 
147 ghuddy 62
Set objFormCollector = CreateObject("Scripting.Dictionary")
63
 
64
'------------ CONDITIONS ----------------------
65
'----------------------------------------------
66
%>
67
<%
68
'------------------------------------------------------------------------------------------------------------------------------------------
69
' For the specified project ID, get a list of all that project's releases that are not closed/archived.
70
' Return True if at least one release was found, else False
71
'------------------------------------------------------------------------------------------------------------------------------------------
72
Function ReleasesAvailable(NNproj_id)
73
   Dim rsTemp, Query_String
74
 
75
   ReleasesAvailable = True
76
   Query_String = "SELECT rtag_id, rtag_name "&_
77
                  "  FROM release_tags rt"&_
78
                  " WHERE rt.proj_id = "& NNproj_id &_
79
                  "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"
80
 
81
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
82
   If rsTemp.RecordCount = 0 Then
83
      ReleasesAvailable = False
84
   End If
85
 
86
   rsTemp.Close
87
   Set rsTemp = nothing
88
End Function
89
'------------------------------------------------------------------------------------------------------------------------------------------
90
' For the specified Release, get a list of all that release's daemon configurations.
91
' Return True if at least one daemon configuration was found, else False
92
'------------------------------------------------------------------------------------------------------------------------------------------
93
Function DaemonsAvailable(NNrtag_id)
94
   Dim rsTemp, Query_String
95
 
96
   DaemonsAvailable = True
97
   Query_String = "SELECT * "&_
98
                  "  FROM release_config rc"&_
99
                  " WHERE rc.rtag_id = "& NNrtag_id
100
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
101
   If rsTemp.RecordCount = 0 Then
102
      DaemonsAvailable = False
103
   End If
104
 
105
   rsTemp.Close
106
   Set rsTemp = nothing
107
End Function
108
'------------------------------------------------------------------------------------------------------------------------------------------
109
' Formulate the HTML for a combo box listing all the daemon instruction operations, and select the one that matches
110
' the op-code passed in as a parameter. If the parameter value could not be found, correct it to the first valid op-code
111
' in the list.
112
'------------------------------------------------------------------------------------------------------------------------------------------
113
Function Get_OpCodes ( NNop_code )
149 ghuddy 114
   Dim op_code_str_array
115
   Dim op_code_str
116
   Dim op_code_val
147 ghuddy 117
	Dim selectedFound
118
   Dim tempLINK
119
   Dim s
120
 
149 ghuddy 121
   selectedFound = False
147 ghuddy 122
 
149 ghuddy 123
   ' Get the op-codes in terms of human readable string names - these will be used in the drop down select list
124
   Call GetDaemonInstructionOperationNameArray(op_code_str_array)
147 ghuddy 125
 
149 ghuddy 126
   s = "<td width='20%' align='left'>Operation</td>"
147 ghuddy 127
   s = s + "<td align='left'><select name='op_code_list' id='op_code_list' class='form_item' onchange=""MM_jumpMenu('parent',this,0)"">"
128
 
149 ghuddy 129
   For each op_code_str in op_code_str_array
147 ghuddy 130
 
149 ghuddy 131
      ' get equivalent op-code value for this op-code string
132
      op_code_val = DaemonInstructionOperationValue(op_code_str)
133
 
147 ghuddy 134
      tempLINK = scriptName & "?inst_id="& parInst_id &_
149 ghuddy 135
                              "&op_code="& op_code_val &_
147 ghuddy 136
                              "&rtag_id=" & parRtag_id &_
137
                              "&pv_id=" & parPv_id &_
149 ghuddy 138
                              "&sort=" & parSortOrder &_
147 ghuddy 139
                              "&sdt="& parSchDateTime &_
140
                              "&repeat="& parRepeat &_
141
                              "&rfile="& parRfile
142
 
149 ghuddy 143
      If ((NNop_code = op_code_val) OR (NNop_code = "0")) AND (selectedFound = False) Then
144
         s = s + "<option value='"& tempLINK &"' selected>"& op_code_str &"</option>"
147 ghuddy 145
         selectedFound = True
149 ghuddy 146
         NNop_code = op_code_val
147 ghuddy 147
      Else
149 ghuddy 148
         s = s + "<option value='"& tempLINK &"'>"& op_code_str &"</option>"
147 ghuddy 149
      End If
150
   Next
151
 
152
   s = s + "</select></td>"
153
   Get_OpCodes = s
154
End Function
155
'------------------------------------------------------------------------------------------------------------------------------------------
156
' Formulate the HTML for a combo box listing all the Projects, and select the one that matches
157
' the proj-id passed in as a parameter. If the parameter value could not be found, correct it to the first valid proj-id
158
' in the list.
159
'------------------------------------------------------------------------------------------------------------------------------------------
160
Function Get_Projects ( NNproj_id )
161
   Dim rsTemp, Query_String, projName, tempLINK, selectedFound, s
162
 
163
   selectedFound = False
164
   Query_String = "SELECT * FROM projects ORDER BY  UPPER( proj_name )"
165
 
166
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
167
 
168
   s = "<td>Project</td>"
169
   s = s + "<td><select id='proj_id_list' name='proj_id_list' class='form_item' onChange=""MM_jumpMenu('parent',this,0)"">"
170
 
171
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
172
      projName = UCase(rsTemp.Fields("proj_name"))
173
 
174
      tempLINK = scriptName & "?inst_id="& parInst_id &_
175
                              "&op_code="& parOp_code &_
176
                              "&proj_id=" & rsTemp.Fields("proj_id") &_
177
                              "&sdt="& parSchDateTime &_
178
                              "&repeat="& parRepeat &_
149 ghuddy 179
                              "&sort=" & parSortOrder &_
147 ghuddy 180
                              "&rfile="& parRfile
181
 
182
      If ((NNproj_id = Cstr(rsTemp.Fields("proj_id"))) OR (NNproj_id = "0")) AND (selectedFound = False) Then
183
         s = s + "<option value='"& tempLINK &"' selected>"& projName &"</option>"
184
         selectedFound = True
185
         NNproj_id = CStr(rsTemp.Fields("proj_id"))
186
      Else
187
         s = s + "<option value='"& tempLINK &"'>"& projName &"</option>"
188
      End If
189
 
190
      rsTemp.MoveNext
191
   WEnd
192
   s = s + "</select>"
193
 
194
   ' Correct for a situation where selectedFound is still FALSE.
195
   If NOT selectedFound Then
196
      rsTemp.MoveFirst
197
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
198
         NNproj_id = CStr(rsTemp.Fields("proj_id"))
199
      Else
200
         NNproj_id = "0"
201
      End If
202
   End If
203
 
204
   rsTemp.Close
205
   Set rsTemp = nothing
206
 
207
   s = s + "</td>"
208
 
209
   Get_Projects = s
210
End Function
211
 
212
'------------------------------------------------------------------------------------------------------------------------------------------
213
' Formulate the HTML for a combo box listing all the Release for a specified project, and select the one that matches
214
' the release-tag passed in as a parameter. If the parameter value could not be found, correct it to the first valid release-tag
215
' in the list.
216
'------------------------------------------------------------------------------------------------------------------------------------------
217
Function Get_Releases ( NNproj_id, NNrtag_id )
149 ghuddy 218
   Dim rsTemp, Query_String, releaseName, tempLINK, selectedFound, s, numReleases
147 ghuddy 219
 
220
   selectedFound = False
149 ghuddy 221
 
222
   numReleases = 0
223
 
147 ghuddy 224
   Query_String = "SELECT rtag_id, rtag_name "&_
225
                  "  FROM release_tags rt"&_
226
                  " WHERE rt.proj_id = "& NNproj_id &_
227
                  "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
228
                  " ORDER BY UPPER(rtag_name)"
229
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
230
 
231
   s = "<td>Release</td>"
232
   s = s + "<td><select id='rtag_id_list' name='rtag_id_list' class='form_item' onChange=""MM_jumpMenu('parent',this,0)"">"
233
 
234
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
235
      releaseName = rsTemp.Fields("rtag_name")
236
 
237
      tempLINK = scriptName & "?inst_id="& parInst_id &_
238
                              "&op_code="& parOp_code &_
239
                              "&proj_id="& NNproj_id &_
240
                              "&rtag_id="& rsTemp.Fields("rtag_id") &_
241
                              "&sdt="& parSchDateTime &_
242
                              "&repeat="& parRepeat &_
149 ghuddy 243
                              "&sort=" & parSortOrder &_
147 ghuddy 244
                              "&rfile="& parRfile
245
 
246
      If ((NNrtag_id = CStr(rsTemp.Fields("rtag_id"))) OR (NNrtag_id = "0")) AND (selectedFound = False) Then
247
            s = s + "<option value='"& tempLINK &"' selected>"& releaseName &"</option>"
248
         selectedFound = True
249
         NNrtag_id = Cstr(rsTemp.Fields("rtag_id"))
250
      Else
251
         s = s + "<option value='"& tempLINK &"'>"& releaseName &"</option>"
252
      End If
253
 
149 ghuddy 254
      numReleases = numReleases + 1
255
 
147 ghuddy 256
      rsTemp.MoveNext
257
   WEnd
258
   s = s + "</select>"
259
 
260
   ' Correct for a situation where selectedFound is still FALSE.
261
   If NOT selectedFound Then
262
      rsTemp.MoveFirst
263
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
264
         NNrtag_id = CStr(rsTemp.Fields("rtag_id"))
265
      Else
266
         NNrtag_id = "0"
267
      End If
268
   End If
269
 
149 ghuddy 270
   ' If no releases were found then replace drop down list with some warning text and disable form submission
271
   If numReleases = 0 Then
272
      bPreventSubmit = True
273
      s = "<td>Release</td><td><a style=color:Red>WARNING: No active releases found. The operation cannot be performed.</a></td>"
274
   Else
275
      ' If the selected release does not have a daemon configuration, append some warning text to the right of the drop down list.
276
      If DaemonsAvailable(NNrtag_id) = False Then
277
         s = s + "<a style=color:Red>WARNING: Release has no build daemon(s)</a>"
278
      End If
279
   End If
280
 
147 ghuddy 281
   rsTemp.Close
282
   Set rsTemp = nothing
283
 
284
   s = s + "</td>"
285
 
286
   Get_Releases = s
287
End Function
288
'------------------------------------------------------------------------------------------------------------------------------------------
289
' Formulate the HTML for a combo box listing all the Package Versions in a specified release, and select the one that matches
290
' the pv_id passed in as a parameter. If the parameter value could not be found, correct it to the first valid pv_id
291
' in the list.
149 ghuddy 292
' This function must deal with op-codes that want to read package versions from the work_in_progress table, and op-codes
293
' that need to read package versions from the release_content table.
294
' The function should only be called if a package versions drop down list is required for the form.
147 ghuddy 295
'------------------------------------------------------------------------------------------------------------------------------------------
149 ghuddy 296
Function Get_Packages ( NNrtag_id, NNpv_id, NNop_code )
297
   Dim rsTemp, Query_String, pkgName, tempLINK, selectedFound, s, numPackages
147 ghuddy 298
 
299
   selectedFound = False
300
 
149 ghuddy 301
   numPackages = 0
302
 
303
   If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then
304
      ' Get list of packages from from work_in_progress table
305
      Query_String = "SELECT pk.pkg_id, pk.pkg_name, pv.pkg_version, wip.pv_id "&_
306
                     "  FROM work_in_progress wip, release_tags rt, packages pk, package_versions pv "&_
307
                     " WHERE wip.rtag_id = "& Cstr(NNrtag_id) &_
308
                     "   AND wip.rtag_id = rt.rtag_id"&_
309
                     "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
310
                     "   AND wip.pv_id = pv.pv_id"&_
311
                     "   AND pk.pkg_id = pv.pkg_id"&_
312
                     " ORDER BY UPPER(pkg_name)"
313
 
314
   Else
315
      ' Get list of packages from from release_content table
316
      Query_String = "SELECT pk.pkg_id, pk.pkg_name, pv.pkg_version, rc.pv_id "&_
317
                     "  FROM release_content rc, release_tags rt, packages pk, package_versions pv "&_
318
                     " WHERE rc.rtag_id = "& Cstr(NNrtag_id) &_
319
                     "   AND rc.rtag_id = rt.rtag_id"&_
320
                     "   AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_
321
                     "   AND rc.pv_id = pv.pv_id"&_
322
                     "   AND pk.pkg_id = pv.pkg_id"&_
323
                     " ORDER BY UPPER(pkg_name)"
324
   End If
325
 
147 ghuddy 326
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
327
 
149 ghuddy 328
   ' modify the control heading to indicate the source of the package version list
329
   If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then
330
      s = "<td>WIP Package</td>"
331
   Else
332
      s = "<td>Released Package</td>"
333
   End If
334
 
147 ghuddy 335
   s = s + "<td><select id='pv_id_list' name='pv_id_list' class='form_item' onChange=""MM_jumpMenu('parent',this,0)"">"
336
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
337
      pkgName = rsTemp.Fields("pkg_name") & " " & rsTemp.Fields("pkg_version")
338
 
339
      tempLINK = scriptName & "?inst_id="& parInst_id &_
149 ghuddy 340
                              "&op_code="& NNop_code &_
147 ghuddy 341
                              "&proj_id="& parProj_id &_
342
                              "&rtag_id="& NNrtag_id &_
343
                              "&pv_id="&   rsTemp.Fields("pv_id") &_
344
                              "&sdt="& parSchDateTime &_
345
                              "&repeat="& parRepeat &_
149 ghuddy 346
                              "&sort=" & parSortOrder &_
147 ghuddy 347
                              "&rfile="& parRfile
348
 
349
      If ((NNpv_id = Cstr(rsTemp.Fields("pv_id"))) OR (NNpv_id = "0")) AND (selectedFound = False) Then
350
         s = s + "<option value='"& tempLINK &"' selected>"& pkgName &"</option>"
351
         selectedFound = True
352
         NNpv_id = CStr(rsTemp.Fields("pv_id"))
353
      Else
354
         s = s + "<option value='"& tempLINK &"'>"& pkgName &"</option>"
355
      End If
356
 
149 ghuddy 357
      numPackages = numPackages + 1
358
 
147 ghuddy 359
      rsTemp.MoveNext
360
   WEnd
361
   s = s + "</select></td>"
362
 
363
   ' Correct for a situation where selectedFound is still FALSE.
364
   If NOT selectedFound Then
365
      rsTemp.MoveFirst
366
      If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
367
         NNpv_id = Cstr(rsTemp.Fields("pv_id"))
368
      Else
369
         NNpv_id = "0"
370
      End If
371
   End If
372
 
149 ghuddy 373
   ' replace drop down list with a warning if no package versions were found, and ensure that the user cannot submit the form
374
   If numPackages = 0 Then
375
      bPreventSubmit = True
376
      If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then
377
         s = "<td>Package</td><td><a style=color:Red>WARNING: No WIP package versions found. The operation cannot be performed.</a></td>"
378
      Else
379
         s = "<td>Package</td><td><a style=color:Red>WARNING: No released package versions found. The operation cannot be performed.</a></td>"
380
      End If
381
   End If
382
 
147 ghuddy 383
   rsTemp.Close
384
   Set rsTemp = nothing
385
 
386
   Get_Packages = s
387
End Function
388
 
389
'------------------------------------------------------------------------------------------------------------------------------------------
390
' This function will be called if and only if the form is first opened in circumstances where the user is editing an existing record
391
' and all of the form's parameters must be set to the values found in that record. The database record must be obtained using a query
392
' and the relevant parameters assigned from the record fields
393
'------------------------------------------------------------------------------------------------------------------------------------------
394
Sub Get_All_Params_From_Inst_Id(NNInstId)
395
   Dim rsTemp, Query_String
396
 
397
   Query_String = "SELECT op_code, rtag_id, pv_id, repeat_secs, "&_
398
                  "  TO_CHAR(scheduled_datetime, 'DD-MM-YYYY HH24:MI:SS') AS schedDate "&_
399
                  "  FROM DAEMON_INSTRUCTIONS "&_
400
                  " WHERE DAEMON_INSTRUCTIONS_ID = " & NNInstId
401
	Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
402
   If rstemp.RecordCount = 0 Then
403
      Call RaiseMsg(enum_MSG_ERROR, "Attempt to Edit a non-existent record")
404
   End If
405
 
406
   ' assign record fields to global parameters
407
   parOp_code = rsTemp("op_code")
408
   parRtag_id = rsTemp("rtag_id")
409
   parPv_id   = rsTemp("pv_id")
410
   parRepeat  = rsTemp("repeat_secs")
411
   parSchDateTime = rsTemp("schedDate")
412
 
413
   ' derive project id since that is not stored in the table
414
   If NOT IsNull(parRtag_id) AND parRtag_id <> "" Then
415
      parProj_id = Get_Proj_ID(parRtag_id)
416
   Else
417
      parProj_id = "0"
418
   End If
419
 
420
   rsTemp.Close
421
   Set rsTemp = nothing
422
End Sub
423
'------------------------------------------------------------------------------------------------------------------------------------------
424
%>
425
<%
426
'------------ RUN BEFORE PAGE RENDER ----------
427
 
428
' Are we in edit mode? If so, populate all parameters from the record being edited
429
If (NOT IsNull(parInst_id)) AND (parInst_id <> "") AND (Request("edit") = "true") Then
430
   If NOT DaemonInstructionInProgress(Request("inst_id")) Then
431
      Call Get_All_Params_From_Inst_Id(parInst_id)
432
   Else
433
      CloseWindow   ' close the form we were opening
434
      ' redirect to an error message in the parent form
435
      Call RaiseMsgInParent(enum_MSG_ERROR, "Cannot edit an instruction that is currently being processed by a Daemon")
436
   End If
437
End If
438
 
439
' Make sure we dont have any null strings or empty strings for our parameters
440
If IsNull(parOp_code) OR parOp_code = "" Then
441
   parOp_code = "0"
442
End If
443
If IsNull(parProj_id) OR parProj_id = "" Then
444
   parProj_id = "0"
445
End If
446
If IsNull(parRtag_id) OR parRtag_id = "" Then
447
   parRtag_id = "0"
448
End If
449
If IsNull(parPv_id) OR parPv_id = "" Then
450
   parPv_id = "0"
451
End If
452
If IsNull(parRepeat) OR parRepeat = "" Then
453
   parRepeat = "0"
454
End If
455
If IsNull(parRfile) OR parRfile = "" Then
456
   parRfile = "admin_daemon_instructions.asp"
457
End If
458
 
459
If IsNull(parSchDateTime) OR parSchDateTime = "" Then
460
   parSchDateTime = EuroDateTimeForCalendarControl(Now())
461
End If
462
 
463
' If this form is opened with an OP_CODE, RTAG_ID and PV_ID only, then we need to derive the PROJ_ID before
464
' calling Get_Projects() to generate the project drop down list.
465
If parProj_id = "0" AND NOT IsNull(parRtag_id) AND parRtag_id <> "" AND parRtag_id <> "0" Then
466
   parProj_id = Get_Proj_ID(parRtag_id)
467
End If
468
 
149 ghuddy 469
' Hide the Package drop-down list if the Daemon Instruction does not require it
470
If DaemonInstructionNeedsPV_ID(parOp_code) Then
471
   bHidePackages = False
472
Else
473
   bHidePackages = True
147 ghuddy 474
   parPv_id = "0"
475
End If
149 ghuddy 476
' NOTE: from this moment on, any real use of parPv_id has to be guarded by examination of bHidePackages
147 ghuddy 477
 
149 ghuddy 478
 
147 ghuddy 479
' Hide the Repeat buttons if the Daemon Instruction does not require them
149 ghuddy 480
If DaemonInstructionNeedsRepeat(parOp_code) Then
481
   bHideRepeat = False
482
Else
147 ghuddy 483
   bHideRepeat = True
484
End If
485
 
149 ghuddy 486
 
487
 
147 ghuddy 488
' Call some 'Get' procedures without HTML generation to determine the values of parProj_id, par_Rtag_id, and parPv_id
489
' in case they are not currently present in the query string. This will then allow the use of the ReleasesAvailable() and
490
' DaemonsAvailable() functions further below to hide the form submit button.
491
' It will also support the submit action itself when it takes place during the editing of an existing record where
492
' the user changes (for example) the project without making any changes to release or package and so those items
493
' are nullified and must be reset to something other than their original values that came through the query string
494
' when the edit form was just opened.
495
Call Get_Projects(parProj_id)                  ' Ensures parProj_id has a good value
496
Call Get_Releases(parProj_id, parRtag_id)      ' Ensures parRtag_id has a good value
497
 
149 ghuddy 498
If NOT bHidePackages Then
499
   Call Get_Packages (parRtag_id, parPv_id, parOp_code)
147 ghuddy 500
End If
501
 
502
' Check if form submit is happening
503
If CBool(Request("action")) Then
504
 
505
   Dim RepeatSeconds
506
   Dim ScheduledDateTime
507
   Dim ReleaseMode
508
 
509
   ReleaseMode = GetReleaseMode(parRtag_id)
510
 
153 ghuddy 511
   ' determine if insert/update is enabled by permissions
512
   if NOT UserCanAddOrEditThisDaemonInst(parProj_id, ReleaseMode, parOp_code) Then
147 ghuddy 513
      ' redirect to an error message
514
      Call RaiseMsg(enum_MSG_ERROR, "You have been denied permission to add/update daemon instructions for the specified release.")
515
   End If
516
 
149 ghuddy 517
   ' do daemon instruction validation, continuing only if it passes
518
   If ValidateDaemonInstruction(parOp_code, parRtag_id, parPv_id) = True Then
147 ghuddy 519
 
149 ghuddy 520
      ' Setup the repeat seconds count according to the radio button value
521
      If IsNull(Request("repeat_inst")) OR Request("repeat_inst") = "" OR Request("repeat_inst") = "No" Then
522
         RepeatSeconds = 0
523
      Else
524
         RepeatSeconds = 86400
525
      End If
147 ghuddy 526
 
149 ghuddy 527
      ' If user has not entered a scheduled time, set the scheduled date/time to now
528
      ScheduledDateTime = Request("scheduled_time")
529
      If IsNull(ScheduledDateTime) OR ScheduledDateTime = "" Then
530
         ScheduledDateTime = ORA_SYSDATETIME
531
      Else
532
         ScheduledDateTime = "TO_DATE( '"& ScheduledDateTime &"','DD-MM-YYYY HH24:MI:SS' )"
533
      End If
147 ghuddy 534
 
149 ghuddy 535
      ' nullify parPv_id for the SQL, if the instruction op-code does not require one
536
      If bHidePackages Then
537
         parPv_id = "NULL"
538
      End If
147 ghuddy 539
 
149 ghuddy 540
      ' if the page has been provided an inst_id, we must be editing an existing record so we do an update
541
      If (NOT IsNull(parInst_id)) AND (parInst_id <> "") Then
542
         ' We are updating an existing record
543
         objEH.TryORA ( OraSession )
544
         On Error Resume Next
147 ghuddy 545
 
149 ghuddy 546
         OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.update_daemon_inst( "& parInst_id & ", " &_
547
                                                                        parOp_code & ", " &_
548
                                                                        parRtag_id & ", " &_
549
                                                                        parPv_id & ", " &_
550
                                                                        ScheduledDateTime & ", " &_
551
                                                                        CStr(RepeatSeconds) & ", " &_
552
                                                                        ORA_SYSDATETIME & ", " &_
553
                                                                        objAccessControl.UserId & "); END;"
554
         objEH.CatchORA ( OraSession )
555
 
556
         If objEH.Finally Then
557
            If parRfile = "admin_daemon_instructions.asp" Then
558
               Call OpenInParentWindow (parRfile & "?sort=" & parSortOrder)
559
            Else
560
               Call OpenInParentWindow (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id)
561
            End If
562
            Call CloseWindow()
147 ghuddy 563
         End If
149 ghuddy 564
      Else ' We are adding a new record
565
         objEH.TryORA ( OraSession )
566
         On Error Resume Next
147 ghuddy 567
 
149 ghuddy 568
         OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.insert_daemon_inst( "& parOp_code & ", " &_
569
                                                                        parRtag_id & ", " &_
570
                                                                        parPv_id & ", " &_
571
                                                                        ScheduledDateTime & ", " &_
572
                                                                        CStr(RepeatSeconds) & ", " &_
573
                                                                        ORA_SYSDATETIME & ", " &_
574
                                                                        objAccessControl.UserId & "); END;"
575
         objEH.CatchORA ( OraSession )
576
         If objEH.Finally Then
577
            If parRfile = "admin_daemon_instructions.asp" Then
578
               Call OpenInParentWindow (parRfile & "?sort=" & parSortOrder)
579
            Else
580
               Call OpenInParentWindow (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id)
581
            End If
582
            Call CloseWindow()
147 ghuddy 583
         End If
584
      End If
585
   End If
586
End If
587
 
588
'----------------------------------------------
589
%>
590
<script language="JavaScript" type="text/javascript">
591
<!--
592
 
593
// This function is designed to be called when a repeat radio button is pressed. It reloads the page with an updated query string
594
// to reflect the new setting of the radio button set
595
function Refresh_Repeat(newRepeat)
596
{
597
   var s;
598
   s  = '<%=scriptName%>';
599
   s += '?inst_id=' + document.getElementById('inst_id').value;
600
   s += '&op_code=' + document.getElementById('op_code').value;
601
   s += '&proj_id=' + document.getElementById('proj_id').value;
602
   s += '&rtag_id=' + document.getElementById('rtag_id').value;
603
   s += '&pv_id='   + document.getElementById('pv_id').value;
149 ghuddy 604
   s += '&sort='    + document.getElementById('sortOrder').value;
147 ghuddy 605
   s += '&sdt='     + document.getElementById('scheduled_time').value;
606
   s += '&repeat='  + newRepeat;
607
   s += '&rfile='   + document.getElementById('rfile').value;
608
 
609
   document.location = s;
610
}
611
 
612
//-->
613
</script>
614
 
615
<html>
616
   <head>
617
      <title>Release Manager</title>
618
      <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
619
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
620
      <link href="images/release_manager_style.css" rel="stylesheet" type="text/css">
621
      <script language="JavaScript" src="scripts/common.js"></script>
622
      <script language="JavaScript" src="images/ts_picker.js"></script>
623
   </head>
624
 
625
   <body background="images/bg_bage_0.gif" leftmargin="0" topmargin="0" >
626
      <table width="100%"  border="0" cellspacing="0" cellpadding="10">
627
         <tr>
628
            <td bgcolor="#FFFFFF" class="body_txt"><span class="body_h1"><img src="icons/i_linkarrow_black.gif" width="11" height="11" align="absmiddle">&nbsp;Add/Update Daemon Instruction</span> <br>
629
               Add a new Daemon Instruction or edit an existing Daemon Instruction.
630
            </td>
631
         </tr>
632
 
633
 
634
         <%
635
         '-- FROM START --------------------------------------------------------------------------------------------------------------
636
         objFormComponent.FormName = "DaemonInstruction"
637
         objFormComponent.Action = ScriptName &_
638
                                   "?inst_id="& parInst_id &_
639
                                   "&op_code="& parOp_code &_
640
                                   "&proj_id="& parProj_id &_
641
                                   "&rtag_id="& parRtag_id &_
642
                                   "&pv_id="&   parPv_id &_
149 ghuddy 643
                                   "&sort="&    parSortOrder &_
147 ghuddy 644
                                   "&rfile="& parRfile
645
         objFormComponent.OnSubmit = "ShowProgress();"
646
         Call objFormComponent.FormStart()
647
 
648
 
649
         %>
650
         <tr>
651
            <td background="images/bg_login.gif">
652
               <table width="50%"  border="0" cellspacing="0" cellpadding="0">
653
                  <tr>
654
                     <td><%=ProgressBar()%></td>
655
                     <td align="right">
149 ghuddy 656
                        <%If ReleasesAvailable(parProj_id) AND DaemonsAvailable(parRtag_id) AND NOT bPreventSubmit Then%>
147 ghuddy 657
                           <input name="btn" type="submit" class="form_btn" value="Add/Update">
658
                        <%Else%>
149 ghuddy 659
                           <input name="btn" type="submit" class="form_btn_disabled" value="Add/Update" disabled="disabled" >
147 ghuddy 660
                        <%End If%>
661
 
662
                        <input name="btn" type="reset" class="form_btn" value="Cancel" onClick="self.close();">
663
                     </td>
664
                  </tr>
665
               </table>
666
            </td>
667
         </tr>
668
         <tr>
669
            <td>
670
               <!-- NEW PRODUCT ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
671
               <%Call Messenger ( sMessage , 3, "100%" )%>
672
               <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
673
               <!--#include file="messages/_msg_inline.asp"-->
674
               <table width="100%" border="0">
675
                  <tr>
676
                     <td width="1%">
677
                        <%=Get_OpCodes(parOp_code)%>
678
                     </td>
679
                  </tr>
680
                  <tr><td>&nbsp;</td></tr>
681
                  <tr>
682
                     <td>
683
                        <div id="SelectProject" style="visibility:visible">
684
                           <%=Get_Projects(parProj_id)%>
685
                        </div>
686
                     </td>
687
                  </tr>
688
                  <tr>
689
                     <td>
690
                        <div id="SelectRelease" style="visibility:visible">
691
                           <%=Get_Releases(parProj_id, parRtag_id)%>
692
                        </div>
693
                     </td>
694
                  </tr>
695
 
149 ghuddy 696
                  <%If NOT bHidePackages Then%>
147 ghuddy 697
                  <tr>
698
                     <td>
699
                        <div id="SelectPackageVersion" style="visibility:visible">
149 ghuddy 700
                           <%=Get_Packages ( parRtag_id, parPv_id, parOp_code )%>
147 ghuddy 701
                        </div>
702
                     </td>
703
                  </tr>
704
                  <%End If%>
705
 
706
                  <tr><td>&nbsp;</td></tr>
707
                  <tr>
708
                     <td>
709
                        <td nowrap>Scheduled Time</td>
710
                        <td>
711
                           <input type="text" id="scheduled_time" name="scheduled_time" size="20" class="form_ivalue" value="<%=parSchDateTime%>">
712
                           <a href="javascript:show_calendar('document.DaemonInstruction.scheduled_time', document.DaemonInstruction.scheduled_time.value);">
713
                              <img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to select the (future) time at which to carry out the instruction">
714
                           </a>
715
                        </td>
716
                     </td>
717
                  </tr>
718
 
719
                  <%If NOT bHideRepeat Then%>
720
                     <tr>
721
                        <td>
722
                           <td>Repeat</td>
723
                           <td>
724
                              <input type="radio" name="repeat_inst" id="repeat_inst_no"     value="No"   <%If parRepeat =     "0" Then%>checked<%End If%> onchange='Refresh_Repeat(0)'     >No
725
                              <input type="radio" name="repeat_inst" id="repeat_inst_24hrs"  value="24Hrs"<%If parRepeat = "86400" Then%>checked<%End If%> onchange='Refresh_Repeat(86400)' >24 Hrs
726
                           </td>
727
                        </td>
728
                     </tr>
729
                  <%End If%>
730
 
731
                  <tr>
732
                     <td>
733
                        <input type="hidden" id="inst_id"     name="inst_id"      value="<%=parInst_id%>">
734
                        <input type="hidden" id="op_code"     name="op_code"      value="<%=parOp_code%>">
735
                        <input type="hidden" id="proj_id"     name="proj_id"      value="<%=parProj_id%>">
736
                        <input type="hidden" id="rtag_id"     name="rtag_id"      value="<%=parRtag_id%>">
737
                        <input type="hidden" id="pv_id"       name="pv_id"        value="<%=parPv_id%>">
738
                        <input type="hidden" id="repeat_secs" name="repeat_secs"  value="<%=parRepeat%>">
739
                        <input type="hidden" id="rfile"       name="rfile"        value="<%=parRfile%>">
149 ghuddy 740
                        <input type="hidden" id="sortOrder"   name="sortOrder"    value="<%=parSortOrder%>">
147 ghuddy 741
                     </td>
742
                  </tr>
743
               </table>
744
            </td>
745
         </tr>
746
         <%=objPMod.ComposeHiddenTags()%>
747
         <input type="hidden" name="action" value="true">
748
 
749
         <%
750
         Call objFormComponent.FormEnd()
751
         '-- FROM END ----------------------------------------------------------------------------------------------------------------
752
         %>
753
      </table>
754
   </body>
755
</html>
756
<%
757
'------------ RUN AFTER PAGE RENDER -----------
758
Set objFormCollector = Nothing
759
'----------------------------------------------
760
Call Destroy_All_Objects
761
%>
762
 
763