ทำ Access Matrix
This commit is contained in:
@@ -29,6 +29,7 @@ namespace TodoAPI2.Controllers
|
||||
private ILogger<core_permission_listController> _logger;
|
||||
private Icore_permission_listService _repository;
|
||||
private IConfiguration Configuration { get; set; }
|
||||
private Iexternal_employeeService emp;
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -39,12 +40,18 @@ namespace TodoAPI2.Controllers
|
||||
/// Default constructure for dependency injection
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="inemp"></param>
|
||||
/// <param name="logger"></param>
|
||||
public core_permission_listController(ILogger<core_permission_listController> logger, Icore_permission_listService repository, IConfiguration configuration)
|
||||
public core_permission_listController(ILogger<core_permission_listController> logger,
|
||||
Icore_permission_listService repository,
|
||||
IConfiguration configuration,
|
||||
Iexternal_employeeService inemp
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_repository = repository;
|
||||
emp = inemp;
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
@@ -102,19 +109,46 @@ namespace TodoAPI2.Controllers
|
||||
{
|
||||
excel.Workbook.Worksheets.Add("Sheet1");
|
||||
|
||||
var headerRow = new List<string[]>()
|
||||
{
|
||||
new string[] { "Column Name", "Data Type", "Size", "Primary Key", "FK", "UI", "MultiSelectionTable", "Desc", "Desc EN", "row", "column", "length" }
|
||||
};
|
||||
|
||||
// Determine the header range (e.g. A1:D1)
|
||||
string headerRange = "A1:" + Char.ConvertFromUtf32(headerRow[0].Length + 64) + "1";
|
||||
|
||||
// Target a worksheet
|
||||
var worksheet = excel.Workbook.Worksheets["Sheet1"];
|
||||
|
||||
// Popular header row data
|
||||
worksheet.Cells[headerRange].LoadFromArrays(headerRow);
|
||||
var alluser = emp.GetAllUser();
|
||||
var allmenu = emp.GetAllMenu();
|
||||
|
||||
int i = 2;
|
||||
foreach (var u in alluser)
|
||||
{
|
||||
worksheet.Cells[1, i].Value = u.name;
|
||||
i++;
|
||||
}
|
||||
|
||||
int j = 2;
|
||||
foreach (var m in allmenu)
|
||||
{
|
||||
worksheet.Cells[j, 1].Value = m.display_name;
|
||||
j++;
|
||||
}
|
||||
|
||||
i = 2;
|
||||
j = 2;
|
||||
foreach (var u in alluser)
|
||||
{
|
||||
var user_menu = emp.GetMenuByUser(u.id);
|
||||
j = 2;
|
||||
foreach (var m in allmenu)
|
||||
{
|
||||
var x = (from k in user_menu
|
||||
where k.id == m.id
|
||||
select k).FirstOrDefault();
|
||||
|
||||
if(x != null)
|
||||
{
|
||||
worksheet.Cells[j, i].Value = "X";
|
||||
}
|
||||
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
//convert the excel package to a byte array
|
||||
byte[] bin = excel.GetAsByteArray();
|
||||
|
||||
Reference in New Issue
Block a user