2012-08-24 2 views
1

를보고 난 내 결정 모든 보고서를 표시하는 페이지가 아래 그림대로 :프로그래밍 변경 하이퍼 링크 URL은 영문 페이지

이 보고서는 가지고 (슬프게도, 하드 코딩) 포인트 https://myserver.bla.bla 그들에 URL 공식을 예 해당

어떻게 든 프로그래밍 방식으로 URL의 인스턴스를 찾고 다른 것으로 변경하고 싶습니다. (이 보고서가 수백 개이고 모든 링크를 이동하고 변경할 충분한 시간이 없습니다.)

저는 FieldObjects를 둘러 보았지만 형식 지정 수식을 변경하는 방법을 알 수 없었습니다. reportdocument.fieldformulas를 보면 url 서식 지정 수식이 없습니다.

공공 부분 클래스 보고서 : System.Web.UI.Page {

protected void Page_Load(object sender, EventArgs e) 
    { 
     iLogger logger = LoggingFactory.CreateLogger(); 

     ReportDocument rd = new ReportDocument(); 

     string fileName = Request.QueryString["reportfile"]; 


     if(!Regex.IsMatch(fileName,@"^[ 0-9a-zA-Z-_\\]+.rpt$")) 
     { 
      ArgumentException aex = new ArgumentException("Invalid file/path specified."); 
      logger.LogError(ActionTypes.Administration, HttpContext.Current.User.Identity.Name, 
          "Passed invalid file path to report viewer: " + fileName, aex); 
      throw aex; 
     } 



     if(Path.IsPathRooted(fileName)) 
     { 
      ArgumentException aex = new ArgumentException("Absolute path passed to report viewer."); 
      logger.LogError(ActionTypes.Administration, HttpContext.Current.User.Identity.Name, 
         "Passed invalid file path to report viewer: " + fileName, aex); 
      throw aex; 
     } 

     string rootPath = Server.MapPath("~/Reports/"); 

     string path = Path.Combine(rootPath, fileName); 



     if (File.Exists(path)) 
     { 
      rd.Load(path); 
     } 

     //get all keys starting with Prompt 
     var prompts = Request.QueryString.AllKeys.Where(q => q.StartsWith("Prompt")); 

     foreach (string promptKey in prompts) 
     { 
      //try to convert the rest of the string to an int 
      //yes, this should probably not just be a replace here... 
       string withoutPrompt = promptKey.Replace("Prompt", ""); 

       int promptVal; 
       if (int.TryParse(withoutPrompt, out promptVal)) 
       { 
        rd.SetParameterValue(promptVal, Request.QueryString[promptKey]); 
       } 
       //rd.SetParameterValue(promptKey, Request.QueryString[promptKey]); 

     CrystalReportViewer1.ReportSource = rd;       
    } 
} 

답변

1

좋아. 적어도 URL을 얻는 방법을 발견 했으므로 내가 가진 것을 모두와 공유 할 것이라고 생각했습니다.

CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument cDoc = rd.ReportClientDocument; 

     ReportObjects reportObjects = rd.ReportDefinition.ReportObjects; 



     CrystalDecisions.ReportAppServer.ReportDefModel.ReportObjects objects = 
     cDoc.ReportDefController.ReportObjectController.GetReportObjectsByKind(
      CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindField); 


     foreach(ISCRReportObject obj in objects) 

     { 
      //CrystalDecisions.ReportAppServer.ReportDefModel.ObjectFormatConditionFormulas formulas =obj.Format.ConditionFormulas[]; 
      ConditionFormula hyperFormulas = obj.Format.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeHyperlink]; 

      if (hyperFormulas != null && hyperFormulas.Text != null) 
      { 
       hyperFormulas.Text = hyperFormulas.Text.Replace(@"https://my/old/url","https://my/new/url"); 
      } 

     } 

는 사실은 내가 값이 슬프게도, 설정 후 내가 그것을 수정하고 생각이 :(

하지만 아직 공식을 수정하는 것입니다 생각하지 않습니다.

우트. 알았어요 :)

foreach(ISCRReportObject obj in objects) 

     { 
      //CrystalDecisions.ReportAppServer.ReportDefModel.ObjectFormatConditionFormulas formulas =obj.Format.ConditionFormulas[]; 
      ConditionFormula hyperFormulas = obj.Format.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeHyperlink]; 

      if (hyperFormulas != null && hyperFormulas.Text != null) 
      { 
       hyperFormulas.Text = hyperFormulas.Text.Replace(@"{{old url}}",{{new url}}); 

       cDoc.ReportDefController.ReportObjectController.Modify(
        cDoc.ReportDefController.ReportDefinition.FindObjectByName(obj.Name), obj); 

      } 

     } 

가 큰 작품 : 같은

내 수정 루틴이 보인다!

+0

가치가있는 경우 렌더링 된 후에 클라이언트 페이지에서이 값을 변경하는 것이 좋습니다 (예 : 자바 스크립트에서 URL을 변경하는 것). 그런 식으로 하위 보고서를로드하는 등의 방법으로도로드 할 수 있습니다. – Yablargo