Ejemplo n.º 1
0
        public IHttpContext breakEdit(IHttpContext context, string breakId)
        {
            try
            {
                if (!context.token().hasPermission("breaks.write"))
                {
                    context.Response.StatusCode = HttpStatusCode.NotFound;
                    context.Response.SendResponse("");
                    return(context);
                }
                ValidationBuilder    valBuilder = new ValidationBuilder();
                ValidationCollection valCollection;
                string[]             valArray =
                {
                    "name=StartTime, isRequired=,isTime=",
                    "name=EndTime, isRequired=,isTime=",
                };

                valCollection = valBuilder.build(valArray);
                Breaks brk = BaseController.getUserInput <Breaks>(context, valCollection);
                brk.Id = uint.Parse(breakId);
                Breaks.edit(brk.Id, brk);

                context.Response.SendResponse("");
            }
            catch (Exception ex)
            {
                context.Response.StatusCode = HttpStatusCode.InternalServerError;
                context.Response.SendResponse(ex.Message);
            }

            return(context);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Shift other &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((EmployeeId == null && other.EmployeeId == null) || (EmployeeId?.Equals(other.EmployeeId) == true)) &&
                   ((LocationId == null && other.LocationId == null) || (LocationId?.Equals(other.LocationId) == true)) &&
                   ((Timezone == null && other.Timezone == null) || (Timezone?.Equals(other.Timezone) == true)) &&
                   ((StartAt == null && other.StartAt == null) || (StartAt?.Equals(other.StartAt) == true)) &&
                   ((EndAt == null && other.EndAt == null) || (EndAt?.Equals(other.EndAt) == true)) &&
                   ((Wage == null && other.Wage == null) || (Wage?.Equals(other.Wage) == true)) &&
                   ((Breaks == null && other.Breaks == null) || (Breaks?.Equals(other.Breaks) == true)) &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   ((Version == null && other.Version == null) || (Version?.Equals(other.Version) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)) &&
                   ((TeamMemberId == null && other.TeamMemberId == null) || (TeamMemberId?.Equals(other.TeamMemberId) == true)));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Remove breakpoints in the past
 /// </summary>
 public void UpdateBreakpoints()
 {
     while (Time > Breaks.First)
     {
         Breaks.ClearBreakpoint();
     }
 }
Ejemplo n.º 4
0
        public IHttpContext breakList(IHttpContext context)
        {
            try
            {
                if (!context.token().hasPermission("breaks.read"))
                {
                    context.Response.StatusCode = HttpStatusCode.NotFound;
                    context.Response.SendResponse("");
                    return(context);
                }
                var data = context.Request.QueryString;

                int pageSize = data["pagesize"] != null?int.Parse(data["pagesize"]) : 0;

                int skip = data["skip"] != null?int.Parse(data["skip"]) : 0;

                var breaks = Breaks.list(pageSize, skip);

                context.Response.SendResponse(JsonConvert.SerializeObject(breaks));
            }
            catch (Exception ex)
            {
                context.Response.StatusCode = HttpStatusCode.InternalServerError;
                context.Response.SendResponse(ex.Message);
            }
            return(context);
        }
