0
我需要实现报告级别的dll,如果我们添加了那个dll,那么一些repors会显示..为此我创建了类库CustomeReports..in这个类文件我已经列出了一些动态的报告,你可以看到下面的代码...检查dll是否存在,并基于那个类库的使用属性
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomeReports
{
public class keyPairTextC
{
public bool keyID { get; set; }
public string keyN { get; set; }
public string keyE { get; set; }
public string keyFromDate { get; set; }
public string keyTillDate { get; set; }
}
public class CustomReport
{
public List<keyPairTextC> GetReportNameList()
{
CustomReport rpt = new CustomReport();
List<keyPairTextC> getReportName = new List<keyPairTextC>();
getReportName.Add(new keyPairTextC
{
keyID = false,
keyN = "Report2",
keyE = "R",
keyFromDate = "NA",
keyTillDate = "NA",
});
return getReportName;
}
public static string getKeyEmp(string strPropertyValue)
{
try
{
List<string> newList1 = new List<string>();
newList1 = getKeyValue(strPropertyValue).Select(C => C.keyE).ToList();
strPropertyValue = newList1[0].ToString();
}
catch (Exception ex)
{
strPropertyValue = "";
}
return strPropertyValue;
}
public static List<keyPairTextC> getKeyValue(string strPropertyValue)
{
List<keyPairTextC> newList = new List<keyPairTextC>();
CustomReport crm = new CustomReport();
newList = crm.GetReportNameList();
newList = newList.Where(c => c.keyN.Contains(strPropertyValue)).ToList();
return newList;
}
}
}
,现在我想用这个类方法getReportNameList到的情况下,本报告我加入这个库的这个DLL或引用绑定。
在我的aspx形式,我有下面的代码所以......
var className = "CustomReports";
var assemblyName = "CustomeReports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
{
if (a.FullName == assemblyName)
{
assembly = a;
break;
}
}
if (assembly != null)
{
ViewState["AssemblyInfo"] = assembly;
hdnDLLValue.Value = "1";
string strReportName = "Custom Reports";
object result = null;
result = returnDLLObject("GetReportNameList");
}
我有回报的DLL对象以下方法
public object returnDLLObject(string MethodName)
{
string className = "CustomeReports.CustomReports";
object result = null;
object classInstance = null;
if (assembly == null)
assembly=(Assembly)ViewState["AssemblyInfo"];
if (assembly != null)
{
try
{
Type _type_2 = assembly.GetType(className);
var methodInfo = _type_2.GetMethod(MethodName);
ParameterInfo[] parameters = methodInfo.GetParameters();
classInstance = Activator.CreateInstance(_type_2, null);
if (parameters.Length == 0)
{
result = methodInfo.Invoke(classInstance, null);
}
else
{
object[] parametersArray = new object[] { ViewState["nodevalue"].ToStringIC() };
result = methodInfo.Invoke(classInstance, parametersArray);
}
}
catch (Exception ex)
{
result=null;
}
}
return result;
}
所以现在我无法这份报告对象绑定到列表类型类,也无法从该类库中获取属性值...