Subversion Repositories DevTools

Rev

Rev 7244 | Rev 7246 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'   wAddBuildMachine.asp
'=====================================================
%>
<%
Option explicit
Response.Expires = 0
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/formating.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->
<!--#include file="common/_form_window_common.asp"-->
<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_login.asp"-->
<!--#include file="_access_control_general.asp"-->
<%
'------------ VARIABLE DEFINITION -------------
Dim sMessage

Dim display_name
Dim machine_hostname
Dim gbe_id
Dim active, activeChecked
Dim description
Dim platformList
Dim bIsaClone : bIsaClone = FALSE

'------------ CONSTANTS DECLARATION -----------
'------------ VARIABLE INIT -------------------
sMessage = NULL
Set objFormCollector = CreateObject("Scripting.Dictionary")
If Request("type") = "clone" Then
    bIsaClone = TRUE
End If
'------------ CONDITIONS ----------------------
'----------------------------------------------
%>
<%
'--------------------------------------------------------------------------------------------------------------------------
'   Get the data for the display
'   On first request, it will get the data from the database
'   Otherwise the data will be fetched from form elements
Sub GetData
    If CBool(Request("action")) Then

                '   Recover the data from the form
                '   It may contain user changes
        display_name            =   Request("display_name")
        machine_hostname        =   Request("machine_hostname")
        gbe_id                  =   Request("gbe_id")
        active                  =   Request("active")
        description             =   Request("description")
        platformList            =   "," & Request("platform") & ","
        platformList = Replace(platformList," ","",1,-1)

        if active = "Y" Then activeChecked = "checked"

    ElseIf Request("bmcon_id") <> "" Then

                '   Extract data from the database
        Dim rsQry, query

        query = "select * from build_machine_config bm, gbe_machtype gbe "&_
          " where bm.bmcon_id = "& Request("bmcon_id") &_
          " and gbe.gbe_id = bm.gbe_id"
          
        Set rsQry = OraDatabase.DbCreateDynaset( query, cint(0))

        display_name            =   rsQry("display_name")
        machine_hostname        =   rsQry("machine_hostname")
        gbe_id                  =   rsQry("gbe_id")
        active                  =   rsQry("active")
        description             =   rsQry("description")

        activeChecked = ""
        if active = "Y" Then activeChecked = "checked"

         If bIsaClone Then
            description = "Clone of " & machine_hostname & ".<br>" & description 
                display_name = ""
                machine_hostname = ""
         End If

        rsQry.Close()
        Set rsQry = Nothing

                '   Create a list of associated Platforms
                '
        platformList = ""
        query = "select * from build_platforms_config2 bpc2 where bpc2.bmcon_id = "& Request("bmcon_id")
        Set rsQry = OraDatabase.DbCreateDynaset( query, ORADYN_DEFAULT )
        While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
            platformList = platformList & "," & rsQry("BP_ID") 
           rsQry.MoveNext
        Wend
        rsQry.Close()
        Set rsQry = Nothing
        platformList = platformList & ","
    
    Else
        ' New Machine - set defaults
        activeChecked = "checked"
        End If
End Sub

'--------------------------------------------------------------------------------------------------------------------------
'   Get MachTypes - to populate a dropdron list
Function GetMachType ( ngbe_id )
   Dim rsQry, query

   OraDatabase.Parameters.Add "gbe_id",   ngbe_id,   ORAPARM_INPUT, ORATYPE_NUMBER

   query = GetQuery ("GBE_MACHTYPECombo.sql")

   Set rsQry = OraDatabase.DbCreateDynaset( query, ORADYN_DEFAULT )
   If (NOT rsQry.BOF) AND (NOT rsQry.EOF) Then
      GetMachType = rsQry.GetRows()
   Else
      GetMachType = NULL
   End If

   rsQry.Close()
   Set rsQry = Nothing

   OraDatabase.Parameters.Remove "gbe_id"
End Function
'--------------------------------------------------------------------------------------------------------------------------
'   Get configured platforms
'
Function GetPlatforms ()
    Dim rsQry, query

    query = "SELECT bp.BP_ID, bp.BP_ACTIVE, bp.BP_NAME, bp.BP_DESCRIPTION FROM BUILD_PLATFORMS bp, BUILD_PLATFORMS_CONFIG bpc WHERE bp.bp_id = bpc.bp_id AND bpc.gbe_id = 90 ORDER BY UPPER(bp.BP_NAME)"

    Set rsQry = OraDatabase.DbCreateDynaset( query, ORADYN_DEFAULT )
    While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
       Dim checkText
       If InStr(platformList, "," & rsQry("BP_ID") & ",") > 0 Then
        checkText = "checked"
       else 
        checkText = ""
       End If
       GetPlatforms = GetPlatforms & "<tr class=body_txt>"
       GetPlatforms = GetPlatforms & "<td> <input style='margin:0px 3px' type=checkbox name=platform value='"& rsQry("BP_ID") &"' "& checkText &">" & rsQry("BP_NAME") & "</td>"
       GetPlatforms = GetPlatforms & "</tr>"

       rsQry.MoveNext
    Wend
    rsQry.Close()
    Set rsQry = Nothing

   GetPlatforms = "<table>" & GetPlatforms & "</table>"

