DashboardExtractDataSource.UpdateFile(DashboardExtractDataSource, Action<String, ExtractUpdateResult>, Action<String, ExtractUpdateResult>) Method
Static method to update data in the data extract file. Allows you to prevent access to the file until the data is refreshed and the file is re-created.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v24.2.Core.dll
Declaration
public static Task UpdateFile(
DashboardExtractDataSource dataSource,
Action<string, ExtractUpdateResult> onDataUpdated,
Action<string, ExtractUpdateResult> onFileUpdated
)
Parameters
Name | Type | Description |
---|---|---|
dataSource | DashboardExtractDataSource | A DashboardExtractDataSource instance that is the data source to update. |
onDataUpdated | Action<String, ExtractUpdateResult> | A Action delegate that specifies the action to perform when the data is updated. |
onFileUpdated | Action<String, ExtractUpdateResult> | A Action delegate that specifies the action to perform when the file is re-created. |
Returns
Type | Description |
---|---|
Task | The task object that is the asynchronous operation to complete. |
Example
This example demonstrates how to refresh the data contained in the Extract Data Source in web application.
To update the data extract file, an AJAX request is sent to the server and calls the server-side DashboardExtractDataSource.UpdateFile method. When the data is updated and a new extract file is created on the server, the callback returns to the client and calls the ASPxClientDashboard.Refresh method to load new data:
[WebMethod]
public static string UpdateExtractDataSource() {
DashboardExtractDataSource ds = CreateExtractDataSource();
StringBuilder sb = new StringBuilder("We updated your extract data source. ");
var task = DashboardExtractDataSource.UpdateFile(ds,
(fileName, result) => {
sb.AppendLine($"{DateTime.Now.ToString("T")} - Data Updated - {result} - {Path.GetFileName(fileName)}. ");
},
(fileName, result) => {
sb.AppendLine($"{DateTime.Now.ToString("T")} - File Updated - {result} - {Path.GetFileName(fileName)}. ");
});
// Wait until the data is refreshed in the Extract Data Source.
task.Wait();
return sb.ToString();
}
function UpdateExtractDataSource() {
$.ajax({
url: "Default.aspx/UpdateExtractDataSource",
type: "POST",
data: {},
contentType: "application/json; charset=utf-8"
}).then(function (result) {
dashboard.ReloadData();
DevExpress.ui.notify(result.d, "success", 5000);
}, function () {
DevExpress.ui.notify("We could not update extract data source.", "error", 2000)
});
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the UpdateFile(DashboardExtractDataSource, Action<String, ExtractUpdateResult>, Action<String, ExtractUpdateResult>) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.