ManageServerGroup.csp


<%@ Language=JavaScript%>

<%

// This page is called from ChooseServerGroup.csp.  If the user chose

// to add or delete a server group, these actions are managed here.

// If the user decided to manage the servers in a group, then more information

// is required and ManageServerGroupMembers.csp is called.

%>

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

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

<html>

<body>

<%

    

function DeleteServerGroup(IStore, ServerGroupId)

// Delete a server group from the APS.

// Parameters:

// IStore - The InfoStore object.

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

// Returns: None.

{

    try{

        // Query for the selected server group.

        var ServerGroups = IStore.Query("SELECT SI_SERVER_GROUP FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);

        // Concatenate # with the Id and given it to the

        // Delete method. If you give it just the ID, it will

        // treat it as an array index and remove the wrong server.

        ServerGroups.Delete("#" + ServerGroupId);

        IStore.Commit(ServerGroups);

    }

    catch (e){

        Response.Write("Error");

        return;

    };    

}


function AddServerGroup(IStore, Name, Description)

// Add a new server group to the APS.

// Parameters:

// IStore - The InfoStore object.

// Name - The name of the new server group.

// Description - The description of the new server group.

// Returns: None.

{

    try{

        var PluginMgr = IStore.PluginManager;

        // Get the ServerGroup.

        var ServerGroup = PluginMgr.PluginInfo("CrystalEnterprise.ServerGroup");

        // Create a new InfoObjects collection. This will be used to store the new object

        // that will be commmitted later.

        var NewInfoObjects  = IStore.NewInfoObjectCollection();

        // Add the result of the plugin. This will create a new InfoObject that

        // represents a ServerGroup.

        var NewServerGroup = NewInfoObjects.Add (ServerGroup);

        // Set the group's name and description.

        NewServerGroup.Title = Name;

        NewServerGroup.Description = Description;

        // Commit the collection, in which the new group is stored, to the APS.

        IStore.Commit (NewInfoObjects);

    }

    catch (e){

        Response.Write("Error");

        return;

    };

}


function Main()

{

    IStore = RetrieveIStore();

    if (IStore == null)

    {

        Response.Redirect ("Start.csp");

        return;

    }

    // Depending on the user's request, use the functions in this file

    // to add or delete the group.  If the user wants to manage

    // the members of the group, call ChooseServerGroupMembers.csp instead

    // and give it the ID of the group in question as a URL parameter.

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

    if (Request.Form.Item("Remove") == "Remove")

    {

        DeleteServerGroup(IStore,ServerGroupId);

        Response.Redirect ("ChooseServerGroup.csp");

    }

    if (Request.Form.Item("Add") == "Add")

    {

        Name = Request.Form.Item("NewGroupName");

        Description = Request.Form.Item("NewGroupDescription");

        AddServerGroup(IStore,Name,Description);

        Response.Redirect ("ChooseServerGroup.csp");

    }

    if (Request.Form.Item("ManageMembers") == "ManageMembers")

            Response.Redirect ("ChooseServerGroupMembers.csp?ServerGroupId="+ServerGroupId);

}


Main();

    

%>

</body>

</html>




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