Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
147 ghuddy 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'|                                                   |
5
'|                 ADMIN Page                        |
6
'|                 Daemon Instructions               |
7
'|                                                   |
8
'=====================================================
9
%>
10
<%
11
Option explicit
12
' Good idea to set when using redirect
13
Response.Expires = 0   ' always load the page, dont store
14
%>
15
<!--#include file="common/conf.asp"-->
16
<!--#include file="common/globals.asp"-->
17
<!--#include file="common/formating.asp"-->
18
<!--#include file="common/qstr.asp"-->
19
<!--#include file="common/common_subs.asp"-->
20
<!--#include file="sec/Crypt.asp"-->
21
<!--#include file="common/_form_window_common.asp"-->
22
<!--#include file="_action_buttons.asp"-->
23
 
24
<!--#include file="class/classActionButtonControl.asp"-->
25
<!--#include file="common/daemon_instructions.asp"-->
26
 
27
<%
28
'------------ ACCESS CONTROL ------------------
29
%>
30
<!--#include file="_access_control_general.asp"-->
31
<!--#include file="_access_control_login.asp"-->
32
<%
33
'------------ Variable Definition -------------
34
Dim objBtnControl
35
'------------ Constants Declaration -----------
36
'------------ Variable Init -------------------
37
Set objBtnControl = New ActionButtonControl
38
'----------------------------------------------
39
%>
40
<%
41
'--------------------------------------------------------------------------------------------
42
' Cleans up the daemon instructions table to remove old data that might have become stranded
43
' due to crashed daemons or failing build machines.
44
'--------------------------------------------------------------------------------------------
45
Sub CleanupOldData()
46
   On Error Resume Next
47
   objEH.TryORA ( OraSession )
48
   OraDatabase.ExecuteSQL _
49
   "BEGIN PK_BUILDAPI.cleanup_stranded_daemon_insts; END;"
50
   objEH.CatchORA ( OraSession )
51
End Sub
52
 
53
 
54
'--------------------------------------------------------------------------------------------
55
' Get a project name from a release tag
56
'--------------------------------------------------------------------------------------------
57
Function ProjectName(nRtag_Id)
58
   Dim rsTemp
59
   Dim query_string
60
 
61
   ProjectName = ""
62
 
63
   If (NOT IsNull(nRtag_Id)) AND (nRtag_Id <> "") Then
64
 
65
      query_string = "SELECT proj_id FROM release_tags WHERE rtag_id = " & nRtag_Id
66
      Set rsTemp = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )
67
      If (NOT rsTemp.BOF) AND (NOT rsTemp.EOF) Then
68
         query_string = "SELECT proj_name FROM projects WHERE proj_id = " & rsTemp("proj_id")
69
         Set rsTemp = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )
70
         If (NOT rsTemp.BOF) AND (NOT rsTemp.EOF) Then
71
            ProjectName = rsTemp("proj_name")
72
         End If
73
      End If
74
 
75
      rsTemp.Close()
76
      set rsTemp = nothing
77
   End If
78
End Function
79
 
80
'--------------------------------------------------------------------------------------------
81
' Get a release name from a release tag
82
'--------------------------------------------------------------------------------------------
83
Function ReleaseName(nRtag_Id)
84
   Dim rsTemp
85
   Dim query_string
86
 
87
   ReleaseName = ""
88
 
89
   If (NOT IsNull(nRtag_Id)) AND (nRtag_Id <> "") Then
90
 
91
      query_string = "SELECT rtag_name FROM release_tags WHERE rtag_id = " & nRtag_Id
92
      Set rsTemp = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )
93
      If (NOT rsTemp.BOF) AND (NOT rsTemp.EOF) Then
94
         ReleaseName = rsTemp("rtag_name")
95
      End If
96
 
97
      rsTemp.Close()
98
      set rsTemp = nothing
99
   End If
100
End Function
101
 
