كيفية إنشاء تقارير كريستالية في mvc 4 razor c#.net

برمجة


أهلاً،

أريد عمل تقارير كريستالية باستخدام عارض التقارير في صفحة .chtml، فمن الممكن باستخدام pdf ولكن
ليس مع عارض التقرير.

توحي لي إذا كان لديك أي فكرة.

أنا أعمل على محرك عرض الحلاقة،mvc 4، c#،.net

الحل 3

نأمل أن يساعدك هذا البرنامج التعليمي.

[^]

الحل 1

لم أستخدم تقارير Crystal مطلقًا في MVC ولكني وجدت هذه التفاصيل، تحقق منها
استخدام التحكم في Reportviewer، ضمن عرض Razor، في إطار عمل MVC3[^]

الحل 2

الحل 4

@page
@using System.Data.SqlClient;
@using System.Diagnostics;
@model QT2Docs.Pages.JobCostingAPIModel
@{
    string JobNumber = Request.Query["JobNumber"];
    Random rnd = new Random();
    int FileInt = rnd.Next(1, 100);
    string FileNum = FileInt.ToString();
    DateTime today = DateTime.Today;

    string CryConnect = System.Configuration.ConfigurationManager.AppSettings["CReportCon"];
    string FileName = " -F \"C:\\Reports\\JobCostDetailByJob.RPT\"";
    string RptOptions = " -A @JobNumber:" + JobNumber + " -A @StartDate:01/01/1900 -A @EndDate:" + (today.ToString("MM/dd/yyyy")) + " -A @GangRunJobs:0 -A @JobStatus:All -A @GroupBy:0 -A @DateTypeFilter:-1 -A @EstimateData:0 -A @PlantID:All ";
    string TheOutput = " -EPDF -O \"C:\\inetpub\\wwwroot\\QT2Docs\\wwwroot\\JobCostDetailByJob" + FileNum + ".pdf\"";

    string RptPareamiters = CryConnect + FileName + RptOptions + TheOutput;

    var process = Process.Start(@"c:\reports\crexport.exe", RptPareamiters);
    process.WaitForExit();

    //crexport.exe -S server -U sa -P password -D "database"                      /// server connection
    // -F "C:\Reports\InvoiceCreditNotes.rpt"                                     /// report file
    // -A @DocumentType:INVOICE -A @StartNum:%%A -A @EndNum:%%A -A @Batch:1       /// RTP paramiters format -A Paramiter:Value  the @ symbol is for SP value, do not use @ when just passing data
    // -EPDF -O "C:\Reports\InvoiceCreditNotes.pdf"                               /// FIle format and outputfile
    // crexport.exe was recompiled to .net 4.8 and code is from    https://github.com/rainforestnet/CrystalReportsNinja
    // Also *Note The application pool will need to use an identity that has rights to run and store report 
    Response.Redirect("/QT2Docs/JobCostDetailByJob" + FileNum + ".pdf");

This is the contents of JobCostingAPI.cshtml for my razor project called QT2Docs. when this page is feed the job number though http://somewebserver/QT2Docs/JobCostingAPI?Jobnumber=654321
it builds the report parameters and connection then deposits the pdf where i can link it. The FileNum (random)value is to help keep from more than one report over weighting a second concurrent run. Thank the people at rainforestnet for an old app that still kicks butt

コメント

タイトルとURLをコピーしました