public UploadModel AddHandlingUnits(IGrouping <string, Consignment> group, RttSiteDefault site, UploadModel model)
        {
            foreach (var consignment in group)
            {
                consignment.Parcels.ForEach(p =>
                                            model.Add(new HandlingUnit
                {
                    Id                = $"{site.Id}/unit/{p.ParcelID?.Trim()}",
                    Barcode           = p.Barcode?.Trim(),
                    CustomerReference = p.ConsID.ToString(),
                    InternalReference = consignment.ConsignmentNo,
                    Quantity          = 1,
                    Weight            = p.ActualKG,
                    Dimensions        = new HandlingUnitDimensions
                    {
                        Height = p.Height,
                        Length = p.Length,
                        Width  = p.Width
                    },
                    Status = EHandlingUnitStatus.Pending
                }));
            }

            return(model);
        }
        private Action CreateAction(RTTTripDetails details, Consignment consignment, RttSiteDefault site)
        {
            var action = new Action
            {
                Id = utils.CreateActionId(consignment, site),
                InternalReference = consignment.ConsignmentID.ToString(),
                Reference         = consignment.ConsignmentNo?.Trim(),
                CreatedOn         = details.TripDate.GetValueOrDefault(),
                ExpectedDelivery  = details.TripDate,
                ClientId          = site.Id,
                CustomerReference = consignment.Account.Acc_Id.ToString(),
                CustomerCode      = consignment.Account.AccountNo?.Trim(),
                IsCod             = false,
                AmountIncl        = 0,
                Nature            = EActionNature.Product,
                Weight            = consignment.Parcels.Sum(p => p.ActualKG),
                Pieces            = consignment.Parcels.Count,
                Volume            = consignment.Parcels.Sum(p => p.Length * p.Height * p.Width),
                VolumetricMass    = consignment.Parcels.Sum(p => p.VolumizerKG),
                HandlingUnitIds   = consignment.Parcels.Select(p => $"{site.Id}/unit/{p.ParcelID?.Trim()}").ToList(),
            };

            if (consignment.Parcels.Count == 0)
            {
                action.ActionTypeId   = site.RttActionTypeCollection;
                action.ActionTypeName = "Collection";
            }
            else
            {
                action.ActionTypeId   = site.RttActionTypeDelivery;
                action.ActionTypeName = "Delivery";
            }

            return(action);
        }
        public UploadModel Create(RTTTripDetails details, RttSiteDefault site)
        {
            var data        = details.Consignments.OrderBy(x => x.StopNumber).ToList();
            var orderedList = data.GroupBy(p => GetGroupId(p)).ToList();
            var results     = TranslateGrouping(details, orderedList, site);

            return(results);
        }
        public UploadModel Create(RTTTripDetails details, RttSiteDefault site)
        {
            var trips       = details.Consignments.ToList();
            var orderedList = trips.OrderBy(x => x.StopNumber).ToList();
            var results     = Translate(orderedList, site, details);

            return(results);
        }
