Beispiel #1
0
        public static void static_sendSMS(string ID, string phoneNumber, AlgoUtils.Status type)
        {
            SMSMessage message = new SMSMessage();

            message.number = phoneNumber;
            message.status = type;


            if (ConnectionDictionary.mapUidToConnection.ContainsKey(ID))
            {
                Trace.TraceInformation(String.Format("Sending SMS {0} message to user: {1}. ConnectionId {2}",
                                                     type.ToString(), phoneNumber, ConnectionDictionary.mapUidToConnection[ID]));
                try
                {
                    hubContext.Clients.Client(ConnectionDictionary.mapUidToConnection[ID]).receiveSMS(message);
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.Message);
                }
            }
            else
            {
                Trace.TraceError(String.Format("User {0} doesn't exist", ID));
            }
        }
Beispiel #2
0
        public static void static_send(string patientID, string patientName, IEnumerable <Caregiver> caregiversArr,
                                       AlgoUtils.Status status)
        {
            Trace.TraceInformation(String.Format("Sending Patient {0} status: {1} to all caregivers", patientID,
                                                 status.ToString()));
            ConnectionDictionary.mapUidToStatus[patientID] = status; //update patient status

            SampleController sampleController = new SampleController();
            Sample           latestSample     = sampleController.GetLatestSampleForPatient(patientID);

            Message message = new Message()
            {
                ID = patientID, status = status, name = patientName, lat = latestSample.Latitude, lon = latestSample.Longitude
            };

            foreach (var caregiver in caregiversArr)
            {
                try
                {
                    ConnectionDictionary.mapUidToStatus[caregiver.Id] = status;
                    hubContext.Clients.Client(ConnectionDictionary.mapUidToConnection[caregiver.Id]).receiveNotification(message);
                    Trace.TraceInformation(String.Format("Sent message to caregiver {0}", caregiver.Id));
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.Message);
                }
            }
            //Trace.TraceInformation(String.Format("Sending message to patient for testing"));
            //try
            //{
            //    hubContext.Clients.Client(ConnectionDictionary.mapUidToConnection[patientID]).receiveNotification(message);
            //    Trace.TraceInformation(String.Format("Sent message back to patient {0}", patientName));
            //}
            //catch (Exception e)
            //{
            //    Trace.TraceError(e.Message);
            //}
        }