protected override IWriter GetWriter(ReportFormats format)
 {
     if (format != ReportFormats.Excel)
     {
         return(null);
     }
     return(new OptimizationEfficiencyExcludeOleExcelWriter());
 }
 protected override IWriter GetWriter(ReportFormats format)
 {
     if (format == ReportFormats.Excel)
     {
         return(new SupplierExcelWriter());
     }
     return(null);
 }
예제 #3
0
 protected override IWriter GetWriter(ReportFormats format)
 {
     if (format == ReportFormats.Excel)
     {
         return(new PricesOfCompetitorsWriter(Connection, _reportParams, ReportCaption));
     }
     return(null);
 }
예제 #4
0
 protected void TryInitReport <T>(string fileName = "test.xls", ReportFormats format = ReportFormats.Excel)
 {
     if (report == null)
     {
         report               = (BaseReport)Activator.CreateInstance(typeof(T), (MySqlConnection)session.Connection, properties);
         report.Format        = format;
         report.ReportCaption = "test report";
     }
 }
        protected override IWriter GetWriter(ReportFormats format)
        {
            if (format != ReportFormats.Excel)
            {
                return(null);
            }

            return(new PharmacyMixedOleWriter());
        }
예제 #6
0
        protected override IWriter GetWriter(ReportFormats format)
        {
            if (format == ReportFormats.DBF)
            {
                throw new ReportException("Не умею готовить отчет в dbf");
            }

            return(new LeakOffersNativeWriter());
        }
예제 #7
0
 public Report(string reportServerPath, string reportPath, ReportFormats format, NetworkCredential credentials, Dictionary <string, string> reportParams)
 {
     _httpWReq        = null;
     _httpWResp       = null;
     Params           = reportParams ?? new Dictionary <String, String>();
     ReportServerPath = reportServerPath;
     ReportPath       = reportPath;
     Format           = format;
     Credentials      = credentials;
 }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reportServerPath">ex. http://desktop-51p1738/ReportServer_SSRS</param>
 /// <param name="reportPath">ex. ReportFormats.Pdf</param>
 /// <param name="reportFormats">ex. BasicReport or BusinessReports/BasicReport</param>
 /// <param name="credentials">ex. new NetworkCredential("log", "pass")</param>
 /// <param name="reportParams">Dictionary, where [parameterName, parameterValue]></param>
 /// <returns>Report bytes in chosen format.</returns>
 public byte[] GetReportBytes(string reportPath, ReportFormats reportFormat, NetworkCredential credentials, Dictionary <string, string> reportParams)
 {
     using (Report report = new Report(ReportServerPath, reportPath, reportFormat, credentials, reportParams))
     {
         using (var ms = new MemoryStream())
         {
             report.Render().CopyTo(ms);
             return(ms.ToArray());
         }
     }
 }
예제 #9
0
 public static ReportFormat ByCode(ReportFormats code)
 {
     switch (code)
     {
         case ReportFormats.Html: return Html;
         case ReportFormats.MHtml: return Html; //<<======================
         case ReportFormats.Pdf: return Pdf;
         case ReportFormats.Xlsx: return Xlsx;
         case ReportFormats.Docx: return Docx;
         default: return null;
     }
 }
 /// <summary>
 /// Selects a Report Writter.
 /// </summary>
 public static ReportWritter GetReportWritter(System.IO.StreamWriter file, ReportFormats reportFormat = ReportFormats.ExcelReport)
 {
     ReportWritter reportWritter;
     if (reportFormat == ReportFormats.ExcelReport)
     {
         reportWritter = new ExcelWritter(file);
     }
     else
     {
         reportWritter = new CSVWritter(file);
     }
     return reportWritter;
 }
        /// <summary>
        /// Selects a Report Writter.
        /// </summary>
        public static ReportWritter GetReportWritter(System.IO.StreamWriter file, ReportFormats reportFormat = ReportFormats.ExcelReport)
        {
            ReportWritter reportWritter;

            if (reportFormat == ReportFormats.ExcelReport)
            {
                reportWritter = new ExcelWritter(file);
            }
            else
            {
                reportWritter = new CSVWritter(file);
            }
            return(reportWritter);
        }
예제 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reportServerPath">ex. http://desktop-51p1738/ReportServer_SSRS</param>
 /// <param name="reportPath">ex. ReportFormats.Pdf</param>
 /// <param name="reportFormats">ex. BasicReport or BusinessReports/BasicReport</param>
 /// <param name="reportParams">Dictionary, where [parameterName, parameterValue]></param>
 /// <returns>Report bytes in chosen format.</returns>
 public byte[] GetReportBytes(string reportPath, ReportFormats reportFormat, List <ReportParameter> reportParams)
 {
     if (reportPath.Count(p => p == '/') == 1)
     {
         reportPath = reportPath.Replace("/", "");
     }
     using (Report report = new Report(ReportServerPath, reportPath, reportFormat, Credentials, reportParams.ToDictionary(p => p.Name, p => p.Value)))
     {
         using (var ms = new MemoryStream())
         {
             report.Render().CopyTo(ms);
             return(ms.ToArray());
         }
     }
 }
예제 #13
0
파일: Reports.cs 프로젝트: Nelpcli/RZD_SPFS
        public void Save(DataGridView DG1, string Address, ReportFormats RF)
        {
            switch (RF)
            {
            case ReportFormats.Excel:
                ToExcel(DG1).SaveAs(Address);
                break;

            case ReportFormats.PDF:
                ToExcel(DG1).ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, new FileInfo(Address).FullName);
                break;

            case ReportFormats.Word:
                break;
            }
            ;
        }
