示例#1
0
        public void PathVolumeDetail_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _utilsbo_legs_pathvolumedetail = new DSS3_LogisticsPoolingForUrbanDistribution.BO.LegVolumeDetails
            {
                FreeSpace   = 222222.22M,
                Time        = "LegVolumeDetails_Time",
                Distance    = 5449,
                CurrentLoad = 222222.22M,
            };
            var _utilsbo_legs_pathvolumedetail2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.LegVolumeDetails
            {
                FreeSpace   = 222222.22M,
                Time        = "LegVolumeDetails_Time",
                Distance    = 9672,
                CurrentLoad = 222222.22M,
            };
            var _utilsbo_shipment_pathvolumedetail = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Shipment
            {
                Owner          = "Shipment_Owner",
                DepartureTime  = now,
                CurrentStatus  = "Shipment_CurrentStatus",
                Temperature    = "Shipment_Temperature",
                LoadPercentage = 9004,
                TotalVolume    = 222222.22M,
                AverageVolume  = 222222.22M,
                MaxTravelTime  = 6166,
            };

            new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.PathVolumeDetail>(Session)
            .CheckProperty(p => p.TotalTime, "PathVolumeDetail_TotalTime")
            .CheckBag(p => p.Legs, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.LegVolumeDetails>
            {
                _utilsbo_legs_pathvolumedetail,
                _utilsbo_legs_pathvolumedetail2
            }))
            .CheckReference(p => p.Shipment, _utilsbo_shipment_pathvolumedetail)
            .VerifyTheMappings();
        }
