示例#1
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);
            }
        }
示例#2
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);
            }
        }