/// <summary>
        /// Creates the data source.
        /// </summary>
        /// <param name="dataSourceName">Name of the _data source.</param>
        /// <param name="dataSourceLocation">The _data source location.</param>
        /// <param name="sqlServerName">Name of the _SQL server.</param>
        /// <param name="dbName">Name of the _DB.</param>
        /// <returns></returns>
        public bool CreateDataSource(string dataSourceName, string dataSourceLocation, string sqlServerName, string dbName)
        {
            bool resVal;

            var dataSourceDefinition = new DataSourceDefinition
            {
                Extension     = "SQL",
                ConnectString =
                    @"Data Source=" + sqlServerName +
                    @";Initial Catalog=" + dbName,
                ImpersonateUserSpecified = true,
                Prompt              = null,
                WindowsCredentials  = true,
                CredentialRetrieval = CredentialRetrievalEnum.Integrated,
                Enabled             = true
            };

            try
            {
                _reportsServerInstance2005.CreateDataSource(dataSourceName,
                                                            dataSourceLocation,
                                                            false,
                                                            dataSourceDefinition,
                                                            null);
                resVal = true;
            }
            catch (Exception)
            {
                resVal = false;
            }

            return(resVal);
        }
        public void CreateDataSource(DataSource source)
        {
            DataSourceDefinition definition = new DataSourceDefinition();

            definition.ConnectString       = source.RSConnectionString;
            definition.CredentialRetrieval = (CredentialRetrievalEnum)source.CredentialRetrieval;
            if (source.UserName != null)
            {
                definition.UserName = source.UserName;
                definition.Password = source.Password;
            }
            definition.Enabled                  = true;
            definition.EnabledSpecified         = true;
            definition.Extension                = "SQL";
            definition.ImpersonateUser          = false;
            definition.ImpersonateUserSpecified = true;
            definition.Prompt             = null;
            definition.WindowsCredentials = source.WindowsCredentials;

            _proxy.CreateDataSource(
                source.Name,
                Util.FormatPath(source.TargetFolder),
                source.Overwrite,
                definition,
                null);
        }
Example #3
0
        private static void CreateDataSources(ReportingService2005 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);
            }
        }
Example #4
0
        private static void CreateDataSource(ReportingService2005 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);

            ReportingService2005TestEnvironment.CreateFolderFromPath(reportingService, parent);

            reportingService.CreateDataSource(dataSource.Name, parent, true, def, null);
        }
        public override bool Execute()
        {
#if DEBUG
            ReportingService2005 rs2005 = new ReportingService2005();
            rs2005.Url = ReportServerUrl;
            rs2005.UseDefaultCredentials = UseDefaultCredentials;

            SortedList <string, string> ExistingDataSources = new SortedList <string, string>(StringComparer.InvariantCultureIgnoreCase);
            if (!Overwrite)
            {
                foreach (CatalogItem item in rs2005.ListChildren(TargetFolder, false))
                {
                    if (item.Type == ItemTypeEnum.DataSource)
                    {
                        ExistingDataSources[item.Name] = item.Name;
                    }
                }
            }

            foreach (ITaskItem ds in DataSources ?? new ITaskItem[0])
            {
                XPathDocument  doc = new XPathDocument(ds.ItemSpec);
                XPathNavigator nav = doc.CreateNavigator();
                nav.MoveToRoot();

                DataSourceDefinition dsd = new DataSourceDefinition();
                dsd.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
                dsd.Enabled             = true;
                dsd.EnabledSpecified    = true;
                dsd.Prompt             = null;
                dsd.WindowsCredentials = false;

                foreach (XPathNavigator n in nav.Select("/RptDataSource/ConnecionProperties/*"))
                {
                    typeof(DataSetDefinition).InvokeMember(n.LocalName, System.Reflection.BindingFlags.SetProperty, null, dsd, new object[] { n.Value }, CultureInfo.InvariantCulture);
                }

                rs2005.CreateDataSource(nav.SelectSingleNode("/RptDataSource/Name").Value, TargetFolder, Overwrite, dsd, null);
            }
#endif
            return(true);
        }
Example #6
0
 public string createDataSource(string name, string parent, string conecstring, bool overWrite)
 {
     try
     {
         //check exist data source
         if (CheckExist(ItemTypeEnum.DataSource, parent, name) && !overWrite)
         {
             return(String.Format("Datasource {0} is already exist", name));
         }
         //create datasource definition
         DataSourceDefinition definition = createDataSourceDefinition(conecstring);
         //create data source
         rs.CreateDataSource(name, parent, overWrite, definition, null);
         return("");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Example #7
0
        private void CreateDataSource(string location)
        {
            Property prop = new Property();

            prop.Name  = "Description";
            prop.Value = "Data source for SQLsecure Reports.";

            // Define the data source definition.
            DataSourceDefinition definition = new DataSourceDefinition();

            definition.CredentialRetrieval = CredentialRetrievalEnum.Store;
            definition.ConnectString       = "data source=" + _drd.Repository + ";initial catalog=SQLsecure";
            definition.Enabled             = true;
            definition.EnabledSpecified    = true;
            definition.Extension           = "SQL";
            definition.UserName            = _drd.UserName;
            definition.Password            = _drd.Password;
            definition.Prompt             = null;
            definition.WindowsCredentials = true;

            _rs.CreateDataSource("SQLsecure Data Source", location, true, definition, new Property[] { prop });
        }
Example #8
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);
        }