示例#1
0
        public async Task ShowRouteMap()
        {
            var locations = new List <ILocation>();

            RouteStop lastStop = null;

            foreach (var stop in Stops)
            {
                if (stop.Status == RoutеStopStatus.Departed)
                {
                    continue;
                }

                if (stop.Status == RoutеStopStatus.Enroute)
                {
                    locations.Add(await Location.GetCurrentLocation());
                }

                locations.Add(new Location {
                    Address = stop.Address
                });
                lastStop = stop;
            }

            if (locations.Count == 0)
            {
                return;
            }

            if (lastStop.Kind != RouteStopKind.EndPoint)
            {
                lastStop = new RouteEndStop(this);
                locations.Add(new Location {
                    Address = lastStop.Address
                });
            }

            await Maps.MapApplication.OpenDirections(locations, Maps.DefaultOptions);
        }
示例#2
0
        public async Task LoadRoute()
        {
            var route = AppScope.Instance.Route;

            var records = await RouteTable.ListRecords(sortField : RouteRecord._);

            foreach (var rec in records)
            {
                if (rec.Date < route.Date)
                {
                    try {
                        await RouteTable.DeleteRecord(rec.Id);
                    }
                    catch (Exception ex) {
                        Debug.ExceptionCaught(ex);
                    }
                    continue;
                }

                if (rec.Date == route.Date)
                {
                    var codeName = rec.CodeName.Trim();
                    var tag      = rec.Tags?.Trim();
                    var status   = rec.Status?.Trim();

                    try {
                        RouteStop stop;
                        if (tag == Tag.startpoint)
                        {
                            stop = new RouteStartStop(route, codeName);
                        }
                        else if (tag == Tag.endpoint)
                        {
                            stop = new RouteEndStop(route, codeName);
                        }
                        else if (tag == Tag.midpoint)
                        {
                            stop = new RouteMidStop(route, codeName);
                        }
                        else
                        {
                            stop = new CustomerStop(route, codeName);
                        }

                        stop.RecordId = rec.Id;

                        if (status == RouteRecord.Enroute)
                        {
                            stop.Status = RoutеStopStatus.Enroute;
                        }
                        else if (status == RouteRecord.Arrived)
                        {
                            stop.Status = RoutеStopStatus.Arrived;
                        }
                        else if (status == RouteRecord.Departed)
                        {
                            stop.Status = RoutеStopStatus.Departed;
                        }

                        await route.Add(stop, false);
                    }
                    catch (Exception ex) {
                        Debug.ExceptionCaught(ex);
                    }
                }
            }
        }