Hi,
I've implemented process Server-Side Processing with JQuery DataTable. It's really impressive the difference in performance between client side and server side processing.
1- I've synchronize the File Table and Simple Class FileDescription.cs (thanks to @AgaveJoe ) directly in SSMS with script below.
INSERT INTO [dbo].[FileDescriptions] ([Name], [Description], [CreatedTimestamp], [UpdatedTimestamp], [ContentType])
SELECT w.name,
w.[file_type],
GETDATE(),
GETDATE(),
CASE
WHEN w.[file_type] IN ('jpg', 'png', 'gif', 'tif') THEN 'image/' + w.[file_type]
WHEN w.[file_type] IN ('pdf') THEN 'applicaiton/' + w.[file_type]
ELSE 'application/octet-stream'
END
FROM [dbo].[wSerie] as w
LEFT JOIN [dbo].[FileDescriptions] as f ON w.name = f.Name
WHERE f.Name IS NULL
AND [is_archive] = 1
2- I've implemented FileController
[HttpPost]
public IActionResult GetCustomers()
{
try
{
var draw = Request.Form["draw"].FirstOrDefault();
var start = Request.Form["start"].FirstOrDefault();
var length = Request.Form["length"].FirstOrDefault();
var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault();
var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault();
var searchValue = Request.Form["search[value]"].FirstOrDefault();
int pageSize = length != null ? Convert.ToInt32(length) : 0;
int skip = start != null ? Convert.ToInt32(start) : 0;
int recordsTotal = 0;
var customerData = (from tempcustomer in context.FileDescriptions select tempcustomer);
if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDirection)))
{
customerData = customerData.OrderBy(sortColumn + " " + sortColumnDirection);
}
if (!string.IsNullOrEmpty(searchValue))
{
customerData = customerData.Where(m => m.Name.Contains(searchValue)
|| m.Description.Contains(searchValue)
|| m.ContentType.Contains(searchValue));
}
recordsTotal = customerData.Count();
var data = customerData.Skip(skip).Take(pageSize).ToList();
var jsonData = new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data };
return Ok(jsonData);
}
catch (Exception ex)
{
throw;
}
}
So Actually, I've no link in FileDescription class with FileTable to open the File directly in column Name?
Questions :
- I've tried to implemented HierarchyId in FileDescription class but I don't know How I can Synchronise with this kind of the type field?
- How can I make sure that the File Table and FileDescription class are automatically synchronized? Because files can later be added to the File Table
Thanks in advance to your support