Question - blazor scheduler - live update.
Hello.
My question is:
What would be the best method to create 'live-update' scheduler for multiple concurrent users?
I have analyzed help documents and could not find any sort of help / preferred way of moving forward,
Given that:
- App runs on Blazor server
- App uses cqrs without event sourcing (therefore database interactions are similar to "GetEventsForTimePeriod" query , "ModifyEvent" command etc, not a direct db / ef core / any form of controllers - app does not use those at all.)
- App uses Mediator pattern for cqrs.
Target:
- Multiple users concurrently can access scheduler
- One user change event - if successfull - other users scheduler instance should reflect the update.
- Same for delete / modify events.
What is the Syncfusion suggested way of moving forward?
I would be grateful for some sort of minimal working example.
With regards,
Henryk
With regards,
Henryk
SIGN IN To post a reply.
1 Reply
NR
Nevitha Ravi
Syncfusion Team
August 9, 2021 08:49 AM UTC
Hi Henryk,
Greetings from Syncfusion Support.
We have validated your query ‘live update schedule for multiple concurrent user’ at our end and prepared a sample using SignalR which can be downloaded from the following link.
|
HubConnection connection;
protected override async Task OnInitializedAsync()
{
connection.On<List<AppointmentData>>("RecieveData", OnDataChange);
connection.On<View>("ChangeView", OnChangeView);
connection.On<DateTime>("ChangeDate", OnChangeDate);
await connection.StartAsync();
}
public void OnActionCompleted(ActionEventArgs<AppointmentData> args)
{
if (args.ActionType== ActionType.EventCreate || args.ActionType == ActionType.EventRemove || args.ActionType == ActionType.EventChange)
{
connection.InvokeAsync("SendData", DataSource);
}
}
public void OnNavigating(NavigatingEventArgs args)
{
if (args.Action == "view")
{
connection.InvokeAsync("SendViewData", Enum.Parse(typeof(View), args.CurrentView.ToString(), true));
}
if (args.Action == "date")
{
connection.InvokeAsync("SendSelectedDateData", args.CurrentDate);
}
}
Task OnChangeView(View view)
{
this.CurrView = view;
this.StateHasChanged();
return Task.CompletedTask;
}
Task OnChangeDate(DateTime date)
{
this.SelectedDate = date;
this.StateHasChanged();
return Task.CompletedTask;
}
Task OnDataChange(List<AppointmentData> data)
{
this.DataSource = data;
this.StateHasChanged();
return Task.CompletedTask;
}
|
Hub page:
|
public class ScheduleHub:Hub
{
public async Task SendData(List<Index.AppointmentData> data)
{
await Clients.Others.SendAsync("RecieveData", data);
}
public async Task SendViewData(View data)
{
await Clients.Others.SendAsync("ChangeView", data);
}
public async Task SendSelectedDateData(DateTime data)
{
await Clients.Others.SendAsync("ChangeDate", data);
}
} |
Please try the above sample and let us know if you need any further assistance.
Regards,
Nevitha
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
HW Henryk Wisniewski
- Aug 6, 2021 08:23 AM UTC
- Aug 9, 2021 08:49 AM UTC