Пример #1
2
    protected void Button1_Click(object sender, EventArgs e)
    {
        ReportExecutionService reportExecutionService = new ReportExecutionService();   // Web Service proxy
        reportExecutionService.Credentials = new NetworkCredential("reportservice", "Asdfghjkl?", "kswh107");

        string reportPath = "/ReconCurrent/ReconInvest";
        string format = "PDF";

        // Render arguments
        byte[] result = null;
        string historyID = null;

        string encoding;
        string mimeType;
        string extension;
        Warning[] warnings = null;
        string[] streamIDs = null;

        ParameterValue[] parameters = new ParameterValue[4];
        parameters[0] = new ParameterValue();
        parameters[0].Name = "StartDate";
        parameters[1] = new ParameterValue();
        parameters[1].Name = "EndDate";
        parameters[2] = new ParameterValue();
        parameters[2].Name = "IsinCode";
        parameters[3] = new ParameterValue();
        parameters[3].Name = "AccountNumber";

        ExecutionInfo execInfo = new ExecutionInfo();
        ExecutionHeader execHeader = new ExecutionHeader();

        reportExecutionService.ExecutionHeaderValue = execHeader;

        execInfo = reportExecutionService.LoadReport(reportPath, historyID);

        String SessionId = reportExecutionService.ExecutionHeaderValue.ExecutionID;
        parameters[0].Value = DatePickerBegin.SelectedDate.ToShortDateString();
        parameters[1].Value = DatePickerEnd.SelectedDate.ToShortDateString();
        parameters[3].Value = ddlAccount.SelectedValue.ToString();
        parameters[2].Value = ddlInstrument.SelectedValue.ToString();
        reportExecutionService.SetExecutionParameters(parameters, "nl-nl");
        result = reportExecutionService.Render(format, null, out extension, out encoding, out mimeType, out warnings, out streamIDs);

        Response.ClearContent();
        Response.AppendHeader("content-length", result.Length.ToString());
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(result);
        Response.End();
        //Response.Flush();
        //Response.Close();
    }
        public void WhenExecute_With_SSRSProject_StockPriceList_And_Excel_ShouldReturnNotNullResult()
        {
            var client = new ReportExecutionService();
            var request = new ReportExecutionRequest { Name = ReportPath, Format = "EXCEL" };
            var parameters = new Parameter[1];
            parameters[0] = new Parameter {Name = "ListPriceReportParameter1", Value = "0"};
            request.Parameters = parameters;

            var response = client.Execute(request) as ReportExecutionResponse;

            Assert.NotNull(response);

            string fileName = Path.GetTempPath() + "Stock Price List.xls";
            using (FileStream stream = File.OpenWrite(fileName))
            {
                stream.Write(response.Result, 0, response.Result.Length);
            }
        }
Пример #3
0
        public static byte[] Render(string ssrUrl, ExportFormat exportFormat, Dictionary <string, string> parametersAndValues, string reportName, ICredentials credentials)
        {
            using (var reportExecution = new ReportExecutionService(ssrUrl)
            {
                Credentials = credentials ?? CredentialCache.DefaultCredentials
            })
            {
                string    encoding;
                string    mimeType;
                string    extension;
                Warning[] warnings;
                string[]  streamIDs;

                reportExecution.LoadReport(reportName, null);
                if (parametersAndValues.Count > 0)
                {
                    var parameters = new ParameterValue[parametersAndValues.Count];
                    var i          = 0;
                    foreach (var paramsAndValues in parametersAndValues)
                    {
                        parameters[i] = new ParameterValue
                        {
                            Name = paramsAndValues.Key, Value = paramsAndValues.Value
                        };
                        i++;
                    }
                    reportExecution.SetExecutionParameters(parameters, "en-us");
                }
                var results = reportExecution.Render(exportFormat.ToString(), null, out extension, out mimeType,
                                                     out encoding, out warnings, out streamIDs);
                return(results);
            }
        }
Пример #4
0
 public ReportPrinter()
 {
     this.debugOn = System.Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["debug"].Trim());
     rs = new ReportExecutionService();
     rs.Url = System.Configuration.ConfigurationManager.AppSettings["eDSITran_ReportServer_ReportingService"].Trim();
     rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
 }
Пример #5
0
 public ReportPrinter(System.Net.ICredentials rsCr, string reportServerUrl)
 {
     this.debugOn = System.Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["debug"].Trim());
     rs = new ReportExecutionService();
     rs.Url = reportServerUrl;
     rs.Credentials = rsCr;
 }
Пример #6
0
        private void BtnExecuteSelected_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.executeReportsCollection.Clear();
            var execList = new List <ReportExecutionWPFRecord>();

            if (ViewModel.selectedReportsCollection.Count > 0)
            {
                var execService = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>());
                execList = ViewModel.selectedReportsCollection.Select(r =>
                                                                      new ReportExecutionWPFRecord
                {
                    Image     = new BitmapImage(new Uri(@"C:\Users\cameron.heilman\Documents\WR\GIT_JAPI\japi\JAPI\JAPI.App\Resources\clock-8-32.png")),
                    rowStatus = WPFRecrodStatus.Waiting,
                    resultSet = new ReportExecutionResultSet
                    {
                        guid     = Guid.NewGuid(),
                        resource = r,
                        status   = "waiting",
                    }
                }).ToList();

                ViewModel.executeReportsCollection.AddRange(execList);
                Task.Factory.StartNew(async() => { await ViewModel.pollService.SendExecutionRequests(execList); });
            }

            tabResults.IsEnabled  = (ViewModel.executeReportsCollection.Count > 0);
            tabResults.IsSelected = true;
        }
Пример #7
0
        public static async Task <KeyValuePair <string, ExecutionStatus> > PollRequest(string requestId)
        {
            //continuously polls until exit condition is met
            var execService = new ReportExecutionService(SessionRepository);

            return(await execService.PollReportKVP(requestId));
        }
Пример #8
0
        //private rs2005.ReportingService2005 rs;

        public ReporteSSRS(ConexionAFuenteDatos Conexion, Parametros Param)
        {
            _SrvrName             = Conexion.ServerAddress;
            _DbName               = Conexion.Intercompany;
            _IdUsuario            = Conexion.Usuario;
            _Password             = Conexion.Password;
            _IntegratedSecurity   = Conexion.IntegratedSecurity;
            _rutaYReporteSSRS     = Param.rutaReporteSSRS;
            _listaDefParamReporte = Param.ListaParametrosRepSSRS;
            _param = Param;

            try
            {
                _rsExec             = new ReportExecutionService();              // Create a new proxy to the web service
                _rsExec.Credentials = CredentialCache.DefaultCredentials;        // Authenticate to the Web service using Windows credentials
                if (Param.reporteador.Equals("SSRS"))
                {
                    _rsExec.Url = Param.SSRSServer + "/ReportExecution2005.asmx";    // Assign the URL of the Web service
                    _ei         = _rsExec.LoadReport(_rutaYReporteSSRS, _historyID); // Load the selected report.
                }
            }
            catch (Exception Rp)
            {
                ultimoMensaje = "Error al inicializar el reporte [ReporteSSRS]" + Rp.Message;
                numError++;
            }
        }
