Exemple #1
0
        public static void RaiseAppNotificationCreated(string _groupName = null)
        {
            log4net.LogManager.GetLogger(typeof(EventsHub)).Debug("Event 'AppNotificationCreated' was triggered");
            if (AppNotificationCreatedListeners.Count > 0)
            {
                ProcessListeners(AppNotificationCreatedListeners.Select(listener => new Action(() =>
                {
                    listener();
                })), true);
            }
            var guid = Guid.NewGuid();

            CLMS.AppDev.Cache.CacheManager.Current.Add(guid.ToString(), new List <object> {
            });
            Microsoft.AspNet.SignalR.IHubContext hub = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub>();
            Thread.Sleep(1);
            if (string.IsNullOrWhiteSpace(_groupName))
            {
                hub.Clients.All.appNotificationCreated(guid, DateTime.Now.Ticks);
            }
            else
            {
                hub.Clients.Group(_groupName).appNotificationCreated(guid, DateTime.Now.Ticks);
            }
        }
Exemple #2
0
        public static void RaiseOrderCalculationEnded(string user, bool withErrors, string errorDesc, System.Exception exc, string _groupName = null)
        {
            log4net.LogManager.GetLogger(typeof(EventsHub)).Debug("Event 'OrderCalculationEnded' was triggered");
            if (OrderCalculationEndedListeners.Count > 0)
            {
                ProcessListeners(OrderCalculationEndedListeners.Select(listener => new Action(() =>
                {
                    listener(user, withErrors, errorDesc, exc);
                })), true);
            }
            var guid = Guid.NewGuid();

            CLMS.AppDev.Cache.CacheManager.Current.Add(guid.ToString(), new List <object> {
                user, withErrors, errorDesc, exc
            });
            Microsoft.AspNet.SignalR.IHubContext hub = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub>();
            Thread.Sleep(1);
            if (string.IsNullOrWhiteSpace(_groupName))
            {
                hub.Clients.All.orderCalculationEnded(guid, DateTime.Now.Ticks, new { user, withErrors, errorDesc, exc });
            }
            else
            {
                hub.Clients.Group(_groupName).orderCalculationEnded(guid, DateTime.Now.Ticks, new { user, withErrors, errorDesc, exc });
            }
        }
Exemple #3
0
        public static void RaiseOrderForecastCalculationProgressUpdate(string Username, string ProgressMessage, int?Progress, string _groupName = null)
        {
            log4net.LogManager.GetLogger(typeof(EventsHub)).Debug("Event 'OrderForecastCalculationProgressUpdate' was triggered");
            if (OrderForecastCalculationProgressUpdateListeners.Count > 0)
            {
                ProcessListeners(OrderForecastCalculationProgressUpdateListeners.Select(listener => new Action(() =>
                {
                    listener(Username, ProgressMessage, Progress);
                })), true);
            }
            var guid = Guid.NewGuid();

            CLMS.AppDev.Cache.CacheManager.Current.Add(guid.ToString(), new List <object> {
                Username, ProgressMessage, Progress
            });
            Microsoft.AspNet.SignalR.IHubContext hub = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub>();
            Thread.Sleep(1);
            if (string.IsNullOrWhiteSpace(_groupName))
            {
                hub.Clients.All.orderForecastCalculationProgressUpdate(guid, DateTime.Now.Ticks, new { Username, ProgressMessage, Progress });
            }
            else
            {
                hub.Clients.Group(_groupName).orderForecastCalculationProgressUpdate(guid, DateTime.Now.Ticks, new { Username, ProgressMessage, Progress });
            }
        }
Exemple #4
0
        public static void RaiseDebugMessage(string type, string data)
        {
            if ((System.Web.HttpContext.Current == null) || (HttpContext.Current.User?.Identity?.Name != "Administrator"))
            {
                return;
            }
            log4net.LogManager.GetLogger("Events").Debug("Event 'DebugMessage' was triggered");
            RunInNewThread(() =>
            {
                foreach (var listener in DebugListeners)
                {
                    listener(type, data);
                }
            });
            var guid      = Guid.NewGuid();
            var sessionID = System.Web.HttpContext.Current?.Session == null
                            ? guid.ToString()
                            : System.Web.HttpContext.Current.Session.SessionID;

            System.Web.HttpContext.Current?.Cache.Add(guid.ToString(),
                                                      new List <object> {
                type, data
            },
                                                      null,
                                                      System.Web.Caching.Cache.NoAbsoluteExpiration,
                                                      TimeSpan.FromSeconds(30),
                                                      System.Web.Caching.CacheItemPriority.Default,
                                                      (_k, _v, _r) => { });
            Microsoft.AspNet.SignalR.IHubContext hub = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext <DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub>();
            var timeStamp = DateTime.UtcNow;
            var name      = HttpContext.Current?.User.Identity.Name;

            hub.Clients.Group(name).debug(sessionID, guid, timeStamp.Ticks, timeStamp.ToString(System.Globalization.CultureInfo.InstalledUICulture), type, data);
        }
Exemple #5
0
 private HubContext()
 {
     _hubContext = GlobalHost.ConnectionManager.GetHubContext <MIMHub>();
 }
 private ErrorMessage_Service(Microsoft.AspNet.SignalR.IHubContext hub)
 {
     _hubContext = hub;
     Message_Manager.AddFilter(SendErrorEvent);
 }