Issue
Code backup
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
@page
|
||||
@model webapp_local.Pages.IT.UserListModel
|
||||
@{
|
||||
ViewData["Title"] = "Elenco Utenti";
|
||||
}
|
||||
|
||||
@section ToolBar {
|
||||
@(Html.DevExtreme().Toolbar()
|
||||
.Items(items =>
|
||||
{
|
||||
items.Add()
|
||||
.Widget(w => w
|
||||
.Button()
|
||||
.Icon("menu")
|
||||
.OnClick("webapp_shared.onMenuButtonClick")
|
||||
)
|
||||
.Location(ToolbarItemLocation.Before);
|
||||
|
||||
items.Add()
|
||||
.Template(
|
||||
@<text>
|
||||
<div class="toolbar-label">
|
||||
<h4 id="helpText" style="display: block; margin: 0px;"><i class='@Model.NavigationItem.Icon'></i>   @Model.NavigationItem.Text</h4>
|
||||
</div>
|
||||
</text>
|
||||
)
|
||||
.LocateInMenu(ToolbarItemLocateInMenuMode.Never)
|
||||
.Location(ToolbarItemLocation.Center);
|
||||
|
||||
items.Add()
|
||||
.Widget(w => w
|
||||
.Button()
|
||||
.ID("btnAutoRefresh")
|
||||
.Icon("fas fa-recycle")
|
||||
.Hint("Refresh dei dati")
|
||||
.OnClick("reloadData")
|
||||
)
|
||||
.Location(ToolbarItemLocation.After);
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
<div id="mainDiv" class="justify-content-center">
|
||||
@(Html.DevExtreme().DataGrid()
|
||||
.ID("gridADUser")
|
||||
.DataSource(d => d.RemoteController().LoadUrl(Url.Page("UserList", "ADUserData")).Key("id"))
|
||||
.LoadPanel(loadPanel => loadPanel.Enabled(false))
|
||||
.Scrolling(scrolling => scrolling.Mode(GridScrollingMode.Infinite))
|
||||
.Sorting(sorting => sorting.Mode(GridSortingMode.None))
|
||||
.Columns(c =>
|
||||
{
|
||||
c.Add().DataField("initials").Caption("Sigla").SortOrder(SortOrder.Asc);
|
||||
c.Add().DataField("samAccountName").Caption("UserName");
|
||||
c.Add().DataField("name").Caption("Nome");
|
||||
})
|
||||
.WordWrapEnabled(true)
|
||||
.ShowBorders(true)
|
||||
.FilterRow(f => f.Visible(true))
|
||||
.FilterPanel(fp => fp.Visible(true))
|
||||
.HeaderFilter(f => f.Visible(true))
|
||||
.RemoteOperations(true)
|
||||
.ColumnAutoWidth(true)
|
||||
.AllowColumnResizing(true)
|
||||
.CacheEnabled(true)
|
||||
.RowAlternationEnabled(true)
|
||||
.CustomizeColumns("customizeColumns")
|
||||
)
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
var gridADUser;
|
||||
|
||||
$(document).ready(function () {
|
||||
gridADUser = $("#gridADUser").dxDataGrid("instance");
|
||||
|
||||
$(window).resize(function () {
|
||||
if (gridADUser != null) {
|
||||
|
||||
var res = layoutdrawer.option('height') - 15;
|
||||
if (res < 200)
|
||||
res = 200;
|
||||
|
||||
gridADUser.option("height", res);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize();
|
||||
});
|
||||
|
||||
function reloadData() {
|
||||
gridADUser.getDataSource().reload();
|
||||
}
|
||||
</Script>
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using DevExtreme.AspNet.Data;
|
||||
using DevExtreme.AspNet.Mvc;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Collections.Generic;
|
||||
using System.DirectoryServices;
|
||||
using System.DirectoryServices.AccountManagement;
|
||||
using System.Threading.Tasks;
|
||||
using webapp_local.Models;
|
||||
using webapp_shared;
|
||||
using webapp_shared.Code;
|
||||
|
||||
namespace webapp_local.Pages.IT
|
||||
{
|
||||
[UserPermissionsOneOfThesePolicies("CanViewUserList")]
|
||||
[BindProperties]
|
||||
public class UserListModel : _LayoutModel
|
||||
{
|
||||
public UserListModel(IStringLocalizer<_LayoutModel> _localizer, IConfiguration _config, UserManager<ApplicationUser> _userManager) : base(_localizer, _config, _userManager)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<JsonResult> OnGetADUserData(DataSourceLoadOptions options)
|
||||
{
|
||||
var ret = new List<ArrayADUser>();
|
||||
int index = 0;
|
||||
|
||||
using (var context = new PrincipalContext(ContextType.Domain, "pal.local"))
|
||||
{
|
||||
using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
|
||||
{
|
||||
foreach (var result in searcher.FindAll())
|
||||
{
|
||||
DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
|
||||
|
||||
ret.Add(new ArrayADUser()
|
||||
{
|
||||
id = index++,
|
||||
Initials = de.Properties.Contains("Initials") ? de.Properties["Initials"].Value.ToString() : "",
|
||||
SamAccountName = de.Properties.Contains("SamAccountName") ? de.Properties["SamAccountName"].Value.ToString() : "",
|
||||
Name = de.Properties.Contains("Name") ? de.Properties["Name"].Value.ToString() : "",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return new JsonResult(DataSourceLoader.Load(ret, options));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user