Пример #9
0
 public ReportPrinter()
 {
     this.debugOn   = System.Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["debug"].Trim());
     rs             = new ReportExecutionService();
     rs.Url         = System.Configuration.ConfigurationManager.AppSettings["eDSITran_ReportServer_ReportingService"].Trim();
     rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
 }
Пример #10
0
 public ReportPrinter(System.Net.ICredentials rsCr, string reportServerUrl)
 {
     this.debugOn   = System.Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["debug"].Trim());
     rs             = new ReportExecutionService();
     rs.Url         = reportServerUrl;
     rs.Credentials = rsCr;
 }
Пример #11
0
        public async Task ExecuteReportReturnDetails()
        {
            var service    = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>());
            var reportPath = "/reports/X2R_User_Report";

            try
            {
                var requestObject = new ReportExecutionRequest
                {
                    reportUnitUri = reportPath,
                    async         = true,
                    outputFormat  = "pdf",
                };

                var reportJob = await service.ExecuteReportAsync(requestObject);

                if (reportJob != null && !string.IsNullOrEmpty(reportJob.requestId))
                {
                    if (!service.cancelStatuses.Contains(reportJob.status))
                    {
                        Task <ExecutionStatus> pollTask = service.PollReport(reportJob.requestId);
                        pollTask.Wait();
                    }

                    var jobDetails = await service.GetExecutionDetails(reportJob.exports[0].id);


                    Debug.Assert(true);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        private static IReportExecutionService CreateReportExecutionService()
        {
            var executionService = new ReportExecutionService(
                InjectServiceUrl(),
                CredentialCache.DefaultCredentials);

            return(executionService);
        }
Пример #13
0
        public static async Task <string> ExecuteRequest(ReportExecutionResultSet executionSet)
        {
            var requestId   = string.Empty;
            var execService = new ReportExecutionService(SessionRepository);

            var reportJob = await execService.ExecuteReportAsync(executionSet.GetDefaultRequestObject());

            return(reportJob.requestId);
        }
Пример #14
0
        /// <summary>
        /// Gerar arquivo binário conforme formato e caminho do relatório especificado e seus parâmetros
        /// </summary>
        /// <param name="formato"></param>
        /// <param name="caminho"></param>
        /// <param name="parametros"></param>
        /// <returns></returns>
        public byte[] RelatorioBinarioRS(string formato, string caminho, List <ParametroRelatorio> parametros)
        {
            var rs = new ReportExecutionService
            {
                Credentials = CredentialCache.DefaultNetworkCredentials,
                Url         = GerenciadorConfiguracao.ServidorDeRelatorio
            };

            string PastaDoRelatorio = GerenciadorConfiguracao.PastaDoRelatorio;

            byte[] result     = null;
            string reportPath = PastaDoRelatorio + caminho;
            string format     = formato;
            string historyID  = null;
            string devInfo    = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

            var executionParams = new List <ParameterValue>();

            foreach (var parametro in parametros)
            {
                executionParams.Add(new ParameterValue
                {
                    Name  = parametro.IdParametro,
                    Value = parametro.Valor != null ? parametro.Valor.ToString() : null
                });
            }

            string encoding;
            string mimeType;
            string extension;

            Warning[] warnings  = null;
            string[]  streamIDs = null;

            var execInfo   = new ExecutionInfo();
            var execHeader = new ExecutionHeader();

            rs.ExecutionHeaderValue = execHeader;

            execInfo = rs.LoadReport(reportPath, historyID);
            rs.SetExecutionParameters(executionParams.ToArray(), "pt-BR");
            String SessionId = rs.ExecutionHeaderValue.ExecutionID;

            try
            {
                result   = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
                execInfo = rs.GetExecutionInfo();
            }
            catch (Exception ex)
            {
                throw new Exception($"Não foi possível gerar o relatório erro do servidor : {ex.RecuperarMsgExcecaoAninhada()}");
            }

            return(result);
        }
Пример #15
0
        private void Render(ReportExecutionService rs, string extension, ReportRenderArg args)
        {
            byte[] result       = null;
            string ext          = null;
            string executionID  = null;
            var    checkIsEmpty = args.EmptyOutput != null && !string.IsNullOrWhiteSpace(args.MainDataSet);

            try
            {
                Logger.Log(LevelEnum.Info, $"Rendering report {args.ItemPath} for {extension} format...");
                result = rs.Render(GetFormat(extension), null, out ext, out string encoding, out string mimeType, out Warning[] warnings, out string[] streamId);
Пример #16
0
        public void ProcessRequest(HttpContext context)
        {
            ReportExecutionService rs = new ReportExecutionService();
            ExecutionInfo          execInfo = new ExecutionInfo();
            ExecutionHeader        execHeader = new ExecutionHeader();
            string historyId = null, encoding = "";
            string reportPath  = "/wismusta/DistrictAuditionStatistics";
            //string extension = "PDF";
            //string mimeType = "pdf";
            string extension   = "";
            string mimeType    = "";
            string devInfo     = "False";

            Warning[] warning  = null;
            string[]  streamId = null;
            byte[]    result   = null;

            rs.Url = "http://sunflower.arvixe.com/ReportServer_SQL_Service/ReportExecution2005.asmx?wsdl";

            //add credentials
            rs.Credentials = new NetworkCredential("wismusta_reportservr", "33wi8mu8ta44", "sunflower.arvixe.com");

            //add parameters
            ParameterValue[] parameters = new ParameterValue[1];
            parameters[0]       = new ParameterValue();
            parameters[0].Name  = "auditionOrgId";
            parameters[0].Value = "1036";

            rs.ExecutionHeaderValue = execHeader;
            execInfo = rs.LoadReport(reportPath, historyId);
            rs.SetExecutionParameters(parameters, "en-us");
            result = rs.Render("PDF", devInfo, out extension, out mimeType, out encoding, out warning, out streamId);

            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.AppendHeader("content-length", result.Length.ToString());
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.BinaryWrite(result);
            HttpContext.Current.Response.End();
            HttpContext.Current.Response.Flush();

            //HttpContext.Current.Response.ClearContent();
            //HttpContext.Current.Response.AddHeader("Pragma", "public");
            //HttpContext.Current.Response.AddHeader("Content-Description", "File Transfer");
            //HttpContext.Current.Response.AddHeader("X-Download-Options", "noopen");
            //HttpContext.Current.Response.AddHeader("X-Content-Type-Options", "nosniff");
            //HttpContext.Current.Response.AddHeader("Content-Transfer-Encoding", "binary");
            //HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=Student_History_Rpt.pdf");
            //HttpContext.Current.Response.AppendHeader("content-length", result.Length.ToString());
            //HttpContext.Current.Response.ContentType("application/excel");
            //HttpContext.Current.Response.BinaryWrite(result);
            //HttpContext.Current.Response.End();
            //HttpContext.Current.Response.Flush();
        }
 public Report2005(string url)
 {
     Console.WriteLine("{0}: Authenticating to the Web service...", DateTime.Now.ToString("HH:mm:ss fff"));
     try
     {
         res             = new ReportExecutionService(url);
         res.Credentials = CredentialCache.DefaultCredentials;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Пример #18
0
        public static Byte[] DownloadExcel(System.Web.HttpContextBase httpContext, ReportExecutionBE reportexecution)
        {
            var rs     = ReportWebServiceInstance(httpContext);
            var rsExec = new ReportExecutionService();

            rsExec.Timeout     = System.Threading.Timeout.Infinite;
            rsExec.Credentials = rs.Credentials;
            byte[] result  = null;
            string format  = "EXCEL";
            string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
            string extension;
            string encoding;
            string mimeType;

            ReportExecution.Warning[] warnings = null;
            string[] streamIDs = null;

            ExecutionInfo execInfo = new ExecutionInfo();

            //var output = new HttpResponseMessage();
            try
            {
                ReportExecution.ExecutionInfo         ei         = rsExec.LoadReport(reportexecution.ReportPath, null);
                List <ReportExecution.ParameterValue> parameters = new List <ReportExecution.ParameterValue>();

                for (int i = 0; i < reportexecution.Parameters.Count; ++i)
                {
                    for (int j = 0; j < reportexecution.Parameters[i].Value.Length; ++j)
                    {
                        ReportExecution.ParameterValue item = new ReportExecution.ParameterValue();
                        item.Name  = reportexecution.Parameters[i].Name;
                        item.Label = reportexecution.Parameters[i].Label;
                        item.Value = reportexecution.Parameters[i].Value[j];
                        parameters.Add(item);
                    }
                }
                ReportExecution.ParameterValue[] parametersExec = parameters.ToArray();
                rsExec.SetExecutionParameters(parametersExec, "en-us");
                result = rsExec.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

                execInfo = rsExec.GetExecutionInfo();
            }
            catch (SoapException ex)
            {
                //output = new HttpResponseMessage(HttpStatusCode.BadRequest);
                LoggingHelper.LogException("Unable to generate the excel file.", ex);
            }
            //return File(result, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", reportexecution.ReportName + "-" + execInfo.ExecutionDateTime + ".xlsx");
            return(result);
        }
Пример #19
0
        public static bool ReportExists(string reportPath, string ssrsUrl)
        {
            var rs = new ReportExecutionService();

            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rs.Url         = ssrsUrl;

            byte[] result    = null;
            string historyID = null;
            string devInfo   = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
            string encoding;
            string mimeType;
            string extension;

            Warning[] warnings  = null;
            string[]  streamIDs = null;
            string    format    = "XML";

            ParameterValue[] parameters = null;

            ExecutionInfo   execInfo   = new ExecutionInfo();
            ExecutionHeader execHeader = new ExecutionHeader();

            rs.ExecutionHeaderValue = execHeader;

            try
            {
                execInfo = rs.LoadReport(reportPath, historyID);
            }
            catch (SoapException e)
            {
                if (e.Detail.OuterXml.Contains("rsItemNotFound"))
                {
                    Console.WriteLine("Report: {0} not found", reportPath);
                }
                else
                {
                    Console.WriteLine(e.Detail.OuterXml);
                }
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
            return(true);
        }
Пример #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLocation_Click_1(object sender, EventArgs e)
        {
            // Always retrieve the Extensions again, because the report server can be changed!

            var rs = new ReportExecutionService {
                Url = txtReportServer.Text + "/ReportExecution2005.asmx"
            };

            if (WindowsAuthorization)
            {
                rs.Credentials = CredentialCache.DefaultCredentials;
            }
            else
            {
                rs.CookieContainer = new CookieContainer();
                rs.LogonUser(Username, Password, txtReportServer.Text);
            }


            Extension[] extensions;
            // Retrieve a list of all renderingextensions.
            extensions = rs.ListRenderingExtensions();

            if (extensions != null)
            {
                var filter = "";
                foreach (var extension in extensions)
                {
                    // only add supporter extensions
                    if (!_renderExtensions.Contains(extension.Name))
                    {
                        continue;
                    }
                    var supportedExtension = (RenderExtension)_renderExtensions[extension.Name];
                    //build filter like: Acrobat (*.pdf)|*.pdf|Microsoft Excel (*.xls)|*.xls
                    if (filter.Length > 0)
                    {
                        filter += "|";
                    }
                    filter += supportedExtension.FullName + " (" + supportedExtension.Extension + ")|" + supportedExtension.Extension;
                }
                sfdReport.Filter = filter;
            }
            if (sfdReport.ShowDialog() == DialogResult.OK)
            {
                txtLocation.Text = sfdReport.FileName;
            }
        }
Пример #21
0
        public async Task GetExecutedReportContentShouldNotHappenThisWay()
        {
            // f7bebd78-965c-4e08-ac27-6ade43f75163/exports/383b0c75-551d-43b0-9736-06af2fa4610d/outputResource
            var service    = new ReportExecutionService(RepositoryInjector.GetInjector <JAPISessionRepository>());
            var reportPath = "/reports/X2R_User_Report";
            var reportName = "X2R_User_Report.pdf";

            var requestObject = new ReportExecutionRequest
            {
                reportUnitUri = reportPath,
                async         = false,
                outputFormat  = "pdf",
            };

            try
            {
                Task <ReportExecutionResponse> execTask = service.ExecuteReportAsync(requestObject);
                execTask.Wait();

                var execResponse = execTask.Result;
                if (!string.IsNullOrEmpty(execResponse.requestId) && execResponse.status.Equals("ready", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var export in execResponse.exports)
                    {
                        var downloadPath = System.AppContext.BaseDirectory + reportName + ".pdf";

                        if (System.IO.File.Exists(downloadPath))
                        {
                            System.IO.File.Delete(downloadPath);
                        }

                        var rawBytes = await service.GetExecutionOuput(execResponse.requestId, export.id);

                        System.IO.File.WriteAllBytes(downloadPath, rawBytes);
                    }
                }

                Debug.Assert(true);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public byte[] CreateQuoteSheetPdf(CreateQuoteSheetDto dto, bool isDeclinature)
        {
            var parameters = new List <ParameterValue>();
            var reportPath = dto.QuoteSheetTemplateUrl ??
                             ConfigurationManager.AppSettings["QuoteSheetReportPath"];

            using (var reportService = new ReportExecutionService())
            {
                reportService.PreAuthenticate = true;
                reportService.Credentials     = CredentialCache.DefaultCredentials;

                foreach (var option in dto.OptionList)
                {
                    parameters.AddRange(option.OptionVersionNumberList.Select(versionNumber => new ParameterValue
                    {
                        Name  = "OptionVersions",
                        Value = option.OptionId + "," + versionNumber
                    }));
                }

                parameters.Add(new ParameterValue
                {
                    Name  = "QuoteType",
                    Value = dto.QuoteSheetTemplateName
                });

                parameters.Add(new ParameterValue
                {
                    Name  = "isDeclinature",
                    Value = isDeclinature? "True":"False"
                });

                reportService.LoadReport(reportPath, null);
                reportService.SetExecutionParameters(parameters.ToArray(), "en-gb");

                String    extension, encoding, mimetype;
                String[]  streamIds;
                Warning[] warnings;

                return(reportService.Render("PDF", null, out extension, out encoding,
                                            out mimetype, out warnings, out streamIds));
            }
        }
Пример #23
0
        /// <summary>
        /// Executes report and returns file
        /// </summary>
        /// <param name="path">Path to report</param>
        /// <param name="format">Format</param>
        /// <param name="parameters">List of parameters</param>
        /// <returns>Array of bytes</returns>
        public byte[] ExportReport(string path, string format, List <SsrsParameter> parameters)
        {
            string reportPath = path;
            string historyID  = null;
            string devInfo    = @"<DeviceInfo><Toolbar>Full</Toolbar></DeviceInfo>";
            string encoding;
            string mimeType;
            string extension;

            Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.Warning[] warnings = null;
            string[] streamIDs = null;

            ReportExecutionService res = new ReportExecutionService();

            res.Url         = ConfigurationManager.AppSettings["ReportingServiceExecutionUrl"];
            res.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["ReportingServiceLogin"],
                                                               ConfigurationManager.AppSettings["ReportingServicePassword"],
                                                               ConfigurationManager.AppSettings["ReportingServiceDomain"]);

            ExecutionInfo   execInfo   = new ExecutionInfo();
            ExecutionHeader execHeader = new ExecutionHeader();

            res.ExecutionHeaderValue = execHeader;
            execInfo = res.LoadReport(reportPath, historyID);
            if (parameters.Count > 0)
            {
                ParameterValue[] plist = new ParameterValue[parameters.Count];

                for (var i = 0; i < parameters.Count; i++)
                {
                    plist[i] = new ParameterValue
                    {
                        Name  = parameters[i].Name,
                        Value = parameters[i].Value
                    };
                    i++;
                }

                res.SetExecutionParameters(plist, "en-us");
            }

            return(res.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs));
        }
Пример #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ReportExecutionService rs = new ReportExecutionService();

            //set parameters and report settings
            string reportPath = "/StudentHistory";

            rs.Url = "http://sunflower.arvixe.com/ReportServer_SQL_Service/ReportExecution2005.asmx?wsdl";

            DataSourceCredentials credentials = new DataSourceCredentials();

            credentials.DataSourceName = "sunflower.arvixe.com";
            credentials.UserName       = "******";
            credentials.Password       = "******";

            rs.SetExecutionCredentials(new DataSourceCredentials[] { credentials });

            ExecutionInfo   info = new ExecutionInfo();
            ExecutionHeader header = new ExecutionHeader();
            string          historyId = "", extension = "", mimeType = "", encoding = "", devInfo = "False";

            string[]  streamId;
            Warning[] warning;
            byte[]    result;

            ParameterValue param = new ParameterValue();

            param.Name  = "@auditionOrgId";
            param.Value = "1036";

            rs.ExecutionHeaderValue = header;
            info = rs.LoadReport(reportPath, historyId);
            rs.SetExecutionParameters(new ParameterValue[] { param }, "en-us");
            result = rs.Render("PDF", devInfo, out extension, out mimeType, out encoding,
                               out warning, out streamId);

            Response.ClearContent();
            Response.AppendHeader("content-length", result.Length.ToString());
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(result);
            Response.End();
            Response.Flush();
        }
        /// <summary>
        /// Get report with format
        /// </summary>
        /// <param name="reportName">Actual Report Name</param>
        /// <param name="filters">Report Filters</param>
        /// <param name="reportExportType">Report Format</param>
        /// <returns></returns>
        public static byte[] GetReport(string reportName, ReportExportTypes reportExportType = ReportExportTypes.Pdf,
                                       ParameterValue[] filters = null)
        {
            var rs = new ReportExecutionService();
            //set report name
            var reportAbsoluteName = ReportLocalPath + "/" + reportName;

            //set ssrs service uri
            rs.Url = ReportServiceUrl + "/" + ReportServiceName;
            //set authentication
            rs.Credentials = CredentialCache.DefaultCredentials;
            var nc = new NetworkCredential(ReportUser, ReportPass, ReportDomain);

            rs.Credentials = nc;

            //set render args
            string deviceInfo = null;
            var    format     = reportExportType.ToString().ToUpper();

            if (format == "HTML")
            {
                deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
                format     = "HTML4.0";
            }
            //load report
            rs.LoadReport(reportAbsoluteName, null);
            //set filters
            if (filters != null)
            {
                rs.SetExecutionParameters(filters, ReportParamsCulture);
            }

            Warning[] warnings;
            string[]  streamIDs;
            string    extension;
            string    mimeType;
            string    encoding;
            var       results = rs.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings,
                                          out streamIDs);

            return(results);
        }
        private void ListrenderingExtensions(string URL)
        {
            var rs = new ReportExecutionService
            {
                Url         = URL,
                Credentials = System.Net.CredentialCache.DefaultCredentials
            };

            try
            {
                ReportExecution2005.Extension[] extensions = rs.ListRenderingExtensions();

                if (extensions != null)
                {
                    cmbFileType.Items.Clear();
                    cmbFileType.Items.AddRange(extensions);
                }
            }
            catch { }
        }
Пример #27
0
        private byte[] RunReport(string reportPath, ReportFormat format, ICollection <KeyValuePair <string, object> > parameters)
        {
            var service = new ReportExecutionService
            {
                Credentials          = System.Net.CredentialCache.DefaultCredentials,
                Url                  = _reportExecutionUrl,
                ExecutionHeaderValue = new ExecutionHeader()
            };

            service.LoadReport(reportPath, null);

            // Prepare report parameters.

            if (parameters != null && parameters.Count > 0)
            {
                var parameterValues = new ParameterValue[parameters.Count];
                var index           = 0;
                foreach (var parameterPair in parameters)
                {
                    parameterValues[index] = new ParameterValue
                    {
                        Name  = parameterPair.Key,
                        Value = parameterPair.Value == null ? null : parameterPair.Value.ToString()
                    };
                    ++index;
                }

                service.SetExecutionParameters(parameterValues, "en-us");
            }

            const string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
            string       encoding;
            string       mimeType;
            string       extension;

            Warning[] warnings;
            string[]  streamIds;

            return(service.Render(GetFormat(format), deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIds));
        }
Пример #28
0
        private ServerConnection(string server, bool useDefaultCredentials)
        {
            var fixedServerUrl = server.TrimEnd('/');
            var reportSvcUrl   = fixedServerUrl + "/reportservice2010.asmx";
            var reportExecUrl  = fixedServerUrl + "/reportexecution2005.asmx";

            ReportingServiceUrl   = reportSvcUrl;
            ExecutionServiceUrl   = reportExecUrl;
            UseDefaultCredentials = useDefaultCredentials;

            ReportingService = new ReportingService2010
            {
                Url = reportSvcUrl,
                UseDefaultCredentials = useDefaultCredentials
            };

            ExecutionService = new ReportExecutionService()
            {
                Url = reportExecUrl,
                UseDefaultCredentials = useDefaultCredentials
            };
        }
        private ServerConnection(string server, bool useDefaultCredentials)
        {
            var fixedServerUrl = server.TrimEnd('/');
            var reportSvcUrl = fixedServerUrl + "/reportservice2010.asmx";
            var reportExecUrl = fixedServerUrl + "/reportexecution2005.asmx";

            ReportingServiceUrl = reportSvcUrl;
            ExecutionServiceUrl = reportExecUrl;
            UseDefaultCredentials = useDefaultCredentials;

            ReportingService = new ReportingService2010
            {
                Url = reportSvcUrl,
                UseDefaultCredentials = useDefaultCredentials
            };

            ExecutionService = new ReportExecutionService()
            {
                Url = reportExecUrl,
                UseDefaultCredentials = useDefaultCredentials
            };
        }
Пример #30
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ReportExecutionService reportExecutionService = new ReportExecutionService();   // Web Service proxy
        reportExecutionService.Credentials = new NetworkCredential("reportservice", "Asdfghjkl?", "kswh107");

        string reportPath = "/ReconCurrent/ReconCurrent";
        string format = "PDF";

        // Render arguments
        byte[] result = null;
        string historyID = null;

        string encoding;
        string mimeType;
        string extension;
        Warning[] warnings = null;
        string[] streamIDs = null;

        ExecutionInfo execInfo = new ExecutionInfo();
        ExecutionHeader execHeader = new ExecutionHeader();

        reportExecutionService.ExecutionHeaderValue = execHeader;

        execInfo = reportExecutionService.LoadReport(reportPath, historyID);

        String SessionId = reportExecutionService.ExecutionHeaderValue.ExecutionID;

        result = reportExecutionService.Render(format, null, out extension, out encoding, out mimeType, out warnings, out streamIDs);

        Response.ClearContent();
        Response.AppendHeader("content-length", result.Length.ToString());
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(result);
        Response.End();
        //Response.Flush();
        //Response.Close();
    }
Пример #31
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            var tracingService = executionContext.GetExtension <ITracingService>();
            var context        = executionContext.GetExtension <IWorkflowContext>();
            var serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            var service        = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                Guid   RecordId = context.PrimaryEntityId;
                string _rpName  = RptName.Get <string>(executionContext);
                string _appNum  = AppNum.Get <string>(executionContext);
                byte[] result   = null;

                ReportExecutionService rs = new ReportExecutionService();
                rs.Credentials = new NetworkCredential("<Username>", "<Password>", "<Domain>");
                rs.Url         = "<Org_URL>/ReportExecution2005.asmx";
                tracingService.Trace(context.OrganizationName);
                string           reportPath = "/" + context.OrganizationName + "_MSCRM/" + _rpName;
                string           format     = "PDF";
                string           historyID  = null;
                string           devInfo    = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
                string           encoding;
                string           mimeType;
                string           extension;
                Warning[]        warnings   = null;
                string[]         streamIDs  = null;
                ParameterValue[] parameters = new ParameterValue[1];
                parameters[0]       = new ParameterValue();
                parameters[0].Name  = "id";
                parameters[0].Value = RecordId.ToString();
                tracingService.Trace("Id passed: " + RecordId.ToString());
                ExecutionInfo   execInfo   = new ExecutionInfo();
                ExecutionHeader execHeader = new ExecutionHeader();
                rs.ExecutionHeaderValue = execHeader;
                execInfo = rs.LoadReport(reportPath, historyID);
                rs.SetExecutionParameters(parameters, "en-us");
                String SessionId = rs.ExecutionHeaderValue.ExecutionID;

                result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
                Response.Rootobject response = this.GetStamp(Convert.ToBase64String(result), Convert.ToInt32(result.Length.ToString()), _appNum, "<Token>", "<BlockChain_URL>");
                string StamppedFile          = response.UploadZipHash;
                //Create email activity
                Entity attachment = new Entity("activitymimeattachment");
                attachment["objectid"]       = Email.Get <EntityReference>(executionContext);
                attachment["objecttypecode"] = "email";
                attachment["filename"]       = "الشهادة.pdf";
                attachment["subject"]        = "لمن يهمه الأمر";
                attachment["body"]           = System.Convert.ToBase64String(response.StampContent);

                try
                {
                    service.Create(attachment);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error creating attachment - {0}", ex.Message));
                }

                try
                {
                    service.Execute(new SendEmailRequest()
                    {
                        EmailId       = Email.Get <EntityReference>(executionContext).Id,
                        IssueSend     = true,
                        TrackingToken = string.Empty
                    });
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error sending email - {0}", ex.Message));
                }
            }
            catch (Exception err)
            {
                throw new Exception("Exception" + err);
            }
        }
Пример #32
0
        public static string GetReportDataModel(DateTime startDate,
                                                DateTime endDate,
                                                string nodeId,
                                                string appId,
                                                //string segmentId,
                                                //string schemeId,
                                                string cultureInfo,
                                                string strategy
                                                )
        {
            ReportingStartDate = startDate;
            ReportingEndDate   = endDate;
            ReportingAppID     = appId;

            ParameterValue[] paramval = new ParameterValue[0];
            UserDTO          user     = FormsAuthenticationWrapper.User;

            var userApplications = (UserDTO)HttpContext.Current.Session["user"];
            // userApplications.Accounts

            var reportPathPrefix = "";
            var reportName       = string.Empty;

            // the node id should reference feature enum versus primary key

            switch (nodeId)
            {
            case "1":
            case "9004":
                reportPathPrefix  = ConfigurationManager.AppSettings["ReportPrefix"];
                reportName        = "RecommendationDemand";
                paramval          = new ParameterValue[4];
                paramval[0]       = new ParameterValue();
                paramval[0].Name  = "account";
                paramval[0].Value = user.LastAccountID;
                paramval[1]       = new ParameterValue();
                paramval[1].Name  = "applicationid";
                paramval[1].Value = appId.ToLower();
                paramval[2]       = new ParameterValue();
                paramval[2].Name  = "startdate";
                paramval[2].Value = ReportingStartDate.ToShortDateString();
                paramval[3]       = new ParameterValue();
                paramval[3].Name  = "enddate";
                paramval[3].Value = ReportingEndDate.ToShortDateString();
                break;

            case "2":
            case "9005":
                reportPathPrefix  = ConfigurationManager.AppSettings["ReportPrefix"];
                reportName        = "RecommendationDetail";
                paramval          = new ParameterValue[4];
                paramval[0]       = new ParameterValue();
                paramval[0].Name  = "account";
                paramval[0].Value = user.LastAccountID;
                paramval[1]       = new ParameterValue();
                paramval[1].Name  = "app_id";
                paramval[1].Value = appId.ToLower();
                paramval[2]       = new ParameterValue();
                paramval[2].Name  = "startdate";
                paramval[2].Value = ReportingStartDate.ToShortDateString();
                paramval[3]       = new ParameterValue();
                paramval[3].Name  = "enddate";
                paramval[3].Value = ReportingEndDate.ToShortDateString();
                break;

            case "3":
            case "9006":
                reportPathPrefix  = ConfigurationManager.AppSettings["ReportPrefix"];
                reportName        = "RecommendedItems";
                paramval          = new ParameterValue[4];
                paramval[0]       = new ParameterValue();
                paramval[0].Name  = "Account_ID";
                paramval[0].Value = user.LastAccountID;     // "Nike"
                paramval[1]       = new ParameterValue();
                paramval[1].Name  = "ApplicationID";
                paramval[1].Value = appId.ToLower();     // "Nike01US"
                paramval[2]       = new ParameterValue();
                paramval[2].Name  = "T_Start";
                paramval[2].Value = ReportingStartDate.ToShortDateString();
                //paramval[3] = new ParameterValue();
                //paramval[3].Name = "Scheme_ID";
                //paramval[3].Value = schemeId; // "All Schemes"
                paramval[3]       = new ParameterValue();
                paramval[3].Name  = "T_End";
                paramval[3].Value = ReportingEndDate.ToShortDateString();
                paramval[4]       = new ParameterValue();
                paramval[4].Name  = "Segment";
                paramval[4].Value = "All Segments";
                break;

            case "4":
            case "9007":
                reportPathPrefix  = ConfigurationManager.AppSettings["ReportPrefix"];
                reportName        = "StrategyComparison";
                paramval          = new ParameterValue[7];
                paramval[0]       = new ParameterValue();
                paramval[0].Name  = "Account_ID";
                paramval[0].Value = user.LastAccountID;
                paramval[1]       = new ParameterValue();
                paramval[1].Name  = "ApplicationID";
                paramval[1].Value = appId.ToLower();
                paramval[2]       = new ParameterValue();
                paramval[2].Name  = "T_Start";
                paramval[2].Value = ReportingStartDate.ToShortDateString();
                //paramval[3] = new ParameterValue();
                //paramval[3].Name = "Scheme_ID";
                //paramval[3].Value = schemeId; // "All Schemes"
                paramval[3]       = new ParameterValue();
                paramval[3].Name  = "T_End";
                paramval[3].Value = ReportingEndDate.ToShortDateString();
                paramval[4]       = new ParameterValue();
                paramval[4].Name  = "Strategy_Status";
                paramval[4].Value = strategy;
                paramval[5]       = new ParameterValue();
                paramval[5].Name  = "Tag";
                paramval[5].Value = "Ungroup";
                paramval[6]       = new ParameterValue();
                paramval[6].Name  = "GroupByTag";
                paramval[6].Value = "0";
                break;
            }

            Warning[] warnings   = null;
            string[]  streamIDs  = null;
            string    encoding   = string.Empty;
            string    mimeType   = string.Empty;
            string    extension  = string.Empty;
            var       reportHtml = string.Empty;

            try
            {
                var rs             = new ReportExecutionService();
                var reportUsername = ConfigurationManager.AppSettings["ReportUsername"];
                var reportPassword = ConfigurationManager.AppSettings["ReportPassword"];
                var reportDomain   = ConfigurationManager.AppSettings["ReportDomain"];
                rs.Credentials = new NetworkCredential(reportUsername, reportPassword, reportDomain);
                rs.LoadReport(string.Format("{0}{1}", reportPathPrefix, reportName), null);
                rs.SetExecutionParameters(paramval, "en-us");
                reportHtml = System.Text.Encoding.Default.GetString(rs.Render("HTML4.0", string.Empty, out extension, out encoding, out mimeType, out warnings, out streamIDs));
                rs.Timeout = 10000;
            }
            catch (Exception ex)
            {
                _certonaService.Abort();
                throw;
            }

            return(reportHtml);
        }
        /// <summary>
        /// Get report with format
        /// </summary>
        /// <param name="reportName">Actual Report Name</param>
        /// <param name="filters">Report Filters</param>
        /// <param name="reportExportType">Report Format</param>
        /// <returns></returns>
        public static byte[] GetReport(string reportName, ReportExportTypes reportExportType = ReportExportTypes.Pdf,
            ParameterValue[] filters = null)
        {
            var rs = new ReportExecutionService();
            //set report name
            var reportAbsoluteName = ReportLocalPath + "/" + reportName;
            //set ssrs service uri
            rs.Url = ReportServiceUrl + "/" + ReportServiceName;
            //set authentication
            rs.Credentials = CredentialCache.DefaultCredentials;
            var nc = new NetworkCredential(ReportUser, ReportPass, ReportDomain);
            rs.Credentials = nc;

            //set render args
            string deviceInfo = null;
            var format = reportExportType.ToString().ToUpper();

            if (format == "HTML")
            {
                deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
                format = "HTML4.0";
            }
            //load report
            rs.LoadReport(reportAbsoluteName, null);
            //set filters
            if (filters != null)
                rs.SetExecutionParameters(filters, ReportParamsCulture);

            Warning[] warnings;
            string[] streamIDs;
            string extension;
            string mimeType;
            string encoding;
            var results = rs.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings,
                out streamIDs);
            return results;
        }
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            //initialize report execution service
            string RSExecURL = @"http://" + Server + "/ReportServer/ReportExecution2005.asmx";
            ReportExecutionService RSExec2005 = new ReportExecutionService();

            RSExec2005.Credentials = System.Net.CredentialCache.DefaultCredentials;
            RSExec2005.Url         = RSExecURL;

            //prepare variables
            byte[]    Results  = null;
            Warning[] warnings = null;
            string    encoding;
            string    mimetype;

            string[] streamids = null;
            string   extension;

            try
            {
                ExecutionInfo Info = new ExecutionInfo();
                Info = RSExec2005.LoadReport(SelectedReport, null);


                if (DtParameters != null)
                {
                    if (DtParameters.Rows.Count > 0)
                    {
                        List <Tuple <string, string> > lstParameters = new List <Tuple <string, string> >();
                        foreach (DataRow row in DtParameters.Rows)
                        {
                            if (row["ParameterValue"] != null)
                            {
                                if (!string.IsNullOrEmpty(row["ParameterValue"].ToString()))
                                {
                                    //the parameter value has to be a variable
                                    string pName = row["ParameterName"].ToString();

                                    Variables varPValue = null;
                                    variableDispenser.LockOneForRead(row["ParameterValue"].ToString(), ref varPValue);
                                    string pValue = varPValue[0].Value.ToString();

                                    lstParameters.Add(Tuple.Create(pName, pValue));
                                }
                            }
                        }

                        ParameterValue[] Parameters;
                        if (lstParameters.Count > 0)
                        {
                            Parameters = new ParameterValue[lstParameters.Count];

                            for (int i = 0; i < lstParameters.Count; i++)
                            {
                                Parameters[i]       = new ParameterValue();
                                Parameters[i].Name  = lstParameters[i].Item1;
                                Parameters[i].Value = lstParameters[i].Item2;
                            }

                            RSExec2005.SetExecutionParameters(Parameters, "en-us");
                        }
                    }
                }

                //output format and name
                Variables varFileFormat = null;
                variableDispenser.LockOneForRead(FileFormat, ref varFileFormat);

                Variables varFileName = null;
                variableDispenser.LockOneForRead(FileName, ref varFileName);

                Results = RSExec2005.Render(varFileFormat[0].Value.ToString(), null, out extension, out mimetype, out encoding, out warnings, out streamids);
                Info    = RSExec2005.GetExecutionInfo();

                FileStream FS = File.Create(varFileName[0].Value.ToString(), Results.Length);
                FS.Write(Results, 0, Results.Length);
                FS.Close();

                return(DTSExecResult.Success);
            }
            catch (Exception ex)
            {
                componentEvents.FireError(0, "Reporting Service Task", "Task Error: " + ex.ToString(), "", -1);
                return(DTSExecResult.Failure);
            }
        }