Ejemplo n.º 5
0
        private async Task DeleteBreakExecuteAsync(Break @break)
        {
            IsEnable = false;
            await Task.Delay(100);

            var result = await Application.Current.MainPage.DisplayAlert(
                TranslationCodeExtension.GetTranslation("DeleteBreakTitle"),
                TranslationCodeExtension.GetTranslation("DeleteBreakText"),
                TranslationCodeExtension.GetTranslation("YesDeleteBreakText"),
                TranslationCodeExtension.GetTranslation("NoText"));

            if (result)
            {
                await Task.Delay(50);

                if (!_currentAccounting.IsClosed)
                {
                    _timeAccountingContext.Breaks.Remove(@break);
                    await _timeAccountingContext.SaveChangesAsync()
                    .ConfigureAwait(false);
                }
                Breaks.Remove(@break);
            }
            IsEnable = true;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Show error message for each invalid break.
        /// </summary>
        /// <param name="invalidBreaks">Collection with invalid breaks.</param>
        private void _AddErrorMessages(Breaks invalidBreaks)
        {
            // If there is only one break at route.
            if (_route.Breaks.Count == 1)
            {
                this.LogValidationResult(_validationResults,
                                         Properties.Messages.Error_VRP_BreakCannotBeVisited, _route, _key);
            }
            // If all breaks on route are invalid.
            else if (invalidBreaks.Count == _route.Breaks.Count)
            {
                this.LogValidationResult(_validationResults,
                                         Properties.Messages.Error_VRP_AllBreaksCannotBeVisited, _route, _key);
            }
            // If some of the breaks are invalid.
            else if (invalidBreaks.Count != 0)
            {
                var    invalidBreak = invalidBreaks[0] as TimeWindowBreak;
                string message;
                int    indexOfInvalidBreak = _IndexInUnsortedCollection(invalidBreak);

                // If only last break is invalid.
                if (indexOfInvalidBreak == _route.Breaks.Count - 1)
                {
                    message = string.Format(Properties.Messages.Error_VRP_LastBreakCannotBeVisited);
                }
                // If invalid some breaks, starting from the middle.
                else
                {
                    message = string.Format(Properties.Messages.Error_VRP_TheBreakAndAllAfterItCannotBeVisited,
                                            BreaksHelper.GetOrdinalNumberName(indexOfInvalidBreak));
                }
                this.LogValidationResult(_validationResults, message, _route, _key);
            }
        }
        /// <summary>
        /// If breaks are not valid - show message in MessageWindow.
        /// </summary>
        /// <param name="breaks"><c>Breaks</c> to validate.</param>
        public static void ShowErrorMessagesInMessageWindow(Breaks breaks)
        {
            List <MessageDetail> details = new List <MessageDetail>();
            string invalidPropertyFormat = ((string)App.Current.
                                            FindResource("SolveValidationPropertyInvalidFormat"));

            // Check that break has errors.
            foreach (var breakObject in breaks)
            {
                Debug.Assert(breakObject as IDataErrorInfo != null);

                string errorString = (breakObject as IDataErrorInfo).Error;

                // If it has - add new MessageDetail.
                if (!string.IsNullOrEmpty(errorString))
                {
                    details.Add(new MessageDetail(MessageType.Warning, errorString));
                }
            }

            // If we have MessageDetails add new Message to message window.
            if (details.Count > 0)
            {
                string errorMessage = ((string)App.Current.
                                       FindResource("SetupPanelValidationError"));
                App.Current.Messenger.AddMessage(MessageType.Warning, errorMessage, details);
            }
        }
Ejemplo n.º 8
0
        private static String CheckForBreaks(String str)
        {
            LOG.Debug("Check for breaks...");

            StringBuilder calc  = new StringBuilder(str);
            Match         match = null;

            do
            {
                LOG.Debug("Current: " + calc.ToString());

                match = Breaks.Match(calc.ToString());
                if (match.Success)
                {
                    LOG.Debug("Found match: " + match.Value);

                    //Get part
                    String part = match.Value.Substring(1, match.Value.Length - 2);
                    //Compute all operations to one double number
                    double value = CheckForOperatorsAndFunctions(part);

                    //Remove position included breaks
                    calc.Remove(match.Index, match.Length);
                    //Insert double number value on this place
                    calc.Insert(match.Index, value.ToString(CreateForToStringZeros()));

                    LOG.Debug("New string: " + calc.ToString());
                }
            } while (match.Success);

            LOG.Debug("Breaks result: " + str);
            return(calc.ToString());
        }
Ejemplo n.º 9
0
 public TaxTable()
 {
     Breaks.Add(150);
     Breaks.Add(350);
     Percents.Add(.1);
     Percents.Add(.2);
     Percents.Add(.3);
 }
        /// <summary>
        /// Raise propepty changed event for property 'Breaks' for routes, which property is the same
        /// as parameter.
        /// </summary>
        /// <param name="collection">IEnumerable collection with routes.</param>
        /// <param name="breaks">Breaks.</param>
        internal static void RaisePropertyChangedForRoutesBreaks(IEnumerable collection,
            Breaks breaks)
        {
            Debug.Assert(collection != null);

            foreach (Route route in collection)
                (route as IForceNotifyPropertyChanged).RaisePropertyChangedEvent(Route.PropertyNameBreaks);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Return sorted route breaks collection, which breaks are normalized.
        /// </summary>
        /// <returns>Sorted collection of normalized time window breaks.</returns>
        private Breaks _GetSortedBreaks()
        {
            Breaks sortedBreaks = _route.Breaks.Clone() as Breaks;

            sortedBreaks.Sort();

            return(sortedBreaks);
        }
Ejemplo n.º 12
0
        public bool IsInBreak()
        {
            if (Breaks == null || !Breaks.Any())
            {
                return(false);
            }

            return(!Breaks.Last().IsFinished);
        }
Ejemplo n.º 13
0
	public static int Main ()
	{
		Breaks b = new Breaks (3.0);
		b[0, 0] += 3.0;
		if (b[0, 0] != 6.0)
			return 1;

		return 0;
	}
        /// <summary>
        /// Raise propepty changed event for property 'Breaks' for routes, which property is the same
        /// as parameter.
        /// </summary>
        /// <param name="collection">IEnumerable collection with routes.</param>
        /// <param name="breaks">Breaks.</param>
        internal static void RaisePropertyChangedForRoutesBreaks(IEnumerable collection,
                                                                 Breaks breaks)
        {
            Debug.Assert(collection != null);

            foreach (Route route in collection)
            {
                (route as IForceNotifyPropertyChanged).RaisePropertyChangedEvent(Route.PropertyNameBreaks);
            }
        }
Ejemplo n.º 15
0
Archivo: test.cs Proyecto: mono/gert
	public static void Main (string [] args)
	{
		// this works
		Works w = new Works (3.0);
		w [0, 0] += 3.0;

		// this breaks
		Breaks b = new Breaks (3.0);
		b [0, 0] += 3.0;
	}
Ejemplo n.º 16
0
 public Car(int Id)
 {
     this.Id          = Id;
     Accessories      = new List <string>();
     Engine           = new Engine();
     Base             = new Base();
     Breaks           = new Breaks();
     Electronics      = new Electronics();
     ExhaustingSystem = new ExhaustingSystem();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Returns sorted List of <c>Break</c>.
        /// </summary>
        /// <param name="breaks">Breaks.</param>
        /// <returns> Sorted List of <c>Break</c>.</returns>
        public static List <Break> GetSortedList(Breaks breaks)
        {
            List <Break> tempBreaks = new List <Break>();

            for (int i = 0; i < breaks.Count; i++)
            {
                tempBreaks.Add(breaks[i]);
            }
            tempBreaks.Sort(BreaksHelper.Compare);
            return(tempBreaks);
        }
    public static int Main()
    {
        Breaks b = new Breaks(3.0);

        b[0, 0] += 3.0;
        if (b[0, 0] != 6.0)
        {
            return(1);
        }

        return(0);
    }
Ejemplo n.º 19
0
        /// <summary>
        /// Returns index of Break in breaks collection.
        /// </summary>
        /// <param name="breaks"><c>Breaks</c>.</param>
        /// <param name="br"><c>Break</c>.</param>
        /// <returns>Index of break if break is in Breaks and -1 if not.</returns>
        public static int IndexOf(Breaks breaks, Break br)
        {
            for (int i = 0; i < breaks.Count; i++)
            {
                if (breaks[i] as Break == br)
                {
                    return(i);
                }
            }

            // If no such break - return -1.
            return(-1);
        }
        /// <summary>
        /// Validator for <c>Breaks</c>.
        /// </summary>
        /// <param name="objects"><c>Breaks</c> to validate.</param>
        /// <returns>True if all breaks in collection are valid and false otherwise.</returns>
        public static bool IsValid(Breaks collection)
        {
            // If any item is invalid - return false.
            foreach (var item in collection)
            {
                if (!string.IsNullOrEmpty(item.Error))
                {
                    return(false);
                }
            }

            return(true);
        }
        public USchedule[] Build()
        {
            if (MinFinancialHours > MaxFinancialHours)
            {
                throw new Exception($"{nameof(MinFinancialHours)} can't be >= {nameof(MaxFinancialHours)}.");
            }
            if (MinStartTime > MaxStartTime)
            {
                throw new Exception($"{nameof(MinStartTime)} can't be >= {nameof(MaxStartTime)}.");
            }
            if (MinEndTime > MaxEndTime)
            {
                throw new Exception($"{nameof(MinEndTime)} can't be >= {nameof(MaxEndTime)}.");
            }
            if (Days.Count == 0)
            {
                throw new Exception($"There must be at least one day in collection {nameof(Days)}");
            }
            if (Classes.Count == 0)
            {
                throw new Exception($"There must be at least one class in collection {nameof(Classes)}");
            }


            _buildClasses = Classes
                            .Where(c => c.Days.Except(Days.AsEnumerable()).Any() == false)
                            .Where(c => c.StartTime >= MinStartTime && c.EndTime <= MaxEndTime)
                            .Where(c => Breaks.Where(b => c.Intersects(b)).Any() == false)
                            .OrderBy(a => a.StartTime).ToArray();
            _builtSchedules   = new List <USchedule>();
            _buildingSchedule = new USchedule();
            BuildFrom(0);

            var result = _builtSchedules
                         //Filter the schedules and take the ones that fit our conditions
                         .Where(s => s.HasCourses(ObligatoryCourses))
                         .Where(s => s.FirstStartTime >= MinStartTime && s.FirstStartTime <= MaxStartTime)
                         .Where(s => s.LastEndTime >= MinEndTime && s.LastEndTime <= MaxEndTime)

                         .OrderBy(c => c.Days.Count())
                         .ThenBy(c => c.MaximumBreaksTotal)
                         .ThenByDescending(c => c.FinancialHours)
                         .ThenByDescending(c => c.FirstStartTime)
                         .ThenBy(c => c.LastEndTime)
                         .ToArray();

            _builtSchedules.Clear();
            _buildClasses     = null;
            _buildingSchedule = null;
            return(result);
        }
Ejemplo n.º 22
0
    public static void Main(string[] args)

    {
        System.Console.WriteLine("This works");

        Works w = new Works(3.0);

        w[0, 0] += 3.0;

        System.Console.WriteLine("This breaks");

        Breaks b = new Breaks(3.0);

        b[0, 0] += 3.0;
    }
Ejemplo n.º 23
0
        /// <summary>
        /// Check that all route's breaks can be visited.
        /// For invalid breaks add error messages.
        /// </summary>
        /// <param name="tripTimeRange">Trip start time window.</param>
        /// <rereturns>'True' if all breaks can be visited, 'false' otherwise.</rereturns>
        private bool _CheckBreaksCanBeVisited(TimeRange tripTimeRange)
        {
            var result = true;

            // Prepare breaks for validation.
            Breaks sortedBreaks = _GetSortedBreaks();

            // Collection with breaks, which cannot be completed at time.
            Breaks invalidBreaks = new Breaks();

            // Check that all breaks can be completed in time.
            for (int i = 0; i < sortedBreaks.Count; i++)
            {
                TimeWindowBreak breakToCheck = sortedBreaks[i] as TimeWindowBreak;

                // Try to calculate break start.
                var breakStart = tripTimeRange.Intersection(breakToCheck.EffectiveFrom,
                                                            breakToCheck.EffectiveTo);

                // If break cannot be started - it is invalid. Check next break.
                if (breakStart == null)
                {
                    invalidBreaks.Add(breakToCheck);
                }
                // Check that break can be finished.
                else
                {
                    // Try calculate break finish.
                    var breakFinish = breakStart.Shift(TimeSpan.FromMinutes(breakToCheck.Duration));
                    breakFinish = breakFinish.Intersection(tripTimeRange);

                    // If break cannot be finished - it is invalid.
                    if (breakFinish == null)
                    {
                        invalidBreaks.Add(breakToCheck);
                    }
                }
            }

            // If there was invalid breaks - show error messages.
            if (invalidBreaks.Count != 0)
            {
                _AddErrorMessages(invalidBreaks);
                result = false;
            }

            return(result);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Given a break slider's new position, this will update the category related to that break.
        /// </summary>
        /// <param name="slider">The break slider.</param>
        public void UpdateCategory(BreakSlider slider)
        {
            slider.Category.Maximum = slider.Value;
            slider.Category.ApplyMinMax(_scheme.EditorSettings);
            int index = Breaks.IndexOf(slider);

            if (index < 0)
            {
                return;
            }
            if (index < Breaks.Count - 1)
            {
                Breaks[index + 1].Category.Minimum = slider.Value;
                Breaks[index + 1].Category.ApplyMinMax(_scheme.EditorSettings);
            }
        }
Ejemplo n.º 25
0
    public static void Main(string[] args)

    {

        System.Console.WriteLine("This works");

        Works w = new Works(3.0);

        w[0, 0] += 3.0;

        System.Console.WriteLine("This breaks");

        Breaks b = new Breaks(3.0);

        b[0, 0] += 3.0;

    }
Ejemplo n.º 26
0
        private bool OnTimerTick()
        {
            if (DateTime.Today > WorkDate)
            {
                if (_isTimerStarted)
                {
                    CloseEndedDayAsync();
                }
                return(_isTimerStarted = false);
            }

            if (!_currentAccounting.IsStarted)
            {
                return(_isTimerStarted);
            }
            var currentWorkTime = Breaks == null
                ? (DateTime.Now.TimeOfDay - StartWorkTime).TotalMinutes + _workedTime
                : (DateTime.Now.TimeOfDay - StartWorkTime).TotalMinutes
                                  - Breaks.Sum(d => d.EndBreakTime - d.StartBreakTime) + _workedTime;

            CurrentOverWork = _currentAccounting.IsWorking
                ? TimeSpan.FromMinutes(currentWorkTime - DateService.WorkingTime(DateTime.Now.DayOfWeek))
                : TimeSpan.FromMinutes(currentWorkTime);
            var halfTime = TimeSpan.FromMinutes(currentWorkTime
                                                - DateService.WorkingTime(DateTime.Now.DayOfWeek) / 2);

            if (CurrentOverWork > default(TimeSpan) &&
                CurrentOverWork <= TimeSpan.FromSeconds(1) &&
                _currentAccounting.IsWorking &&
                _isTimerStarted)
            {
                ShowWorkingEndAsync();
            }


            if (halfTime > default(TimeSpan) &&
                halfTime <= TimeSpan.FromSeconds(1) &&
                _currentAccounting.IsWorking &&
                _isTimerStarted)
            {
                ShowWorkingHalfAsync();
            }

            TotalOverWork = CurrentOverWork + _totalDbOverWork;
            return(_isTimerStarted);
        }
Ejemplo n.º 27
0
    private void Start()
    {
        engine = new Engine(rigidbody, axles, maxSpeed, maxMotorTorque, this);
        wheels = new Wheels(rigidbody, axles, maxSteeringAngle);
        breaks = new Breaks(axles, breakTorque);

        wheelAnimation = new WheelAnimation(rigidbody, axles, this);

        var mainWeapons = weapons;

        weapons = new Weapon[mainWeapons.Length];

        for (int i = 0; i < mainWeapons.Length; i++)
        {
            var newWeapon = ScriptableObject.Instantiate(mainWeapons[i]);
            weapons[i] = newWeapon;
        }
    }
Ejemplo n.º 28
0
        private async void CloseEndedDayAsync()
        {
            if (WorkDate == DateTime.Today)
            {
                return;
            }
            IsEnable = false;
            await Task.Delay(100);

            if (!_currentAccounting.IsStarted)
            {
                _timeAccountingContext.TimeAccounts.Remove(_currentAccounting);
            }
            else
            {
                _currentAccounting.IsClosed    = true;
                _currentAccounting.EndWorkTime = new TimeSpan(23, 59, 59);

                if (_currentAccounting.StartWorkTime > _currentAccounting.EndWorkTime)
                {
                    _currentAccounting.StartWorkTime = _currentAccounting.EndWorkTime;
                }

                var workTime = Breaks == null
                                    ? (_currentAccounting.EndWorkTime - _currentAccounting.StartWorkTime).TotalMinutes
                                    : (_currentAccounting.EndWorkTime - _currentAccounting.StartWorkTime).TotalMinutes
                               - Breaks.Sum(d => d.EndBreakTime - d.StartBreakTime);
                _currentAccounting.OverWork = _currentAccounting.IsWorking
                        ? workTime - DateService.WorkingTime(_currentAccounting.WorkDate.DayOfWeek)
                        : workTime;
                _timeAccountingContext.Entry(_currentAccounting).State = EntityState.Modified;
                DependencyService.Get <IShowNotify>()
                .CancelAll();
            }
            await _timeAccountingContext.SaveChangesAsync()
            .ConfigureAwait(false);

            var isWorkDay         = DateService.IsWorking(DateTime.Today.DayOfWeek);
            var currentAccounting = new TimeAccount
            {
                WorkDate      = DateTime.Today,
                IsWorking     = isWorkDay,
                IsStarted     = IsStarted,
                StartWorkTime = default,
Ejemplo n.º 29
0
        private async Task AddBreakExecuteAsync()
        {
            var newBreak = new Break
            {
                StartBreakTime = DateTime.Now.TimeOfDay.TotalMinutes,
                EndBreakTime   = DateTime.Now.TimeOfDay.TotalMinutes,
                TimeAccount    = _currentAccounting
            };

            if (!_currentAccounting.IsClosed)
            {
                _timeAccountingContext.Breaks.Add(newBreak);
                await _timeAccountingContext.SaveChangesAsync()
                .ConfigureAwait(false);
            }
            else
            {
                Breaks.Add(newBreak);
            }
        }
Ejemplo n.º 30
0
 public IHttpContext breakDelete(IHttpContext context, string breakId)
 {
     try
     {
         if (!context.token().hasPermission("breaks.write"))
         {
             context.Response.StatusCode = HttpStatusCode.NotFound;
             context.Response.SendResponse("");
             return(context);
         }
         Breaks.delete(uint.Parse(breakId));
         context.Response.SendResponse("");
     }
     catch (Exception ex)
     {
         context.Response.StatusCode = HttpStatusCode.InternalServerError;
         context.Response.SendResponse(ex.Message);
     }
     return(context);
 }
Ejemplo n.º 31
0
        public IHttpContext breakGet(IHttpContext context, string breakId)
        {
            try
            {
                if (!context.token().hasPermission("breaks.read"))
                {
                    context.Response.StatusCode = HttpStatusCode.NotFound;
                    context.Response.SendResponse("");
                    return(context);
                }
                Breaks brk = Breaks.get(uint.Parse(breakId));

                context.Response.SendResponse(JsonConvert.SerializeObject(brk));
            }
            catch (Exception ex)
            {
                context.Response.StatusCode = HttpStatusCode.InternalServerError;
                context.Response.SendResponse(ex.Message);
            }
            return(context);
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Initialize/reset the integration method
        /// </summary>
        public virtual void Initialize()
        {
            // Initialize variables
            Time = 0.0;
            Breaks.Clear();
            Order      = 1;
            Delta      = double.NaN;
            Prediction = null;
            DeltaOld   = new double[MaxOrder + 1];
            Solutions  = new Vector <double> [MaxOrder + 1];
            savetime   = double.NaN;
            savedelta  = double.NaN;

            // Last point was START so the current point is the point after a breakpoint (start)
            Break = true;

            // Initialize the old timesteps - none
            for (int i = 0; i < DeltaOld.Length; i++)
            {
                DeltaOld[i] = double.NaN;
            }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Method converts breaks from routes to GPRecordSet.
        /// </summary>
        /// <param name="routes">Routes collection to get breaks.</param>
        /// <param name="addSequence">Flag, showing that we must
        /// add sequence attribute to break gp feature.</param>
        /// <returns>Breaks GPRecordSet.</returns>
        public GPRecordSet ConvertBreaks(ICollection <Route> routes, bool addSequence)
        {
            Debug.Assert(routes != null);

            List <GPFeature> features = new List <GPFeature>();

            // Convert all breaks for every route to GP Features.
            foreach (Route route in routes)
            {
                Breaks breaks = (Breaks)route.Breaks.Clone();
                features.AddRange(_ConvertToGPBreaks(breaks, route, addSequence));
            }

            GPRecordSet rs = null;

            if (features.Count > 0)
            {
                rs          = new GPRecordSet();
                rs.Features = features.ToArray();
            }

            return(rs);
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Simple logic - If 2 out of 3 fail scenario fails
        /// </summary>
        /// <param name="breaks"></param>
        /// <returns></returns>
        public TestingResult AreBreaksUsable(Breaks breaks)
        {
            int           testsFailed = 0;
            StringBuilder sb          = new StringBuilder();

            if (!breaks.CableNotBroke)
            {
                testsFailed++;
                sb.Append("Breaks have the cable broken" + "\n");
            }
            if (breaks.Overheat > 100)
            {
                testsFailed++;
                sb.Append("Breaks are overheating" + "\n");
            }
            if (breaks.BrakeDistance > 20)
            {
                testsFailed++;
                sb.Append("Breaks have the break distance too big > 20" + "\n");
            }

            if (testsFailed >= 2)
            {
                return(new TestingResult()
                {
                    Passed = false,
                    ResultOfInvestigation = sb.ToString(),
                });
            }
            else
            {
                return(new TestingResult()
                {
                    Passed = true,
                });
            }
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Initializes a new instance of the <c>Route</c> class.
        /// </summary>
        /// <param name="entity">Entity initialize datas.</param>
        internal Route(DataModel.Routes entity)
            : base(entity)
        {
            Debug.Assert(0 < entity.CreationTime); // NOTE: must be inited

            _InitTimeWindow(entity);
            _breaks = Breaks.CreateFromDBString(entity.Breaks);
            _days = Days.CreateFromDBString(entity.Days);

            // If collection is in schedule - remember it schedule.routes and
            // subscribe to collection changed event.
            if (this.Schedule != null)
            {
                this.Schedule.RoutesCollectionInitialized += _ScheduleRoutesCollectionInitialized;
            }

            _InitPropertiesEvents();
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public DefaultBreaksController()
 {
     IsCheckEnabled = true;
     _oldDefaultBreaks = new Breaks();
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Returns sorted List of <c>Break</c>.
 /// </summary>
 /// <param name="breaks">Breaks.</param>
 /// <returns> Sorted List of <c>Break</c>.</returns>
 public static List<Break> GetSortedList(Breaks breaks)
 {
     List<Break> tempBreaks = new List<Break>();
     for (int i = 0; i < breaks.Count; i++)
     {
         tempBreaks.Add(breaks[i]);
     }
     tempBreaks.Sort(BreaksHelper.Compare);
     return tempBreaks;
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Returns index of Break in breaks collection.
        /// </summary>
        /// <param name="breaks"><c>Breaks</c>.</param>
        /// <param name="br"><c>Break</c>.</param>
        /// <returns>Index of break if break is in Breaks and -1 if not.</returns>
        public static int IndexOf(Breaks breaks, Break br)
        {
            for (int i = 0; i < breaks.Count; i++)
                if (breaks[i] as Break == br)
                    return i;

            // If no such break - return -1.
            return -1;
        }