Пример #1
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                string docContents = (string)e.Argument;

                /* Deserializing the response takes to long using the XMLSerializer,
                 * so much that we eneded up missing events.
                 *
                 * New approach is just to pull ou the tages we are looking for
                 */
                XDocument doc = XDocument.Parse(docContents);

                PanicEvent data = (from item in doc.Descendants("Info")
                                   select new PanicEvent
                {
                    SCI = item.Element("SCI").Value,
                    SCICode = Convert.ToInt32(item.Element("SCICode").Value)
                }).SingleOrDefault();

                if (data != null)
                {
                    data.Device = (from item in doc.Descendants("MetadataHeader")
                                   select item.Element("MetaSourceLocalID").Value).SingleOrDefault();

                    if (OnEventRaised != null)
                    {
                        OnEventRaised(data);
                    }
                }
            }catch (Exception ex)
            {
                //If there is an Error, we just want to move one
            }
        }
 private void ReceivedMessage(PanicEvent evnt)
 {
     if (evnt != null)
     {
         String msg = String.Format("{0} {1}", evnt.Device, evnt.SCICode);
         _gpi.QueueMessage(msg);
     }
 }
Пример #3
0
        static void ReceivedMessage(PanicEvent evnt)
        {
            if (evnt != null)
            {
                #if DEBUG
                Console.WriteLine(evnt);
                #endif

                String msg = String.Format("{0} {1}", evnt.Device, evnt.SCICode);
                gpi.QueueMessage(msg);
            }
        }
        public async Task <IHttpActionResult> AddPanicEvent(PanicEvent panic)
        {
            var user = manager.FindById(User.Identity.GetUserId());

            if (user.Role != UserRole.Silver)
            {
                return(BadRequest());
            }
            panic.User = (SilverUser)user;

            db.PanicEvents.Add(panic);
            await db.SaveChangesAsync();

            foreach (var carer in GetCarers())
            {
                FirebaseController.Notify(carer, "New panic event from " + user.FullName + "!", "", FCMType.PanicEvent,
                                          0);
            }

            return(Ok());
        }
Пример #5
0
        private void ReceivedMessageInovonics(PanicEvent evnt)
        {
            if (evnt != null)
            {
                string newCode = "0";

                switch (evnt.SCICode)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                    newCode = evnt.SCICode.ToString();
                    break;

                case 10:
                    newCode = "A";
                    break;

                case 11:
                    newCode = "B";
                    break;

                case 12:
                    newCode = "C";
                    break;

                case 13:
                    newCode = "D";
                    break;

                case 14:
                    newCode = "E";
                    break;

                case 15:
                    newCode = "F";
                    break;

                case 16:
                    newCode = "G";
                    break;

                case 17:
                    newCode = "H";
                    break;

                case 18:
                    newCode = "I";
                    break;

                case 21:
                    newCode = "J";
                    break;

                case 125:
                    newCode = "0";
                    break;

                default:
                    newCode = evnt.SCICode.ToString();
                    break;
                }

                String msg = String.Format("{0} {1}", evnt.Device, newCode);
                _gpi.QueueMessage(msg);
            }
        }
Пример #6
0
        private void ReceivedMessageInovonics(PanicEvent evnt)
        {
            if (evnt != null)
            {
                string newCode="0";

                switch (evnt.SCICode)
                {

                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        newCode = evnt.SCICode.ToString();
                        break;
                    case 10:
                        newCode = "A";
                        break;
                    case 11:
                        newCode = "B";
                        break;
                    case 12:
                        newCode = "C";
                        break;
                    case 13:
                        newCode = "D";
                        break;
                    case 14:
                        newCode = "E";
                        break;
                    case 15:
                        newCode = "F";
                        break;
                    case 16:
                        newCode = "G";
                        break;
                    case 17:
                        newCode = "H";
                        break;
                    case 18:
                        newCode = "I";
                        break;
                    case 21:
                        newCode = "J";
                        break;
                    case 125:
                        newCode = "0";
                        break;
                    default:
                        newCode = evnt.SCICode.ToString();
                        break;
                }

                String msg = String.Format("{0} {1}", evnt.Device, newCode);
                _gpi.QueueMessage(msg);
            }
        }