<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="com.esri.rmims" %>

<script language="C#" runat="server">

    public static Map OpenMap()
    {
        Map map;

        IMSConnection conn = new IMSConnection();
        conn.setConnectionURL(GetConfigStr("par_ServerUrl"));
        conn.setGroup(GetConfigStr("par_Groupid"));
        conn.setUserName(GetConfigStr("par_Uid"));
        conn.setLocale(GetConfigStr("par_Lang"), GetConfigStr("par_Country"));
        conn.setCharset(String.Empty);

        map = conn.loadMap(GetConfigStr("par_MapName")); // excepiton
        conn = null;

        // set image size
        map.setImageSize(GetConfigInt("par_Width"), GetConfigInt("par_Height"));

        // set location
        Location loc = new Location();
        loc.setString(GetConfigStr("par_Location"));
        map.setLocation(loc);
        loc = null;

        // set measure units
        map.setMeasureUnits(GetConfigInt("par_Units"));

        return (map);
    }
        
    public static string GetConfigStr(string keyName)
    {

        string strVal="";

        try
        {
            strVal = ConfigurationSettings.AppSettings[keyName]; // exception
        }
        catch(Exception e)
        {
        }

        return (strVal);
    }


    public static int GetConfigInt(string keyName)
    {

        int nVal=0;

        try
        {
            nVal = Int32.Parse(ConfigurationSettings.AppSettings[keyName]); // exception
        }
        catch(Exception e)
        {
        }

        return (nVal);
    }
    
</script>

<%

    Map map = OpenMap();
    
    // Main code here

%>