102
'--------------------------------------------------------------------------------------------
103
' Get a user name/email from a user ID
104
'--------------------------------------------------------------------------------------------
105
Sub GetUserName(nUserId, outUserName, outUserEmail)
106
 
107
   Dim rsTemp
108
   Dim query_string
109
 
110
   outUserName  = ""
111
   outUserEmail = ""
112
 
113
   If (NOT IsNull(nUserId)) AND (nUserId <> "") Then
114
 
115
      query_string = "SELECT usr.FULL_NAME, usr.USER_EMAIL" &_
116
                     "  FROM USERS usr" &_
117
                     " WHERE usr.USER_ID = " & nUserId
118
 
119
      Set rsTemp = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )
120
      If (NOT rsTemp.BOF) AND (NOT rsTemp.EOF) Then
121
         outUserName  = rsTemp("full_name")
122
         outUserEmail = rsTemp("user_email")
123
      End If
124
 
125
      rsTemp.Close()
126
      set rsTemp = nothing
127
   End If
128
 
129
End Sub
130
%>
131
 
132
<%
133
' Clean up old data
134
CleanupOldData
135
 
136
' Page Access Condition
137
%>
138
<script language="JavaScript" type="text/javascript">
139
<!--
140
 
141
// This function is designed to be called when a user resets the in-progress value from YES back to NO
142
function reset_in_progress(instId)
143
{
144
   var proceed = false;
145
   var s;
146
   s  = '_ResetDaemonInstruction.asp';
147
   s += '?inst_id=' + instId;
148
 
149
   proceed = confirm('Are you sure you want to reset this instructions in-progress flag?\n\n' +
150
                     'You should ensure that the daemons are not operating upon this instruction first.\n\n' +
151
                     'Check the scheduled date/time. Does it appear so far in the past that it is unlikely\n' +
152
                     'a daemon is still undertaking the work for the instruction?\n\n' +
153
                     'Press OK to reset, otherwise press CANCEL\n\n' );
154
 
155
   if (proceed == true) {
156
      document.location = s;
157
   }
158
}
159
//-->
160
</script>
161
 
162
<html>
163
   <head>
164
      <title>Daemon Instructions Administration</title>
165
      <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
166
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
167
      <link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
168
      <link rel="stylesheet" href="images/navigation.css" type="text/css">
169
      <script language="JavaScript" src="images/common.js"></script>
170
      <!-- DROPDOWN MENUS -->
171
      <!--#include file="_menu_def.asp"-->
172
      <script language="JavaScript1.2" src="images/popup_menu.js"></script>
173
   </head>
174
   <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
175
      <!-- MENU LAYERS -------------------------------------->
176
      <div id="popmenu" class="menuskin" onMouseover="clearhidemenu();highlightmenu(event,'on')" onMouseout="highlightmenu(event,'off');dynamichide(event)">
177
      </div>
178
      <!-- TIPS LAYERS -------------------------------------->
179
      <div id="formTipsLayer" style="position: absolute; z-index: 1000; visibility: hidden; left:0; top: 0; width: 10">&nbsp;</div>
180
      <!-- HEADER -->
181
      <!--#include file="_header.asp"-->
182
 
183
      <%
184
      '-- FROM START ---------------------------------------------------------------------------------------------------------
185
      objFormComponent.FormName = "DAEMON_INSTRUCTIONS"
186
      objFormComponent.Action = ScriptName
187
      objFormComponent.OnSubmit = "ShowProgress();"
188
      Call objFormComponent.FormStart()
189
      %>
190
      <table width="100%"  border="0" cellspacing="3" cellpadding="0" >
191
 
192
         <div align="left" class=" body_col">
193
            <br>Current List of DAEMON INSTRUCTIONS
194
         </div>
195
         <tr></tr>
196
         <tr>
197
            <td></td>
198
            <!-- DAEMON INSTRUCTION DETAILS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
