I'm currently developing a page where the user can upload an excel file which then gets transfered to a database. I'm using the Radzen framework for file upload and progress bar widgets.
The razor page:
<div class="row">
<div class="col-md-4">
<RadzenUpload Url="upload/single" Style="margin-bottom: 20px;"
Progress=@(args => OnProgress(args, "Single file upload")) ChooseText="Datei hochladen...">
</RadzenUpload>
</div>
<div class="col-md-2">
<h3>Datei-Upload</h3>
<RadzenProgressBar @bind-Value="progress" Style="margin-bottom: 20px" />
</div>
<div class="col-md-4">
</div>
</div>
<RadzenDataGrid AllowFiltering="true" EditMode="DataGridEditMode.Single" @ref="nowdealsGrid"
IsLoading="@isLoading" AllowColumnResize="true" FilterMode="FilterMode.Simple"
PageSize="25" AllowPaging="true" AllowSorting="true" Data="@nowdeals" TItem="Nowdeals"
ColumnWidth="300px" LogicalFilterOperator="LogicalFilterOperator.Or" RowUpdate="@OnUpdateRow" RowCreate="@OnCreateRow">
<Columns>
<RadzenDataGridColumn TItem="Nowdeals" Property="CommissionNumber" Title="Komm.-Nr" />
<RadzenDataGridColumn TItem="Nowdeals" Property="Aktionsfahrzeuge" Title="Aktions-Fzg." />
<RadzenDataGridColumn TItem="Nowdeals" Property="ApprovedByWs" Title="Freigabe WS" />
<RadzenDataGridColumn TItem="Nowdeals" Property="MerbagChipIn" Title="Merbag Chip in" />
</Columns>
</RadzenDataGrid>
@code{
double progress;
void OnProgress(UploadProgressArgs args, string name)
{
this.progress = args.Progress;
}
}
The URL attribute in the RadzenUpload component sends the file to my controller:
public class UploadController : Controller
{
private dbContext gwContext;
public UploadController(dbContext context)
{
this.context = context;
}
[HttpPost("upload/single")]
public IActionResult Single(IFormFile file)
{
// Here is where I read from the excel file and write it back to the database
}
}
The problem is: the progress bar only shows the status of the actual file upload through its binding to the progress variable, which is used by the RadzenProgressBar. However, the data transfer to the db (which takes about 6 to 7 seconds) is not included in this step. I would like to have a second progress bar that gives the user a feedback about the progress of the data transfer. So I would have to frequently send back the progress from the controller to the razor page. Is that possible?