Пример #1
0
        protected override void OnInit(EventArgs e)
        {
            string reportName = Request.QueryString[DDSetup.QueryReportName];
            string aUId       = Request.QueryString[DDSetup.ReportParameterUid];

            _DatasourceType = Request.QueryString[DDSetup.QueryReportDataSourceType];


            if (string.IsNullOrEmpty(reportName) || string.IsNullOrEmpty(aUId))
            {
                Response.Write(" Can not find the report");
                return;
            }

            if (reportName.EndsWith(".rdlx") || reportName.EndsWith(".RDLX"))
            {
                // RequestID
                //PdmRequestRegisterID
                string reportFileNmae = DDSetup.ReorptSetup.ReportRootPath + @"\" + Request.QueryString[DDSetup.QueryReportName];

                //

                FileInfo         reportFile = new FileInfo(reportFileNmae);
                ReportDefinition rdl        = new ReportDefinition(reportFile);

                DataDynamicsExport.ChangDataSourceInRentime(rdl, _DatasourceType);

                ReportRuntime runtime = new ReportRuntime(rdl);

                DDSetup.SetupDDReportRuntimeParameter(runtime, aUId);

                if (runtime.Parameters[DDSetup.ReportParameterProductReferenceID] != null)
                {
                    string productReferenceId = Request.QueryString[DDSetup.ReportParameterProductReferenceID];
                    if (!string.IsNullOrEmpty(productReferenceId))
                    {
                        if (runtime.Parameters[DDSetup.ReportParameterProductReferenceID] != null)
                        {
                            runtime.Parameters[DDSetup.ReportParameterProductReferenceID].CurrentValue = int.Parse(productReferenceId);
                        }
                        else // try to setup ReportParameterMutipleProductReferenceIDs
                        {
                            runtime.Parameters[DDSetup.ReportParameterMutipleProductReferenceIDs].CurrentValue = productReferenceId;
                        }
                    }
                }

                // new added MainReferenceID 2014-01-17
                if (runtime.Parameters[DDSetup.ReportParameterMainReferenceID] != null)
                {
                    string mainReferenceID = Request.QueryString[DDSetup.ReportParameterMainReferenceID];
                    if (!string.IsNullOrEmpty(mainReferenceID))
                    {
                        runtime.Parameters[DDSetup.ReportParameterMainReferenceID].CurrentValue = int.Parse(mainReferenceID);
                    }
                }

                // new added ReportParameter MasterReferenceID 2014-01-17
                if (runtime.Parameters[DDSetup.ReportParameterMasterReferenceID] != null)
                {
                    string masterReferenceID = Request.QueryString[DDSetup.ReportParameterMasterReferenceID];
                    if (!string.IsNullOrEmpty(masterReferenceID))
                    {
                        runtime.Parameters[DDSetup.ReportParameterMasterReferenceID].CurrentValue = int.Parse(masterReferenceID);
                    }
                }

                // new added reportparamter


                if (runtime.Parameters[DDSetup.ReportParameterImageUrl] != null)
                {
                    runtime.Parameters[DDSetup.ReportParameterImageUrl].CurrentValue = DDSetup.ReorptSetup.ReportingServerImageUrl;
                }

                string PdmRequestRegisterID = Request.QueryString[DDSetup.PdmRequestRegisterID];
                if (!string.IsNullOrEmpty(PdmRequestRegisterID))
                {
                    // need format like this '1,2,3,4,6'
                    string requestContent = DDSetup.GetPdmRequestContent(PdmRequestRegisterID);

                    if (runtime.Parameters[DDSetup.ReportParameterMutipleProductReferenceIDs] != null)
                    {
                        runtime.Parameters[DDSetup.ReportParameterMutipleProductReferenceIDs].CurrentValue = requestContent;
                        // runtime.Parameters[DDSetup.ReportParameterMutipleProductReferenceIDs].Hidden
                    }
                    else// try to set ReportParameterProductReferenceID
                    {
                        runtime.Parameters[DDSetup.ReportParameterProductReferenceID].CurrentValue = requestContent;
                    }
                }


                this.WebReportViewer2.SetReport(runtime);
            }
            else if (reportName.EndsWith(".rpt") || reportName.EndsWith(".RPT"))
            {
                string cystalURL            = string.Empty;
                string lastCharOncrystalurl = DDSetup.ReorptSetup.CrystalReportPublishUrl.Substring(DDSetup.ReorptSetup.CrystalReportPublishUrl.Length - 1, 1);
                if (lastCharOncrystalurl == @"/")
                {
                    cystalURL = DDSetup.ReorptSetup.CrystalReportPublishUrl + "CrystalReportView.aspx?" + DDSetup.QueryReportName + "=" + reportName + "&" + DDSetup.ReportParameterUid + "=" + aUId;
                }
                else
                {
                    cystalURL = DDSetup.ReorptSetup.CrystalReportPublishUrl + "/CrystalReportView.aspx?" + DDSetup.QueryReportName + "=" + reportName + "&" + DDSetup.ReportParameterUid + "=" + aUId;
                }

                this.Response.Redirect(cystalURL, true);
            }
            else
            {
                Response.Write(" Can not find the report");
            }
        }