Exemplo n.º 5
0
 private StopVisitModel CreateStopVisitModel(List <Consignment> consignments, RttSiteDefault site)
 {
     return(new StopVisitModel()
     {
         EntityId = utils.CreateShipToId(consignments[0].Address, site),
         Actions = consignments.Select(x => utils.CreateActionId(x, site)).ToList(),
         MaxServiceTime = SumConsignmentStopTimes(consignments)
     });
 }
        public Entity CreateGroupSellTo(IGrouping <string, Consignment> group, RttSiteDefault site)
        {
            var entity = new Entity
            {
                Id        = CreateSellToId(group, site),
                Reference = group.Select(x => x.Account.AccountNo).FirstOrDefault().ToString(),
                Name      = group.Select(x => x.Account.account_name).FirstOrDefault()
            };

            return(entity);
        }
 public string CreateActionId(IGrouping <string, Consignment> group, RttSiteDefault site)
 {
     if (IsDelivery(group))
     {
         return($"{site.Id}/{group.Select(x => GetGroupId(x)).FirstOrDefault()}");
     }
     else
     {
         return($"{site.Id}/{group.Select(x => GetGroupId(x)).FirstOrDefault()}/C");
     }
 }
        private Entity CreateSellTo(Consignment consignment, RttSiteDefault site)
        {
            var entity = new Entity
            {
                Id        = utils.CreateSellToId(consignment, site),
                Reference = consignment.Account.AccountNo?.Trim(),
                Name      = consignment.Account.account_name?.Trim()
            };

            return(entity);
        }
        private UploadModel Translate(List <Consignment> trip, RttSiteDefault site, RTTTripDetails details)
        {
            var route = new UploadModel();

            if (site == null)
            {
                return(null);
            }
            foreach (var consignment in trip)
            {
                var action = CreateAction(details, consignment, site);
                consignment.Parcels.ForEach(p =>
                                            route.Add(new HandlingUnit
                {
                    Id                = $"{site.Id}/unit/{p.ParcelID?.Trim()}",
                    Barcode           = p.Barcode,
                    CustomerReference = p.ConsID.ToString(),
                    Quantity          = 1,
                    Weight            = p.ActualKG,
                    Dimensions        = new HandlingUnitDimensions
                    {
                        Height = p.Height,
                        Length = p.Length,
                        Width  = p.Width
                    },
                    Status = EHandlingUnitStatus.Pending
                }));
                route.Add(action);
                var sellTo = CreateSellTo(consignment, site);
                var deco   = CreateDeco(consignment, site);
                route.Add(deco);
                var sellToTemp = CreateTempSellTo(consignment, site);
                route.Add(sellToTemp);
                var relationship = Relationship
                                   .Link(action)
                                   .To(sellToTemp)
                                   .At(deco);
                route.Add(relationship);
            }

            route.Add(new EntityContactsDescriptor {
                Authority = EAuthority.Trackmatic
            });
            route.Route = CreateRoute(details, site);
            route.Route.Personnel.Add(new Personnel
            {
                Id             = $"{site.Id}/personnel/{details.Driver.IDNo}",
                Name           = details.Driver.Name?.Trim(),
                IdentityNumber = details.Driver.IDNo.ToString()
            });

            return(route);
        }
Exemplo n.º 10
0
 public string ResolveDecoId(Consignment consignment, RttSiteDefault site)
 {
     if (PermanentSites.Contains(site.Id))
     {
         var decoId = CreateDecoId(consignment, site);
         return(decoId);
     }
     else
     {
         var decoId = CreateAdhocDecoId(consignment, site);
         return(decoId);
     }
 }
        public List <string> HandleGroup(IGrouping <string, Consignment> group, RttSiteDefault site)
        {
            var finalList = new List <string>();

            foreach (var consignment in group)
            {
                var tempList = consignment.Parcels.Select(p => $"{site.Id}/unit/{p.ParcelID.Trim()}");
                foreach (var item in tempList)
                {
                    finalList.Add(item);
                }
            }
            return(finalList);
        }
        private Entity CreateTempSellTo(Consignment consignment, RttSiteDefault site)
        {
            var entity = new Entity
            {
                Id        = utils.CreateSellToId(consignment, site),
                Reference = consignment.Account.AccountNo?.Trim(),
                Name      = consignment.Account.account_name?.Trim(),
            };

            entity.Requirements.Add(new RequireActionDebrief());
            entity.Requirements.Add(new RequireSignature());

            return(entity);
        }
