Rev 6184 | Rev 7029 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%'=====================================================' Common Subs for DAEMON INSTRUCTIONS'=====================================================%><%'--------------------------------------------------------------------------------------------' Indicates if the specified daemon instruction is in progress'--------------------------------------------------------------------------------------------Function DaemonInstructionInProgress( nInstId )Dim rsQryDaemonInstructionInProgress = FalseIf NOT IsNull(nInstId) AND nInstId <> "" ThenSet rsQry = OraDatabase.DbCreateDynaset( "SELECT IN_PROGRESS"&_" FROM DAEMON_INSTRUCTIONS "&_" WHERE DAEMON_INSTRUCTIONS_ID = "& nInstId, ORADYN_DEFAULT )If (NOT rsQry.BOF) AND (NOT rsQry.EOF) ThenIf (NOT IsNull(rsQry("IN_PROGRESS"))) AND (rsQry("IN_PROGRESS") = "1") ThenDaemonInstructionInProgress = TrueEnd IfEnd IfrsQry.CloseSet rsQry = nothingEnd IfEnd Function'--------------------------------------------------------------------------------------------' Assign the inout parameter to an array containing the list of all human readable op-code' strings, in ascending op-code value order. This list will be used to form a drop-down list' control on an html form'--------------------------------------------------------------------------------------------Sub GetDaemonInstructionOperationNameArray(nArray)' append new op-codes to this list when they are inventednArray = array(OP_CODE_0_STR, _OP_CODE_1_STR, _OP_CODE_2_STR)End Sub'--------------------------------------------------------------------------------------------' Convert a Daemon Instruction operation code into a meaningful string' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer' for doing so.'--------------------------------------------------------------------------------------------Function DaemonInstructionOperationName(nOpCode)Select Case nOpCodeCase OP_CODE_0_RIPPLE_BUILD_PACKAGEDaemonInstructionOperationName = OP_CODE_0_STRCase OP_CODE_1_TEST_BUILD_PACKAGEDaemonInstructionOperationName = OP_CODE_1_STRCase OP_CODE_2_FUTURE_BUILDDaemonInstructionOperationName = OP_CODE_2_STRCase ElseDaemonInstructionOperationName = "Undefined (" & nOpCode & ")"End SelectEnd Function'--------------------------------------------------------------------------------------------' Convert a Daemon Instruction operation name into an op-code value' NOTE: could replace this with a global scripting dicitonary, but the code would be no clearer' for doing so.'--------------------------------------------------------------------------------------------Function DaemonInstructionOperationValue(nOpName)Select Case nOpNameCase OP_CODE_0_STRDaemonInstructionOperationValue = OP_CODE_0_RIPPLE_BUILD_PACKAGECase OP_CODE_1_STRDaemonInstructionOperationValue = OP_CODE_1_TEST_BUILD_PACKAGECase OP_CODE_2_STRDaemonInstructionOperationValue = OP_CODE_2_FUTURE_BUILDCase ElseDaemonInstructionOperationValue = ""End SelectEnd Function'--------------------------------------------------------------------------------------------' Determines if a daemon instruction op-code value indicates that a PV_ID is required to be' specified for the instruction.'--------------------------------------------------------------------------------------------Function DaemonInstructionNeedsPV_ID(nOpCode)Select Case nOpCodeCase OP_CODE_0_RIPPLE_BUILD_PACKAGEDaemonInstructionNeedsPV_ID = TrueCase OP_CODE_1_TEST_BUILD_PACKAGEDaemonInstructionNeedsPV_ID = TrueCase OP_CODE_2_FUTURE_BUILDDaemonInstructionNeedsPV_ID = TrueCase ElseDaemonInstructionNeedsPV_ID = FalseEnd SelectEnd Function'--------------------------------------------------------------------------------------------' Determines if a daemon instruction op-code value indicates that a repeat value is required' to be specified for the instruction.'--------------------------------------------------------------------------------------------Function DaemonInstructionNeedsRepeat(nOpCode)' currently - no op-codes need a repeat valueDaemonInstructionNeedsRepeat = FalseEnd Function'--------------------------------------------------------------------------------------------' Convert a Repeat Seconds value into a meaningful string. This takes account of the' daemon instruction op-code too - a repeat seconds value is only relevant for certain' op-codes'--------------------------------------------------------------------------------------------Function DaemonInstructionRepeatString(nOpCode, nRepeatSecs)DaemonInstructionRepeatString = "N/A"' uncomment this when we are ready to introduce the "get release metrics" instruction'Select Case nOpCode'Case OP_CODE_?_GET_RELEASE_METRICS' Select Case nRepeatSecs' Case 86400' DaemonInstructionRepeatString = "24Hrs"' Case Else' DaemonInstructionRepeatString = "NO"' End Select''Case Else' DaemonInstructionRepeatString = "N/A"'End SelectEnd Function'--------------------------------------------------------------------------------------'--------------------------------------------------------------------------------------------' Function to inform caller of whether the user is allowed to reset the daemon instructions' in-progress flag'--------------------------------------------------------------------------------------------Function UserAllowedToResetInProgressUserAllowedToResetInProgress = TrueIf objAccessControl.UserLogedIn ThenIf NOT canActionControlInProject("ResetDaemonInstInProgress") ThenUserAllowedToResetInProgress = FalseEnd IfElseUserAllowedToResetInProgress = FalseEnd IfEnd Function'--------------------------------------------------------------------------------------------' Daemon Instruction validation function'--------------------------------------------------------------------------------------------Function HandleValidateDaemonInstructionError(nOpCode, retERRmsg, ByRef sErrorMsg)Dim ss = ""'retERRmsg = "enum_MSG_BROKEN_DEPENDENCIES_FOUND"HandleValidateDaemonInstructionError = TrueIf NOT IsNull(retERRmsg) Then' Exclusions -' 1) Ignore "unit tests not supplied" error for ripple build package daemon instructionIf NOT ((nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) AND (retERRmsg = "enum_MSG_UNIT_TESTS_NOT_SUPPLIED")) Then' Re-interpret the error message that has been returned from the queries. We do this because normally,' these errors are associated with individual message files but the messsages in those files are slightly' inappropriate for the context of adding a daemon instruction so we will provide our own message display' using the generic enum_WMSG_ERROR file with a bespoke error string.Select Case retERRmsgCase "enum_MSG_MISSING_DEPENDENCIES"s = "Some dependencies of this package are missing from a release."Case "enum_MSG_PACKAGE_INFORMATION_INCOMPLETE"s = "Package information section on Release Notes tab is not fully complete."Case "enum_MSG_AUTOBUILD_PACKAGE_REQUIRES_BUILD_STD_AND_ENV"s = "Package must have a build standard and build environment."Case "enum_MSG_REASON_FOR_THIS_VERSION_NOT_SUPLIED"s = "A reason for this version must be supplied."Case "enum_MSG_UNIT_TESTS_NOT_SUPPLIED"s = "There are no unit tests supplied for this package."Case "enum_MSG_PACKAGE_CHANGETYPE_INCOMPLETE"s = "Package change type in Release Notes Tab is not defined."Case "enum_MSG_BROKEN_DEPENDENCIES_FOUND"s = "Some of the packages dependencies are broken. Fix them first before trying to add a daemon instruction to this package."Case "enum_MSG_UNOFFICIAL_DEPENDENCIES_FOUND"s = "Some dependencies of this package are still not released. Release them first before trying to add a daemon instruction to this package."Case Elses = "Correct any errors in the release notes, and try again."End SelectsErrorMsg = "Cannot add this daemon instruction<br>" & sHandleValidateDaemonInstructionError = FalseEnd IfEnd IfEnd FunctionFunction ValidateDaemonInstruction(nOpCode, nRtag_id, nPv_id, ByRef sErrorMsg)Dim retERRmsgDim retALRTmsgDim retParametersDim pkgTypeDim ss = ""pkgType = 0ValidateDaemonInstruction = TrueSelect Case nOpCodeCase OP_CODE_0_RIPPLE_BUILD_PACKAGE' Note: cannot use CheckRequirementsForMakeApproved here because it fails on the change_type check. This seems' to be because a daemon ripple build results in a new package version that has null in the change_type column' so we cannot validate that column in the package_versions table.' check missing dependencies, bad package info, missing build std/env, reason for version, unit testCall CheckRequirementsForMakePending ( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )If IsNull(retERRmsg) Then' Check broken dependencies, missing dependencies, unofficial dependencies, bad package info, reason for version, unit testCall CheckRequirementsForMakeRelease( nPv_id, nRtag_id, pkgType, retERRmsg, retALRTmsg, retParameters )End If' Process retERRmsg into an error messageValidateDaemonInstruction = HandleValidateDaemonInstructionError(nOpCode,retERRmsg,sErrorMsg)Case OP_CODE_1_TEST_BUILD_PACKAGEValidateDaemonInstruction = True ' no validation checks for this instructionCase ElsesErrorMsg = "Attempt to add an unknown daemon instruction type"ValidateDaemonInstruction = FalseEnd SelectEnd Function'------------------------------------------------------------------------------------------------------------------------------------------Function DaemonInstructionPreventsEditing(nRtag_id, nPv_id)Dim rsQryDim QryStrDaemonInstructionPreventsEditing = FALSEIf (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") ThenQryStr = "SELECT COUNT(*) AS record_count"&_" FROM DAEMON_INSTRUCTIONS "&_" WHERE (OP_CODE = "& OP_CODE_1_TEST_BUILD_PACKAGE &")"&_" AND RTAG_ID = "& nRtag_id&_" AND PV_ID = "& nPv_idSet rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )If rsQry("record_count") <> 0 ThenDaemonInstructionPreventsEditing = TRUEEnd IfrsQry.CloseSet rsQry = nothingEnd IfEnd Function'------------------------------------------------------------------------------------------------------------------------------------------Function DaemonInstructionPresent(nRtag_id, nPv_id, nOpCode)Dim rsQryDim QryStrDaemonInstructionPresent = FALSEIf (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") AND (NOT IsNull(nPv_id)) AND (nPv_id <> "") AND (NOT IsNull(nOpCode)) AND (nOpCode <> "") ThenQryStr = "SELECT COUNT(*) AS record_count"&_" FROM DAEMON_INSTRUCTIONS "&_" WHERE (OP_CODE = "& nOpCode &")"&_" AND RTAG_ID = "& nRtag_id&_" AND PV_ID = "& nPv_idSet rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )If rsQry("record_count") <> 0 ThenDaemonInstructionPresent = TRUEEnd IfrsQry.CloseSet rsQry = nothingEnd IfEnd Function'------------------------------------------------------------------------------------------------------------------------------------------Function DaemonInstructionPreventsReleaseDeletion(nRtag_id)Dim rsQryDim QryStrDaemonInstructionPreventsReleaseDeletion = FALSEIf (NOT IsNull(nRtag_id)) AND (nRtag_id <> "") ThenQryStr = "SELECT COUNT(*) AS record_count"&_" FROM DAEMON_INSTRUCTIONS "&_" WHERE RTAG_ID = "& nRtag_idSet rsQry = OraDatabase.DbCreateDynaset( QryStr, ORADYN_DEFAULT )If rsQry("record_count") <> 0 ThenDaemonInstructionPreventsReleaseDeletion = TRUEEnd IfrsQry.CloseSet rsQry = nothingEnd IfEnd Function'------------------------------------------------------------------------------------------------------------------------------------------Function UserCanAddOrEditThisDaemonInst(nProjId, nReleaseMode, nOpCode)UserCanAddOrEditThisDaemonInst = TRUEIf objAccessControl.UserLogedIn ThenIf NOT canActionInProject() ThenUserCanAddOrEditThisDaemonInst = FalseElseIf (( ReleaseMode <> enumDB_RELEASE_IN_OPEN_MODE ) AND (nOpCode = OP_CODE_0_RIPPLE_BUILD_PACKAGE) ) ThenIf NOT canActionControlInProject("ApproveForAutoBuild") ThenUserCanAddOrEditThisDaemonInst = FalseEnd IfEnd IfElseUserCanAddOrEditThisDaemonInst = FalseEnd IfEnd Function'------------------------------------------------------------------------------------------------------------------------------------------%>