我想加快我一直在从事的 asp.net 项目的加载时间。其中之一dropdownlists
是通过将 sql 表中的员工列表与 Active Directory 成员资格进行比较而获得的经理列表。
这被称为Page_Load
SqlDataSource empDB = (SqlDataSource)Page.Master.FindControl("EmployeeData");
DataView dv = (DataView)empDB.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView drv in dv)
{
employeeList.Add(new Employee(int.Parse(drv["EMP_ID"].ToString()), drv ["FULL_NAME"].ToString()));
}
managerTest();
managerDropDownList.DataSource = managerList;
managerDropDownList.DataTextField = "fullName";
managerDropDownList.DataValueField = "emp_Id";
managerDropDownList.DataBind();
经理测试方法:
private void managerTest()
{
PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, "the_domain");
GroupPrincipal managersGroup = GroupPrincipal.FindByIdentity(domainContext, "Managers and Supervisors");
GroupPrincipal offManagersGroup = GroupPrincipal.FindByIdentity(domainContext, "Office Managers");
GroupPrincipal executivesGroup = GroupPrincipal.FindByIdentity(domainContext, "Executives");
GroupPrincipal managers2Group = GroupPrincipal.FindByIdentity(domainContext, "Managers");
foreach (Employee emp in employeeList)
{
UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, emp.fullName);
if (user != null)
{
if (user.IsMemberOf(managersGroup) || user.IsMemberOf(offManagersGroup) || user.IsMemberOf(executivesGroup) || user.IsMemberOf(managers2Group))
{
managerList.Add(emp);
}
}
}
}
Employee 只是一个简单的类,用于分隔名字、姓氏和全名的值。
问题是页面加载速度非常慢,并且页面上有几个控件可以回发并导致回发需要很长时间。我能做些什么来提高这项工作的效率吗?