/// <summary> /// Adds the report properties. /// </summary> /// <param name="reportResourceFile"> /// The report server reports. /// </param> /// <param name="propertiesString"> /// The properties string. /// </param> private void AddFilesProperties(ReportResourceFile reportResourceFile, string propertiesString) { string[] strings; foreach (string propertery in propertiesString.Split(new[] { ';' })) { strings = propertery.Split(new[] { '=' }); reportResourceFile.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() { // Creates the new instances of the reporting services. // Use the current users windows credentials to connect to the report server. R2DeploymentManger r2DeploymentManger = new R2DeploymentManger(this.ReportServerURL); ReportResourceFile[] reportResourcesFile = new ReportResourceFile[this.Files.Length]; r2DeploymentManger.DeploymentMangerMessages += this.deploymentMangerMessages; try { // loop through the array of reports. for (int index = 0; index < this.Files.Length; index++) { reportResourcesFile[index] = new ReportResourceFile(this.Files[index].GetMetadata("FullPath")); reportResourcesFile[index].MimeType = this.Files[index].GetMetadata("MimeType"); reportResourcesFile[index].ReportServerProperties.Add( "MimeType", reportResourcesFile[index].MimeType); string propertiesString = this.Files[index].GetMetadata("ReportServerProperties"); if (!string.IsNullOrEmpty(propertiesString)) { this.AddFilesProperties(reportResourcesFile[index], propertiesString); } } return(r2DeploymentManger.UploadResource(reportResourcesFile, this.Folder, this.DocumentLibraryURL)); } catch (Exception ex) { // catches the error and then reports out via msbuild. this.BuildEngine.LogErrorEvent( new BuildErrorEventArgs( "Reporting", "AddResources", this.BuildEngine.ProjectFileOfTaskNode, this.BuildEngine.LineNumberOfTaskNode, this.BuildEngine.ColumnNumberOfTaskNode, 0, 0, ex.Message, string.Empty, this.ToString())); return(false); } }