End Function

'--------------------------------------------------------------------------------------------------------------------------
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------

If CBool(Request("action")) Then

   If Request("bmcon_id") <> "" Then

      OraDatabase.Parameters.Add "BMCON_ID",              Request("bmcon_id"),              ORAPARM_INPUT, ORATYPE_NUMBER
      OraDatabase.Parameters.Add "DISPLAY_NAME",          Request("display_name"),          ORAPARM_INPUT, ORATYPE_VARCHAR2
      OraDatabase.Parameters.Add "MACHINE_HOSTNAME",      Request("machine_hostname"),      ORAPARM_INPUT, ORATYPE_VARCHAR2
      OraDatabase.Parameters.Add "GBE_ID",                Request("gbe_id"),                ORAPARM_INPUT, ORATYPE_NUMBER
      OraDatabase.Parameters.Add "DESCRIPTION",           Request("description"),           ORAPARM_INPUT, ORATYPE_VARCHAR2
      OraDatabase.Parameters.Add "ACTIVE",                Request("active"),                ORAPARM_INPUT, ORATYPE_CHAR
      OraDatabase.Parameters.Add "PLATFORM",              Request("platform"),              ORAPARM_INPUT, ORATYPE_VARCHAR2

      objEH.ErrorRedirect = FALSE
      objEH.TryORA ( OraSession )
      On Error Resume Next

      OraDatabase.ExecuteSQL _
      "BEGIN  PK_BUILDAPI.UPDATE_BUILD_MACHINE(:BMCON_ID, :DISPLAY_NAME, :MACHINE_HOSTNAME, :GBE_ID, :DESCRIPTION, :ACTIVE, :PLATFORM);  END;"

      objEH.CatchORA ( OraSession )

      OraDatabase.Parameters.Remove "BMCON_ID"
      OraDatabase.Parameters.Remove "DISPLAY_NAME"
      OraDatabase.Parameters.Remove "MACHINE_HOSTNAME"
      OraDatabase.Parameters.Remove "GBE_ID"
      OraDatabase.Parameters.Remove "DESCRIPTION"
      OraDatabase.Parameters.Remove "ACTIVE"
      OraDatabase.Parameters.Remove "PLATFORM"

      If objEH.Finally Then
         Call OpenInParentWindow ("admin_build_machine.asp?bmcon_id="&Request("bmcon_id"))
         Call CloseWindow()
      End If

      rsQry.Close
      Set rsQry = nothing

   Else
      OraDatabase.Parameters.Add "DISPLAY_NAME",          Request("display_name"),          ORAPARM_INPUT, ORATYPE_VARCHAR2
      OraDatabase.Parameters.Add "MACHINE_HOSTNAME",      Request("machine_hostname"),      ORAPARM_INPUT, ORATYPE_VARCHAR2
      OraDatabase.Parameters.Add "GBE_ID",                Request("gbe_id"),                ORAPARM_INPUT, ORATYPE_NUMBER
      OraDatabase.Parameters.Add "DESCRIPTION",           Request("description"),           ORAPARM_INPUT, ORATYPE_VARCHAR2
      OraDatabase.Parameters.Add "ACTIVE",                Request("active"),                ORAPARM_INPUT, ORATYPE_CHAR
      OraDatabase.Parameters.Add "PLATFORM",              Request("platform"),              ORAPARM_INPUT, ORATYPE_VARCHAR2

      objEH.ErrorRedirect = FALSE
      objEH.TryORA ( OraSession )
      On Error Resume Next

      OraDatabase.ExecuteSQL _
      "BEGIN  PK_BUILDAPI.ADD_BUILD_MACHINE(:DISPLAY_NAME, :MACHINE_HOSTNAME, :GBE_ID, :DESCRIPTION, :ACTIVE, :PLATFORM);  END;"

      objEH.CatchORA ( OraSession )

      OraDatabase.Parameters.Remove "DISPLAY_NAME"
      OraDatabase.Parameters.Remove "MACHINE_HOSTNAME"
      OraDatabase.Parameters.Remove "GBE_ID"
      OraDatabase.Parameters.Remove "DESCRIPTION"
      OraDatabase.Parameters.Remove "ACTIVE"
      OraDatabase.Parameters.Remove "PLATFORM"

      If objEH.Finally Then
         Call OpenInParentWindow ("admin_build_machine.asp?bmcon_id="&Request("bmcon_id"))
         Call CloseWindow()
      End If

      rsQry.Close
      Set rsQry = nothing

   End If

