public async Task Subscriber(SubscribeEventData eventdata) { await _notificationHubContext.Clients.All.SendAsync("smartadmin.eventbus", eventdata); this._notificationService.Subscribe(eventdata); await this._unitOfWork.SaveChangesAsync(); }
private void SubscribeEvent(SubscribeEventData data) { EventRegistration eventRegistration = serviceDispatcher.SubscribeEvent(data.ServiceName, data.EventName, this, (s, e) => { if (data.CallbackId != null) { Application.Current.Dispatcher.Invoke(() => webBrowser.InvokeScript("eval", string.Format("serviceDispatcher._eventCallback('{0}', '{1}')", data.CallbackId, JsonConvert.SerializeObject(e)))); } }); eventRegistrations.AddOrUpdate(data.CallbackId, eventRegistration, (k, e) => e); }
public void Subscribe(SubscribeEventData data) { var item = new Notification() { Content = data.content, From = data.from, Title = data.title, Group = data.group, Link = data.url, PublishDate = DateTime.Now, Publisher = data.publisher, To = data.to }; this.Insert(item); }
public WebBrowserPage(IServiceDispatcher serviceDispatcher, IPlatformProvider platformProvider) { webView = new ShellWebView(); eventRegistrations = new ConcurrentDictionary <string, EventRegistration>(); webView.RegisterCallback("initialize", args => { platformProvider.ExecuteOnUIThread(() => webView.InjectJavaScript(string.Format("serviceDispatcher._initializeCallback({0});", JsonConvert.SerializeObject(serviceDispatcher.Services)))); }); webView.RegisterCallback("dispatch", args => { DispatchData dispatchData = JsonConvert.DeserializeObject <DispatchData>(args); string result = string.IsNullOrEmpty(dispatchData.InstanceName) ? JsonConvert.SerializeObject(serviceDispatcher.Dispatch(dispatchData.ServiceName, dispatchData.MethodName, dispatchData.Arguments)) : JsonConvert.SerializeObject(serviceDispatcher.Dispatch(dispatchData.ServiceName, dispatchData.InstanceName, dispatchData.MethodName, dispatchData.Arguments)); if (dispatchData.CallbackId != null) { platformProvider.ExecuteOnUIThread(() => webView.InjectJavaScript(string.Format("serviceDispatcher._dispatchCallback('{0}', {1});", dispatchData.CallbackId, result))); } }); webView.RegisterCallback("subscribeEvent", args => { SubscribeEventData subscribeEventData = JsonConvert.DeserializeObject <SubscribeEventData>(args); EventRegistration eventRegistration = serviceDispatcher.SubscribeEvent(subscribeEventData.ServiceName, subscribeEventData.EventName, this, (s, e) => { if (subscribeEventData.CallbackId != null) { platformProvider.ExecuteOnUIThread(() => webView.InjectJavaScript(string.Format("serviceDispatcher._eventCallback('{0}', '{1}');", subscribeEventData.CallbackId, JsonConvert.SerializeObject(e)))); } }); eventRegistrations.AddOrUpdate(subscribeEventData.CallbackId, eventRegistration, (k, e) => e); }); webView.RegisterCallback("unsubscribeEvent", args => { UnsubscribeEventData unsubscribeEventData = JsonConvert.DeserializeObject <UnsubscribeEventData>(args); EventRegistration eventRegistration = null; if (eventRegistrations.TryRemove(unsubscribeEventData.CallbackId, out eventRegistration)) { serviceDispatcher.UnsubscribeEvent(unsubscribeEventData.ServiceName, eventRegistration); } }); Content = webView; SetBinding(UrlProperty, new Binding("Url")); SetBinding(HtmlProperty, new Binding("Html")); webView.NavigationCompleted += (s, e) => { if (webView.Source is UrlWebViewSource) { Url = e; } }; }
public async Task Subscriber(SubscribeEventData eventdata) { this.notificationService.Subscribe(eventdata); await this.unitOfWork.SaveChangesAsync(); }