Esempio n. 1
0
        public IQueryable <Schedule> GetAll(bool showPastSchedules, Guid?personId)
        {
            if (personId.HasValue)
            {
                return(_unitOfWork.ScheduleRepository.GetList().Where(s => (showPastSchedules || s.EndAt >= _dateTimeManager.GetNow()) && s.Responsible.Id.Equals(personId.Value)));
            }

            return(_unitOfWork.ScheduleRepository.GetList().Where(s => (showPastSchedules || s.EndAt >= _dateTimeManager.GetNow())));
        }
Esempio n. 2
0
 public FibonacciNumberMessage Build(FibonacciNumber number)
 {
     return(new FibonacciNumberMessage
            (
                id: guidManager.GetNew(),
                createdAt: dateTimeManager.GetNow(),
                data: new FibonacciNumber
                (
                    index: number.Index,
                    value: number.Value
                )
            ));
 }
Esempio n. 3
0
        private IEnumerable <Message> OnMessageWithAcknowledgeToSend(MessageWithAcknowledge arg)
        {
            var sentDate = _dateTimeManager.GetNow();
            var message  = arg.Message;

            if (arg.From != null)
            {
                message = $"From : {arg.From.Name} \n {arg.Message}";
            }

            var alert = new Alert
            {
                Responsible = arg.To,
                Status      = StatusType.New
            };

            alert.NotificationsSent.Add(sentDate);
            alert.Actors.Add(arg.To);

            _janelUnitOfWork.AlertRepository.Insert(alert);

            return(SendNotificationWithAcknowledge(sentDate, arg.To, (arg.To.PreferedCommunications?.FirstOrDefault() ?? CommunicationType.Email), message, null, alert));
        }
Esempio n. 4
0
        private IEnumerable <Message> ValidatePendingAlerts(TaskTimerElapsed arg)
        {
            foreach (var alert in _ongoingAlerts)
            {
                switch (alert.Status)
                {
                case StatusType.Acknowledge:
                case StatusType.Fixed:
                case StatusType.Transferring:
                    if (alert.UpdatedAt.AddMinutes(60) >= _dateTimeManager.GetNow())
                    {
                        EscalateAlert(alert);
                    }
                    break;

                case StatusType.Escalated:
                    if (alert.UpdatedAt.AddMinutes(60) >= _dateTimeManager.GetNow())
                    {
                        //In Deep shit !
                        var newResponsible = _scheduleManager.GetNextPersonInCharge(alert.Responsible);

                        alert.Status       = StatusType.Transferring;
                        alert.Description += $"\n\nAlert were escalated but was still not responded.";
                        alert.UpdatedAt    = _dateTimeManager.GetNow();

                        _unitOfWork.AlertRepository.Update(alert);

                        JanelObserver.EventManager.Dispatch(new AlertChanged(alert, StatusType.Transferring.ToString()));
                        JanelObserver.EventManager.Dispatch(new AlertReceived(alert, newResponsible));
                    }
                    break;
                }
            }

            return(JanelObserver.Success());
        }