199
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">OPERATION</td>
200
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">PROJECT</td>
201
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">RELEASE</td>
202
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">MODE</td>
203
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">PACKAGE</td>
204
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">VERSION</td>
205
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">SCHEDULED TIME<br>(<SPAN style=color:Red>Red</SPAN> = overdue)<br>(<SPAN style=color:Green>Green</SPAN> = ready)</td>
206
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">REPEAT</td>
207
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">ADDED BY</td>
208
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">LAST<br>UPDATED</td>
209
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">IN<br>PROGRESS</td>
210
            <td align="left" nowrap background="images/bg_table_col.gif" class="body_col">EDIT/DELETE</td>
211
         </tr>
212
         <tr>
213
            <td colspan="13" background="images/bg_table_border.gif"><img src="images/spacer.gif" width="1" height="1"></td>
214
         </tr>
215
 
216
         <%
217
         ' Load some action buttons
218
         Call objBtnControl.LoadActionButtons ( Array("btnEditDaemonInst", "btnDeleteDaemonInst"), OraDatabase )
219
         objBtnControl.ButtonSpacer = 1
220
 
221
         Dim rsQry
222
         Dim ProjId
223
         Dim PkgId
224
         Dim PkgName
225
         Dim PkgVersion
226
         Dim UserName
227
         Dim UserEmail
228
         Dim bInProgress
229
         Dim bIsReady
230
         Dim bIsOverdue
231
         Dim daemonInstId  ' This variable is needed to support the action buttons to Edit/Delete
232
         Dim bEditEnabled
233
         Dim bResetInProgressEnabled
234
 
235
         ' determine if user can reset the in-progress state of a daemon instruction
236
         bResetInProgressEnabled = UserAllowedToResetInProgress()
237
 
238
         ' query the daemon_instructions table and also create an indication of an overdue instruction,
239
         ' which is defined as being one that was scheduled for action
240
         Set rsQry = OraDatabase.DbCreateDynaset( "SELECT DAEMON_INSTRUCTIONS_ID,"&_
241
                                                  "       OP_CODE,"&_
242
                                                  "       RTAG_ID,"&_
243
                                                  "       PV_ID,"&_
244
                                                  "       SCHEDULED_DATETIME,"&_
245
                                                  "       REPEAT_SECS,"&_
246
                                                  "       ADDED_DATETIME,"&_
247
                                                  "       USER_ID,"&_
248
                                                  "       IN_PROGRESS,"&_
249
                                                  "       (CASE WHEN SCHEDULED_DATETIME <= SYSDATE THEN 1 ELSE 0 END) AS READY,"&_
250
                                                  "       (CASE WHEN (SCHEDULED_DATETIME + (1/144)) < SYSDATE THEN 1 ELSE 0 END) AS OVERDUE"&_
251
                                                  "  FROM DAEMON_INSTRUCTIONS "&_
252
                                                  "  ORDER BY RTAG_ID, PV_ID, SCHEDULED_DATETIME, DAEMON_INSTRUCTIONS_ID", ORADYN_DEFAULT )
253
         While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
254
 
255
            daemonInstId = rsQry("DAEMON_INSTRUCTIONS_ID")
256
 
257
            If IsNull(rsQry("IN_PROGRESS")) OR rsQry("IN_PROGRESS") = "0" Then
258
               bInProgress = False
259
            Else
260
               bInProgress = True
261
            End If
262
 
263
            ' only flag as overdue if time threshold has been met but the daemon has not marked the instruction as being in progress.
264
            If rsQry("OVERDUE") AND NOT bInProgress Then
265
               bIsOverdue = True
266
            Else
267
               bIsOverdue = False
268
            End If
269
 
270
            If rsQry("READY") Then
271
               bIsReady = True
272
            Else
273
               bIsReady = False
274
            End If
275
 
276
            ' Get as much info about the package as we can
277
            ProjId=""
278
            PkgId = 0
279
            PkgName = "N/A"
