static void Main(string[] args)
    {
        ReportingService2010 rs = new ReportingService2010();

        rs.Url = "http://<Server Name>" +
                 "/_vti_bin/ReportServer/ReportService2010.asmx";
        rs.Credentials =
            System.Net.CredentialCache.DefaultCredentials;
        string name   = "AdventureWorks.rsds";
        string parent = "http://<Server Name>/Docs/Documents/";
        // Define the data source definition.
        DataSourceDefinition definition = new DataSourceDefinition();

        definition.CredentialRetrieval =
            CredentialRetrievalEnum.Integrated;
        definition.ConnectString =
            "data source=(local);initial catalog=AdventureWorks";
        definition.Enabled                  = true;
        definition.EnabledSpecified         = true;
        definition.Extension                = "SQL";
        definition.ImpersonateUserSpecified = false;
        //Use the default prompt string.
        definition.Prompt             = null;
        definition.WindowsCredentials = false;
        try
        {
            rs.CreateDataSource(name, parent, false,
                                definition, null);
        }
        catch (SoapException e)
        {
            Console.WriteLine(e.Detail.InnerXml.ToString());
        }
    }
        /// <summary>
        /// Create DataSource
        /// </summary>
        /// <param name="client"></param>
        /// <param name="connectionString"></param>
        /// <param name="folderName"></param>
        private static void CreateDataSource(ReportingService2010 client, string connectionString, string folderName)
        {
            try
            {
                string name   = "ReportDataSource";
                string parent = $"/{folderName}";

                DataSourceDefinition definition = new DataSourceDefinition
                {
                    CredentialRetrieval      = CredentialRetrievalEnum.Integrated,
                    ConnectString            = connectionString,
                    Enabled                  = true,
                    EnabledSpecified         = true,
                    Extension                = "SQL",
                    ImpersonateUserSpecified = false,
                    Prompt             = null,
                    WindowsCredentials = false
                };
                //Use the default prompt string.
                try
                {
                    client.CreateDataSource(name, parent, true, definition, null);
                }
                catch (SoapException e)
                {
                    Console.WriteLine(e.Detail.InnerXml.ToString());
                    throw e;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public RSCatalogItem CreateDataSource(string DataSource, string Parent, bool Overwrite, RSDataSourceDefinition Definition, RSProperty[] Properties)
        {
            DataSourceDefinition dsDef = (DataSourceDefinition)Converter.Convert(Definition);

            Property[]  props  = (Property[])Converter.Convert(Properties);
            CatalogItem outval = rs.CreateDataSource(DataSource, Parent, Overwrite, dsDef, props);

            return((RSCatalogItem)Converter.Convert(outval));
        }
        private static void CreateDataSources(ReportingService2010 reportingService, string path)
        {
            if (reportingService == null)
            {
                throw new ArgumentNullException("reportingService");
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("path");
            }

            foreach (DataSourceItem dataSource in SetupDataSourceItems)
            {
                DataSourceDefinition def = new DataSourceDefinition();
                def.ConnectString = dataSource.ConnectString;

                switch (dataSource.CredentialsRetrieval)
                {
                case "Integrated":
                    def.CredentialRetrieval = CredentialRetrievalEnum.Integrated; break;

                case "None":
                    def.CredentialRetrieval = CredentialRetrievalEnum.None; break;

                case "Prompt":
                    def.CredentialRetrieval = CredentialRetrievalEnum.Prompt; break;

                case "Store":
                    def.CredentialRetrieval = CredentialRetrievalEnum.Store; break;
                }

                def.Enabled                              = dataSource.Enabled;
                def.EnabledSpecified                     = dataSource.EnabledSpecified;
                def.Extension                            = dataSource.Extension;
                def.ImpersonateUser                      = dataSource.ImpersonateUser;
                def.ImpersonateUserSpecified             = dataSource.ImpersonateUserSpecified;
                def.OriginalConnectStringExpressionBased = dataSource.OriginalConnectStringExpressionBased;
                def.Password                             = dataSource.Password;
                def.Prompt = dataSource.Prompt;
                def.UseOriginalConnectString = dataSource.UseOriginalConnectString;
                def.UserName           = dataSource.UserName;
                def.WindowsCredentials = dataSource.WindowsCredentials;

                string fullPath = string.Format(dataSource.Path, path);
                string parent   = TesterUtility.GetParentPath(fullPath);

                reportingService.CreateDataSource(dataSource.Name, parent, true, def, null);
            }
        }
        private static void CreateDataSource(ReportingService2010 reportingService, DataSourceItem dataSource)
        {
            if (reportingService == null)
            {
                throw new ArgumentNullException("reportingService");
            }

            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }

            DataSourceDefinition def = new DataSourceDefinition();

            def.ConnectString = dataSource.ConnectString;

            switch (dataSource.CredentialsRetrieval)
            {
            case "Integrated":
                def.CredentialRetrieval = CredentialRetrievalEnum.Integrated; break;

            case "None":
                def.CredentialRetrieval = CredentialRetrievalEnum.None; break;

            case "Prompt":
                def.CredentialRetrieval = CredentialRetrievalEnum.Prompt; break;

            case "Store":
                def.CredentialRetrieval = CredentialRetrievalEnum.Store; break;
            }

            def.Enabled                              = dataSource.Enabled;
            def.EnabledSpecified                     = dataSource.EnabledSpecified;
            def.Extension                            = dataSource.Extension;
            def.ImpersonateUser                      = dataSource.ImpersonateUser;
            def.ImpersonateUserSpecified             = dataSource.ImpersonateUserSpecified;
            def.OriginalConnectStringExpressionBased = dataSource.OriginalConnectStringExpressionBased;
            def.Password                             = dataSource.Password;
            def.Prompt = dataSource.Prompt;
            def.UseOriginalConnectString = dataSource.UseOriginalConnectString;
            def.UserName           = dataSource.UserName;
            def.WindowsCredentials = dataSource.WindowsCredentials;

            string parent = TesterUtility.GetParentPath(dataSource.Path);

            ReportingService2010TestEnvironment.CreateFolderFromPath(reportingService, parent);

            reportingService.CreateDataSource(dataSource.Name, parent, true, def, null);
        }
        private void CreateDataSource(string parentFolder, string subFolder, string dataSourceName, string dataSourceConnectionString, string dataSourceUserName, string dataSourcePassWord)
        {
            var definition = new DataSourceDefinition
            {
                CredentialRetrieval      = CredentialRetrievalEnum.Store,
                ConnectString            = dataSourceConnectionString,
                Enabled                  = true,
                EnabledSpecified         = true,
                Extension                = "SQL",
                ImpersonateUser          = false,
                ImpersonateUserSpecified = true,
                Prompt             = null,
                WindowsCredentials = false,
                UserName           = dataSourceUserName,
                Password           = dataSourcePassWord
            };

            Log("Creating data source {0} with value: {1}", dataSourceName, dataSourceConnectionString);
            rs.CreateDataSource(dataSourceName, string.Format("/{0}/{1}", parentFolder, subFolder), true, definition, null);
            Log("Created data source {0}", dataSourceName);
        }
示例#7
0
        public void CreateDataSource(Datasource datasource, string parent)
        {
            var dataSourceDefinition = new DataSourceDefinition
            {
                ConnectString      = datasource.ConnectionString,
                Enabled            = datasource.Enabled,
                Extension          = datasource.Extension,
                Password           = datasource.Password,
                Prompt             = datasource.Prompt,
                UserName           = datasource.Username,
                ImpersonateUser    = datasource.SetExecutionContext,
                WindowsCredentials =
                    datasource
                    .UsePromptedCredentialsAsWindowsCredentials ||
                    datasource.UseStoredCredentialsAsWindowsCredentials,
                CredentialRetrieval =
                    GetSSRSCredentialRetrievalTypeFromEnum(
                        datasource.CredentialRetrievalType)
            };

            webserviceProxy.CreateDataSource(datasource.Name, parent, true, dataSourceDefinition, null);
        }
示例#8
0
        private void ImportReports()
        {
            this.Cursor = Cursors.WaitCursor;
            string connectionString = ConfigurationManager.ConnectionStrings["SQL_PTO_Report.Properties.Settings.SQLPTOConnectionString"].ConnectionString;

            //Create SQLPTO Data Source
            ReportingService2010 rs = new ReportingService2010();

            rs.Url         = SSRSWS;
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

            try
            {
                rs.CreateFolder("Data Sources", @"/", null);
            }
            catch { }

            try
            {
                rs.CreateFolder("SQLPTOReports", @"/", null);
            }
            catch { }

            try
            {
                rs.CreateFolder("SQLPTOSummaryReports", @"/", null);
            }
            catch { }

            DataSourceDefinition definition = new DataSourceDefinition();

            definition.CredentialRetrieval      = CredentialRetrievalEnum.Integrated;
            definition.ConnectString            = "Data Source=" + SqlServer + ";Initial Catalog=SQLPTO";
            definition.Enabled                  = true;
            definition.EnabledSpecified         = true;
            definition.Extension                = "SQL";
            definition.ImpersonateUser          = false;
            definition.ImpersonateUserSpecified = true;
            definition.Prompt             = null;
            definition.WindowsCredentials = false;

            rs.CreateDataSource("SQLPTO", @"/Data Sources", true, definition, null);

            //Create SQLPTOSummary Data Source

            DataSourceDefinition definitionsum = new DataSourceDefinition();

            definitionsum.CredentialRetrieval      = CredentialRetrievalEnum.Integrated;
            definitionsum.ConnectString            = "Data Source=" + SqlServer + ";Initial Catalog=SQLPTOSummary";
            definitionsum.Enabled                  = true;
            definitionsum.EnabledSpecified         = true;
            definitionsum.Extension                = "SQL";
            definitionsum.ImpersonateUser          = false;
            definitionsum.ImpersonateUserSpecified = true;
            definitionsum.Prompt             = null;
            definitionsum.WindowsCredentials = false;

            rs.CreateDataSource("SQLPTOsummary", @"/Data Sources", true, definitionsum, null);


            //Create reports
            // Open the report (rdl) file and
            // read the data into the stream.
            DeployReportItems(@".\Reports\SQLPTOSummaryReports", @"/SQLPTOSummaryReports", @"/Data Sources/SQLPTOSummary");
            DeployReportItems(@".\Reports\SQLPTOReports", @"/SQLPTOReports", @"/Data Sources/SQLPTO");
            rs.Dispose();

            MessageBox.Show("Reports imported successfully!");

            this.Cursor = Cursors.Default;
        }