End If


'----------------------------------------------
%>
<html>
<head>
<title>Release Manager</title>
<link rel="shortcut icon" href="<%=FavIcon%>"/>
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="images/release_manager_style.css?ver=<%=VixVerNum%>" rel="stylesheet" type="text/css">
<script language="JavaScript" src="scripts/common.js?ver=<%=VixVerNum%>"></script>
</head>
<body leftmargin="0" topmargin="0" onLoad="self.focus();FormName.display_name.focus();">
<table width="100%"  border="0" cellspacing="0" cellpadding="10">
   <tr>
      <td class="body_txt">
         Add a new Build Machine or edit an existing Build Machine.
      </td>
   </tr>
   <%
   '-- FROM START --------------------------------------------------------------------------------------------------------------
   objFormComponent.FormName = "FormName"
   objFormComponent.FormClass = "form_tight"
   objFormComponent.Action = ScriptName
   objFormComponent.OnSubmit = "ShowProgress();"
   Call objFormComponent.FormStart()
   Call GetData()
   %>
   <tr>
      <td class="form_field_bg" >
         <!-- NEW PRODUCT ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
         <%Call Messenger ( sMessage , 3, "100%" )%>
         <!-- MESSAGE +++++++++++++++++++++++++++++++++++++++++++++++++++ -->
         <!--#include file="messages/_msg_inline.asp"-->
         <%
         If Request("bmcon_id") <> "" Then%>
                        <%If NOT bIsaClone Then%>
                                <input type="hidden" name="bmcon_id" value="<%=Request("bmcon_id")%>">
            <%End If
          End If%>
         <table width="50%" border="0">
            <tr>
               <td><span class="body_txt nowrap">Display Name</span></td>
               <td>
                  <input name="display_name" type="text" class="body_txt" value="<%=display_name%>" size=24 maxlength=20>
               </td>
            </tr>
            <tr>
               <td><span class="body_txt">Machine HostName</span></td>
               <td>
                  <input name="machine_hostname" type="text" class="body_txt" value="<%=machine_hostname%>" size=50 maxlength=50>
               </td>
            </tr>
            <tr>
               <td><span class="body_txt nowrap">GBE_MACHTYPE</span></td>
               <td><%=objFormComponent.Combo ( "gbe_id", GetMachType( gbe_id ), CBool(Request("bmcon_id") = ""), "size=1 class='body_txt'" )%></td>
            </tr>
            <tr>
               <td><span class="body_txt nowrap">Allow Use</span></td>
               <td>
                  <input type="checkbox" name="active" value="Y" <%=activeChecked%>>
                  <span class="body_txt">Allow users to add this machine to a build set</span>
               </td>
            </tr>
            <tr>
               <td><span class="body_txt nowrap">Description</span></td>
               <td>
                  <textarea name="Description" cols=50 rows=5 class='body_txt'><%=Description%></textarea>
               </td>
            </tr>
            <tr>
               <td><span class="body_txt nowrap">Platforms</span></td>
               <td style="border: darkgrey 1px solid">
                                <div style="overflow-y: scroll;height: 20em;">
                                          <%=GetPlatforms%>
                                </div>
               </td>
            </tr>

         </table>
      </td>
   </tr>
   <tr>
      <td>
         <table class="full_table">
            <tr>
               <td><%=ProgressBar()%></td>
               <td align="right">
                  <input name="btn" type="submit" class="form_btn" value="Add/Update">
                  <input name="btn" type="reset" class="form_btn" value="Cancel" onclick="parent.closeIFrame();">
               </td>
            </tr>
         </table>
      </td>
   </tr>
   <%=objPMod.ComposeHiddenTags()%>
   <input type="hidden" name="action" value="true">
   <%
   Call objFormComponent.FormEnd()
   '-- FROM END ----------------------------------------------------------------------------------------------------------------
   %>
</table>
</body>
</html>
<%
'------------ RUN AFTER PAGE RENDER -----------
Set objFormCollector = Nothing
'----------------------------------------------
Call Destroy_All_Objects
%>