280
            PkgVersion = "N/A"
281
            If (NOT IsNull(rsQry("PV_ID"))) AND (rsQry("PV_ID") <> "") Then
282
               Call Get_Pkg_Short_Info(rsQry("PV_ID"), PkgId, PkgName, PkgVersion, NULL, NULL, NULL)
283
            End If
284
 
285
            ' derive the proj_id from the rtag_id
286
            If (NOT IsNull(rsQry("RTAG_ID"))) AND (rsQry("RTAG_ID") <> "") Then
287
               ProjId = Get_Proj_ID(rsQry("RTAG_ID"))
288
               ReleaseMode = GetReleaseMode( rsQry("RTAG_ID") )
289
            Else
290
               ReleaseMode = "Y" ' closed mode used to prevent editing
291
            End If
292
 
293
            ' determine if editing is enabled by permissions
294
            bEditEnabled = True
295
            If objAccessControl.UserLogedIn Then
296
               If NOT objAccessControl.IsDataActive ("PROJECTS", ProjId, "EditProjects") OR NOT objAccessControl.IsDataVisible ("PROJECTS", ProjId, "EditProjects")  Then
297
                  bEditEnabled = False
298
               ElseIf NOT objAccessControl.IsDataActive ("PROJECTS", ProjId, enumDB_PERMISSION_TYPE_ACTIVE) Then
299
                  bEditEnabled = False
300
               ElseIf ( ReleaseMode <> enumDB_RELEASE_IN_OPEN_MODE ) Then
301
                  If NOT objAccessControl.IsActive("ApproveForAutoBuild") Then
302
                     bEditEnabled = False
303
                  End If
304
               End If
305
            Else
306
               bEditEnabled = False
307
            End If
308
 
309
            Call GetUserName(rsQry("User_Id"), UserName, UserEmail)
310
 
311
            %>
312
            <tr>
313
               <input type="hidden" name="DAEMON_INSTRUCTIONS_ID_" & daemonInstId value=daemonInstId>
314
 
315
               <td></td>
316
 
317
               <td align="left" valign="top" class="body_txt">
318
                  <%=DaemonInstructionOperationName(rsQry("OP_CODE"))%>
319
               </td>
320
 
321
               <td align="left" valign="top" class="body_txt">
322
                  <%If ProjId <> "" Then%>
323
                     <a href='rtree.asp?proj_id=<%=ProjId%>'><%=ProjectName(rsQry("RTAG_ID"))%>
324
                  <%End If%>
325
               </td>
326
 
327
               <td align="left" valign="top" class="body_txt">
328
                  <%If ProjId <> "" Then%>
329
                     <a href='dependencies.asp?rtag_id=<%=rsQry("RTAG_ID")%>'><%=ReleaseName(rsQry("RTAG_ID"))%>
330
                  <%End If%>
331
               </td>
332
 
333
               <td align="left" valign="top" class="body_txt">
334
                  <%=Get_Official(ReleaseMode)%>
335
               </td>
336
 
337
               <td align="left" valign="top" class="body_txt">
338
                  <%If (NOT IsNull(rsQry("PV_ID"))) AND (rsQry("PV_ID") <> "") Then%>
339
                     <a href='fixed_issues.asp?rtag_id=<%=rsQry("RTAG_ID")%>&pv_id=<%=rsQry("PV_ID")%>'><%=PkgName%>
340
                  <%Else%>
341
                     <%=PkgName%>
342
                  <%End If%>
343
               </td>
344
 
345
               <td align="left" valign="top" class="body_txt">
346
                  <%=PkgVersion%>
347
               </td>
348
 
349
               <td align="left" valign="top" class="body_txt" <%If bIsOverdue Then%>style=color:Red<%Elseif bIsReady Then%>style=color:Green<%End If%>><%=EuroDateTime(rsQry("SCHEDULED_DATETIME"))%></td>
350
 
