Subversion Repositories DevTools

Rev

Rev 4240 | Blame | Last modification | View Log | RSS feed

<%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'|                                                   |
'|                ADMIN Page                         |
'|               Build Service                       |
'|                                                   |
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0   ' always load the page, dont store
%>
<!--#include file="common/conf.asp"-->
<!--#include file="common/globals.asp"-->
<!--#include file="common/qstr.asp"-->
<!--#include file="common/common_subs.asp"-->

<%
'------------ ACCESS CONTROL ------------------
%>
<!--#include file="_access_control_general.asp"-->
<%
'------------ Variable Definition -------------
Dim parTest
Dim LocalPath
Dim rvRemExec
Dim rvEmail
Dim rvEmail1
Dim rvEmail2
Dim rvEvent
Dim active

'------------ Constants Declaration -----------
'------------ Variable Init -------------------
parTest = QStrPar("test")
rvRemExec = ""
rvEmail = ""
rvEmail1 = ""
rvEmail2 = ""
rvEvent = ""
active = objAccessControl.IsActive("ConfigureBuildService")
if NOT active Then parTest = ""

'----------------------------------------------

function testFromRegistry (strRegistryKey )
    Dim WSHShell, value

    On Error Resume Next
    Set WSHShell = CreateObject("WScript.Shell")
    value = WSHShell.RegRead( strRegistryKey )

    testFromRegistry = NOT (err.number <> 0)

    set WSHShell = nothing
end function

