Monitor Server Progress Status Using Progressbar and SignalR

I would like to report the server's status with Syncfusion's Progressbar using SignalR such sample C# code below.


                int totalRows = dtCategories.Rows.Count;
                int rowIndex = 0;

                foreach (DataRow row in dtCategories.Rows)
                {

                       int percentage = (int)Math.Round(((double)rowIndex++ / (double)totalRows) * 100);
                       progressBar.NotifyProgress(connectionId, percentage);

                       //perform some tasks.....
               }

Please provide sample code for C# .NET 4.5 ASP.NET MVC 5 SYNCFUSION WEB (Essential JS1) VERSION 16.1.24.

Thank you

1 Reply

IB Ilakkiya Baskar Syncfusion Team June 1, 2018 10:23 AM UTC

Hi Marie,   
    
Thanks for contacting Syncfusion Support.   
  
We suggest you to use jQuery ajax to change the ProgressBar value. Here on changes in client side, the ajax request is made. Based on that, you can send the value to the ProgressBar component. Please refer to the below code,   
$(function () {   
            // Reference the auto-generated proxy for the hub.   
            var chat = $.connection.chatHub;   
            // Create a function that the hub can call back to display messages.   
            chat.client.addNewMessageToPage = function (name, message) {   
                // Add the message to the page.   
                $('#discussion').append('<li><strong>' + htmlEncode(name)   
                    + '</strong>: ' + htmlEncode(message) + '</li>');   
                $.ajax({ // use ajax to get the value   
                    type: "POST",   
                    url: "Value",   
                    async: false,   
                    dataType: "json",   
                    contentType: "text/plain",   
                    success: function (data) {   
                        debugger   
                        var progress = $("#rtlBar").data("ejProgressBar");   
                        progress.setModel({ value: data + " %" });   
                        progress.setModel({ text: data + " %" });   
   
                    },   
                    error: function () {   
                        alert('Error Loading Data');   
                    },   
                });   
                   
            };   
            // Get the user name and store it to prepend to messages.   
            $('#displayname').val(prompt('Enter your name:'''));   
           // Set initial focus to message input box.   
            $('#message').focus();   
            // Start the connection.   
            $.connection.hub.start().done(function () {   
                $('#sendmessage').click(function () {   
                    // Call the Send method on the hub.   
                    chat.server.send($('#displayname').val(), $('#message').val());   
                    // Clear text box and reset focus for next comment.   
                    $('#message').val('').focus();   
                });   
            });   
        });   
   
[controller]   
[HttpPost]   
        public ActionResult Value()   
        {   
            return Content("90"); // to send the data to the ajax method   
        }   
   
Please refer to the sample in the below location,   
   
Please let us know, if there is any concern.   
    
Regards,    
Ilakkiya B.    


Loader.
Up arrow icon