MapPoint 2011 COM 可扩展吗?

发布于 2024-12-14 06:00:45 字数 1058 浏览 0 评论 0原文

我的任务是编写一个可以从我们两个工厂地点之一调用的网络服务,这将使我们的运输部门能够获得一组交货的最有效路线。我们还讨论了设立区域以及将送货分配给区域以及将区域分配给司机的可能性。

我的问题最简单的形式是:MapPoint 2011 允许您通过 COM 使用其对象模型。我对这种类型的编程不是很熟悉,但似乎每次调用逻辑时都会创建一个新的应用程序实例。这种类型的使用是否可扩展?如果同时接到十个电话会发生什么?

我在下面提供了一些从 MSDN 中提取的示例代码作为参考。

//set up application
MapPoint.Application objApp = new Application();
objApp.Visible = false;
objApp.UserControl = false;

MapPoint.Route objRoute;
MapPoint.Map objMap;

objMap = objApp.ActiveMap;
objRoute = objMap.ActiveRoute;

objMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;

//Get locations for route
object item = 1;
objRoute.Waypoints.Add(objMap.FindResults("Redmond, WA").get_Item(ref item), 
    "Redmond, WA");
objRoute.Waypoints.Add(objMap.FindResults("Seattle, WA").get_Item(ref item), 
    "Seattle, WA");
objRoute.Waypoints.Add(objMap.FindResults("Portland, OR").get_Item(ref item), 
    "Portland, OR");

// Calculate the route
objRoute.Calculate();

//Asks if you want to save the map? How would you say no programmatically?
objApp.Quit();

I've been tasked with writing a web service that can be called from one of our two plant locations that will allow our shipping department to get the most efficient route for a set of deliveries. We've also discussed the possibility of setting up territories and assigning deliveries to territories and territories to drivers.

My question, in its simplest form, is this: MapPoint 2011 allows you to use its object model through COM. I'm not terribly familiar with this type of programming but it seems to create a new instance of the application each time the logic is called. Is this type of usage scalable? What will happen if ten calls are received simultaneously?

I've included some sample code pulled from MSDN below as a point of reference.

//set up application
MapPoint.Application objApp = new Application();
objApp.Visible = false;
objApp.UserControl = false;

MapPoint.Route objRoute;
MapPoint.Map objMap;

objMap = objApp.ActiveMap;
objRoute = objMap.ActiveRoute;

objMap.Parent.PaneState = MapPoint.GeoPaneState.geoPaneRoutePlanner;

//Get locations for route
object item = 1;
objRoute.Waypoints.Add(objMap.FindResults("Redmond, WA").get_Item(ref item), 
    "Redmond, WA");
objRoute.Waypoints.Add(objMap.FindResults("Seattle, WA").get_Item(ref item), 
    "Seattle, WA");
objRoute.Waypoints.Add(objMap.FindResults("Portland, OR").get_Item(ref item), 
    "Portland, OR");

// Calculate the route
objRoute.Calculate();

//Asks if you want to save the map? How would you say no programmatically?
objApp.Quit();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

溺孤伤于心 2024-12-21 06:00:45

不,它不可扩展,而且是一个非常坏主意。在服务器环境中运行任何严重依赖于桌面会话的程序(例如 MapPoint 2011)都会出现问题,主要是因为桌面会话不可用。

此外,此类桌面应用程序不是为服务器环境开发的,因此它们消耗的资源与您预期的不同(通常更积极)。

就您而言,如果您同时收到十个调用,那么您的服务器上将运行十个应用程序实例(然后关闭,但仍然如此)。对于这种类型的应用程序来说,这通常是不可扩展的。

MapPoint 2011 与 Office 属于同一类别,因为根据 Microsoft 的规定,它不应在服务器环境中运行自己的推荐

No, it is not scaleable and it is a very bad idea. Running any program that relies heavily on a desktop session (such as MapPoint 2011) in a server environment has issues, mainly because a desktop session isn't available.

Additionally, desktop application such as this are not developed for server environments, so they consume resources differently (and usually more aggressively) than you might expect.

In your case, if you receive ten calls at the same time, then you will have ten instances of the application run on your server (and then shut down, but still). This generally is not scaleable for applications of this type.

MapPoint 2011 falls in the same category as Office, in that it should not be run in a server environment, as per Microsoft's own recommendation.

耳钉梦 2024-12-21 06:00:45

@casperOne 是对的,这是一个坏主意。您正在谈论 1-2 个位置,因此这里还有另外两种方法:

首先,为什么不在听起来您正在使用的 4-5 台计算机上本地安装和运行 MapPoint?在本地进行路由。

其次,MapPoint 有一个ActiveX 控件。这可以嵌入到 Web 应用程序中,但您必须在每台客户端 PC 上拥有许可的 MapPoint 应用程序。

否则我认为您正在寻找在线服务。 Bing 地图也很不错;如果 OpenStreetMaps 的数据质量足以满足您的运营区域需求,那么总是可以使用 OpenStreetMaps。

@casperOne is right that this is a bad idea. You are talking about 1-2 locations, so here Here are two other approaches:

First, Why not install and run MapPoint locally on the 4-5 machines it sounds like you are using? Do the routing locally.

Secondly, MapPoint has an ActiveX control. This can be embedded in a web app BUT you must have licensed MapPoint applications on each client PC.

otherwise I think you are looking at an online service. Bing Maps is pretty good too; and there's always OpenStreetMaps if their data quality is sufficient in your area of operations.

樱娆 2024-12-21 06:00:45

如果你想保存地图?

如何以编程方式拒绝?

 objApp.ActiveMap.saved = true

If you want to save the map?

How would you say no programmatically?

 objApp.ActiveMap.saved = true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文