/// <summary> /// Adds the report properties. /// </summary> /// <param name="reportServerDataSource"> /// The report server data source. /// </param> /// <param name="propertiesString"> /// The properties string. /// </param> private void AddReportProperties(ReportServerDataSource reportServerDataSource, string propertiesString) { string[] strings; foreach (string propertery in propertiesString.Split(new[] { ';' })) { strings = propertery.Split(new[] { '=' }); reportServerDataSource.ReportServerProperties.Add(strings[0], strings[1]); } }
/// <summary> /// The execute method which is call msbuild to run the task /// </summary> /// <returns> /// <c>true</c> if successful ; otherwise, <c>false</c>. /// </returns> public override bool Execute() { R2DeploymentManger r2DeploymentManger = new R2DeploymentManger(this.ReportServerURL); r2DeploymentManger.DeploymentMangerMessages += this.deploymentMangerMessages; ReportServerDataSource[] reportServerDataSources = new ReportServerDataSource[this.DataSources.Length]; try { // loop through the array of reports. for (int index = 0; index < this.DataSources.Length; index++) { reportServerDataSources[index] = new ReportServerDataSource { DataSourceFolder = this.DataSources[index].GetMetadata("Folder"), DocumentLibraryURL = string.IsNullOrEmpty(this.DataSources[index].GetMetadata("DocumentLibraryURL")) ? string.Empty : this.DataSources[index].GetMetadata("DocumentLibraryURL"), Name = this.DataSources[index].ItemSpec, ReportDataSourceNames = string.IsNullOrEmpty(this.DataSources[index].GetMetadata("ReportDataSourceNames")) ? null : this.DataSources[index].GetMetadata("ReportDataSourceNames").Split(new[] { ';' }) }; } return(r2DeploymentManger.SetReportDataSource( this.ReportItem, this.DocumentLibraryURL, this.Recursive, reportServerDataSources, this.UseMatchCase)); } catch (Exception ex) { this.BuildEngine.LogErrorEvent( new BuildErrorEventArgs( "Reporting", "SetReportDataSource", this.BuildEngine.ProjectFileOfTaskNode, this.BuildEngine.LineNumberOfTaskNode, this.BuildEngine.ColumnNumberOfTaskNode, 0, 0, ex.Message, string.Empty, this.ToString())); return(false); } }
/// <summary> /// The execute method which is call MSBuild to run the task /// </summary> /// <returns> /// <c>true</c> if successful ; otherwise, <c>false</c>. /// </returns> public override bool Execute() { string invaildDataourceMessage; // Connecting to the reporting server IntegratedDeploymentManager integratedDeploymentManager = new IntegratedDeploymentManager(this.SharePointSiteUrl); integratedDeploymentManager.DeploymentMangerMessages += this.deploymentMangerMessages; ReportServerDataSource[] reportServerDataSources = new ReportServerDataSource[this.DataSources.Length]; try { // loop through the array of reports. for (int index = 0; index < this.DataSources.Length; index++) { if (!this.isDataSourceValid(this.DataSources[index], out invaildDataourceMessage)) { throw new Exception(invaildDataourceMessage); } reportServerDataSources[index] = new ReportServerDataSource { ConnectionString = this.DataSources[index].GetMetadata("ConnectionString"), DataSourceFolder = this.DataSources[index].GetMetadata("Folder"), Name = this.DataSources[index].ItemSpec, OverWrite = Convert.ToBoolean(this.DataSources[index].GetMetadata("OverWrite")), Provider = (DataProviderOprions) Enum.Parse( typeof(DataProviderOprions), this.DataSources[index].GetMetadata("Provider"), true) }; if (!String.IsNullOrEmpty(this.DataSources[index].GetMetadata("WindowsUser")) && !String.IsNullOrEmpty(this.DataSources[index].GetMetadata("WindowsUserPassword"))) { reportServerDataSources[index].WindowCredentials = new ReportServerDataSourceWindowsCredentials( this.DataSources[index].GetMetadata("WindowsUser"), this.DataSources[index].GetMetadata("WindowsUserPassWord")); } string propertiesString = this.DataSources[index].GetMetadata("ReportServerProperties"); if (!string.IsNullOrEmpty(propertiesString)) { this.AddReportProperties(reportServerDataSources[index], propertiesString); } } return(integratedDeploymentManager.CreateDataSource(reportServerDataSources)); } catch (Exception ex) { this.BuildEngine.LogErrorEvent( new BuildErrorEventArgs( "Reporting", "CreateReportingDataSource", this.BuildEngine.ProjectFileOfTaskNode, this.BuildEngine.LineNumberOfTaskNode, this.BuildEngine.ColumnNumberOfTaskNode, 0, 0, ex.Message, string.Empty, this.ToString())); return(false); } }