예제 #14
0
    public static ReportFormat ByCode(ReportFormats code)
    {
        switch (code)
        {
        case ReportFormats.Html: return(Html);

        case ReportFormats.MHtml: return(Html);    //<<======================

        case ReportFormats.Pdf: return(Pdf);

        case ReportFormats.Xlsx: return(Xlsx);

        case ReportFormats.Docx: return(Docx);

        default: return(null);
        }
    }
예제 #15
0
 protected virtual IWriter GetWriter(ReportFormats format)
 {
     return(null);
 }
예제 #16
0
 protected override IWriter GetWriter(ReportFormats format)
 {
     return(new CostDynamicWriter());
 }
예제 #17
0
        public Responses.RenderResponse RenderReport(string reportPath,
                                                     Dictionary <string, string> parameters,
                                                     string dataSourceName,
                                                     bool overrideCredentials = true,
                                                     ReportFormats format     = ReportFormats.PDF)
        {
            //Set the format
            string reportFormat = null;

            switch (format)
            {
            case ReportFormats.XML:
                reportFormat = "XML";
                break;

            case ReportFormats.NULL:
                reportFormat = "NULL";
                break;

            case ReportFormats.CSV:
                reportFormat = "CSV";
                break;

            case ReportFormats.IMAGE:
                reportFormat = "IMAGE";
                break;

            case ReportFormats.PDF:
                reportFormat = "PDF";
                break;

            case ReportFormats.HTML40:
                reportFormat = "HTML4.0";
                break;

            case ReportFormats.HTML32:
                reportFormat = "HTML3.2";
                break;

            case ReportFormats.MHTML:
                reportFormat = "MHTML";
                break;

            case ReportFormats.EXCEL:
                reportFormat = "EXCEL";
                break;

            case ReportFormats.Word:
                reportFormat = "Word";
                break;

            default:
                reportFormat = "PDF";
                break;
            }

            //Create the communication channel
            var channelFactory = CreateReportExecutionServiceFactory();
            var client         = channelFactory.CreateChannel();

            //Setup the parameters
            Execution.ParameterValue[] reportParameters = null;

            if (parameters != null)
            {
                reportParameters = new Execution.ParameterValue[parameters.Count];

                for (int i = 0; i < reportParameters.Length; i++)
                {
                    reportParameters[i]       = new Execution.ParameterValue();
                    reportParameters[i].Name  = parameters.Keys.ElementAt(i);
                    reportParameters[i].Value = parameters.Values.ElementAt(i);
                }
            }
            else
            {
                reportParameters = new Execution.ParameterValue[0];
            }

            var loadedReport = client.LoadReport(new LoadReportRequest
            {
                Report = reportPath
            });


            if (overrideCredentials) /* °\(^▿^)/°  (ノ°ο°)ノ */
            {
                //**These lines are for setting the datasource of the report before rendering it**
                ReportServer.Execution.DataSourceCredentials datasetCredential = new ReportServer.Execution.DataSourceCredentials();
                datasetCredential.DataSourceName = dataSourceName;
                datasetCredential.UserName       = _DataSourceUserName;
                datasetCredential.Password       = _DataSourcePassword;

                ReportServer.Execution.DataSourceCredentials[] credentials = new ReportServer.Execution.DataSourceCredentials[1];
                credentials[0] = datasetCredential;

                client.SetExecutionCredentials(new SetExecutionCredentialsRequest(loadedReport.ExecutionHeader, new Execution.TrustedUserHeader(), credentials));
            }

            //Just set the parameters if there are some
            if (reportParameters.Length > 0)
            {
                try
                {
                    client.SetExecutionParameters(new SetExecutionParametersRequest
                    {
                        Parameters        = reportParameters,
                        ExecutionHeader   = loadedReport.ExecutionHeader,
                        ParameterLanguage = "en-us"
                    });
                }catch (Exception e)
                {
                    if (e.Message.Contains("dataSource"))
                    {
                        reportParameters = reportParameters.Where(r => r.Name != "dataSource").ToArray();
                        client.SetExecutionParameters(new SetExecutionParametersRequest
                        {
                            Parameters        = reportParameters,
                            ExecutionHeader   = loadedReport.ExecutionHeader,
                            ParameterLanguage = "en-us"
                        });
                    }
                }
            }

            //Build the render request
            var request = new RenderRequest()
            {
                Format          = reportFormat,
                ExecutionHeader = loadedReport.ExecutionHeader
            };

            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("es-ES");
            //Render the report
            var renderedReport = client.Render(request);

            //Close de communication channel
            channelFactory.Close();

            var result = new Responses.RenderResponse();

            result.Content     = renderedReport.Result;
            result.ContentType = renderedReport.MimeType;
            result.Extension   = renderedReport.Extension;
            return(result);
        }
 public static async Task <ReportExportResult> ExportReportToFormatAsync(ReportViewerModel model, ReportFormats format, int?startPage = 0, int?endPage = 0)
 {
     return(await ExportReportToFormatAsync(model, format.GetName(), startPage, endPage));
 }
예제 #19
0
 public static ReportExportResult ExportReportToFormat(ReportViewerModel model, ReportFormats format, int?startPage = 0, int?endPage = 0)
 {
     return(ExportReportToFormat(model, format.GetName(), startPage, endPage));
 }
예제 #20
0
        public byte[] GetReport(string path, List <ReportParameter> parameters, ReportFormats format)
        {
            ReportClient client = new ReportClient(Config.ReportingServiceServerPath);

            return(client.GetReportBytes(path, format, parameters));
        }