private Stream genericReportSetting(ReportDocument report, HttpContext httpctx) { PropertyBag connectionAttributes = new PropertyBag(); connectionAttributes.Add("Auto Translate", "-1"); connectionAttributes.Add("Connect Timeout", "15"); connectionAttributes.Add("Data Source", ConfigurationManager.AppSettings["Server"]); connectionAttributes.Add("General Timeout", "0"); connectionAttributes.Add("Initial Catalog", ConfigurationManager.AppSettings["Database"]); connectionAttributes.Add("Integrated Security", false); connectionAttributes.Add("Locale Identifier", "1040"); connectionAttributes.Add("OLE DB Services", "-5"); connectionAttributes.Add("Provider", "SQLOLEDB"); connectionAttributes.Add("Tag with column collation when possible", "0"); connectionAttributes.Add("Use DSN Default Properties", false); connectionAttributes.Add("Use Encryption for Data", "0"); PropertyBag attributes = new PropertyBag(); attributes.Add("Database DLL", "crdb_ado.dll"); attributes.Add("QE_DatabaseName", ConfigurationManager.AppSettings["Database"]); attributes.Add("QE_DatabaseType", "OLE DB (ADO)"); attributes.Add("QE_LogonProperties", connectionAttributes); attributes.Add("QE_ServerDescription", httpctx.Server); attributes.Add("QESQLDB", true); attributes.Add("SSO Enabled", false); CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo ci = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo(); ci.Attributes = attributes; ci.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE; ci.UserName = ConfigurationManager.AppSettings["UserID"]; ci.Password = ConfigurationManager.AppSettings["Password"]; foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table table in report.ReportClientDocument.DatabaseController.Database.Tables) { CrystalDecisions.ReportAppServer.DataDefModel.Procedure newTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure(); newTable.ConnectionInfo = ci; newTable.Name = table.Name; newTable.Alias = table.Alias; newTable.QualifiedName = ConfigurationManager.AppSettings["Database"] + ".dbo." + table.Name; report.ReportClientDocument.DatabaseController.SetTableLocation(table, newTable); } Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat); report.Dispose(); return(stream); }
private Stream genericReportSetting(ReportDocument report, HttpContext httpctx) { PropertyBag connectionAttributes = new PropertyBag(); connectionAttributes.Add("Auto Translate", "-1"); connectionAttributes.Add("Connect Timeout", "15"); connectionAttributes.Add("Data Source", ConfigurationManager.AppSettings["Server"]); connectionAttributes.Add("General Timeout", "0"); connectionAttributes.Add("Initial Catalog", ConfigurationManager.AppSettings["Database"]); connectionAttributes.Add("Integrated Security", false); connectionAttributes.Add("Locale Identifier", "1040"); connectionAttributes.Add("OLE DB Services", "-5"); connectionAttributes.Add("Provider", "SQLOLEDB"); connectionAttributes.Add("Tag with column collation when possible", "0"); connectionAttributes.Add("Use DSN Default Properties", false); connectionAttributes.Add("Use Encryption for Data", "0"); PropertyBag attributes = new PropertyBag(); attributes.Add("Database DLL", "crdb_ado.dll"); attributes.Add("QE_DatabaseName", ConfigurationManager.AppSettings["Database"]); attributes.Add("QE_DatabaseType", "OLE DB (ADO)"); attributes.Add("QE_LogonProperties", connectionAttributes); attributes.Add("QE_ServerDescription", httpctx.Server); attributes.Add("QESQLDB", true); attributes.Add("SSO Enabled", false); CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo ci = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo(); ci.Attributes = attributes; ci.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE; ci.UserName = ConfigurationManager.AppSettings["UserID"]; ci.Password = ConfigurationManager.AppSettings["Password"]; foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table table in report.ReportClientDocument.DatabaseController.Database.Tables) { CrystalDecisions.ReportAppServer.DataDefModel.Procedure newTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure(); newTable.ConnectionInfo = ci; newTable.Name = table.Name; newTable.Alias = table.Alias; newTable.QualifiedName = ConfigurationManager.AppSettings["Database"] + ".dbo." + table.Name; report.ReportClientDocument.DatabaseController.SetTableLocation(table, newTable); } Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat); report.Dispose(); return stream; }