Ejemplo n.º 1
0
    private static CommonHost GetHost(Configuration.MapTabRow mapTab, string type)
    {
        string userName = mapTab.IsUserNameNull() ? "" : mapTab.UserName;
        string password = mapTab.IsPasswordNull() ? "" : mapTab.Password;

        CommonHost host = null;

        try
        {
            switch (type)
            {
            case "AGS":
                if (String.IsNullOrEmpty(userName) && String.IsNullOrEmpty(password))
                {
                    host = new AgsHost(mapTab.MapHost);
                }
                else
                {
                    try
                    {
                        host = new AgsHost(mapTab.MapHost, userName, password, true);
                    }
                    catch { }

                    if (host == null)
                    {
                        host = new AgsHost(mapTab.MapHost, userName, password, false);
                    }
                }
                break;

            case "ArcIMS":
                host = new ArcImsHost(mapTab.MapHost, userName, password);
                break;
            }
        }
        catch { }

        return(host);
    }
Ejemplo n.º 2
0
    private static CommonMapService GetService(Configuration.MapTabRow mapTab, string type)
    {
        Dictionary <String, CommonMapService> services = GetCachedServices();

        string           serviceKey = mapTab.GetServiceKey(type);
        CommonMapService service    = null;

        if (services.ContainsKey(serviceKey))
        {
            service = services[serviceKey];
        }
        else
        {
            CommonHost host = GetHost(mapTab, type);

            if (host != null)
            {
                try
                {
                    service = host.GetMapService(mapTab.MapService);

                    ArcImsService arcImsService = service as ArcImsService;

                    if (arcImsService != null && !arcImsService.IsArcMap)
                    {
                        arcImsService.LoadToc(true);
                    }

                    services.Add(serviceKey, service);
                }
                catch { }
            }
        }

        return(service);
    }