2017-04-12 58 views
0

보고서 수준 dll을 구현해야합니다. 여기서 dll을 추가하면 일부 리포러지가 표시됩니다.이 클래스의 CustomeReports .. 클래스 파일을 생성했습니다. 당신이 코드 아래에 볼 수 난 ...체크 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; 
     } 
    } 
} 

일부 동적 보고서를 나열했다 그리고 지금은 내가이 라이브러리의 DLL 또는 참조를 추가하고 경우에이 보고서를 결합하는이 클래스의 메소드 getReportNameList를 사용하고 싶습니다. 내가 코드를 아래에있는 내 영문 양식에 따라서

...

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"); 
      } 

난 반환이 너무

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; 
     } 

지금 내가 목록에이 보고서 개체를 바인딩 할 수 없습니다입니다 방법 아래에있는 객체 DLL이 클래스 클래스 또한 해당 클래스 라이브러리에서 속성 값을 얻을 수 없습니다 ....

답변

0

너무 많은 검색 후 나는 dll을 찾고 keypairtext 속성을 사용하는 방법을 발견 ....덕분에 여기

이 파일을 확인하는 방법 및 DLL이 반환 부울 ​​값을

 internal static bool FileOrDirectoryExists(string name) 
     { 
      return (Directory.Exists(name) || File.Exists(name)); 
     } 

존재하고 .. DLL을 발견하고 그 클래스 라이브러리 속성을 사용하는 aspx 페이지 내 아래 코드입니다 당신이

string path = Server.MapPath(@"../CustomReports/CustomeReports.dll"); 

     if (FileOrDirectoryExists(path)) 
     { 
      var className = "CustomReports"; 
      var ProductVersion = FileVersionInfo.GetVersionInfo(path).ProductVersion; 
      var assemblyName = "CustomeReports, Version=" + ProductVersion.ToStringIC() + ", Culture=neutral, PublicKeyToken=null"; 
      assembly = Assembly.LoadFrom(path); 

      // ViewState["AssemblyInfo"] = assembly; 
      hdnDLLValue.Value = "1"; 
      string strReportName = "Custom Reports"; 
      object result = null; 
      result = returnDLLObject("GetReportNameList"); 
      int a = SpectraBL.Application.AccessControl.ToInt32IC(); 

      if (result != null) 
      { 
       if (result is IEnumerable) 
       { 
        List<object> list = new List<object>(); 
        var enumerator = ((IEnumerable)result).GetEnumerator(); 
        while (enumerator.MoveNext()) 
        { 
         list.Add(enumerator.Current); 
        } 
        List<dynamic> dynamicList = list.Select(x => (dynamic)x).ToList(); 
        if (dynamicList.Count != 0) 
        { 
         Childnode = new TreeNode("<span id='reportgrp' class='reportmenu label' onclick= OnNodeClick('G','" + strReportName + "','1'); > " + strReportName + " </span>", "Dynamic Reports"); 
         Childnode.SelectAction = TreeNodeSelectAction.None; 
         TreeView1.Nodes.Add(Childnode); 
         for (var i = 0; i < dynamicList.Count; i++) 
         { 
          string strChildName = dynamicList[i].ReportName; 
          if (dynamicList[i].isDisplay) 
          { 
           TreeNode Namenode = new TreeNode(); 
           if (ReportID == dynamicList[i].Reportid) 
           { 
            //With selection on pageload 
            Namenode = new TreeNode("<span id='report" + dynamicList[i].ReportName + "' class='reportmenu label selected' onclick= OnNodeClick('C','" + dynamicList[i].Reportid + "','1'); > " + strChildName + " </span>", strChildName); 
           } 
           else 
           { 
            //Without selection 
            Namenode = new TreeNode("<span id='report" + dynamicList[i].ReportName + "' class='reportmenu label' onclick= OnNodeClick('C','" + dynamicList[i].Reportid + "','1'); > " + strChildName + " </span>", strChildName); 
           } 
           Namenode.SelectAction = TreeNodeSelectAction.None; 
           Childnode.ChildNodes.Add(Namenode); 
          } 
         } 
        } 
       } 
      } 
     } 

을 볼 수 있습니다 아래의 코드에서, 그래서 페이지로드에 내가 여기 t의 인스턴스를 생성합니다 내 returnDLLObject 방법입니다 ... 보고서를 결합하는 기능을 가지고

) 그는 클래스와 반환 객체 .. 당신이 의심 어떤 쿼리 나있는 경우 알려 주시기 토론한다

public object returnDLLObject(string MethodName) 
     { 
      string className = "CustomeReports.CustomReports"; 
      object result = null; 
      object classInstance = null; 
      string path = Server.MapPath(@"../CustomReports/CustomeReports.dll"); 

      // if (!FileOrDirectoryExists(path)) 
      assembly = Assembly.LoadFrom(path); 

      if (FileOrDirectoryExists(path)) 
      { 
       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) 
       { 
        //Error.BLErrorDesc = ex.Message; 
        result = null; 
       } 
      } 
      return result; 
     } 

... 감사합니다 ...