Ejemplo n.º 1
0
        public static async Task <string> SendAsync(string groupName, Message m)
        {
            string status = WebApiTracking.SetUpSignalRTracking();

            if (status != "OK")
            {
                return(status);
            }
            await WebApiTracking.hubConnection.InvokeAsync("AddToGroup", groupName);

            await WebApiTracking.hubConnection.InvokeAsync("SendMessage", groupName, m);

            await WebApiTracking.hubConnection.InvokeAsync("RemoveFromGroup", groupName);

            return(status);
        }
Ejemplo n.º 2
0
        public static async Task SendToSignalRWithTimeUsedAsync(UserJwt user, string header, string body, string footer, Stopwatch stopwatch, DateTime timeStart, DateTime timeEnd)
        {
            if (string.IsNullOrEmpty(user.TrackingStatus))
            {
                return;
            }

            if (user.TrackingStatus != "T")
            {
                return;
            }
            if (WebApiTracking.SetUpSignalRTracking() != "OK")
            {
                return;
            }
            string trackMessage = string.Empty;

            TimeSpan ts = stopwatch.Elapsed;

            trackMessage += System.Environment.NewLine
                            + " Time : " + timeStart.ToString() + " => " + timeEnd.ToString()
                            + System.Environment.NewLine
                            + " Time used : " + String.Format("{0:00} Hours {1:00} Minutes {2:00} Seconds {3:00} Milliseconds",
                                                              ts.Hours, ts.Minutes, ts.Seconds,
                                                              ts.Milliseconds / 10)
                            + System.Environment.NewLine;


            Message m = new Message();

            m.Header    = header;
            m.Body      = body;
            m.Footer    = footer;
            m.TimeStamp = trackMessage;

            await WebApiTracking.hubConnection.InvokeAsync("AddToGroup", user.UserId);

            await WebApiTracking.hubConnection.InvokeAsync("SendMessage", user.UserId, m);

            await WebApiTracking.hubConnection.InvokeAsync("RemoveFromGroup", user.UserId);
        }