private static void Deploy(string origem, string destination, string dataSourcePath) { string[] files = System.IO.Directory.GetFiles(origem); foreach (var file in files) { FileInfo info = new FileInfo(file); if (info.Extension != ".jrxml") continue; string OnlyName = info.Name.Replace(info.Extension, ""); Console.Write("Sending jrxml file: {0}", OnlyName); JasperDescriptor descriptor = new JasperDescriptor(); descriptor.Label = OnlyName; descriptor.Description = OnlyName; descriptor.PermissionMark = 0; descriptor.Version = 0; descriptor.Type = info.Extension.Replace(".", ""); descriptor.ContentFile(file); var resultado = client.File(string.Format("{0}/jrxml", destination), JasperReportFileAction.UPLOAD, descriptor); Console.Write(" => {0}", resultado.GetStatus().ToString()); Console.WriteLine(); if (resultado.GetStatus() == JasperStatus.Success) { Console.Write("Creating the report file for \"{0}\"", OnlyName); string FileNameReportJrxml = ValidateFileName(OnlyName); JasperDescriptor descriptorDeploy = new JasperDescriptor(); descriptorDeploy.Label = info.Name; descriptorDeploy.AlwaysPromptControls = true; descriptorDeploy.ControlsLayout = ControlsLayout.inPage.ToString(); descriptorDeploy.DataSource = new JasperCollection<JasperDataSourceReference> { new JasperDataSourceReference(dataSourcePath) }; descriptorDeploy.Jrxml = new JasperCollection<JrxmlFileReference> { new JrxmlFileReference(string.Format("{0}/jrxml/{1}", destination, FileNameReportJrxml)) }; var resultadoDeploy = client.DeployReport(destination, descriptorDeploy); Console.Write(" => {0}", resultadoDeploy.GetStatus().ToString()); Console.WriteLine(); } Console.WriteLine(); } }
public static void Upload(string origem, string destination) { string[] files = System.IO.Directory.GetFiles(origem); foreach (var file in files) { FileInfo info = new FileInfo(file); Console.Write("Name: {0} || Extension: {1}", info.Name, info.Extension); JasperDescriptor descriptor = new JasperDescriptor(); descriptor.Label = info.Name; descriptor.Description = info.Name; descriptor.PermissionMark = 0; descriptor.Version = 0; descriptor.Type = info.Extension.Replace(".", ""); descriptor.ContentFile(file); var resultado = client.File(destination, JasperReportFileAction.UPLOAD, descriptor); Console.Write(" => {0}", resultado.GetStatus().ToString()); Console.WriteLine(); } }
public void UploadJrxmlFile() { JasperClient report = GetClient(); byte[] reportFile = null; using (StreamReader read = new StreamReader(@"..\..\..\JasperManagerTest\Files\Exemplo.jrxml")) { reportFile = new byte[read.BaseStream.Length]; read.BaseStream.Read(reportFile, 0, (int)read.BaseStream.Length); } JasperDescriptor descriptor = new JasperDescriptor(); descriptor.Label = "Sample"; descriptor.Description = "Test File"; descriptor.PermissionMark = 0; descriptor.Version = 0; descriptor.Type = "jrxml"; descriptor.ContentFile(reportFile); JasperResult result = report.File("/reports/jrxml", JasperReportFileAction.UPLOAD, descriptor); Assert.AreEqual(result.GetStatus(), JasperStatus.Success, result.GetMessage()); }