Exemplo n.º 13
0
        private Entity CreateShipTo(Model.Address address, RttSiteDefault site)
        {
            var entity = new Entity
            {
                Id        = utils.CreateShipToId(address, site),
                Reference = address.Addr_id.ToString(),
                Name      = address.Name
            };

            entity.Requirements.Add(new RequireActionDebrief());
            entity.Requirements.Add(new RequireHandlingUnitDebrief());

            return(entity);
        }
        private RouteModel CreateRoute(RTTTripDetails details, RttSiteDefault site)
        {
            var route = new RouteModel
            {
                Name         = details.TripHeaderID,
                Id           = $"{site.Id}/{details.TripHeaderID}",
                Registration = details.Vehicle.VehRegno.CleanVehicleReg(),
                Reference    = details.TripHeaderID,
                Schedule     = true,
                StartDate    = details.TripDate.GetValueOrDefault().ToUniversalTime(),
                TemplateId   = site.RttTemplateId
            };

            return(route);
        }
        public Entity CreateGroupShipTo(IGrouping <string, Consignment> group, RttSiteDefault site)
        {
            var entity = new Entity
            {
                Id        = CreateShipToId(group, site),
                Reference = group.Select(x => x.Address.Addr_id).FirstOrDefault().ToString(),
                Name      = group.Select(x => x.Address.Name).FirstOrDefault()
            };

            entity.Requirements.Add(new RequireHandlingUnitDebrief()
            {
                CaptureQuantityPerSku = true
            });

            return(entity);
        }
Exemplo n.º 16
0
        private RouteModel CreateRoute(RTTTripDetails details, RttSiteDefault site)
        {
            var route = new RouteModel
            {
                Name         = details.TripHeaderID,
                Id           = $"{site.Id}/{details.TripHeaderID}",
                Registration = details.Vehicle.VehRegno.CleanVehicleReg(),
                Reference    = details.TripHeaderID,
                Schedule     = true,
                StartDate    = CreateDefaultStartDate(details),
                TemplateId   = site.RttTemplateId,
                Extensions   = CreateRouteExtensions(details)
            };

            return(route);
        }
Exemplo n.º 17
0
        private StopModel CreateStopModel(List <Consignment> consignments, RttSiteDefault site)
        {
            var stopModel = new StopModel
            {
                DueTime    = consignments[0].PlannedStopArrivalTime.GetValueOrDefault(),
                LocationId = utils.ResolveDecoId(consignments[0], site),
                TimeAtStop = SumConsignmentStopTimes(consignments),
                Visits     = new List <StopVisitModel>()
                {
                    CreateStopVisitModel(consignments, site)
                },
                PathToStop = new PathModel()
                {
                    Distance   = consignments[0].PlannedTravelDistance,
                    TravelTime = TimeSpan.FromMinutes(consignments[0].PlannedTravelDuration)
                }
            };

            return(stopModel);
        }
        public OLocation CreateGroupDeco(IGrouping <string, Consignment> group, RttSiteDefault site)
        {
            var lat = group.Select(x => x.Address.GpsLat).FirstOrDefault();
            var lon = group.Select(x => x.Address.GpsLong).FirstOrDefault();

            var deco = new OLocation
            {
                Name            = group.Select(x => x.Address.Name).FirstOrDefault(),
                Id              = CreateDecoId(group, site),// $"{site.Id}/{consignment.Address.Addr_Id}",
                ClientId        = site.Id,
                Reference       = group.Select(x => x.Address.Addr_id).FirstOrDefault().ToString(),
                DefaultStopTime = TimeSpan.FromMinutes(20),
                Shape           = EZoneShape.Radius,
                Coords          = new SpecializedObservableCollection <OCoord>
                {
                    new OCoord
                    {
                        Latitude  = Convert.ToDouble(string.IsNullOrWhiteSpace(lat) ? "0" : lat),
                        Longitude = Convert.ToDouble(string.IsNullOrWhiteSpace(lon) ? "0" : lon),
                        Radius    = 200
                    }
                },
                StructuredAddress = new StructuredAddress
                {
                    Street     = group.Select(x => x.Address.Address1).FirstOrDefault(),
                    Suburb     = group.Select(x => x.Address.Suburb).FirstOrDefault(),
                    City       = group.Select(x => x.Address.Town).FirstOrDefault(),
                    PostalCode = group.Select(x => x.Address.Postal).FirstOrDefault()
                },
                Entrance = new OCoord
                {
                    Latitude  = Convert.ToDouble(string.IsNullOrWhiteSpace(lat) ? "0" : lat),
                    Longitude = Convert.ToDouble(string.IsNullOrWhiteSpace(lon) ? "0" : lon),
                    Radius    = 200
                }
            };

            return(deco);
        }
