Ejemplo n.º 1
0
 public JasperResult(string Url, JasperDescriptor Descriptor, JasperStatus Status, string MessageDetails)
 {
     // TODO: Complete member initialization
     this.Url = Url;
     this.Descriptor = Descriptor;
     this.Status = Status;
     this.MessageDetails = MessageDetails;
 }
Ejemplo n.º 2
0
        public void DeployReportAsNewDocument()
        {
            JasperDescriptor descriptor = new JasperDescriptor();

            descriptor.Label = "SampleReport";
            descriptor.AlwaysPromptControls = false;
            descriptor.ControlsLayout = ControlsLayout.inPage.ToString();
            descriptor.DataSource = new JasperCollection<JasperDataSourceReference> { new JasperDataSourceReference("/datasources/repositoryDS") };
            descriptor.Jrxml = new JasperCollection<JrxmlFileReference> { new JrxmlFileReference("/reports/jrxml/Sample") };

            JasperClient report = GetClient();

            JasperResult result = report.DeployReport("/reports/ReportFile/Test", descriptor);

            Assert.AreEqual(result.GetStatus(), JasperStatus.Success, result.GetMessage());
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
        public JasperResult DeployReport(string Path, JasperDescriptor Descriptor)
        {
            JasperHttpMethod method = JasperHttpMethod.POST;

            WebClient web = new WebClient();
            web.Credentials = new NetworkCredential(Auth.GetUsuario(), Auth.GetPassword());
            web.Headers.Add("Content-Type", "application/repository.reportUnit+json");

            string url = string.Format("{0}resources{1}", Config.GetBaseUrl(), Path);

            try
            {
                string response = web.UploadString(url, method.ToString(), Descriptor.ToJson());

                return new JasperResult(url, null, JasperStatus.Success, response);
            }
            catch (WebException ex)
            {
                return new JasperResult(url, Descriptor, JasperStatus.Error, ex.Message);
            }
        }
Ejemplo n.º 5
0
        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();
            }
        }
Ejemplo n.º 6
0
        public JasperResult File(string Path, JasperReportFileAction Action, JasperDescriptor Descriptor)
        {
            JasperHttpMethod method = JasperHttpMethod.POST;

            switch (Action)
            {
                case JasperReportFileAction.UPLOAD:
                    {
                        method = JasperHttpMethod.POST;
                    }
                    break;
                case JasperReportFileAction.DELETE:
                    {
                        method = JasperHttpMethod.DELETE;
                    }
                    break;
                default:
                    break;
            }

            WebClient web = new WebClient();
            web.Credentials = new NetworkCredential(Auth.GetUsuario(), Auth.GetPassword());
            web.Headers.Add("Content-Type", "application/repository.file+json");

            string url = string.Format("{0}resources{1}", Config.GetBaseUrl(), Path);

            try
            {
                string response = web.UploadString(url, method.ToString(), Descriptor.ToJson());

                return new JasperResult(url, null, JasperStatus.Success, response);
            }
            catch (WebException ex)
            {
                return new JasperResult(url, Descriptor, JasperStatus.Error, ex.Message);
            }
        }
Ejemplo n.º 7
0
        public void MakeFolder()
        {
            JasperClient report = GetClient();

            JasperDescriptor descriptor = new JasperDescriptor();

            descriptor.Label = "ReportFile";
            descriptor.Description = "Folder Sample";
            descriptor.PermissionMark = 0;
            descriptor.Version = 0;

            JasperResult result = report.Folder("/reports", JasperReportFolderAction.CREATE, descriptor);

            Assert.AreEqual(result.GetStatus(), JasperStatus.Success);
        }
Ejemplo n.º 8
0
        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());
        }