Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            string request = context.Request["request"];

            string[] parts = request.Split('~');


            string Query = string.Empty;

            Query = "SELECT Appointment.ID as Id, person.FirstName as FirstName, person.LastName as LastName,"
                    + " CONVERT(varchar, [ApptDay], 101) as DateOfAppointment,CONVERT(varchar(15), CAST([ApptTime] AS TIME), 100) as TimeOfAppointment,"
                    + " CONVERT(varchar, person.DOB, 101) as DateOfBirth, '0' as Account"
                    + " FROM Appointment"
                    + " inner join webid"
                    + " on webid.ID = appointment.UserID"
                    + " inner join person"
                    + " on person.ID = webid.PersonID"
                    + " where[ApptDay] = '" + parts[0] + "'"
                    //+ " where[ApptDay] = '06/26/2020'"
                    + " and person.locationid = " + parts[1]
                    //+ " and person.locationid = 2"
                    + " order by Appointment.ApptDay, Appointment.ApptTime";

            var report = new PrintSchedule();

            Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
            sqlDataSource.ConnectionString = "Server = 64.41.86.25; Database = Appointment; Uid = Appointment; Pwd = 0griswold;";
            sqlDataSource.SelectCommand    = Query;

            report.DataSource = sqlDataSource;
            var reportPackager = new ReportPackager();

            using (var targetStream = System.IO.File.Create(@"C:\temp\PrintReport.trdp"))
            {
                reportPackager.Package(report, targetStream);
            }


            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            var deviceInfo = new System.Collections.Hashtable();

            var reportSource = new Telerik.Reporting.UriReportSource();

            //// reportName is the path to the TRDP/TRDX file
            reportSource.Uri = @"C:\temp\PrintReport.trdp";


            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string filePath = System.IO.Path.Combine(@"C:\waldenltd\ionicwithvuedev\fairfield-app-admin\public\", "output.pdf");

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write("OK");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string databaseConnection = System.Configuration.ConfigurationManager.AppSettings["allergyConnection"];
            string reportLocation     = System.Configuration.ConfigurationManager.AppSettings["reportLocation"];
            string outputPath         = System.Configuration.ConfigurationManager.AppSettings["outputPath"];

            string Query = string.Empty;

            Query = "SELECT Appointment.ID as Id,person.HPhone, person.FirstName as FirstName, person.LastName as LastName,"
                    + " CONVERT(varchar, [ApptDay], 101) as DateOfAppointment,CONVERT(varchar(15), CAST([ApptTime] AS TIME), 100) as TimeOfAppointment,"
                    + " CONVERT(varchar, person.DOB, 101) as DateOfBirth, '0' as Account"
                    + " FROM Appointment"
                    + " inner join webid"
                    + " on webid.ID = appointment.UserID"
                    + " inner join person"
                    + " on person.ID = webid.PersonID"
                    + " where[ApptDay] = '" + args[0] + "'"
                    + " and person.locationid = " + args[1]
                    + " order by Appointment.ApptDay, Appointment.ApptTime";
            Console.WriteLine(Query);
            var report = new PrintSchedule();


            Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
            sqlDataSource.ConnectionString = databaseConnection;
            sqlDataSource.SelectCommand    = Query;

            report.DataSource = sqlDataSource;
            var reportPackager = new ReportPackager();

            using (var targetStream = System.IO.File.Create(reportLocation))
            {
                reportPackager.Package(report, targetStream);
            }


            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            var deviceInfo = new System.Collections.Hashtable();

            var reportSource = new Telerik.Reporting.UriReportSource();

            //// reportName is the path to the TRDP/TRDX file
            reportSource.Uri = reportLocation;


            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

            string filePath = System.IO.Path.Combine(outputPath, "output.pdf");

            using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
Exemplo n.º 3
0
        protected override ReportSource ResolveReport(string reportName)
        {
            var guid = new Guid(reportName.Split('.')[0]);

            using (var context = new ReportDbContext())
            {
                var reportFile     = _reportFileDBService.GetFileAsNoTracking(context, guid);
                var reportPackager = new ReportPackager();

                using (var sourceStream = new MemoryStream(reportFile.Content))
                {
                    return(GetReportSource(context, reportFile, null));
                }
            }
        }
Exemplo n.º 4
0
        public static ReportSource RenderReportData(byte[] ReportBinaryData, Dictionary <string, object> Parameters)
        {
            ReportPackager pack = new ReportPackager();

            Telerik.Reporting.Report doc = pack.Unpackage(new MemoryStream(ReportBinaryData));

            InstanceReportSource instance = new InstanceReportSource();

            instance.ReportDocument = doc;

            if (Parameters != null)
            {
                foreach (KeyValuePair <string, object> kvp in Parameters)
                {
                    instance.Parameters.Add(new Telerik.Reporting.Parameter(kvp.Key, kvp.Value));
                }
            }

            return(instance);
        }
Exemplo n.º 5
0
        public void ProcessServiceReports(string fromDate, string toDate, string company,
                                          string totalBillable, string balanceFromPreviousMonth,
                                          string hoursPurchasedThisMonth, string balancedRemaining, string month)
        {
            string Query = string.Empty;

            var report = new ServiceReport(totalBillable, balanceFromPreviousMonth, hoursPurchasedThisMonth, balancedRemaining, month);

            Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
            sqlDataSource.ConnectionString  = "Server=ITD-CW02.ITD.local;User ID=reports;password=C0nn3ct3d;Database=cwwebapp_itd;Persist Security Info=True";
            sqlDataSource.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
            sqlDataSource.SelectCommand     = "ITD_ServiceRpt";
            sqlDataSource.Parameters.Add("@FromDate", (System.Data.DbType)TypeCode.String, fromDate);
            sqlDataSource.Parameters.Add("@ToDate", (System.Data.DbType)TypeCode.String, toDate);
            sqlDataSource.Parameters.Add("@company", (System.Data.DbType)TypeCode.String, company);

            report.DataSource = sqlDataSource;
            var reportPackager = new ReportPackager();

            using (var targetStream = System.IO.File.Create("C:\\temp\\ServiceReport.trdp"))
            {
                reportPackager.Package(report, targetStream);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Возвращает источник для отчета.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="reportFile"></param>
        /// <param name="parentOid"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        ReportSource GetReportSource(
            ReportDbContext context
            , DAL.Entities.ReportFileDB reportFile
            , Guid?parentOid
            , ParameterCollection parameters = null)
        {
            ReportSource reportSource   = null;
            var          reportPackager = new ReportPackager();

            using (var sourceStream = new MemoryStream(reportFile.Content))
            {
                switch (reportFile.Extension?.Split('.')?.Last()?.ToUpper())
                {
                case "TRDX":
                    reportSource = new XmlReportSource()
                    {
                        Xml = System.Text.Encoding.UTF8.GetString(reportFile.Content)
                    };
                    break;

                case "TRBP":     //книга
                    var reportBook = (ReportBook)reportPackager.UnpackageDocument(sourceStream);
                    var pOid       = parentOid.HasValue ? parentOid.Value : reportFile.GuidId;
                    SetReportBookSorces(context, pOid, ref reportBook);
                    reportSource = new InstanceReportSource()
                    {
                        ReportDocument = reportBook
                    };
                    break;

                case "TRDP":
                default:
                    var report = (Report)reportPackager.UnpackageDocument(sourceStream);

                    //установка источника для вложенных секций отчета
                    var prOid = parentOid.HasValue ? parentOid.Value : reportFile.GuidId;
                    report.Items.Flatten(f => f.Items)
                    .Where(i => (i.GetType().GetProperty(nameof(ReportSource)) != null) ||
                           (i.Action != null && i.Action.GetType().GetProperty(nameof(ReportSource)) != null))
                    .ToList()
                    .ForEach(f =>
                    {
                        var prop = f.GetType().GetProperty(nameof(ReportSource));
                        if (prop != null)
                        {
                            prop.SetValue(f, GetSubReportSorce(context, (ReportSource)prop.GetValue(f), prOid));
                        }

                        if (f.Action != null)
                        {
                            var aprop = f.Action.GetType().GetProperty(nameof(ReportSource));
                            if (aprop != null)
                            {
                                aprop.SetValue(f.Action, GetSubReportSorce(context, (ReportSource)aprop.GetValue(f.Action), prOid));
                            }
                        }
                    });

                    reportSource = new InstanceReportSource()
                    {
                        ReportDocument = report
                    };

                    //назначение параметров
                    if (parameters != null && parameters.Count() > 0)
                    {
                        reportSource.Parameters.Clear();
                        foreach (var par in parameters)
                        {
                            reportSource.Parameters.Add(par.Name, par.Value);
                        }
                    }


                    break;
                }
            }

            return(reportSource);
        }