Ejemplo n.º 1
0
        private static DM.Device _FindDevice(DM.Device[] devices, string trackingId)
        {
            Debug.Assert(devices != null);
            Debug.Assert(trackingId != null);

            foreach (DM.Device device in devices)
            {
                if (device != null &&
                    !String.IsNullOrEmpty(device.Name) &&
                    device.Name == trackingId)
                {
                    return device;
                }
            }

            return null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fills time window properties for the specified tracking stop using data from
        /// the specified stop.
        /// </summary>
        /// <param name="stop">The reference to the stop object to read time window properties
        /// from.</param>
        /// <param name="plannedDate">The date/time when time window should be applied.</param>
        /// <param name="trackingStop">The reference to the tracking stop object to
        /// fill time window properties for.</param>
        private static void _FillTimeWindows(
            Stop stop,
            DateTime plannedDate,
            DM.Stop trackingStop)
        {
            Debug.Assert(stop != null);

            switch (stop.StopType)
            {
                case StopType.Order:
                    {
                        // Use time windows from Order associated with the stop.
                        var order = (Order)stop.AssociatedObject;
                        var timeWindow = order.TimeWindow.ToDateTime(plannedDate);
                        trackingStop.TimeWindowStart1 = timeWindow.Item1.ToUniversalTime();
                        trackingStop.TimeWindowEnd1 = timeWindow.Item2.ToUniversalTime();

                        timeWindow = order.TimeWindow2.ToDateTime(plannedDate);
                        trackingStop.TimeWindowStart2 = timeWindow.Item1.ToUniversalTime();
                        trackingStop.TimeWindowEnd2 = timeWindow.Item2.ToUniversalTime();
                    }

                    break;

                case StopType.Location:
                    {
                        // Use time windows from Location associated with the stop.
                        var location = (Location)stop.AssociatedObject;
                        var timeWindow = location.TimeWindow.ToDateTime(plannedDate);
                        trackingStop.TimeWindowStart1 = timeWindow.Item1.ToUniversalTime();
                        trackingStop.TimeWindowEnd1 = timeWindow.Item2.ToUniversalTime();
                    }

                    break;

                case StopType.Lunch:
                    {
                        // Use time windows from Break associated with the stop's Route.
                        var lunch = stop.Route.Breaks
                            .OfType<TimeWindowBreak>()
                            .Where(item => item.Duration > 0.0)
                            .FirstOrDefault();
                        if (lunch != null)
                        {
                            // TODO: implement good breaks support.
                            trackingStop.TimeWindowStart1 = null;
                            trackingStop.TimeWindowEnd1 = null;
                        }
                    }

                    break;

                default:
                    break;
            }
        }