Exemplo n.º 19
0
        private OLocation CreateDeco(Consignment consignment, RttSiteDefault site, RTTTripDetails trip)
        {
            var deco = new OLocation
            {
                Name            = consignment.Address.Name?.Trim(),
                Id              = utils.ResolveDecoId(consignment, site),
                ClientId        = site.Id,
                Reference       = consignment.Address.Addr_id.ToString(),
                DefaultStopTime = DetermineStopTime(consignment.PlannedStopOffloadDuration),
                Shape           = EZoneShape.Radius,
                Coords          = new SpecializedObservableCollection <OCoord>
                {
                    new OCoord
                    {
                        Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                        Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                        Radius    = 100
                    }
                },
                StructuredAddress = new StructuredAddress
                {
                    Street     = consignment.Address.Address1?.Trim(),
                    Suburb     = consignment.Address.Suburb?.Trim(),
                    City       = consignment.Address.Town?.Trim(),
                    PostalCode = consignment.Address.Postal?.Trim()
                },
                Entrance = new OCoord
                {
                    Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                    Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                    Radius    = 100
                },
                Extensions = CreateStopExtensions(trip, consignment)
            };

            return(deco);
        }
        private OLocation CreateDeco(Consignment consignment, RttSiteDefault site)
        {
            var deco = new OLocation
            {
                Name            = consignment.Address.Name?.Trim(),
                Id              = utils.ResolveDecoId(consignment, site),// $"{site.Id}/{consignment.Address.Addr_Id}",
                ClientId        = site.Id,
                Reference       = consignment.Address.Addr_id.ToString(),
                DefaultStopTime = TimeSpan.FromMinutes(20),
                Shape           = EZoneShape.Radius,
                Coords          = new SpecializedObservableCollection <OCoord>
                {
                    new OCoord
                    {
                        Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                        Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                        Radius    = 200
                    }
                },
                StructuredAddress = new StructuredAddress
                {
                    Street     = consignment.Address.Address1?.Trim(),
                    Suburb     = consignment.Address.Suburb?.Trim(),
                    City       = consignment.Address.Town?.Trim(),
                    PostalCode = consignment.Address.Postal?.Trim()
                },
                Entrance = new OCoord
                {
                    Latitude  = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLat) ? "0" : consignment.Address.GpsLat),
                    Longitude = Convert.ToDouble(string.IsNullOrEmpty(consignment.Address.GpsLong) ? "0" : consignment.Address.GpsLong),
                    Radius    = 200
                }
            };

            return(deco);
        }
        private UploadModel TranslateGrouping(RTTTripDetails details, List <IGrouping <string, Consignment> > grouping, RttSiteDefault site)
        {
            var model = new UploadModel();

            if (site == null)
            {
                return(null);
            }

            foreach (var group in grouping)
            {
                var route  = CreateGroupRoute(details, site);
                var action = CreateGroupAction(details, group, site);
                var deco   = CreateGroupDeco(group, site);
                var shipTo = CreateGroupShipTo(group, site);
                var sellTo = CreateGroupSellTo(group, site);

                model.Add(action);
                model.Add(deco);
                model.Add(shipTo);
                model.Add(sellTo);
                model.Route = route;

                var relationship = Relationship
                                   .Link(action)
                                   .To(shipTo)
                                   .At(deco)
                                   .SellTo(sellTo);
                model.Add(relationship);

                relationship.Mst         = TimeSpan.FromMinutes(15);
                relationship.MstOverride = TimeSpan.FromMinutes(15);

                model = AddHandlingUnits(group, site, model);
            }

            return(model);
        }
 public string CreateDecoId(IGrouping <string, Consignment> group, RttSiteDefault site)
 {
     return($"{site.Id}/{group.Select(x => x.Address.Addr_id).FirstOrDefault().GetValueOrDefault().ToString()}");
 }
