<%@LANGUAGE="VBSCRIPT"%> <% '===================================================== '| | '| wAddDaemonInstruction | '| | '===================================================== %> <% Option explicit Response.Expires = 0 %> <% '------------ ACCESS CONTROL ------------------ %> <% '------------ VARIABLE DEFINITION ------------- Dim sMessage Dim parProj_id Dim parPv_id Dim parOp_code Dim parRepeat Dim parInst_id Dim parSchDateTime Dim parRfile Dim bHideRepeat Dim bHidePackages Dim bPreventSubmit Dim parSortOrder '------------ CONSTANTS DECLARATION ----------- '------------ VARIABLE INIT ------------------- sMessage = NULL bPreventSubmit = False ' collect all parameters from query string parOp_code = Request("op_code") parProj_id = Request("proj_id") parPv_id = Request("pv_id") parRepeat = Request("repeat") parInst_id = Request("inst_id") parSchDateTime = Request("sdt") parRfile = Request("rfile") parSortOrder = Request("sort") If IsNull(parSortOrder) OR parSortOrder = "" Then parSortOrder = "0" End If Set objFormCollector = CreateObject("Scripting.Dictionary") '------------ CONDITIONS ---------------------- '---------------------------------------------- %> <% '------------------------------------------------------------------------------------------------------------------------------------------ ' For the specified project ID, get a list of all that project's releases that are not closed/archived. ' Return True if at least one release was found, else False '------------------------------------------------------------------------------------------------------------------------------------------ Function ReleasesAvailable(NNproj_id) Dim rsTemp, Query_String ReleasesAvailable = True Query_String = "SELECT rtag_id, rtag_name "&_ " FROM release_tags rt"&_ " WHERE rt.proj_id = "& NNproj_id &_ " AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If rsTemp.RecordCount = 0 Then ReleasesAvailable = False End If rsTemp.Close Set rsTemp = nothing End Function '------------------------------------------------------------------------------------------------------------------------------------------ ' For the specified Release, get a list of all that release's daemon configurations. ' Return True if at least one daemon configuration was found, else False '------------------------------------------------------------------------------------------------------------------------------------------ Function DaemonsAvailable(NNrtag_id) Dim rsTemp, Query_String DaemonsAvailable = True Query_String = "SELECT * "&_ " FROM release_config rc"&_ " WHERE rc.rtag_id = "& NNrtag_id Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If rsTemp.RecordCount = 0 Then DaemonsAvailable = False End If rsTemp.Close Set rsTemp = nothing End Function '------------------------------------------------------------------------------------------------------------------------------------------ ' Formulate the HTML for a combo box listing all the daemon instruction operations, and select the one that matches ' the op-code passed in as a parameter. If the parameter value could not be found, correct it to the first valid op-code ' in the list. '------------------------------------------------------------------------------------------------------------------------------------------ Function Get_OpCodes ( NNop_code ) Dim op_code_str_array Dim op_code_str Dim op_code_val Dim selectedFound Dim tempLINK Dim s selectedFound = False ' Get the op-codes in terms of human readable string names - these will be used in the drop down select list Call GetDaemonInstructionOperationNameArray(op_code_str_array) s = "Operation" s = s + "" Get_OpCodes = s End Function '------------------------------------------------------------------------------------------------------------------------------------------ ' Formulate the HTML for a combo box listing all the Projects, and select the one that matches ' the proj-id passed in as a parameter. If the parameter value could not be found, correct it to the first valid proj-id ' in the list. '------------------------------------------------------------------------------------------------------------------------------------------ Function Get_Projects ( NNproj_id ) Dim rsTemp, Query_String, projName, tempLINK, selectedFound, s selectedFound = False Query_String = "SELECT * FROM projects ORDER BY UPPER( proj_name )" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) s = "Project" s = s + "" ' Correct for a situation where selectedFound is still FALSE. If NOT selectedFound Then rsTemp.MoveFirst If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then NNproj_id = CStr(rsTemp.Fields("proj_id")) Else NNproj_id = "0" End If End If rsTemp.Close Set rsTemp = nothing s = s + "" Get_Projects = s End Function '------------------------------------------------------------------------------------------------------------------------------------------ ' Formulate the HTML for a combo box listing all the Release for a specified project, and select the one that matches ' the release-tag passed in as a parameter. If the parameter value could not be found, correct it to the first valid release-tag ' in the list. '------------------------------------------------------------------------------------------------------------------------------------------ Function Get_Releases ( NNproj_id, NNrtag_id ) Dim rsTemp, Query_String, releaseName, tempLINK, selectedFound, s, numReleases selectedFound = False numReleases = 0 Query_String = "SELECT rtag_id, rtag_name "&_ " FROM release_tags rt"&_ " WHERE rt.proj_id = "& NNproj_id &_ " AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_ " ORDER BY UPPER(rtag_name)" Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) s = "Release" s = s + "" ' Correct for a situation where selectedFound is still FALSE. If NOT selectedFound Then rsTemp.MoveFirst If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then NNrtag_id = CStr(rsTemp.Fields("rtag_id")) Else NNrtag_id = "0" End If End If ' If no releases were found then replace drop down list with some warning text and disable form submission If numReleases = 0 Then bPreventSubmit = True s = "ReleaseWARNING: No active releases found. The operation cannot be performed." Else ' If the selected release does not have a daemon configuration, append some warning text to the right of the drop down list. If DaemonsAvailable(NNrtag_id) = False Then s = s + "WARNING: Release has no build daemon(s)" End If End If rsTemp.Close Set rsTemp = nothing s = s + "" Get_Releases = s End Function '------------------------------------------------------------------------------------------------------------------------------------------ ' Formulate the HTML for a combo box listing all the Package Versions in a specified release, and select the one that matches ' the pv_id passed in as a parameter. If the parameter value could not be found, correct it to the first valid pv_id ' in the list. ' This function must deal with op-codes that want to read package versions from the work_in_progress table, and op-codes ' that need to read package versions from the release_content table. ' The function should only be called if a package versions drop down list is required for the form. '------------------------------------------------------------------------------------------------------------------------------------------ Function Get_Packages ( NNrtag_id, NNpv_id, NNop_code ) Dim rsTemp, Query_String, pkgName, tempLINK, selectedFound, s, numPackages selectedFound = False numPackages = 0 If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then ' Get list of packages from from work_in_progress table Query_String = "SELECT pk.pkg_id, pk.pkg_name, pv.pkg_version, wip.pv_id "&_ " FROM work_in_progress wip, release_tags rt, packages pk, package_versions pv "&_ " WHERE wip.rtag_id = "& Cstr(NNrtag_id) &_ " AND wip.rtag_id = rt.rtag_id"&_ " AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_ " AND wip.pv_id = pv.pv_id"&_ " AND pk.pkg_id = pv.pkg_id"&_ " ORDER BY UPPER(pkg_name)" Else ' Get list of packages from from release_content table Query_String = "SELECT pk.pkg_id, pk.pkg_name, pv.pkg_version, rc.pv_id "&_ " FROM release_content rc, release_tags rt, packages pk, package_versions pv "&_ " WHERE rc.rtag_id = "& Cstr(NNrtag_id) &_ " AND rc.rtag_id = rt.rtag_id"&_ " AND ((rt.official = 'N') OR (rt.official = 'C') OR (rt.official = 'R'))"&_ " AND rc.pv_id = pv.pv_id"&_ " AND pk.pkg_id = pv.pkg_id"&_ " ORDER BY UPPER(pkg_name)" End If Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) ' modify the control heading to indicate the source of the package version list If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then s = "WIP Package" Else s = "Released Package" End If s = s + "" ' Correct for a situation where selectedFound is still FALSE. If NOT selectedFound Then rsTemp.MoveFirst If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then NNpv_id = Cstr(rsTemp.Fields("pv_id")) Else NNpv_id = "0" End If End If ' replace drop down list with a warning if no package versions were found, and ensure that the user cannot submit the form If numPackages = 0 Then bPreventSubmit = True If (NNop_code = OP_CODE_1_TEST_BUILD_PACKAGE) Then s = "PackageWARNING: No WIP package versions found. The operation cannot be performed." Else s = "PackageWARNING: No released package versions found. The operation cannot be performed." End If End If rsTemp.Close Set rsTemp = nothing Get_Packages = s End Function '------------------------------------------------------------------------------------------------------------------------------------------ ' This function will be called if and only if the form is first opened in circumstances where the user is editing an existing record ' 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 ' and the relevant parameters assigned from the record fields '------------------------------------------------------------------------------------------------------------------------------------------ Sub Get_All_Params_From_Inst_Id(NNInstId) Dim rsTemp, Query_String Query_String = "SELECT op_code, rtag_id, pv_id, repeat_secs, "&_ " TO_CHAR(scheduled_datetime, 'DD-MM-YYYY HH24:MI:SS') AS schedDate "&_ " FROM DAEMON_INSTRUCTIONS "&_ " WHERE DAEMON_INSTRUCTIONS_ID = " & NNInstId Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0)) If rstemp.RecordCount = 0 Then Call RaiseMsg(enum_MSG_ERROR, "Attempt to Edit a non-existent record") End If ' assign record fields to global parameters parOp_code = rsTemp("op_code") parRtag_id = rsTemp("rtag_id") parPv_id = rsTemp("pv_id") parRepeat = rsTemp("repeat_secs") parSchDateTime = rsTemp("schedDate") ' derive project id since that is not stored in the table If NOT IsNull(parRtag_id) AND parRtag_id <> "" Then parProj_id = Get_Proj_ID(parRtag_id) Else parProj_id = "0" End If rsTemp.Close Set rsTemp = nothing End Sub '------------------------------------------------------------------------------------------------------------------------------------------ %> <% '------------ RUN BEFORE PAGE RENDER ---------- ' Are we in edit mode? If so, populate all parameters from the record being edited If (NOT IsNull(parInst_id)) AND (parInst_id <> "") AND (Request("edit") = "true") Then If NOT DaemonInstructionInProgress(Request("inst_id")) Then Call Get_All_Params_From_Inst_Id(parInst_id) Else CloseWindow ' close the form we were opening ' redirect to an error message in the parent form Call RaiseMsgInParent(enum_MSG_ERROR, "Cannot edit an instruction that is currently being processed by a Daemon") End If End If ' Make sure we dont have any null strings or empty strings for our parameters If IsNull(parOp_code) OR parOp_code = "" Then parOp_code = "0" End If If IsNull(parProj_id) OR parProj_id = "" Then parProj_id = "0" End If If IsNull(parRtag_id) OR parRtag_id = "" Then parRtag_id = "0" End If If IsNull(parPv_id) OR parPv_id = "" Then parPv_id = "0" End If If IsNull(parRepeat) OR parRepeat = "" Then parRepeat = "0" End If If IsNull(parRfile) OR parRfile = "" Then parRfile = "admin_daemon_instructions.asp" End If If IsNull(parSchDateTime) OR parSchDateTime = "" Then parSchDateTime = EuroDateTimeForCalendarControl(Now()) End If ' If this form is opened with an OP_CODE, RTAG_ID and PV_ID only, then we need to derive the PROJ_ID before ' calling Get_Projects() to generate the project drop down list. If parProj_id = "0" AND NOT IsNull(parRtag_id) AND parRtag_id <> "" AND parRtag_id <> "0" Then parProj_id = Get_Proj_ID(parRtag_id) End If ' Hide the Package drop-down list if the Daemon Instruction does not require it If DaemonInstructionNeedsPV_ID(parOp_code) Then bHidePackages = False Else bHidePackages = True parPv_id = "0" End If ' NOTE: from this moment on, any real use of parPv_id has to be guarded by examination of bHidePackages ' Hide the Repeat buttons if the Daemon Instruction does not require them If DaemonInstructionNeedsRepeat(parOp_code) Then bHideRepeat = False Else bHideRepeat = True End If ' Call some 'Get' procedures without HTML generation to determine the values of parProj_id, par_Rtag_id, and parPv_id ' in case they are not currently present in the query string. This will then allow the use of the ReleasesAvailable() and ' DaemonsAvailable() functions further below to hide the form submit button. ' It will also support the submit action itself when it takes place during the editing of an existing record where ' the user changes (for example) the project without making any changes to release or package and so those items ' are nullified and must be reset to something other than their original values that came through the query string ' when the edit form was just opened. Call Get_Projects(parProj_id) ' Ensures parProj_id has a good value Call Get_Releases(parProj_id, parRtag_id) ' Ensures parRtag_id has a good value If NOT bHidePackages Then Call Get_Packages (parRtag_id, parPv_id, parOp_code) End If ' Check if form submit is happening If CBool(Request("action")) Then Dim RepeatSeconds Dim ScheduledDateTime Dim ReleaseMode ReleaseMode = GetReleaseMode(parRtag_id) ' determine if insert/update is enabled by permissions if NOT UserCanAddOrEditThisDaemonInst(parProj_id, ReleaseMode, parOp_code) Then ' redirect to an error message Call RaiseMsg(enum_MSG_ERROR, "You have been denied permission to add/update daemon instructions for the specified release.") End If ' do daemon instruction validation, continuing only if it passes If ValidateDaemonInstruction(parOp_code, parRtag_id, parPv_id) = True Then ' Setup the repeat seconds count according to the radio button value If IsNull(Request("repeat_inst")) OR Request("repeat_inst") = "" OR Request("repeat_inst") = "No" Then RepeatSeconds = 0 Else RepeatSeconds = 86400 End If ' If user has not entered a scheduled time, set the scheduled date/time to now ScheduledDateTime = Request("scheduled_time") If IsNull(ScheduledDateTime) OR ScheduledDateTime = "" Then ScheduledDateTime = ORA_SYSDATETIME Else ScheduledDateTime = "TO_DATE( '"& ScheduledDateTime &"','DD-MM-YYYY HH24:MI:SS' )" End If ' nullify parPv_id for the SQL, if the instruction op-code does not require one If bHidePackages Then parPv_id = "NULL" End If ' if the page has been provided an inst_id, we must be editing an existing record so we do an update If (NOT IsNull(parInst_id)) AND (parInst_id <> "") Then ' We are updating an existing record objEH.TryORA ( OraSession ) On Error Resume Next OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.update_daemon_inst( "& parInst_id & ", " &_ parOp_code & ", " &_ parRtag_id & ", " &_ parPv_id & ", " &_ ScheduledDateTime & ", " &_ CStr(RepeatSeconds) & ", " &_ ORA_SYSDATETIME & ", " &_ objAccessControl.UserId & "); END;" objEH.CatchORA ( OraSession ) If objEH.Finally Then If parRfile = "admin_daemon_instructions.asp" Then Call OpenInParentWindow (parRfile & "?sort=" & parSortOrder) Else Call OpenInParentWindow (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id) End If Call CloseWindow() End If Else ' We are adding a new record objEH.TryORA ( OraSession ) On Error Resume Next OraDatabase.ExecuteSQL "BEGIN PK_BUILDAPI.insert_daemon_inst( "& parOp_code & ", " &_ parRtag_id & ", " &_ parPv_id & ", " &_ ScheduledDateTime & ", " &_ CStr(RepeatSeconds) & ", " &_ ORA_SYSDATETIME & ", " &_ objAccessControl.UserId & "); END;" objEH.CatchORA ( OraSession ) If objEH.Finally Then If parRfile = "admin_daemon_instructions.asp" Then Call OpenInParentWindow (parRfile & "?sort=" & parSortOrder) Else Call OpenInParentWindow (parRfile & "?rtag_id=" & parRtag_id & "&pv_id=" & parPv_id) End If Call CloseWindow() End If End If End If End If '---------------------------------------------- %> Release Manager <% '-- FROM START -------------------------------------------------------------------------------------------------------------- objFormComponent.FormName = "DaemonInstruction" objFormComponent.Action = ScriptName &_ "?inst_id="& parInst_id &_ "&op_code="& parOp_code &_ "&proj_id="& parProj_id &_ "&rtag_id="& parRtag_id &_ "&pv_id="& parPv_id &_ "&sort="& parSortOrder &_ "&rfile="& parRfile objFormComponent.OnSubmit = "ShowProgress();" Call objFormComponent.FormStart() %> <%=objPMod.ComposeHiddenTags()%> <% Call objFormComponent.FormEnd() '-- FROM END ---------------------------------------------------------------------------------------------------------------- %>
 Add/Update Daemon Instruction
Add a new Daemon Instruction or edit an existing Daemon Instruction.
<%=ProgressBar()%> <%If ReleasesAvailable(parProj_id) AND DaemonsAvailable(parRtag_id) AND NOT bPreventSubmit Then%> <%Else%> <%End If%>
<%Call Messenger ( sMessage , 3, "100%" )%> <%If NOT bHidePackages Then%> <%End If%> <%If NOT bHideRepeat Then%> <%End If%>
<%=Get_OpCodes(parOp_code)%>
 
<%=Get_Projects(parProj_id)%>
<%=Get_Releases(parProj_id, parRtag_id)%>
<%=Get_Packages ( parRtag_id, parPv_id, parOp_code )%>
 
Scheduled Time Click Here to select the (future) time at which to carry out the instruction
Repeat checked<%End If%> onchange='Refresh_Repeat(0)' >No checked<%End If%> onchange='Refresh_Repeat(86400)' >24 Hrs
<% '------------ RUN AFTER PAGE RENDER ----------- Set objFormCollector = Nothing '---------------------------------------------- Call Destroy_All_Objects %>