LoginLog.AddLogManagement(Convert.ToInt32(this.ME.ID),"管理员",LogCategory.Login,"管理员登陆")
/// <summary>
/// 遍历执行dll中的某个方法
/// </summary>
/// <param name="MethodName">需要遍历执行dll中的方法名称</param>
/// <returns>SortedList</returns>
public SortedList ReturnMoudleName(string MethodName)
{
SortedList sl = new SortedList();
DllDirectory=System.Configuration.ConfigurationSettings.AppSettings["DllDirectory"];
// MethodName=System.Configuration.ConfigurationSettings.AppSettings["MethodName"];
System.IO.FileInfo[] filesinfo=new System.IO.DirectoryInfo(Path.Combine(Server.MapPath("~"),DllDirectory)).GetFiles();
//循环调用生成的DLL文件数组
foreach (System.IO.FileInfo file in filesinfo)
{
//从固定的文件路径中加载程序集,判断是否为dll文件
if(file.Name.EndsWith(".dll"))
{
System.Reflection.Assembly Ass=Assembly.LoadFrom(file.FullName.ToString());
Type[] dlltypes = Ass.GetTypes();
foreach(Type dlltype in dlltypes)
{
MethodInfo minfo =dlltype.GetMethod(MethodName);
object obj = Ass.CreateInstance(dlltype.Namespace+"."+dlltype.Name);
try
{
sl.Add(dlltype.Namespace+"."+dlltype.Name,(string)minfo.Invoke(obj,new string[]{"ssss"}));
}
catch
{
sl.Add("该文件没有实现需要提供的方法!->",file.Name);
}
}
}
// else
// {
// sl.Add("很抱歉,目录中含有非标准文件->",file.Name);
// }
}
return sl;
}
#region 查询模块名称FindModuleName()
public DataTable FindModuleName()
{
WindICFrameNet.ApplicationConfig.AssemblyConfig assembly=new AssemblyConfig();
assembly.Create();
DataTable dt=new DataTable();
dt.Columns.Add("ModuleName",Type.GetType("System.String"));
dt.Columns.Add("ModuleClassName",Type.GetType("System.String"));
foreach(WindICFrameNet.ApplicationConfig.AssemblyClass assemblyClass in assembly.ClassList)
{
if(assemblyClass.UseFlag=="Manage" && assemblyClass.ModeArea!="UnView")
{
WindICFrameNet.ApplicationConfig.AssemblyMethod method=assemblyClass.FindMethodInfoByName("MoudleName");
if(method!=null)
{
if(File.Exists(Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~"),method.MethodClassPath))==true)
{
try
{
string sClient=(string)method.Invoke(null);
DataRow dr=dt.NewRow();
dr["ModuleName"]=sClient;
dr["ModuleClassName"]=assemblyClass.ClassName;
dt.Rows.Add(dr);
}
catch
{
}
}
}
}
}
return dt;
}
#endregion 查询模块名称FindModuleName()
#region 查询模块的菜单列表FindModuleMenuList
public DataTable FindModuleMenuList(string sModuleName)
{
//菜单表结构
//MenuID Menu ID
//MenuName Menu Name
//TopID Menu Top Level ID
WindICFrameNet.ApplicationConfig.AssemblyConfig assembly=new AssemblyConfig();
assembly.Create();
WindICFrameNet.ApplicationConfig.AssemblyClass assemblyClass=assembly.FindClassInfoByName(sModuleName);
DataTable dt=new DataTable();
dt.Columns.Add("MenuID",Type.GetType("System.Int32"));
dt.Columns.Add("MenuName",Type.GetType("System.String"));
dt.Columns.Add("TopID",Type.GetType("System.Int32"));
if(assemblyClass!=null)
{
if(assemblyClass.UseFlag=="Manage")
{
WindICFrameNet.ApplicationConfig.AssemblyMethod method=assemblyClass.FindMethodInfoByName("FindModuleMenu");
if(method!=null)
{
if(File.Exists(Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~"),method.MethodClassPath))==true)
{
try
{
dt=(DataTable)method.Invoke(null);
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.ToString());
}
}
}
}
}
return dt;
}
#endregion 查询模块的菜单列表FindModuleMenuList
/// <summary>
/// 将一个字符串用md5加密
/// </summary>
public class Security
{
/// <summary>
/// 加密方法
/// </summary>
/// <param name="cleanString"></param>
/// <returns></returns>
public static string Encrypt(string cleanString)
{
Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
return BitConverter.ToString(hashedBytes);
}
}
public static Pilot4.IDAL.ILogin CreateLogin()
{
string className = path + ".Login";
return (Pilot4.IDAL.ILogin)Assembly.Load(path).CreateInstance(className);
}
public static Pilot4.IDAL.IUserRoleRight CreateUserRoleRight()
{
string className = path + ".UserRoleRight";
return (Pilot4.IDAL.IUserRoleRight)Assembly.Load(path).CreateInstance(className);
}
public static Pilot4.IDAL.IHolsSetup CreateIHolsSetup()
{
string className = path + ".HolsSetup";
return (Pilot4.IDAL.IHolsSetup)Assembly.Load(path).CreateInstance(className);
}