Exemplo n.º 23
0
 public string CreateAdhocDecoId(Consignment consignment, RttSiteDefault site)
 {
     return($"{site.Id}/$tmp/{consignment.Address.Addr_id.GetValueOrDefault().ToString()}");
 }
 public string CreateShipToId(IGrouping <string, Consignment> group, RttSiteDefault site)
 {
     return($"{site.Id}/entity/{group.Select(x => x.Address.Addr_id).FirstOrDefault()}");
 }
 public string CreateSellToId(IGrouping <string, Consignment> group, RttSiteDefault site)
 {
     return($"{site.Id}/entity/{group.Select(x => x.Account.AccountNo).FirstOrDefault()}");
 }
Exemplo n.º 26
0
        private UploadModel Translate(List <Consignment> trip, RttSiteDefault site, RTTTripDetails details)
        {
            var planModel    = new PlanModel();
            var route        = new UploadModel();
            var decosToCheck = trip.Where(x => x.ConsType.ToLower() != "depot").ToList();

            decosToCheck.Add(trip[0]);
            var timeIsValid     = decosToCheck.All(x => CheckForInvalidTimes(details, x));
            var lastStopIsValid = IsLastStopInvalid(trip[trip.Count - 1]);
            var depots          = trip.Where(x => x.ConsType.ToLower() == "depot").ToList();

            if (timeIsValid && lastStopIsValid)
            {
                route.Add(site.StaticDeco);
                planModel.Stops.Add(new StopModel
                {
                    LocationId = site.StaticDeco.Id,
                    DueTime    = depots[0].PlannedStopDepartureTime.GetValueOrDefault()
                });
            }

            if (site == null)
            {
                return(null);
            }
            foreach (var consignment in trip)
            {
                if (consignment.ConsType.ToLower() == "depot")
                {
                    continue;
                }

                var action = CreateAction(details, consignment, site);

                consignment.Parcels.ForEach(p =>
                                            route.Add(new HandlingUnit
                {
                    Id                = $"{site.Id}/unit/{p.ParcelID?.Trim()}",
                    Barcode           = p.Barcode,
                    CustomerReference = p.ConsID.ToString(),
                    Quantity          = 1,
                    Weight            = p.ActualKG,
                    Dimensions        = new HandlingUnitDimensions
                    {
                        Height = p.Height,
                        Length = p.Length,
                        Width  = p.Width
                    },
                    Status = EHandlingUnitStatus.Pending
                }));

                route.Add(action);

                var sellTo = CreateSellTo(consignment, site);

                var deco = CreateDeco(consignment, site, details);

                route.Add(deco);

                var shipTo = CreateShipTo(consignment.Address, site);
                route.Add(shipTo);
                route.Add(sellTo);

                var relationship = Relationship
                                   .Link(action)
                                   .To(shipTo)
                                   .At(deco)
                                   .SellTo(sellTo);
                route.Add(relationship);
            }

            foreach (var consignments in trip.Where(x => x.ConsType.ToLower() != "depot").GroupBy(x => x.Address.Addr_id))
            {
                var stopModel = CreateStopModel(consignments.ToList(), site);
                planModel.Stops.Add(stopModel);
            }

            route.Add(new EntityContactsDescriptor {
                Authority = EAuthority.Trackmatic
            });
            route.Add(new RelationshipMstDescriptor {
                Authority = EAuthority.Lob
            });
            route.Add(new LocationDefaultStopTimeDescriptor {
                Authority = EAuthority.Lob
            });
            route.Add(new LocationExtensionsDescriptor {
                Authority = EAuthority.Lob
            });

            route.Route = CreateRoute(details, site);

            route.Route.Personnel.Add(new Personnel
            {
                Id             = $"{site.Id}/personnel/{details.Driver.IDNo?.ToString()}",
                Name           = details.Driver.Name?.Trim(),
                IdentityNumber = details.Driver.IDNo?.ToString()
            });

            if (timeIsValid && lastStopIsValid)
            {
                planModel.Stops.Add(new StopModel
                {
                    LocationId = site.StaticDeco.Id,
                    DueTime    = depots[1].PlannedStopArrivalTime.GetValueOrDefault()
                });

                route.Plan            = planModel;
                route.Route.StartDate = DeterminePlanModelDate(details);
                route.Route.IsLocked  = true;
            }
            else
            {
                route = CreateUniqueStopTime(route, 8);
            }
            return(route);
        }
        private Action CreateGroupAction(RTTTripDetails details, IGrouping <string, Consignment> group, RttSiteDefault site)
        {
            var action = new Action
            {
                Id = CreateActionId(group, site),
                InternalReference = group.Select(x => x.ConsignmentID).FirstOrDefault().ToString(),
                Reference         = group.Select(x => GetGroupId(x)).FirstOrDefault().ToString(),
                CreatedOn         = details.TripDate.GetValueOrDefault(),
                ExpectedDelivery  = details.TripDate,
                ClientId          = site.Id,
                CustomerReference = group.Select(x => x.ConsignmentID).FirstOrDefault().ToString(),
                CustomerCode      = group.Select(x => x.Address.Addr_id).FirstOrDefault().ToString(),
                IsCod             = false,
                AmountIncl        = 0,
                Nature            = EActionNature.Product,
                Weight            = group.Sum(x => x.Parcels.Select(y => y.ActualKG).Sum()),
                Pieces            = group.Select(x => x.TotalParcelCount).Sum(),
                VolumetricMass    = group.Sum(x => x.Parcels.Select(y => y.VolumizerKG).Sum()),
                HandlingUnitIds   = HandleGroup(group, site),
                Direction         = EActionDirection.Outbound
            };

            if (group.Select(x => x).FirstOrDefault().IsCollection())
            {
                action.ActionTypeId   = site.RttActionTypeCollection;
                action.ActionTypeName = "Collection";
            }
            else
            {
                action.ActionTypeId   = site.RttActionTypeDelivery;
                action.ActionTypeName = "Delivery";
            }

            return(action);
        }