示例#2
0
        public void Route_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _vrpsolution_vehicule_routes = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Shipment
            {
                Owner          = "Shipment_Owner",
                DepartureTime  = now,
                CurrentStatus  = "Shipment_CurrentStatus",
                Temperature    = "Shipment_Temperature",
                LoadPercentage = 8535,
                TotalVolume    = 222222.22M,
                AverageVolume  = 222222.22M,
                MaxTravelTime  = 6241,
            };
            var _vrpsolution_activities_routes = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Activity
            {
                TravelDistance = 5150,
                TravelDuration = 5883,
            };
            var _vrpsolution_activities_routes2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Activity
            {
                TravelDistance = 1169,
                TravelDuration = 3355,
            };

            new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.Route>(Session)
            .CheckProperty(p => p.TotalTime, 2213)
            .CheckProperty(p => p.TotalDistance, 1506)
            .CheckReference(p => p.Vehicule, _vrpsolution_vehicule_routes)
            .CheckBag(p => p.Activities, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.Activity>
            {
                _vrpsolution_activities_routes,
                _vrpsolution_activities_routes2
            }))
            .VerifyTheMappings();
        }
        public void ShippingOrder_persistence_test()
        {
            DateTime now = DateTime.Now;

            // Get datetime without milliseconds
            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var _actionsbo_shipment_shippingorders = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Shipment
            {
                Owner          = "Shipment_Owner",
                DepartureTime  = now,
                CurrentStatus  = "Shipment_CurrentStatus",
                Temperature    = "Shipment_Temperature",
                LoadPercentage = 9319,
                TotalVolume    = 222222.22M,
                AverageVolume  = 222222.22M,
                MaxTravelTime  = 7944,
            };
            var _actionsbo_shipment_shippingorders2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Shipment
            {
                Owner          = "Shipment_Owner",
                DepartureTime  = now,
                CurrentStatus  = "Shipment_CurrentStatus",
                Temperature    = "Shipment_Temperature",
                LoadPercentage = 5253,
                TotalVolume    = 222222.22M,
                AverageVolume  = 222222.22M,
                MaxTravelTime  = 823,
            };
            var _ordersbo_departurepoint_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Location
            {
                Name     = "Location_Name",
                Street   = "Location_Street",
                City     = "Location_City",
                Country  = "Location_Country",
                Number   = "Location_Number",
                PostCode = "Location_PostCode",
                Label    = "Location_Label",
            };
            var _ordersbo_arrivalpoint_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Location
            {
                Name     = "Location_Name",
                Street   = "Location_Street",
                City     = "Location_City",
                Country  = "Location_Country",
                Number   = "Location_Number",
                PostCode = "Location_PostCode",
                Label    = "Location_Label",
            };
            var _ordersbo_statusevolution_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.StatusEvolution
            {
                TimeChanged = now,
                Description = "StatusEvolution_Description",
            };
            var _ordersbo_statusevolution_shippingorder2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.StatusEvolution
            {
                TimeChanged = now,
                Description = "StatusEvolution_Description",
            };
            var _ordersbo_parent_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder
            {
                DepartureDate   = now,
                ArrivalDate     = now,
                Shipper         = "ShippingOrder_Shipper",
                Carrier         = "ShippingOrder_Carrier",
                ItemDescription = "ShippingOrder_ItemDescription",
                Conditions      = "ShippingOrder_Conditions",
                AggregateVolume = 222222.22M,
                Priority        = 9512,
            };
            var _ordersbo_plannedvolume_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume
            {
                Weight = 222222.22M,
            };
            var _ordersbo_plannedvolume_shippingorder2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume
            {
                Weight = 222222.22M,
            };
            var _ordersbo_actualvolume_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume
            {
                Weight = 222222.22M,
            };
            var _ordersbo_actualvolume_shippingorder2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume
            {
                Weight = 222222.22M,
            };
            var _ordersbo_itemtype_shippingorder = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ItemType
            {
                Description = "ItemType_Description",
                Temperature = 6695,
            };

            new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder>(Session)
            .CheckProperty(p => p.DepartureDate, now)
            .CheckProperty(p => p.ArrivalDate, now)
            .CheckProperty(p => p.Shipper, "ShippingOrder_Shipper")
            .CheckProperty(p => p.Carrier, "ShippingOrder_Carrier")
            .CheckProperty(p => p.ItemDescription, "ShippingOrder_ItemDescription")
            .CheckProperty(p => p.Conditions, "ShippingOrder_Conditions")
            .CheckProperty(p => p.AggregateVolume, 222222.22M)
            .CheckProperty(p => p.Priority, 5417)
            .CheckBag(p => p.Shipment, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.Shipment>
            {
                _actionsbo_shipment_shippingorders,
                _actionsbo_shipment_shippingorders2
            }))
            .CheckReference(p => p.DeparturePoint, _ordersbo_departurepoint_shippingorder)
            .CheckReference(p => p.ArrivalPoint, _ordersbo_arrivalpoint_shippingorder)
            .CheckBag(p => p.StatusEvolution, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.StatusEvolution>
            {
                _ordersbo_statusevolution_shippingorder,
                _ordersbo_statusevolution_shippingorder2
            }))
            .CheckReference(p => p.Parent, _ordersbo_parent_shippingorder)
            .CheckBag(p => p.PlannedVolume, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume>
            {
                _ordersbo_plannedvolume_shippingorder,
                _ordersbo_plannedvolume_shippingorder2
            }))
            .CheckBag(p => p.ActualVolume, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume>
            {
                _ordersbo_actualvolume_shippingorder,
                _ordersbo_actualvolume_shippingorder2
            }))
            .CheckReference(p => p.ItemType, _ordersbo_itemtype_shippingorder)
            .VerifyTheMappings();
        }
