ChooseServerGroupMembers.csp


<%@ Language=JavaScript%>

<%

// This file is called from ManageServerGroup.csp.  It presents

// the user with the option of adding and removing servers to and from

// the group he or she choose in ChooseServerGroup.csp.  It uses

// ManageServerGroupMembers.csp to do this.

%>

<!-- #include file="RetrieveIStore.csp" -->

<!-- #include file=helper_js.csp -->

<html>

<body>

<%

    

function GetServers(IStore)

// This function returns a listbox popuplated with all servers

// connected to the APS and all APSs.

// Parameters:

// IStore - The InfoStore object.

// Returns: HTML table.

{    

    try{

        //Query for all servers in the APS(s).

        var Servers = IStore.Query

        ("SELECT SI_NAME FROM CI_SYSTEMOBJECTS WHERE SI_PROGID='CrystalEnterprise.Server'");


        if (Servers.Count == 0)

        {    

            return "";

        }


        var k;

        var HTML="<select name=ServerName>";

        var Server;

        for (k=1;k<=Servers.Count;k++)

        {

            HTML = HTML + "<option value='"+Servers.Item(k).Title+"'>"+Servers.Item(k).Title;

        }

        HTML= HTML + "</select>";

        return HTML;

    }

    catch (e){

        Response.Write("Error");

        return;

    };

}


function GetServersInGroup(IStore, ServerGroupId)

// This prints a drop down box of all the servers that are in a group.

// Parameters:

// IStore - The InfoStore object.

// ServerGroupId - The InfoObject ID of the selected ServerGroup object.

// Returns: HTML table.

{

    try{

        // Query for the ServerGroup object for the group you are interested in.

        var ServerGroups = IStore.Query

        ("SELECT SI_GROUP_MEMBERS FROM CI_SYSTEMOBJECTS WHERE SI_ID=" + ServerGroupId);


        if (ServerGroups.Count == 0)

        {    

            return "";

        }


        var ServerGroup = ServerGroups.Item(1).PluginInterface("");

        Response.Write(ServerGroupId + "<BR>");

        var k;


        // Iterate through the members in the Servers collection to

        // build a drop down box.

        var HTML="<select name=MemberName>";

        for (k=1;k<=ServerGroup.Servers.Count;k++)

        {

            HTML = HTML + "<option value='"+ServerGroup.Servers.Item(k)+"'>"+ServerGroup.Servers.Item(k);

        }

        HTML= HTML + "</select>";

        return HTML;

    }

    catch (e){

        Response.Write("Error");

        return;

    };

}


function GetServerGroups(IStore)

// This function returns a listbox popuplated with all the server groups.

// Parameters:

// IStore - The InfoStore object.

// Returns: HTML table.

{    

    try{

        var ServerGroups = IStore.Query

        // Query for the ServerGroup object for the group you are interested in.

        ("SELECT SI_SERVER_GROUP FROM CI_SYSTEMOBJECTS WHERE SI_PROGID='CrystalEnterprise.ServerGroup'");

        if (ServerGroups.Count == 0)

        {    

            return "";

        }

        var k;


        var HTML="<select name=GroupID>";

        for (k=1;k<=ServerGroups.Count;k++)

        {

            HTML = HTML + "<option value='"+ServerGroups.Item(k).ID+"'>"+ServerGroups.Item(k).Title;

        }

        HTML= HTML + "</select>";

        return HTML;

    }

    catch (e){

        Response.Write("Error");

        return;

    };

}


function GetGroupAssociatesInGroup(IStore, ServerGroupId)

// Retrieve a list of all ServerGroups on the APS.  Return the list

// in an HTML string that will draw a drop down box.

// Parameters:

// IStore - The InfoStore object.

// ServerGroupId - The InfoObject ID of the selected ServerGroup object.

// Returns: HTML table.

{

    try{

        // Query for the ServerGroup object for the group you are interested in.

        var ServerGroups = IStore.Query

        ("SELECT SI_SUBGROUPS From CI_SYSTEMOBJECTS WHERE SI_ID=" + ServerGroupId);

    

        if (ServerGroups.Count == 0)

        {    

            return "";

        }

    

        var k;

        // (Long) Holds the ID of the server group associate.

        var GroupAssociateID;

        // (String) Holds the Title of the server group associate.

        var GroupAssociateName;

        // Retrieve the ServerGroup plugin.

        var ServerGroup = ServerGroups.Item(1).PluginInterface("");

        var HTMLTable="<select name=SubGroupID>";

    

        // Iterate through all groups and build the drop down box.

        for (k=1;k<=ServerGroup.SubGroups.Count;k++)

        {

            GroupAssociateID = ServerGroup.SubGroups.Item(k);

            ServerGroups = IStore.Query

            ("SELECT SI_SERVER_GROUP From CI_SYSTEMOBJECTS WHERE SI_ID=" + GroupAssociateID);

            GroupAssociateName = ServerGroups.Item(1).Title;

                

            HTMLTable = HTMLTable + "<option value='"+GroupAssociateID+"'>"+GroupAssociateName;

        }

        HTMLTable= HTMLTable + "</select>";

        return HTMLTable;

    }

    catch (e){

        Response.Write("Error");

        return;

    };

}


function Main()

{

    IStore = RetrieveIStore();

    if (IStore == null)

    {

        Response.Redirect ("Start.csp");

        return;

    }

        

    ServerGroupId = Request.QueryString.Item("ServerGroupId");

    Response.Write("ServerGroupID: " + ServerGroupId);

    Response.Write ("<H2>Server group member administration</H2>");

    Response.Write ("<form action='ManageServerGroupMembers.csp?ServerGroupId="+ServerGroupId+"' method=post name='ServerGroupMembers'>");

    

    // Print a drop down box with all servers and an add button.

    Response.Write ("Available servers: <BR>");

    Response.Write (GetServers(IStore));

    Response.Write ("<BR><input type=submit name='AddServer' value='Add a server'><HR>");

    

    // Print a drop down box with the servers in the group and

    // a remove button.

    Response.Write ("Servers in group: <BR>");

    Response.Write (GetServersInGroup(IStore, ServerGroupId));

    Response.Write ("<BR><input type=submit name='RemoveServer' value='Remove a server'> ");

    // Add a button to clear all servers from the group.

    Response.Write ("<input type=submit name='ClearServers' value='Clear all servers'><HR>");

        

    // Print a drop down box with all group associates and an add button.

    Response.Write ("Available groups: <BR>");

    Response.Write (GetServerGroups(IStore));

    Response.Write ("<BR><input type=submit name='AddGroup' value='Add a group'><HR>");


    // Print a drop down box with the group associates in the group and

    // a remove button.

    Response.Write ("Group associates in a group: <BR>");

    Response.Write (GetGroupAssociatesInGroup(IStore, ServerGroupId));

    Response.Write ("<BR><input type=submit name='RemoveGroup' value='Remove a group'> ");

    // Add a button to clear all group associates.

    Response.Write ("<input type=submit name='ClearGroups' value='Clear all groups'><HR>");

    

    Response.Write ("</FORM>");

}


Main();

    

%>

</body>

</html>




Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com