Exemplo n.º 28
0
 public string CreateShipToId(Address address, RttSiteDefault site)
 {
     return($"{site.Id}/entity/{address.Addr_id.GetValueOrDefault().ToString()}");
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            var jetParkSite = new RttSiteDefault
            {
                Id                      = "394",
                RttTemplateId           = "394/2c354768-4035-4eeb-8bd6-bbe19b2c75fe",
                RttActionTypeDelivery   = "394/398d4e87-b074-432f-8a33-4082a35fd198",
                RttActionTypeCollection = "394/7f7cd168-9a61-4cbf-b634-17f52bb3e96c",
                StaticDeco              = new OLocation()
                {
                    Id       = "",
                    Name     = "",
                    ClientId = "394",
                    Coords   = new SpecializedObservableCollection <OCoord>()
                    {
                        new OCoord()
                        {
                            Longitude = 28.231505155563354,
                            Latitude  = -26.1658477711121,
                        },
                        new OCoord()
                        {
                            Longitude = 28.230292797088623,
                            Latitude  = -26.163295962866382,
                        },
                        new OCoord()
                        {
                            Longitude = 28.23786735534668,
                            Latitude  = -26.163199667122342,
                        },
                        new OCoord()
                        {
                            Longitude = 28.237717151641846,
                            Latitude  = -26.16590554725614,
                        },
                    },
                    Entrance = new OCoord()
                    {
                        Longitude = 28.233511447906494,
                        Latitude  = -26.165674442508227,
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Polygon,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var peSite = new RttSiteDefault
            {
                Id                      = "339",
                RttTemplateId           = "339/401ca3ab-d1b9-4a20-be4d-f8b5db3ec84a",
                RttActionTypeDelivery   = "339/a0a98523-e356-476b-a432-5b789c6f6788",
                RttActionTypeCollection = "339/0056d557-6951-4aa4-9a08-92572fa7e4ae",
                StaticDeco              = new OLocation()
                {
                    Id       = "339/9d0cab26-0cba-479b-92ec-dc6e0c4e3554",
                    Name     = "RTT - Port Elizabeth Depot",
                    ClientId = "339",
                    Coords   = new SpecializedObservableCollection <OCoord>
                    {
                        new OCoord()
                        {
                            Longitude = 25.616447925567627,
                            Latitude  = -33.89357360965879,
                            Radius    = 100
                        }
                    },
                    Entrance = new OCoord()
                    {
                        Latitude  = -33.89366266698077,
                        Longitude = 25.616512298583984,
                        Radius    = 100
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Radius,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var trackmaticSite = new RttSiteDefault()
            {
                Id = "110",
                RttActionTypeCollection = "110/collection",
                RttActionTypeDelivery   = "110/delivery",
                RttTemplateId           = "110/6dae0856-0874-4ea9-8510-c7051347f2e7",
                StaticDeco = new OLocation()
                {
                    Id       = "110/d7876ece-1ea1-4e1a-b0c4-a6375f1d1e1a",
                    Name     = "RTT Tarsus",
                    ClientId = "110",
                    Coords   = new SpecializedObservableCollection <OCoord>
                    {
                        new OCoord()
                        {
                            Longitude = 28.09668123722076,
                            Latitude  = -26.051563604041345,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.09471786022186,
                            Latitude  = -26.05400218935181,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.096600770950314,
                            Latitude  = -26.05517808982661,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.098574876785275,
                            Latitude  = -26.05237807790099,
                            Radius    = 100
                        }
                    },
                    Entrance = new OCoord()
                    {
                        Latitude  = -26.052060000025836,
                        Longitude = 28.098086714744564,
                        Radius    = 100
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Radius,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var ihsSite = new RttSiteDefault()
            {
                Id                      = "378",
                RttTemplateId           = "378/4d14ef5e-0a09-448b-bbb9-e3d4d9695400",
                RttActionTypeDelivery   = "378/9703c84e-39f3-45c5-a714-bb792a4b59e6",
                RttActionTypeCollection = "378/84ea6c3d-a63c-4934-983a-78f8bc706c6c",
                StaticDeco              = new OLocation()
                {
                    Id       = "378/a57af681-8760-48b3-b3c3-162815c8703f",
                    Name     = "Imperial Home Depot",
                    ClientId = "378",
                    Coords   = new SpecializedObservableCollection <OCoord>
                    {
                        new OCoord()
                        {
                            Longitude = 28.164407,
                            Latitude  = -25.888873,
                            Radius    = 100
                        }
                    },
                    Entrance = new OCoord()
                    {
                        Latitude  = -25.88819086675887,
                        Longitude = 28.164511620998383,
                        Radius    = 100
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Radius,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var tarsusSite = new RttSiteDefault()
            {
                Id                      = "351",
                RttTemplateId           = "351/cdc56cc1-6349-48c9-892b-38facef37669",
                RttActionTypeDelivery   = "351/7b7e7866-f138-48db-be34-94f1355dc938",
                RttActionTypeCollection = "351/989588c8-b269-4131-a7bf-12a6e7f43fb6",
                StaticDeco              = new OLocation()
                {
                    Id       = "351/4039fe1c-ba5c-4ebb-854a-202354a0b322",
                    Name     = "RTT - Tarsus",
                    ClientId = "351",
                    Coords   = new SpecializedObservableCollection <OCoord>
                    {
                        new OCoord()
                        {
                            Longitude = 28.095903396606445,
                            Latitude  = -26.05597326173905,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.097459077835083,
                            Latitude  = -26.05387206849224,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.096354007720944,
                            Latitude  = -26.05325519726616,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.09619307518005,
                            Latitude  = -26.052619045413532,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.094390630722042,
                            Latitude  = -26.052416632736286,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.094336986541748,
                            Latitude  = -26.055549170723882,
                            Radius    = 100
                        },
                    },
                    Entrance = new OCoord()
                    {
                        Latitude  = -26.052079277497377,
                        Longitude = 28.09802770614624,
                        Radius    = 100
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Radius,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var cptSite = new RttSiteDefault
            {
                Id                      = "334",
                RttTemplateId           = "334/f754ce40-afbd-4fff-9dfd-26b16300cede",
                RttActionTypeDelivery   = "334/9a3f0045-d530-4a2c-85a8-49af89b1dee5",
                RttActionTypeCollection = "334/a4b3c4e3-80f5-4592-9325-8e6e81b73e39",
                StaticDeco              = new OLocation()
                {
                    Id       = "334/4a831a16-aeee-4402-b375-c429fb5d63c2",
                    Name     = "RTT Cape Town Depot",
                    ClientId = "334",
                    Coords   = new SpecializedObservableCollection <OCoord>
                    {
                        new OCoord()
                        {
                            Longitude = 18.614450097084045,
                            Latitude  = -33.936964672204326,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 18.61704111099243,
                            Latitude  = -33.93530013091732,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 18.613409399986267,
                            Latitude  = -33.933559893871575,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 18.61248135566711,
                            Latitude  = -33.935122103185066,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 18.612636923789978,
                            Latitude  = -33.93587426781812,
                            Radius    = 100
                        }
                    },
                    Entrance = new OCoord()
                    {
                        Latitude  = -33.935599,
                        Longitude = 18.613556,
                        Radius    = 100
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Radius,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var styleSite = new RttSiteDefault
            {
                Id                      = "331",
                RttTemplateId           = "331/99781316-3987-4d90-9b0d-67e8a68002a4",
                RttActionTypeDelivery   = "331/5118fb3b-7252-4792-a411-5931d60ad457",
                RttActionTypeCollection = "331/d03780db-f113-4492-9c29-e7b43fbf3f21",
                StaticDeco              = new OLocation()
                {
                    Id       = "331/281ea35d-6fdf-42f2-a567-9cb571be31f4",
                    Name     = "RTT JHB Depot",
                    ClientId = "331",
                    Coords   = new SpecializedObservableCollection <OCoord>
                    {
                        new OCoord()
                        {
                            Longitude = 28.230164051055908,
                            Latitude  = -26.162987816205614,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.231601715087887,
                            Latitude  = -26.165838141751987,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.238811492919922,
                            Latitude  = -26.16591517661071,
                            Radius    = 100
                        },
                        new OCoord()
                        {
                            Longitude = 28.23887586593628,
                            Latitude  = -26.16312263046987,
                            Radius    = 100
                        }
                    },
                    Entrance = new OCoord()
                    {
                        Latitude  = -26.165626295628087,
                        Longitude = 28.233511447906494,
                        Radius    = 100
                    },
                    IsActive = true,
                    Shape    = EZoneShape.Radius,
                    Tags     = new SpecializedObservableCollection <string>()
                    {
                        "Home Base"
                    }
                }
            };

            var uploadModelFactory = new DefaultUploadModelFactory();

            var uploadModelFactoryFactory = new UploadModelFactoryFactory();

            var tripDetails = JsonConvert.DeserializeObject <RTTTripDetails>(TestTrip.Trip_9000932);

            //var uploads = uploadModelFactory.Create(consignments, trackmaticSite).ToList();

            var factory = uploadModelFactoryFactory.Create(ihsSite.Id);

            var uploads = factory.Create(tripDetails, ihsSite);

            var json  = uploads.ToJson(true);
            var json2 = uploads.Relationships.Select(x => x.ActionId).ToList().ToJson(true);

            //uploads.Route.Id = $"339/{Guid.NewGuid()}";

            var api = CreateLogin("378");

            //File.AppendAllLines("JsonTarsus.json",new[] { uploads.ToJson() });

            var asyncResponse = api.ExecuteRequest(new Upload(api.Context, uploads));

            //foreach (var item in uploads)
            //{
            //    var response = api.ExecuteRequest(new Upload(api.Context, item));
            //}
        }
Exemplo n.º 30
0
 public string CreateSellToId(Consignment consignment, RttSiteDefault site)
 {
     return($"{site.Id}/entity/{consignment.Account.AccountNo.Trim()}");
 }