You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.7 KiB
118 lines
3.7 KiB
using System;
|
|
using System.Reflection;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml.Linq;
|
|
using System.Web;
|
|
using QMAPP.Common.Web.Models;
|
|
using QMAPP.Common.Web.Controllers;
|
|
|
|
namespace QMAPP.Common.Web.Util
|
|
{
|
|
/// <summary>
|
|
/// 程序管理工具
|
|
/// </summary>
|
|
public class ProgramHelper
|
|
{
|
|
#region 获取查询模块对应ViewModel类型
|
|
|
|
/// <summary>
|
|
/// 获取查询模块对应ViewModel类型
|
|
/// </summary>
|
|
/// <param name="programName">程序名</param>
|
|
/// <returns>ViewModel类型</returns>
|
|
public Type GetProgramVMType(string programName)
|
|
{
|
|
string prgListName = System.Web.HttpContext.Current.Server.MapPath(HttpRuntime.AppDomainAppVirtualPath) + "App_Data\\ProgramList.xml";
|
|
string viewModel = "";
|
|
try
|
|
{
|
|
XElement xel = XElement.Load(prgListName);
|
|
|
|
var datas = from x in xel.Descendants("Program")
|
|
select x;
|
|
|
|
foreach (XElement d in datas)
|
|
{
|
|
if (d.Attribute("ProgramName").Value == programName)
|
|
{
|
|
viewModel = d.Attribute("ViewModel").Value;
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
if (viewModel == "")
|
|
{
|
|
throw new Exception("未对该程序模块进行相应配置。");
|
|
}
|
|
|
|
|
|
//提取程序集信息
|
|
datas = from x in xel.Descendants("AssemblyInfo")
|
|
select x;
|
|
string assemblyFile = "";
|
|
if (datas!=null)
|
|
{
|
|
foreach (XElement d in datas)
|
|
{
|
|
assemblyFile = d.Attribute("AssemblyFile").Value;
|
|
}
|
|
}
|
|
|
|
Assembly asse = Assembly.LoadFile(QController.PhysicsRootPath + @"bin\" + assemblyFile);
|
|
Type t = asse.GetType(viewModel);
|
|
return t;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("未对该程序模块进行相应配置。");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取查询条件定义
|
|
|
|
/// <summary>
|
|
/// 获取查询模块对应ViewModel类型
|
|
/// </summary>
|
|
/// <param name="programName">程序名</param>
|
|
/// <returns>ViewModel类型</returns>
|
|
public string GetProgramWhereList(string programName)
|
|
{
|
|
string prgListName = System.Web.HttpContext.Current.Server.MapPath(HttpRuntime.AppDomainAppVirtualPath) + "App_Data\\ProgramList.xml";
|
|
string whereList = "";
|
|
try
|
|
{
|
|
XElement xel = XElement.Load(prgListName);
|
|
|
|
var datas = from x in xel.Descendants("Program")
|
|
select x;
|
|
|
|
foreach (XElement d in datas)
|
|
{
|
|
if (d.Attribute("ProgramName").Value == programName)
|
|
{
|
|
if (d.Attribute("WhereList") != null)
|
|
whereList = d.Attribute("WhereList").Value;
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
if (whereList == "")
|
|
{
|
|
throw new Exception("未对该程序模块进行相应配置。");
|
|
}
|
|
return whereList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("未对该程序模块进行相应配置。");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|