Beispiel #1
0
 internal static string MediaURL(string namedresource, int?maxwidth_pix, int?maxheight_pix, dal.business.FileType[] coerce_filetype)
 {
     return(BuiltinReportDescriptor.MediaURL(-1, namedresource, maxwidth_pix, maxheight_pix, coerce_filetype));
 }
        public bool RenderRep0000(string virtualbasepath, string printername, string jobname, bool dinA5, string footerinfoline, string participantname, string participationdatetime, string trainingtopic, string fexpires, out MemoryStream chunk, out string mime, out string encoding, out string uri)
        {
            /* make a direct (synchronous) PDF from training participation certificate data */
            chunk    = new MemoryStream();
            mime     = sherm.core.formatting.mime.cstMIMEPDF;
            encoding = System.Text.Encoding.UTF8.EncodingName;
            uri      = String.Format("Teilnahmezertifikat-{0}-{1}.pdf",
                                     trainingtopic.Replace(" ", "_"),
                                     participantname.Replace(" ", "_")
                                     );
            try
            {
                var rpt_format = "PDF";
                /* instantiate and render the rdlc */
                var rpt = new LocalReport()
                {
                    ReportEmbeddedResource = "sherm.rpt.msdbrpt.ReportHardcopyTrainingCert.rdlc",
                    EnableExternalImages   = true
                };
                if (dinA5)
                {
                    rpt.ReportEmbeddedResource = "sherm.rpt.msdbrpt.ReportHardcopyTrainingCertA5.rdlc";
                }
                /* data binding */
                var Logo = String.Format("{0}{1}",
                                         virtualbasepath,
                                         BuiltinReportDescriptor.MediaURL(sherm.core.formatting.mime.BINGET_NAMEDRESOURCE_CORPORATELOGO, null, null, new FileType[] { FileType.ft_png })
                                         );
                rpt.SetParameters(new ReportParameter[]
                {
                    new ReportParameter("LogoURL", Logo),
                    new ReportParameter("ParticipantName", participantname),
                    new ReportParameter("ParticipationTime", participationdatetime),
                    new ReportParameter("Topic", trainingtopic),
                    new ReportParameter("Expires", fexpires),
                    new ReportParameter("FooterInfoline", footerinfoline)
                });
                /* rendition - with [sic(k)] placeholder table to satisfy the rdlc's data binding */
                var table = new List <ReportHardcopyPSAPlanRow>();
                table.Add(new ReportHardcopyPSAPlanRow());
                var dsTable     = "dsRow";
                var dynDS_Table = new ReportDataSource(dsTable, table);
                rpt.DataSources.Add(dynDS_Table);
                rpt.Refresh();
                string[]  streams;
                Warning[] warnings;
                string    extension;

                /* [pkosec 20140521] set dpi for rdlc (MEA-2014-00207 initiative)
                 * [pkosec 20140506] use the default value (null), if DPI has not been set */
                string devinfo = null;
                devinfo = String.Format("<DeviceInfo><DpiX>{0}</DpiX><DpiY>{0}</DpiY></DeviceInfo>", 300);
                if (printername == null)
                {
                    /* [dlatikay 20180625] can now send directly */
                    var result = rpt.Render(rpt_format, devinfo, PageCountMode.Actual, out mime, out encoding, out extension, out streams, out warnings);
                    foreach (var w in warnings)
                    {
                        Tracing.WarningCore("Code: {0}, Message: {1}, Objectname: {2}, Objecttype: {3}, Severity: {4}",
                                            w.Code,
                                            w.Message,
                                            w.ObjectName,
                                            w.ObjectType,
                                            w.Severity.ToString()
                                            );
                    }
                    chunk = new MemoryStream(result);
                }
                else
                {
                    rpt.PrintToPrinter(printername, jobname);
                }
                /* succeeded */
                return(true);
            }
            catch (Exception ex)
            {
                Tracing.ErrorCore("{0}", ex.ToString());
                return(false);
            }
        }