我的任务是编写一个可以从我们两个工厂之一调用的 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();