Esempio n. 1
0
        public static void Mock(int id)
        {
            using (var db = new RescContext())
            {
                var user = db.FirstResponders.SingleOrDefault(r => r.Id == id);
                if (user != null)
                {
                    return;
                }

                user = new FirstResponder {
                    Id = id
                };
                user.Name        = "TestName" + id;
                user.Description = "TestDescription" + id;

                db.FirstResponders.Add(user);

                db.SaveChanges();
            }
        }
Esempio n. 2
0
        public void SendNotification(FirstResponder responder, Intervention intervention)
        {
            var pushEndpoint = responder.PushEndpoint;
            var p256dh       = responder.PushKey;
            var auth         = responder.PushAuth;

            var subject    = @"mailto:[email protected]";
            var publicKey  = @"BOYIC7mz-ejuM6Nq4AFlZn3lYfA4NpxHI62RwubkdOEcY1qysVLGvtWXXKdoZYg6mMVujYYNfvMvGr7P8ChtII4";
            var privateKey = @"hgg0q6HVAtKwb1AKeYJlIkyQbqRfxujp6hULhflh6f8";

            var subscription = new PushSubscription(pushEndpoint, p256dh, auth);
            var vapidDetails = new VapidDetails(subject, publicKey, privateKey);

            var webPushClient = new WebPushClient();

            try
            {
                webPushClient.SendNotification(subscription, "{\"id\": " + intervention.Id + ", \"userid\": " + responder.Id + ", \"overview\": \"" + intervention.Overview + "\"}", vapidDetails);
            }
            catch (WebPushException exception)
            {
                Console.WriteLine("Http STATUS code" + exception.StatusCode);
            }
        }
Esempio n. 3
0
        public override void SendEvent(NSEvent theEvent)
        {
            DebugUtility.WriteInfoIfChanged(theEvent);

            // See notes in IsKeyWindow below.
            if (disposed)
            {
                return;
            }

            lastEventType = theEvent.Type;
            currentEvent  = theEvent;

            switch (theEvent.Type)
            {
            case NSEventType.LeftMouseDown:
            case NSEventType.RightMouseDown:
            case NSEventType.OtherMouseDown:
            case NSEventType.BeginGesture:
                if (PreprocessMouseDown(theEvent))
                {
                    return;
                }
                break;

            case NSEventType.LeftMouseDragged:
                if (PreProcessMouseDragged(theEvent))
                {
                    return;
                }
                break;

            case NSEventType.LeftMouseUp:
            case NSEventType.RightMouseUp:
            case NSEventType.OtherMouseUp:
                if (PreProcessMouseUp(theEvent))
                {
                    return;
                }
                break;

            case NSEventType.ScrollWheel:
                if (PreprocessScrollWheel(theEvent))
                {
                    return;
                }
                break;

            case NSEventType.KeyUp:
            case NSEventType.KeyDown:
                // Emulation of ToolStrip's modal filter
                if (Application.KeyboardCapture is ToolStripDropDown capture)
                {
                    var resp = FirstResponder;
                    var h    = resp?.Handle ?? IntPtr.Zero;
                    if (h != IntPtr.Zero)
                    {
                        if (!ToolStripManager.IsChildOfActiveToolStrip(h))
                        {
                            resp = capture.Handle.AsNSObject <NSResponder>();
                        }
                    }

                    if (resp != null)
                    {
                        if (theEvent.Type == NSEventType.KeyDown)
                        {
                            resp.KeyDown(theEvent);
                        }
                        else
                        {
                            resp.KeyUp(theEvent);
                        }
                        return;
                    }
                }

                // Deliver key messages also to SWF controls that are wrappers of native controls.
                // This gives them a the chance to handle special keys
                if (!FirstResponder.IsSwfControl() && !(FirstResponder is WindowsEventResponder))
                {
                    var control = Control.FromChildHandle(FirstResponder.Handle);
                    if (control != null && control.Handle.ToNSObject() is NSView obj)
                    {
                        theEvent.ToKeyMsg(out Msg msg, out IntPtr wParam, out IntPtr lParam);
                        if (theEvent.KeyCode != (int)NSKey.Escape)                                 // Preserve ESC for closing IME window
                        {
                            if (IntPtr.Zero != driver.SendMessage(control.Handle, msg, wParam, lParam))
                            {
                                return;
                            }
                        }
                    }
                }

                break;
            }

            base.SendEvent(theEvent);
            currentEvent = null;
        }