Пример #2
0
        protected override void OnInit(EventArgs e)
        {
            // test traceing
            // DDSetup.WriteReportTrace("test admin", " testtt");
            string reportName = Request.QueryString[DDSetup.QueryReportName];
            string sessionUid = Request.QueryString[DDSetup.ReportParameterUid];

            _DatasourceType = Request.QueryString[DDSetup.QueryReportDataSourceType];


            string reportFileName = string.Empty;

            int?userid = DDSetup.GetUserIdFromSessionId(sessionUid);


            if (!userid.HasValue)
            {
                Response.Write(" access denied ");
                return;
            }
            else
            {
                reportFileName = DDSetup.GetUserReportFileName(userid.Value, reportName);

                if (string.IsNullOrEmpty(reportFileName))
                {
                    Response.Write(" access denied ");
                    return;
                }
            }
            string reportFileNmae = DDSetup.ReorptSetup.ReportRootPath + @"\" + reportFileName;

            FileInfo         reportFile = new FileInfo(reportFileNmae);
            ReportDefinition rdl        = new ReportDefinition(reportFile);
            ReportRuntime    runtime    = new ReportRuntime(rdl);

            DataDynamicsExport.ChangDataSourceInRentime(rdl, _DatasourceType);



            DDSetup.SetupDDReportRuntimeParameter(runtime, userid);

            if (runtime.Parameters[DDSetup.ReportParameterProductReferenceID] != null)
            {
                string productReferenceId = Request.QueryString[DDSetup.ReportParameterProductReferenceID];
                if (!string.IsNullOrEmpty(productReferenceId))
                {
                    if (runtime.Parameters[DDSetup.ReportParameterProductReferenceID] != null)
                    {
                        runtime.Parameters[DDSetup.ReportParameterProductReferenceID].CurrentValue = int.Parse(productReferenceId);
                    }
                    else                     // try to setup ReportParameterMutipleProductReferenceIDs
                    {
                        runtime.Parameters[DDSetup.ReportParameterMutipleProductReferenceIDs].CurrentValue = productReferenceId;
                    }
                }
            }

            // new added MainReferenceID 2014-01-17
            if (runtime.Parameters[DDSetup.QueryReportParameterMainReferenceID] != null)
            {
                string mainReferenceID = Request.QueryString[DDSetup.QueryReportParameterMainReferenceID];
                if (!string.IsNullOrEmpty(mainReferenceID))
                {
                    runtime.Parameters[DDSetup.QueryReportParameterMainReferenceID].CurrentValue = int.Parse(mainReferenceID);
                }
            }

            // new added ReportParameter MasterReferenceID 2014-01-17
            if (runtime.Parameters[DDSetup.QueryReportParameterMasterReferenceID] != null)
            {
                string masterReferenceID = Request.QueryString[DDSetup.QueryReportParameterMasterReferenceID];
                if (!string.IsNullOrEmpty(masterReferenceID))
                {
                    runtime.Parameters[DDSetup.QueryReportParameterMasterReferenceID].CurrentValue = int.Parse(masterReferenceID);
                }
            }

            // new added reportparamter


            if (runtime.Parameters[DDSetup.ReportParameterImageUrl] != null)
            {
                runtime.Parameters[DDSetup.ReportParameterImageUrl].CurrentValue = DDSetup.ReorptSetup.ReportingServerImageUrl;
            }

            string PdmRequestRegisterID = Request.QueryString[DDSetup.QueryPdmRequestRegisterID];

            if (!string.IsNullOrEmpty(PdmRequestRegisterID))
            {
                // need format like this '1,2,3,4,6'
                DDSetup.SetupDynamicReportRequesttRegisterId(runtime, PdmRequestRegisterID);
            }


            this.WebReportViewer2.SetReport(runtime);
        }