Пример #35
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            bool userok = GetUserVerify();
            bool sqlok  = BuildSQL();

            if (!userok)
            {
                return;
            }

            if (!sqlok)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(networkdomain) || string.IsNullOrWhiteSpace(networkuser) ||
                string.IsNullOrWhiteSpace(networkpassword))
            {
                MessageBox.Show("Network Authentication is not available to send reports", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //check if report type is selected or not

            if (cmbRptType.SelectedIndex < 0)
            {
                MessageBox.Show("Please Select the Report Type", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string err = string.Empty;

            switch (cmbRptType.SelectedItem.ToString())
            {
            case "Monthly Attendance Report":
                err = ValidateMonthlyAttd();
                break;     /* optional */

            case "Daily Performance Report":
                err = ValidateDailyPerformance();
                break;     /* optional */

            case "Monthly Lunch Halfday Report":
                err = ValidateDailyPerformance();
                break;     /* optional */
            }

            if (!string.IsNullOrEmpty(err))
            {
                MessageBox.Show(err, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            /* now lock all controls */
            btnAdd.Enabled      = false;
            btnRemove.Enabled   = false;
            cmbRptType.Enabled  = false;
            txtUserName.Enabled = false;
            txtPassword.Enabled = false;
            btnReset.Enabled    = false;
            lstWrkGrp.Enabled   = false;
            btnSend.Enabled     = false;

            DataSet ds      = Utils.Helper.GetData(subscrsql, Utils.Helper.constr);
            bool    hasRows = ds.Tables.Cast <DataTable>().Any(table => table.Rows.Count != 0);

            if (!hasRows)
            {
                MessageBox.Show("No any Subscription found in selected criteria", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            pBar1.Minimum = 0;
            pBar1.Maximum = ds.Tables[0].Rows.Count;
            pBar1.Value   = 0;

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                NetworkCredential    clientCredentials = new NetworkCredential(networkuser, networkpassword, networkdomain);
                ReportingService2010 rs = new ReportingService2010();
                rs.Credentials = clientCredentials;

                //rs.Url = "http://172.16.12.47/reportserver/reportservice2010.asmx";
                rs.Url = Globals.G_ReportServiceURL;

                ReportExecutionService rsExec = new ReportExecutionService();
                rsExec.Credentials = clientCredentials;
                //rsExec.Url = "http://172.16.12.47/reportserver/reportexecution2005.asmx";
                rsExec.Url = Globals.G_ReportSerExeUrl;
                string    historyID  = null;
                string    reportPath = string.Empty;
                string    deviceInfo = null;
                string    extension;
                string    encoding;
                string    mimeType;
                Warning[] warnings  = null;
                string[]  streamIDs = null;
                string    format    = "EXCEL";
                Byte[]    results;
                string    subscrid = row["SubScriptionID"].ToString();


                switch (cmbRptType.SelectedItem.ToString())
                {
                case "Monthly Attendance Report":
                    reportPath = "/Attendance/Automail Reports/Monthly Attendance Report";
                    rsExec.LoadReport(reportPath, historyID);
                    ParameterValue[] executionParams = new ParameterValue[4];
                    executionParams[0]       = new ParameterValue();
                    executionParams[0].Name  = "WrkGrp";
                    executionParams[0].Value = row["Param1WrkGrp"].ToString();

                    executionParams[1]       = new ParameterValue();
                    executionParams[1].Name  = "SubScriptionID";
                    executionParams[1].Value = row["SubScriptionID"].ToString();

                    executionParams[2]       = new ParameterValue();
                    executionParams[2].Name  = "FromDt";
                    executionParams[2].Value = txtDtFrom.Value.ToString("yyyy-MM-dd");

                    executionParams[3]       = new ParameterValue();
                    executionParams[3].Name  = "ToDate";
                    executionParams[3].Value = txtDtTo.Value.ToString("yyyy-MM-dd");
                    rsExec.SetExecutionParameters(executionParams, "en-us");
                    string substr1 = "Monthly Attendance Report For " + txtDtFrom.Value.ToString("dd-MMM") + " To " + txtDtTo.Value.ToString("dd-MMM");
                    results = rsExec.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
                    MailAttachment m = new MailAttachment(results, "Monthly Attendance Report.xls");
                    Email(row["EmailTo"].ToString(), row["EmailCopy"].ToString(), row["BCCTo"].ToString(),
                          "Monthly Attendance Report", substr1, "*****@*****.**", "Attendance IPU", "", "", subscrid, m);

                    break;     /* optional */

                case "Daily Performance Report":
                    reportPath = "/Attendance/Automail Reports/New Daily Performance Report With Date Para";
                    rsExec.LoadReport(reportPath, historyID);
                    ParameterValue[] executionParams1 = new ParameterValue[3];
                    executionParams1[0]       = new ParameterValue();
                    executionParams1[0].Name  = "WrkGrp";
                    executionParams1[0].Value = row["Param1WrkGrp"].ToString();

                    executionParams1[1]       = new ParameterValue();
                    executionParams1[1].Name  = "SubScriptionID";
                    executionParams1[1].Value = row["SubScriptionID"].ToString();

                    executionParams1[2]       = new ParameterValue();
                    executionParams1[2].Name  = "tDate";
                    executionParams1[2].Value = txtDtFrom.Value.ToString("yyyy-MM-dd");
                    rsExec.SetExecutionParameters(executionParams1, "en-us");
                    string substr2 = "Daily Performance Report For " + txtDtFrom.Value.ToString("dd-MMM");
                    results = rsExec.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
                    MailAttachment m1 = new MailAttachment(results, "Daily Performance Report.xls");
                    Email(row["EmailTo"].ToString(), row["EmailCopy"].ToString(), row["BCCTo"].ToString(),
                          "Daily Performance Report", substr2, "*****@*****.**", "Attendance IPU", "", "", subscrid, m1);

                    break;     /* optional */

                case "Monthly Lunch Halfday Report":
                    reportPath = "/Attendance/Automail Reports/Monthly Lunch Halfday Report";
                    rsExec.LoadReport(reportPath, historyID);
                    ParameterValue[] executionParams2 = new ParameterValue[4];
                    executionParams2[0]       = new ParameterValue();
                    executionParams2[0].Name  = "WrkGrp";
                    executionParams2[0].Value = row["Param1WrkGrp"].ToString();

                    executionParams2[1]       = new ParameterValue();
                    executionParams2[1].Name  = "SubScriptionID";
                    executionParams2[1].Value = row["SubScriptionID"].ToString();

                    executionParams2[2]       = new ParameterValue();
                    executionParams2[2].Name  = "pFromDt";
                    executionParams2[2].Value = txtDtFrom.Value.ToString("yyyy-MM-dd");

                    executionParams2[3]       = new ParameterValue();
                    executionParams2[3].Name  = "pToDt";
                    executionParams2[3].Value = txtDtTo.Value.ToString("yyyy-MM-dd");
                    rsExec.SetExecutionParameters(executionParams2, "en-us");
                    string substr3 = "Monthly Lunch Halfday Report For " + txtDtFrom.Value.ToString("dd-MMM") + " To " + txtDtTo.Value.ToString("dd-MMM");

                    results = rsExec.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
                    MailAttachment m2 = new MailAttachment(results, "Monthly Lunch Halfday Report.xls");
                    Email(row["EmailTo"].ToString(), row["EmailCopy"].ToString(), row["BCCTo"].ToString(),
                          "Monthly Lunch Halfday Report", substr3, "*****@*****.**", "Attendance IPU", "", "", subscrid, m2);



                    break;
                }
                lblSid.Text = "Exec : SID - " + subscrid;
                lblSid.Update();
                pBar1.Value += 1;
                if (string.IsNullOrEmpty(reportPath))
                {
                    break;
                }
            }


            /* now unlock all controls */
            btnAdd.Enabled      = true;
            btnRemove.Enabled   = true;
            cmbRptType.Enabled  = true;
            txtUserName.Enabled = true;
            txtPassword.Enabled = true;
            btnReset.Enabled    = true;
            lstWrkGrp.Enabled   = true;
            btnSend.Enabled     = true;
        }
Пример #36
0
        private byte[] GetRsReport_New(MD_ReportItem _reportItem, string Format)
        {
            byte[] results;

            ReportExecutionService rs = new ReportExecutionService();

            rs.Credentials = new System.Net.NetworkCredential(RsConfig.Name, RsConfig.Pass);
            rs.Url         = RsConfig.RsURL;

            // Render arguments
            byte[] result     = null;
            string reportPath = "/海关总署缉私局/" + _reportItem.ReportName.ReportName;
            string historyID  = null;
            string devInfo    = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

            // Prepare report parameter.
            ReportService2008.ParameterValue[] param = new ReportService2008.ParameterValue[3];
            param[0]       = new ReportService2008.ParameterValue();
            param[0].Name  = "Report_Parameter_Year";
            param[0].Value = _reportItem.StartDate.Year.ToString();
            param[1]       = new ReportService2008.ParameterValue();
            param[1].Name  = "Report_Parameter_month";
            param[1].Value = _reportItem.StartDate.Month.ToString("D2");
            param[2]       = new ReportService2008.ParameterValue();
            param[2].Name  = "Report_Parameter_Dw";
            param[2].Value = _reportItem.ReportDWID;

            ReportService2008.DataSourceCredentials[] credentials = null;
            string showHideToggle = null;
            string encoding;
            string mimeType;
            string extension;

            ReportService2008.Warning[]        warnings = null;
            ReportService2008.ParameterValue[] reportHistoryParameters = null;
            string[] streamIDs = null;

            ExecutionInfo   execInfo   = new ExecutionInfo();
            ExecutionHeader execHeader = new ExecutionHeader();

            rs.ExecutionHeaderValue = execHeader;

            execInfo = rs.LoadReport(reportPath, historyID);

            rs.SetExecutionParameters(param, "en-us");
            String SessionId = rs.ExecutionHeaderValue.ExecutionID;

            try
            {
                result = rs.Render(Format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

                execInfo = rs.GetExecutionInfo();

                //Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime);
            }
            catch (SoapException e)
            {
                OralceLogWriter.WriteSystemLog(e.Detail.OuterXml, "ERROR");
            }
            return(result);
        }
Пример #37
0
        public void SenderMarkerMail(string reportName, string subject, string body, int markerHeader)
        {
            string deviceInfo = null;
            var    extension  = String.Empty;
            var    mimeType   = String.Empty;
            var    encoding   = String.Empty;

            Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.Warning[] warnings = null;
            string[] streamIDs = null;
            string   historyId = null;
            var      rsExec    = new ReportExecutionService();

            rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

            using (var context = new WorkFlowManagerDBEntities())
            {
                if (string.IsNullOrEmpty(ReportServer))
                {
                    ReportServer = context.tblChainSetups.SingleOrDefault(x => x.sGlobalSettingCode == "ReportServer").sSetupValue;
                }
            }

            rsExec.Url = ReportServer + "/ReportExecution2005.asmx";

            // Load the report
            var execInfo = rsExec.LoadReport("/Report/" + reportName, historyId);
            var para     = new ObservableCollection <string> {
                markerHeader.ToString()
            };
            var parameters = new ParameterValue[para.Count];

            foreach (var row in para)
            {
                var index = para.IndexOf(row);
                parameters[0]           = new ParameterValue();
                parameters[index].Value = row;
                parameters[index].Name  = execInfo.Parameters[index].Name;

                // paramters) { Name = , Value = row } }, "en-us");
            }
            rsExec.SetExecutionParameters(parameters, "en-us");

            // get pdf of report
            var results = rsExec.Render("PDF", deviceInfo,
                                        out extension, out encoding,
                                        out mimeType, out warnings, out streamIDs);

            //Walla...almost no code, it's easy to manage and your done.

            //Take the bytes and add as an attachment to a MailMessage(SMTP):

            var attach = new Attachment(new MemoryStream(results),
                                        String.Format("{0}.pdf", reportName));

            string emailFrom;
            var    emailTo = new List <string>();

            using (var model = new WorkFlowManagerDBEntities())
            {
                emailFrom = "*****@*****.**";

                var brandsectionMail = model.TblMarkerMails;

                foreach (var variable in brandsectionMail.Select(x => x.Emp))
                {
                    emailTo.Add(model.Employees.FirstOrDefault(x => x.EMPLID == variable).Email);
                }
            }
            SendEmail(attach, emailFrom, emailTo, subject, body);
        }