Example #1
0
 public virtual void AddAtIndexPrivateTemplates(int index, ScheduledRouteTemplate __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!privateTemplates.Contains(__item))
     {
         privateTemplates.Insert(index, __item);
     }
     if (!__item.VisibleTo.Contains(this))
     {
         __item.AddVisibleTo(this);
     }
 }
Example #2
0
 public virtual void SetPrivateTemplatesAt(ScheduledRouteTemplate __item, int __index)
 {
     if (__item == null)
     {
         privateTemplates[__index].RemoveVisibleTo(this);
     }
     else
     {
         privateTemplates[__index] = __item;
         if (!__item.VisibleTo.Contains(this))
         {
             __item.AddVisibleTo(this);
         }
     }
 }
Example #3
0
 public virtual void AddPrivateTemplates(ScheduledRouteTemplate __item)
 {
     if (__item == null)
     {
         return;
     }
     if (!privateTemplates.Contains(__item))
     {
         InternalAddPrivateTemplates(__item);
     }
     if (!__item.VisibleTo.Contains(this))
     {
         __item.AddVisibleTo(this);
     }
 }
Example #4
0
/// <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 [ScheduledRouteTemplate] instance to use as the destination.</param>
/// <returns>A copy of the object</returns>
        public virtual ScheduledRouteTemplate Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, ScheduledRouteTemplate copy = null)
        {
            if (copiedObjects == null)
            {
                copiedObjects = new Hashtable();
            }
            if (copy == null && copiedObjects.Contains(this))
            {
                return((ScheduledRouteTemplate)copiedObjects[this]);
            }
            copy = copy ?? new ScheduledRouteTemplate();
            if (!asNew)
            {
                copy.TransientId = this.TransientId;
                copy.Id          = this.Id;
            }
            copy.Origin                      = this.Origin;
            copy.Destination                 = this.Destination;
            copy.DaysOfWeek                  = this.DaysOfWeek;
            copy.PricePerPallet              = this.PricePerPallet;
            copy.PricePerKilogram            = this.PricePerKilogram;
            copy.PricePerCubicMeter          = this.PricePerCubicMeter;
            copy.TotalAvailableCapacityKG    = this.TotalAvailableCapacityKG;
            copy.EffectiveFrom               = this.EffectiveFrom;
            copy.EffectiveTo                 = this.EffectiveTo;
            copy.TypeOfGoods                 = this.TypeOfGoods;
            copy.AvailableCapacityLaden      = this.AvailableCapacityLaden;
            copy.CreatedOn                   = this.CreatedOn;
            copy.Frequency                   = this.Frequency;
            copy.IsPrivate                   = this.IsPrivate;
            copy.TotalAvailableCapacityLaden = this.TotalAvailableCapacityLaden;
            copy.TotalAvailableCapacityM3    = this.TotalAvailableCapacityM3;
            copy.AvailableCapacityKG         = this.AvailableCapacityKG;
            copy.AvailableCapacityM3         = this.AvailableCapacityM3;
            copy.FixedPrice                  = this.FixedPrice;
            copy.TruckPlate                  = this.TruckPlate;
            copy.DeliveryDate                = this.DeliveryDate;
            copy.ByRA = this.ByRA;
            if (!copiedObjects.Contains(this))
            {
                copiedObjects.Add(this, copy);
            }
            if (deep && this.owner != null)
            {
                if (!copiedObjects.Contains(this.owner))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.Owner = this.Owner;
                    }
                    else if (asNew)
                    {
                        copy.Owner = this.Owner.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.owner = this.owner.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.Owner = (RegionalAgent)copiedObjects[this.Owner];
                    }
                    else
                    {
                        copy.owner = (RegionalAgent)copiedObjects[this.Owner];
                    }
                }
            }
            copy.visibleTo = new List <LSP>();
            if (deep && this.visibleTo != null)
            {
                foreach (var __item in this.visibleTo)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddVisibleTo(__item);
                        }
                        else
                        {
                            copy.AddVisibleTo(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddVisibleTo((LSP)copiedObjects[__item]);
                    }
                }
            }
            if (deep && this.ownerLSP != null)
            {
                if (!copiedObjects.Contains(this.ownerLSP))
                {
                    if (asNew && reuseNestedObjects)
                    {
                        copy.OwnerLSP = this.OwnerLSP;
                    }
                    else if (asNew)
                    {
                        copy.OwnerLSP = this.OwnerLSP.Copy(deep, copiedObjects, true);
                    }
                    else
                    {
                        copy.ownerLSP = this.ownerLSP.Copy(deep, copiedObjects, false);
                    }
                }
                else
                {
                    if (asNew)
                    {
                        copy.OwnerLSP = (LSP)copiedObjects[this.OwnerLSP];
                    }
                    else
                    {
                        copy.ownerLSP = (LSP)copiedObjects[this.OwnerLSP];
                    }
                }
            }
            copy.visibleToRAs = new List <RegionalAgent>();
            if (deep && this.visibleToRAs != null)
            {
                foreach (var __item in this.visibleToRAs)
                {
                    if (!copiedObjects.Contains(__item))
                    {
                        if (asNew && reuseNestedObjects)
                        {
                            copy.AddVisibleToRAs(__item);
                        }
                        else
                        {
                            copy.AddVisibleToRAs(__item.Copy(deep, copiedObjects, asNew));
                        }
                    }
                    else
                    {
                        copy.AddVisibleToRAs((RegionalAgent)copiedObjects[__item]);
                    }
                }
            }
            return(copy);
        }