private void test_1()
        {
            NetworkCredential clientCredentials = new NetworkCredential("Chathuranga", "blahhhhh", "Chathu-Nable");


            ReportingService2010SoapClient client = new ReportingService2010SoapClient();

            client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            client.ClientCredentials.Windows.ClientCredential          = clientCredentials;



            client.Open();
            TrustedUserHeader t = new TrustedUserHeader();



            CatalogItem[] items;
            // I need to list of children of a specified folder.
            ServerInfoHeader oServerInfoHeader = client.ListChildren(t, "/", true, out items);

            foreach (var item in items)
            {
                // I can access any properties of item
                Console.WriteLine(item.ID);
            }

            Console.ReadLine();
        }
        public IEnumerable <object> GetReports()
        {
            NetworkCredential clientCredentials = new NetworkCredential("nrodas", "P@ssw0rd", "CLIN");

            ReportingServices.ReportingService2010SoapClient client = new ReportingServices.ReportingService2010SoapClient();
            client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            client.ClientCredentials.Windows.ClientCredential          = clientCredentials;
            client.Open();
            TrustedUserHeader t = new TrustedUserHeader();

            CatalogItem[] items;
            // I need to list of children of a specified folder.
            ServerInfoHeader oServerInfoHeader = client.ListChildren(t, "/", true, out items);

            return(items);
        }
        /// <summary>
        /// Download the specified report file
        /// </summary>
        /// <param name="itemPath"></param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task <System.Xml.XmlDocument> GetReportDefinition(string itemPath)
        {
            TrustedUserHeader header = new TrustedUserHeader();

            return(await System.Threading.Tasks.Task.Factory.FromAsync <System.Xml.XmlDocument>(
                       _service.BeginGetItemDefinition(header, itemPath, null, null),
                       (ar) =>
            {
                byte[] data;
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                ServerInfoHeader result = _service.EndGetItemDefinition(ar, out data);
                MemoryStream stream = new MemoryStream(data);

                doc.Load(stream);
                return doc;
            }));
        }
Exemple #4
0
        public string RunReport(string path, string reportCode, Dictionary <string, string> dicParams)
        {
            var format = "";
            var result = "";

            try
            {
                DataSourceCredentials[] credentials = null;
                string    encoding;
                string    mimeType;
                string    extension;
                Warning[] warnings  = null;
                string[]  streamIDs = null;

                string historyID    = null;
                byte[] reportResult = null;
                var    devInfo      = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

                var rs = new ReportExecutionServiceSoapClient(GetDefaultBinding(), new EndpointAddress(@"http://localhost:8282/ReportServer/ReportExecution2005.asmx"));
                rs.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                rs.ClientCredentials.Windows.ClientCredential          = System.Net.CredentialCache.DefaultNetworkCredentials;

                rs.ClientCredentials.UserName.UserName = "******";
                rs.ClientCredentials.UserName.Password = "******";
                // Render arguments
                var execInfo      = new ExecutionInfo();
                var execHeader    = new ExecutionHeader();
                var trustedHeader = new TrustedUserHeader();
                var serverInfo    = new ServerInfoHeader();

                var path2 = "/" + path + "/" + reportCode;
                rs.LoadReport(trustedHeader, path2, historyID, out serverInfo, out execInfo);

                // Genera los parametros apartir de un diccionario
                var parameters = new ParameterValue[dicParams.Count];
                var index      = 0;

                foreach (var param in dicParams)
                {
                    var paramValue = new ParameterValue
                    {
                        Name  = param.Key,
                        Value = param.Value
                    };
                    parameters[index] = paramValue;
                    index++;
                }

                execHeader.ExecutionID = execInfo.ExecutionID;
                rs.SetExecutionParameters(execHeader, trustedHeader, parameters, "en-us", out execInfo);

                //Invocacion del reporte
                format = "PDF";

                rs.Render(execHeader, trustedHeader, format, devInfo, out reportResult, out extension, out mimeType, out encoding, out warnings, out streamIDs);

                result = Convert.ToBase64String(reportResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
Exemple #5
0
        public object ReporteFormatoEtiquetasOrdenRecepcion(int ordenRecepcionID, Sam3_Usuario usuario)
        {
            try
            {
                #region parametros
                byte[]            reporte;
                string            historyID  = null;
                string            deviceInfo = null;
                string            extension;
                string            encoding;
                string            mimeType;
                Warning[]         warnings;
                string[]          streamIDs    = null;
                string            format       = "PDF";
                string            rutaReporte  = "/Reportes/Formato de Etiquetas";
                NetworkCredential credenciales = new NetworkCredential(usuarioReportes, passReportes);
                #endregion

                ReportExecutionServiceSoapClient cliente = new ReportExecutionServiceSoapClient();
                cliente.ClientCredentials.Windows.ClientCredential          = credenciales;
                cliente.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
                cliente.ClientCredentials.UserName.UserName = usuarioReportes;
                cliente.ClientCredentials.UserName.Password = passReportes;

                ParameterValue[] parametros = new ParameterValue[1];
                parametros[0]       = new ParameterValue();
                parametros[0].Name  = "OrdenRecepcionID";
                parametros[0].Value = ordenRecepcionID.ToString();

                ExecutionInfo     infoEjecucion         = new ExecutionInfo();
                TrustedUserHeader encabezadoSeguro      = null;
                ExecutionHeader   encabezadoDeEjecucion = new ExecutionHeader();
                ServerInfoHeader  encavezadoDeServidor  = new ServerInfoHeader();

                encabezadoDeEjecucion = cliente.LoadReport(encabezadoSeguro, rutaReporte, historyID, out encavezadoDeServidor, out infoEjecucion);
                cliente.SetExecutionParameters(encabezadoDeEjecucion, encabezadoSeguro, parametros, "en-US", out infoEjecucion);

                cliente.Render(encabezadoDeEjecucion, encabezadoSeguro, format, deviceInfo, out reporte, out extension, out mimeType, out encoding, out warnings, out streamIDs);

                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);

                Stream iStream = new MemoryStream(reporte);

                response.Content = new StreamContent(iStream);
                response.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/pdf");
                response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentDisposition.FileName = "EtiquetasMaterial_" + ordenRecepcionID.ToString() + ".pdf";

                return(response);
            }
            catch (Exception ex)
            {
                //-----------------Agregar mensaje al Log -----------------------------------------------
                LoggerBd.Instance.EscribirLog(ex);
                //-----------------Agregar mensaje al Log -----------------------------------------------

                TransactionalInformation result = new TransactionalInformation();
                result.ReturnMessage.Add("Error al cargar el reporte");
                result.ReturnCode     = 500;
                result.ReturnStatus   = false;
                result.IsAuthenicated = true;

                return(result);
            }
        }