Exemple #1
0
        private void SetDataSourceLocation(ReportConnectionInfo info, ReportDocument crystalReportDocument)
        {
            foreach (IConnectionInfo connectInfo in crystalReportDocument.DataSourceConnections)
            {
                connectInfo.SetConnection(info.Server, info.Database, info.Username, info.Password);
            }

            //Create a new Database Table to replace the reports current table.
            var boTable = new CrystalDecisions.ReportAppServer.DataDefModel.Table();

            //boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
            PropertyBag boMainPropertyBag = new PropertyBag();
            //boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
            //In the main property bag (boMainPropertyBag)
            PropertyBag boInnerPropertyBag = new PropertyBag();

            //Set the attributes for the boInnerPropertyBag
            boInnerPropertyBag.Add("Database", info.Database);
            boInnerPropertyBag.Add("DSN", info.Server);
            boInnerPropertyBag.Add("SSOKey", "");
            boInnerPropertyBag.Add("Trusted_Connection", (info.IntegratedSecurity ? "True" : "False"));
            boInnerPropertyBag.Add("UseDSNProperties", "False");

            //Set the attributes for the boMainPropertyBag
            boMainPropertyBag.Add("Database DLL", "crdb_odbc.dll");
            boMainPropertyBag.Add("QE_DatabaseName", info.Database);
            boMainPropertyBag.Add("QE_DatabaseType", "ODBC (RDO)");
            //Add the QE_LogonProperties we set in the boInnerPropertyBag Object
            boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
            boMainPropertyBag.Add("QE_ServerDescription", info.Server);
            boMainPropertyBag.Add("QE_SQLDB", "True");
            boMainPropertyBag.Add("SSO Enabled", (info.IntegratedSecurity ? "True" : "False"));

            //Create a new ConnectionInfo object
            var boConnectionInfo = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();

            //Pass the database properties to a connection info object
            boConnectionInfo.Attributes = boMainPropertyBag;
            //Set the connection kind
            boConnectionInfo.Kind     = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
            boConnectionInfo.UserName = info.Username;
            boConnectionInfo.Password = info.Password;
            boTable.ConnectionInfo    = boConnectionInfo;

            CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables = ReportClientDocument.DatabaseController.Database.Tables;

            foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table table in boTables)
            {
                boTable.Name          = table.Name;
                boTable.QualifiedName = table.QualifiedName;
                boTable.Alias         = table.Alias;
                ReportClientDocument.DatabaseController.SetTableLocation(table, boTable);
            }

            //Verify the database after adding substituting the new table.
            //To ensure that the table updates properly when adding Command tables or Stored Procedures.
            //VerifyDatabase();
        }
Exemple #2
0
        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;
        }