示例#1
0
 public async Task DeleteRouteStop(RouteStop stop)
 {
     await RouteTable.DeleteRecord(stop.RecordId);
 }
示例#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);
                    }
                }
            }
        }