351
               <td align="left" valign="top" class="body_txt"><%=DaemonInstructionRepeatString(rsQry("OP_CODE"), rsQry("REPEAT_SECS"))%></td>
352
 
353
               <td align="left" valign="top" class="body_txt">
354
                  <%If UserName <> "" AND UserEmail <> "" Then%>
355
                     <a href="mailto:<%=UserEmail%>" title="<%=UserEmail%>" class="txt_linked"><%=UserName%></a>
356
                  <%End If%>
357
               </td>
358
 
359
               <td align="left" valign="top" class="body_txt">
360
                  <%=EuroDateTime(rsQry("ADDED_DATETIME"))%>
361
               </td>
362
 
363
               <td align="left" valign="top" class="body_txt">
364
                  <%If bInProgress Then%>
365
                     <%If bResetInProgressEnabled Then%>
366
                        <img src="images/i_reset.gif" onclick="reset_in_progress(<%=daemonInstId%>);"></img>
367
                     <%End If%>
368
                     YES
369
                  <%Else%>
370
                     NO
371
                  <%End If%>
372
               </td>
373
 
374
               <td align="left" valign="top" class="body_txt">
375
                  <%If bEditEnabled Then%>
376
                     <%Call objBtnControl.Render ( Array("btnEditDaemonInst", "btnDeleteDaemonInst"), objAccessControl )%>
377
                  <%Else%>
378
                     No Edit Permission
379
                  <%End If%>
380
               </td>
381
 
382
            </tr>
383
            <%
384
            rsQry.MoveNext()
385
            %>
386
            <tr>
387
               <td colspan="13" background="images/bg_table_border.gif"><img src="images/spacer.gif" width="1" height="1"></td>
388
            </tr>
389
            <%
390
         Wend
391
         rsQry.Close()
392
         Set rsQry = nothing
393
         %>
394
      </table>
395
 
396
      <table width="50%"  border="0" cellspacing="3" cellpadding="0" >
397
         <tr>
398
            <td class="form_iname">&nbsp;</td>
399
            <td class="val_err"><a href=""><%Call Action_Buttons ( "Add Daemon Instruction" )%> </a>
400
            <td>&nbsp;</td>
401
         </tr>
402
      </table>
403
 
404
      <table width="100%"  border="0" cellspacing="3" cellpadding="0" >
405
         <tr>
406
            <td>NOTE:</td>
407
         </tr>
408
         <tr>
409
            <td valign="top" class="help_txt">1)</td>
410
            <td valign="top" class="help_txt">Instructions become overdue when they are more than 10 minutes old and are not in-progress</td>
411
         </tr>
412
         <tr>
413
            <td valign="top" class="help_txt">2)</td>
414
            <td valign="top" class="help_txt">Instructions that take a long time to act upon, may cause other instructions for the same release to become overdue. This is not a real problem.</td>
415
         </tr>
416
         <tr>
417
            <td valign="top" class="help_txt">3)</td>
418
            <td valign="top" class="help_txt">Instructions may become stranded in the "in-progress" state if build daemons crash, or a problem occurs on a build machine.
419
            Automatic deletion of the instruction will eventually occur (see next note). Contact a release manager administrator to correct this problem before automatic deletion.</td>
420
         </tr>
421
         <tr>
422
            <td valign="top" class="help_txt">4)</td>
423
            <td valign="top" class="help_txt">Instructions with scheduled times 5 days or older will be deleted automatically.</td>
424
         </tr>
425
 
426
      </table>
427
 
428
      <%=objPMod.ComposeHiddenTags()%>
429
      <input type="hidden" name="action" value="true">
430
      <%
431
      Call objFormComponent.FormEnd()
432
      '-- FROM END ----------------------------------------------------------------------------------------------------------------
433
      %>
434
   </body>
435
</html>
436
<!-- FOOTER -->
437
<!--#include file="_footer.asp"-->
438
<%
439
Call Destroy_All_Objects
440
%>