【发布时间】:2011-12-23 16:33:29
【问题描述】:
我的任务是编写一个 Web 服务,该服务可以从我们的两个工厂位置之一调用,这将使我们的运输部门能够为一组交付获得最有效的路线。我们还讨论了设置区域并将交付分配到区域和区域分配给司机的可能性。
我的问题是最简单的形式: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();
【问题讨论】:
-
使用给定的代码,您将启动 10 个 MapPoint 实例。是的,这不会很好地扩展。您可以自己序列化查询以减轻这种打击,减慢服务速度,但至少不会使机器翻倒。 Microsoft 通常不建议在服务器场景中使用其桌面应用程序。
标签: c# com map scalability mappoint