Exemple #1
0
        private IEnumerable <Message> OnAlertReceived(AlertReceived arg)
        {
            var responsible = arg.OverridePerson ?? _scheduleManager.GetPersonInCharge();
            var sentDate    = _dateTimeManager.GetNow();

            if (responsible == null)
            {
                JanelObserver.EventManager.Dispatch(new ErrorOccurred("No Responsible found"));
                return(new List <Message> {
                    new Message {
                        Description = "No Responsible found", Succeeded = false
                    }
                });
            }

            arg.Alert.Responsible = responsible;
            arg.Alert.NotificationsSent.Add(sentDate);
            arg.Alert.Actors.Add(responsible);
            arg.Alert.Status = StatusType.New;

            _janelUnitOfWork.AlertRepository.Update(arg.Alert);

            var message = $"Alert received from {arg.Alert.Service.Name}, on {_dateTimeManager.GetNow().ToString("yyyy-MM-dd hh:mm:ss")}. Message : {arg.Alert.Description}";

            return(SendNotificationWithAcknowledge(sentDate, responsible, (responsible.PreferedCommunications?.First() ?? CommunicationType.Email), message, null, arg.Alert));
        }
Exemple #2
0
        public ConnService(HubConnection connection)
        {
            this._connection = connection;

            /* All signalR responses are received here and respective action invoke*/

            _connection.On <StatusModel>("ReceiveStatus", (status) => StatusReceived?.Invoke(status));
            _connection.On <Sender>("UpdateAlerts", (sender) => HandleEventReceived?.Invoke(sender));
            _connection.On <CasesModel>("AlertBroadcast", (sender) => AlertReceived?.Invoke(sender));
            _connection.On <string, string, string>("SMSSendingSuccess", (Sid, view, agent) => SendingSuccess?.Invoke(Sid, view, agent));
            _connection.On <string, string>("SMSResponseSuccess", (Sid, response) => ResponseSuccess?.Invoke(Sid, response));
            _connection.On <string>("NewUserConnected", (id) => NewUserSync?.Invoke(id));
            _connection.On <List <UsersRank> >("UsersRank", (rank) => Ranking?.Invoke(rank));
            _connection.On <string>("DisconnectUser", (connId) => DisconnectUser?.Invoke(connId));
            _connection.On <ResponseViewModel, string>("ProgressReportA", (obj, id) => ProgressReportA?.Invoke(obj, id));
            _connection.On <EMTInfo, string>("ProgressReportB", (obj, id) => ProgressReportB?.Invoke(obj, id));
            _connection.On <MedicalInfo, string>("ProgressReportC", (obj, id) => ProgressReportC?.Invoke(obj, id));
            _connection.On <string>("Test", (obj) => Test?.Invoke(obj));
            _connection.On <string>("RestartedResponse", (obj) => Restarted?.Invoke(obj));
            _connection.On <string, string, string>("CallSuccess", (sid, sender, agent) => CallSuccess?.Invoke(sid, sender, agent));
        }
 protected virtual Task OnAlertReceived(AlertTrigger trigger, Alert alert)
 => AlertReceived == null ? Task.CompletedTask : Task.WhenAll(AlertReceived.GetInvocationList()
                                                              .Select(s => s.DynamicInvoke(trigger, alert)).Cast <Task>());