/// <summary>
/// Copies the current object to a new instance
/// </summary>
/// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
/// <param name="copiedObjects">Objects that should be reused</param>
/// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
/// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
/// <param name="copy">Optional - An existing [Shipment] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual Shipment Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, Shipment copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((Shipment)copiedObjects[this]);
            }
            copy = copy ?? new Shipment();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Owner          = this.Owner;
            copy.DepartureTime  = this.DepartureTime;
            copy.CurrentStatus  = this.CurrentStatus;
            copy.Temperature    = this.Temperature;
            copy.LoadPercentage = this.LoadPercentage;
            copy.TotalVolume    = this.TotalVolume;
            copy.AverageVolume  = this.AverageVolume;
            copy.MaxTravelTime  = this.MaxTravelTime;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            copy.shippingOrders = new List <ShippingOrder>();
            if (deep && this.shippingOrders != null)
            {
                foreach (var __item in this.shippingOrders)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddShippingOrders(__item);
                        }
                        else
                        {
                            copy.AddShippingOrders(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddShippingOrders((ShippingOrder)copiedObjects[__item]);
                    }
                }
            }
            copy.shipmentStatus = new List <ShipmentStatus>();
            if (deep && this.shipmentStatus != null)
            {
                foreach (var __item in this.shipmentStatus)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddShipmentStatus(__item);
                        }
                        else
                        {
                            copy.AddShipmentStatus(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddShipmentStatus((ShipmentStatus)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.departurePoint != null)
            {
                if (!copiedObjects.Contains(this.departurePoint))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.DeparturePoint = this.DeparturePoint;
                    }
                    else if (asNew)
                    {
                        copy.DeparturePoint = this.DeparturePoint.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.departurePoint = this.departurePoint.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.DeparturePoint = (Location)copiedObjects[this.DeparturePoint];
                    }
                    else
                    {
                        copy.departurePoint = (Location)copiedObjects[this.DeparturePoint];
                    }
                }
            }
            if (deep && this.finalDestination != null)
            {
                if (!copiedObjects.Contains(this.finalDestination))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.FinalDestination = this.FinalDestination;
                    }
                    else if (asNew)
                    {
                        copy.FinalDestination = this.FinalDestination.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.finalDestination = this.finalDestination.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.FinalDestination = (Location)copiedObjects[this.FinalDestination];
                    }
                    else
                    {
                        copy.finalDestination = (Location)copiedObjects[this.FinalDestination];
                    }
                }
            }
            if (deep && this.driver != null)
            {
                if (!copiedObjects.Contains(this.driver))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Driver = this.Driver;
                    }
                    else if (asNew)
                    {
                        copy.Driver = this.Driver.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.driver = this.driver.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Driver = (Driver)copiedObjects[this.Driver];
                    }
                    else
                    {
                        copy.driver = (Driver)copiedObjects[this.Driver];
                    }
                }
            }
            if (deep && this.occupiedVolume != null)
            {
                if (!copiedObjects.Contains(this.occupiedVolume))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.OccupiedVolume = this.OccupiedVolume;
                    }
                    else if (asNew)
                    {
                        copy.OccupiedVolume = this.OccupiedVolume.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.occupiedVolume = this.occupiedVolume.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.OccupiedVolume = (CustomVolume)copiedObjects[this.OccupiedVolume];
                    }
                    else
                    {
                        copy.occupiedVolume = (CustomVolume)copiedObjects[this.OccupiedVolume];
                    }
                }
            }
            copy.acceptedConditions = new List <Condition>();
            if (deep && this.acceptedConditions != null)
            {
                foreach (var __item in this.acceptedConditions)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddAcceptedConditions(__item);
                        }
                        else
                        {
                            copy.AddAcceptedConditions(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddAcceptedConditions((Condition)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.vehiculeType != null)
            {
                if (!copiedObjects.Contains(this.vehiculeType))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.VehiculeType = this.VehiculeType;
                    }
                    else if (asNew)
                    {
                        copy.VehiculeType = this.VehiculeType.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.vehiculeType = this.vehiculeType.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.VehiculeType = (Vehicule)copiedObjects[this.VehiculeType];
                    }
                    else
                    {
                        copy.vehiculeType = (Vehicule)copiedObjects[this.VehiculeType];
                    }
                }
            }
            copy.path = new List <Point>();
            if (deep && this.path != null)
            {
                foreach (var __item in this.path)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddPath(__item);
                        }
                        else
                        {
                            copy.AddPath(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddPath((Point)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }
/// <summary>
///     Returns true if self and the provided entity have the same Id values
///     and the Ids are not of the default Id value
/// </summary>
        protected bool HasSameNonDefaultIdAs(Shipment compareTo)
        {
            return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
        }