Exemplo n.º 1
0
 public Trackmatic.Rest.Planning.Model.Action UpdateActionIds(Trackmatic.Rest.Planning.Model.Action action, SiteData fromSite, SiteData toSite)
 {
     // action.ActionTypeId = $"{toSite.ClientId}/{action.ActionTypeId.Split('/')[1]}";
     action.ActionTypeId   = "";
     action.Id             = action.Id.Replace(fromSite.ClientId, toSite.ClientId);
     action.ClientId       = toSite.ClientId;
     action.Entity.Id      = action.Entity.Id.Replace(fromSite.ClientId, toSite.ClientId);
     action.Entity.Deco.Id = action.Entity.Deco.Id.Replace(fromSite.ClientId, toSite.ClientId);
     return(action);
 }
        public static Trackmatic.Rest.Planning.Model.Action CreateRouteBuilderAction(SiteData _site, ActionItem action)
        {
            var routeBuilderAction = new Trackmatic.Rest.Planning.Model.Action
            {
                Id                = AsId(_site.Id, action.GetActionReference()),
                Reference         = action.GetActionReference(),
                CustomerReference = action.GetCustomerReference(),
                InternalReference = action.GetInternalReference(),
                ActionTypeId      = AsId(action.GetActionTypeName()),
                ActionTypeName    = action.GetActionTypeName(),
                // ExpectedDelivery = action.GetExpectedDeliveryDate(),
                ReceivedOn   = DateTime.UtcNow,
                Direction    = action.DetermineDirection(),
                ClientId     = _site.Id,
                Instructions = action.GetInstructions(),
                //ZoneId = "",
                //ZoneName = "",
                SellTo = new SellTo
                {
                    Id = AsEntityId(_site.Id, action.GetSellToReference()),
                    //IsAdhoc = false,
                    Name      = action.GetSellToName(),
                    Reference = action.GetSellToReference(),
                },
                Measure      = action.DetermineMeasure(),
                Restrictions = new List <string>
                {
                    action.GetRestrictions()
                },
                Entity = new Entity
                {
                    Id        = AsEntityId(_site.Id, action.GetShipToReference()),
                    Name      = action.GetShipToName(),
                    Reference = action.GetShipToReference(),
                    Mst       = action.GetMaxStopTime(),
                    Deco      = new Deco
                    {
                        Id        = AsId(_site.Id, action.GetShipToReference()),
                        Name      = action.GetShipToName(),
                        Reference = action.GetShipToReference(),
                        Position  = new List <double> {
                            action.GetShipToLongitude(), action.GetShipToLatitude()
                        }.ToArray(),
                Address = new Address
                        {
                            UnitNo            = action.GetUnitNo(),
                            BuildingName      = action.GetBuildingName(),
                            StreetNo          = action.GetStreetNo(),
                            SubDivisionNumber = action.GetSubDivisionNumber(),
                            Street            = action.GetStreet(),
                            Suburb            = action.GetSuburb(),
                            City       = action.GetCity(),
                            Province   = action.GetProvince(),
                            PostalCode = action.GetPostalCode(),
                            MapCode    = action.GetMapCode(),
                        }
                    }
                },
                Metrics = new Trackmatic.Rest.Planning.Model.Metrics
                {
                    Weight         = action.GetWeight(),
                    Pieces         = action.GetPieces(),
                    Pallets        = action.GetPallets(),
                    VolumetricMass = action.GetVolumetricMass(),
                    AmountEx       = action.GetAmountEx(),
                    AmountIncl     = action.GetAmountIncl(),
                },
            };

            return(routeBuilderAction);
        }
        public Trackmatic.Rest.Planning.Model.Action CreateRouteBuilderAction()
        {
            var existingDeco       = GetExistingDecoCoordsFromCuro(profileData.CreateLogin(), AsId(profileData.ClientId, action.ShipToAddressId));
            var routeBuilderAction = new Trackmatic.Rest.Planning.Model.Action
            {
                Id                = AsId(profileData.ClientId, action.ActionReference),
                Reference         = action.ActionReference,
                CustomerReference = action.CustomerReference,
                InternalReference = action.InternalReference,
                ActionTypeId      = AsId(action.ActionTypeId),
                ActionTypeName    = action.ActionTypeName,
                ExpectedDelivery  = action.ExpectedDelivery,
                ReceivedOn        = DateTime.UtcNow,
                Direction         = action.Direction,
                ClientId          = profileData.ClientId,
                Instructions      = action.Instructions,
                Measure           = action.Measure,
                Entity            = new Entity
                {
                    Id        = AsEntityId(profileData.ClientId, action.ShipToReference),
                    Name      = action.ShipToName,
                    Reference = action.ShipToReference,
                    Mst       = action.MaximumServiceTime,
                    Deco      = new Deco
                    {
                        Id        = AsId(profileData.ClientId, action.ShipToAddressId),
                        Name      = action.ShipToAddressName,
                        Reference = action.ShipToReference,
                        Position  = new List <double>
                        {
                            (existingDeco != null) ? existingDeco.Entrance.Longitude : 0.0,
                            (existingDeco != null) ? existingDeco.Entrance.Latitude : 0.0
                        }.ToArray(),
                Address = new Trackmatic.Rest.Planning.Model.Address
                        {
                            UnitNo            = action.UnitNo,
                            BuildingName      = action.BuildingName,
                            StreetNo          = action.StreetNo,
                            SubDivisionNumber = action.SubDivisionNumber,
                            Street            = action.Street,
                            Suburb            = action.Suburb,
                            City       = action.City,
                            Province   = action.Province,
                            PostalCode = action.PostalCode,
                            MapCode    = action.MapCode,
                        }
                    }
                },
                Metrics = new Trackmatic.Rest.Planning.Model.Metrics
                {
                    Weight         = action.Weight,
                    Pieces         = action.Pieces,
                    Pallets        = action.Pallets,
                    VolumetricMass = action.VolumetricMass,
                    AmountEx       = action.AmountEx,
                    AmountIncl     = action.AmountIncl,
                },
            };

            return(routeBuilderAction);
        }