Function makeButton( text, test, result )
    If result <> "" Then result = "&nbsp;" & result
    If active Then
        makeButton = "&nbsp;&nbsp;<a class=""form_btn"" href=""admin_build_test_page.asp?test="&test&""" title=""" &text& """>"&text&"</a>" & result
    Else
        makeButton = "&nbsp;&nbsp;<a class=""form_btn_disabled"" title=""" &text& """>"&text&"</a>" & result
    End If
End Function

Function makeAjaxButton( text, script )
    If active Then
        makeAjaxButton = "&nbsp;&nbsp;<a id="""&script &""" href="""" class=""form_btn"" title=""" &text& """ onclick="""&script&"();return false;"">"&text&"</a>"
    Else
        makeAjaxButton = "&nbsp;&nbsp;<a class=""form_btn_disabled"" title=""" &text& """>"&text&"</a>"
    End If
End Function

'-------------------------------------------
' Perform tests on request
'
If parTest = "email" Then
    Call Send_Email ( "Release Manager Notification", adminEmail, objAccessControl.UserEmail, "Test Email", "This is a Test Email generated by the Release Manager Test.", Null )
    rvEmail = "Sent"

ElseIf parTest = "email1" Then
    LocalPath = Server.MapPath("images\img_reports_admin.jpg")
    Call Send_Email ( "Release Manager Notification", adminEmail, objAccessControl.UserEmail, "Test Email", "This is a Test Email generated by the Release Manager Test. This email has an attachment", LocalPath )
    rvEmail1 = "Sent"

ElseIf parTest = "email2" Then
    Set objWSH = Server.CreateObject("WScript.Shell")
    rv = objWSH.Run ("cmd.exe /c cscript.exe //B //NoLogo " & rootPath & SCRIPTS_FOLDER & "\Admin_Test.wsf //job:onTestMail", 0, TRUE)
    Set objWSH = Nothing
    If rv = 0 Then
        rvEmail2 = "OK"
    Else
        rvEmail2 = "Error ("&rv&")"
    End IF

ElseIf parTest = "event" Then
    Set objWSH = Server.CreateObject("WScript.Shell")
    rv = objWSH.Run ("cmd.exe /c cscript.exe //B //NoLogo " & rootPath & SCRIPTS_FOLDER & "\Admin_Test.wsf //job:onRaiseEvent", 0, TRUE)
    Set objWSH = Nothing
    If rv = 0 Then
        rvEvent = "OK"
    Else
        rvEvent = "Error ("&rv&")"
    End IF

ElseIf parTest = "remExec" Then
    Set objWSH = Server.CreateObject("WScript.Shell")
    rv = objWSH.Run ("cmd.exe /c cscript.exe //B //NoLogo " & rootPath & SCRIPTS_FOLDER & "\Admin_Test.wsf //job:onTestArchiveAccess", 0, TRUE)
    Set objWSH = Nothing
    If rv = 0 Then
        rvRemExec = "OK"
    Else
        rvRemExec = "Error ("&rv&")"
    End IF
End If

%>
<script type="text/javascript" src="scripts/json2.js"></script>
<script language="JavaScript" src="scripts/remote_scripting.js"></script>
<script type="text/javascript" charset="utf-8">
///////////////////////////////////////////////
//  Function:    ajaxOpr
//  Description: Perform an ajax operation
//  Args       :    args - Part of URL to pass to script
//                  callback    - Callback on success
//                  ecall       - Callback on error            
//
function ajaxOpr(args, callback, ecall)
{
    xmlHttp=GetXmlHttpObject(function(){ ajaxOprCallback(callback, ecall);});
    if (xmlHttp==null)
    {
      alert ("Your browser does not support AJAX!");
      return;
    }

    var url = "_json_jiraIssues.asp?" + args;

    // Use async request, otherwise the spinner will not work
    xmlHttp.open("GET",url,true);  // `false` makes the request synchronous
    xmlHttp.send(null);
}
///////////////////////////////////////////////
//  Function:    ajaxOprCallback
//  Description: Perform an Ajax operation generic error handling
//  Args       : callback - Function to process json results
//                          Json has been decoded and is a javascript object
//                          Handle errors for the user
//
function ajaxOprCallback(callback, ecall)
{
    //readyState of 4 or 'complete' represents that data has been returned
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
    {
        // alert("Got to getAllProjectKeysDone"+ xmlHttp.responseText);
        if (xmlHttp.status !== 200) {
            ecall('Bad Status');
            alert("Internal AJAX error: " + xmlHttp.status);
        }
        else
        {
            // Gather the results from the callback
            var str = xmlHttp.responseText;
            try {
                var myJson = JSON.parse(str);
                //alert("ajaxOprCallback:" + str);
                if (myJson.result != 0) {
                    ecall('Error');
                    alert("AJAX request error: " + myJson.emsgSummary);
                }
                else {
                    callback(myJson);
                }
            }
            catch(e) {
            }
        }
    }
}

///////////////////////////////////////////////
//  Function:       jiraTest   
//  Description:    Get the list of projects from the Jira Server
//
function jiraTest()
{
    //  Show that testing has started
    var el = document.getElementById("jiraTest");
    el.innerText = 'Testing';

    ajaxOpr('Opr=getAllKeys', 
            function(myJson){ el.innerText = 'Test OK'; },
            function(txt){ el.innerText = "Test Failed:" + txt}
           );
    
}
</script>
<html>
<head>

<title>Admin Test Page</title>

<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="images/release_manager_style.css" type="text/css">
<link rel="stylesheet" href="images/navigation.css" type="text/css">
<script language="JavaScript" src="images/common.js"></script>
<!-- DROPDOWN MENUS -->
<!--#include file="_menu_def.asp"-->
<script language="JavaScript1.2" src="images/popup_menu.js"></script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" >
<!-- MENU LAYERS -------------------------------------->
<div id="popmenu" class="menuskin" onMouseover="clearhidemenu();highlightmenu(event,'on')" onMouseout="highlightmenu(event,'off');dynamichide(event)">
</div>
<!-- TIPS LAYERS -------------------------------------->
<div id="formTipsLayer" style="position: absolute; z-index: 1000; visibility: hidden; left:0; top: 0; width: 10">&nbsp;</div>
<!-- HEADER -->
<!--#include file="_header.asp"-->

   <%
   '-- FROM START ---------------------------------------------------------------------------------------------------------
   %>
   <tr>
      <td background="images/bg_login.gif">
         <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
               <td><%=ProgressBar%></td>
               <td align="right">&nbsp;          </td>
            </tr>
         </table>
      </td>
   </tr>
   <tr>
      <td>
         <table style="margin-left:auto; margin-right:auto; width:50%"  border="0" cellpadding="0" cellspacing="2" bgcolor="#FFCC00">
            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap class="body_col">Test</td>
               <td valign="top" nowrap class="body_col">Result</td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">User ID</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=objAccessControl.UserId%></td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">User Name</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=objAccessControl.UserName%></td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">User Email</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=objAccessControl.UserEmail%></td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">DataBase Name</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=OraDatabase.DatabaseName%></td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Archive Server</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=archive_server%></td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Package Archive Access - Map File System</td>
            <%

            Dim objWSH,rv,result
            Set objWSH = Server.CreateObject("WScript.Shell")
            rv = objWSH.Run ("cmd.exe /c cscript.exe //B //NoLogo " & rootPath & SCRIPTS_FOLDER & "\Admin_Test.wsf //job:onTestMapArchive", 0, TRUE)
            Set objWSH = Nothing
            If rv = 0 Then
                result = "OK"
            Else
                result = "Error ("&rv&")"
            End IF

            %>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=result%></td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Package Archive Access - Remote cmd execution</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">
                    <%=makeButton("Test", "remExec",rvRemExec)%>
                </td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
            <%
                Dim sKey1, sKey2, sValue1, sValue2, kFragment
                kFragment = "rsa2@22:" & archive_server
                sKey1 = "HKEY_USERS\S-1-5-20\Software\SimonTatham\PuTTY\SshHostKeys\" & kFragment
                sKey2 = "HKEY_USERS\.DEFAULT\Software\SimonTatham\PuTTY\SshHostKeys\" & kFragment
                sValue1 = testFromRegistry(sKey1)
                sValue2 = testFromRegistry(sKey2)
            %>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Plink Key [<%=sKey1%>]</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=sValue1%></td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Plink Key [<%=sKey2%>]</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=sValue2%></td>
            </tr>
            
           <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Email Server</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=MAIL_SERVER%></td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Admin Email</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=adminEmail%></td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Send Email</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">
                    <%=makeButton("eMail", "email",rvEmail)%>
              </td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Send Email With attachment</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">
                    <%=makeButton("eMail", "email1",rvEmail1)%>
            </tr>
            <tr>
              <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Send Email from WSH script</td>
              <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">
                    <%=makeButton("eMail", "email2",rvEmail2)%>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
             <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Generate error event</td>
             <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">
                    <%=makeButton("event", "event",rvEvent)%>
            </tr>


            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Jira Server</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col"><%=JIRA_URL%></td>
            </tr>
            <tr>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">Jira Test</td>
               <td valign="top" nowrap background="images/bg_table_col.gif" class="body_col">
                    <%=makeAjaxButton("Test", "jiraTest")%>
              </td>
            </tr>

            <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
            <tr>
               <td valign="top" nowrap class="body_col">End of Tests</td>
               <td><a class="form_btn" href="admin_build_test_page.asp" title="Refresh Page">Refresh</a></td>
            </tr>
            
         </table>
      </td>
  </tr>
  <input type="hidden" name="action" value="true">
  <p>
</body>
</html>
<!-- FOOTER -->
<!--#include file="_footer.asp"-->
<%
Call Destroy_All_Objects
%>