C# 如何在后台运行报表并同时加载其数据

C# 如何在后台运行报表并同时加载其数据,c#,activereports,C#,Activereports,我创建了一个报告(活动报告)并运行它。但是,在加载整个报告之前,不会显示报告窗口或报告 我希望报告应该立即打开,只要我点击“显示报告”按钮,报告中的数据应该在后台加载 private void ViwerGLactivityReport_Load(object sender, EventArgs e) { try { ar = new ActiveReport(); ar = LoadReport(wSession,

我创建了一个报告(活动报告)并运行它。但是,在加载整个报告之前,不会显示报告窗口或报告

我希望报告应该立即打开,只要我点击“显示报告”按钮,报告中的数据应该在后台加载

private void ViwerGLactivityReport_Load(object sender, EventArgs e)
{
        try
        {
            ar = new ActiveReport();
            ar = LoadReport(wSession, ar, CurrentUserContext, StartDate, EndDate, accountstart, accountEnd, PostInvoiceDate, JournalIDInvoiceNo);
            ViwerGLactivityReport.Document = ar.Document;
            ar.Run();
        }
        catch (Exception ex)
        {
            CusException cex = new CusException(ex);
            cex.Show(MessageBoxIcon.Error);
        }
}

   public ActiveReport LoadReport(NHSessionManager.SessionForWindows wSession, ActiveReport ar, M3.Globals.UserContext CurrentUserContext, DateTime StartDate, DateTime EndDate, double accountstart, double accountEnd, string PostInvoiceDate, string JournalIDInvoiceNo)
    {
        ar = new ActiveReport();
        try
        {
            Company = CurrentUserContext.CurrentCompany;
            Assembly asm = Assembly.GetAssembly(this.GetType());
            ar.DataInitialize += new EventHandler(ar_DataInitialize);
            ar.FetchData += new ActiveReport.FetchEventHandler(ar_FetchData);

            System.IO.Stream stre = asm.GetManifestResourceStream(asm.GetName().Name + ".GL.arActivity.rpx");

            using (XmlTextReader xr = new XmlTextReader(stre))
            {
                ar.LoadLayout(xr);
            }
    foreach (var itemAccRange in lstLedAccOrderBy)
            {
                List<M3.UDT.ReportDataGLActivityTransactions> lstReportData = new List<ReportDataGLActivityTransactions>();

                lstReportData = obj.GLActivityReport(Company, Property, itemAccRange.Account, StartDate, EndDate);
                var Acc = lstLedAcc.Where(x => x.Account == itemAccRange.Account).FirstOrDefault();
                foreach (var item in lstReportData)
                {
                    item.AccountNumber = itemAccRange.Account;


                    string AccName = string.Empty;
                    if (Acc != null)
                    {
                        AccName = Acc.FName;
                    }
                    item.AccountName = AccName;

                    if (Property != null)
                    {
                        item.CompanyName = Property.FName;
                    }
                    else
                    {
                        item.CompanyName = Company.FName;
                    }

                    ((DataDynamics.ActiveReports.Label)ar.Sections["PageFooter"].Controls["lblDateTime"]).Value = DateTime.Now.ToShortDateString() + " at " + DateTime.Now.ToLongTimeString();
                    item.PostInvoiceDate = PostInvoiceDate;
                    item.JournalIDInvoiceNo = JournalIDInvoiceNo;
                    item.StartAcc = accountstart;
                    item.EndAcc = accountEnd;
                    item.TotalForAccountNumber = itemAccRange.Account;

                    item.PostDate = item.fPostDate.ToShortDateString();

                    if (item.DebitAmount == Convert.ToDecimal("0.00"))
                    {
                        item.DebitAmtDisplay = "";
                    }
                    else
                    {
                        item.DebitAmtDisplay = Convert.ToString(item.DebitAmount);
                    }

                    if (item.CreditAmount == Convert.ToDecimal("0.00"))
                    {
                        item.CreditAmtDisplay = "";
                    }
                    else
                    {
                        item.CreditAmtDisplay = Convert.ToString(item.CreditAmount);
                    }

                    item.period = string.Format(" {0} {1} {2} {3}", CultureManager.GetReportMessageString("IdPeriod"), item.fPostDate.Month, CultureManager.GetReportMessageString("IdOf"), item.fPostDate.Year);
                    item.Totalperiod = string.Format(" {0} {1} {2} {3}", CultureManager.GetReportMessageString("IdTotalPerid"), item.fPostDate.Month, CultureManager.GetReportMessageString("IdOf"), item.fPostDate.Year);
                    if (ShowAccountsHeader == "show")
                    {
                        item.ShowAccountsHeader = CultureManager.GetReportMessageString("IdShowAcc"); //"Show Accounts with no activity";
                    }
                    else if (ShowAccountsHeader == "hide")
                    {
                        item.ShowAccountsHeader = CultureManager.GetReportMessageString("IdHideAcc");//"Hide Accounts with no activity";
                    }
                    else if (ShowAccountsHeader == "zero")
                    {
                        item.ShowAccountsHeader = CultureManager.GetReportMessageString("IdShowAccBalZero"); //"Show Accounts with no activity if Begining Balance is not zero";
                    }
                    else
                    {

                    }
                    lstReportDataPrint.Add(item); //added by jitendra
                    lstReportDataPrint.GroupBy(elem => elem.fJEID).Select(group => group.First());
                }

            }
  ar.DataSource = lstReportDataPrint;
  ar.Run();
private void ViwerGLactivityReport\u加载(对象发送方,事件参数e)
{
尝试
{
ar=新的ActiveReport();
ar=LoadReport(wSession、ar、CurrentUserContext、StartDate、EndDate、accountstart、accountEnd、PostInvoiceDate、JournalidVoiceNo);
ViwergActivityReport.Document=应收文件;
ar.Run();
}
捕获(例外情况除外)
{
CusException cex=新的CusException(ex);
显示(MessageBoxIcon.Error);
}
}
公共ActiveReport LoadReport(NHSessionManager.SessionForWindows WSSession、ActiveReport ar、M3.Globals.UserContext CurrentUserContext、DateTime StartDate、DateTime EndDate、double accountstart、double accountEnd、string PostInvoiceDate、string JournalIDInvoiceNo)
{
ar=新的ActiveReport();
尝试
{
Company=CurrentUserContext.CurrentCompany;
Assembly asm=Assembly.GetAssembly(this.GetType());
ar.DataInitialize+=新事件处理程序(ar_DataInitialize);
ar.FetchData+=新的ActiveReport.FetchEventHandler(ar\u FetchData);
System.IO.Stream stre=asm.GetManifestResourceStream(asm.GetName().Name+“.GL.arActivity.rpx”);
使用(XmlTextReader xr=new XmlTextReader(stre))
{
ar.LoadLayout(xr);
}
foreach(LstleDecorderby中的var itemAccRange)
{
List lstReportData=新列表();
lstReportData=obj.GLActivityReport(公司、财产、itemAccRange.Account、开始日期、结束日期);
var Acc=lstLedAcc.Where(x=>x.Account==itemAccRange.Account).FirstOrDefault();
foreach(lstReportData中的var项)
{
item.AccountNumber=itemAccRange.Account;
string AccName=string.Empty;
如果(Acc!=null)
{
AccName=Acc.FName;
}
item.AccountName=AccName;
if(属性!=null)
{
item.CompanyName=Property.FName;
}
其他的
{
item.CompanyName=Company.FName;
}
((DataDynamics.ActiveReports.Label)ar.Sections[“PageFooter”]。Controls[“lblDateTime”])。Value=DateTime.Now.toSortDateString()+“at”+DateTime.Now.toLongtimestString();
item.PostInvoiceDate=PostInvoiceDate;
item.JournalIDInvoiceNo=JournalIDInvoiceNo;
item.StartAcc=accountstart;
item.EndAcc=会计结束;
item.TotalForAccountNumber=itemAccRange.Account;
item.PostDate=item.fPostDate.ToShortDateString();
如果(item.DebitAmount==Convert.ToDecimal(“0.00”))
{
item.DebitAmtDisplay=“”;
}
其他的
{
item.DebitAmtDisplay=转换为字符串(item.DebitAmount);
}
如果(item.CreditAmount==转换为指定值(“0.00”))
{
item.CreditAmtDisplay=“”;
}
其他的
{
item.CreditAmtDisplay=转换为字符串(item.CreditAmount);
}
item.period=string.Format(“{0}{1}{2}{3}”、CultureManager.GetReportMessageString(“IdPeriod”)、item.fPostDate.Month、CultureManager.GetReportMessageString(“IdOf”)、item.fPostDate.Year);
item.Totalperiod=string.Format(“{0}{1}{2}{3}”、CultureManager.GetReportMessageString(“idTotalPeriod”)、item.fPostDate.Month、CultureManager.GetReportMessageString(“IdOf”)、item.fPostDate.Year);
if(showcountsheader==“show”)
{
item.ShowAccountsHeader=CultureManager.GetReportMessageString(“IdShowAcc”);/“显示没有活动的帐户”;
}
else if(showcountsheader==“hide”)
{
item.showcountsheader=CultureManager.GetReportMessageString(“idhideac”);/“隐藏没有活动的帐户”;
}
else if(showcountsheader==“零”)
{
item.ShowAccountsHeader=CultureManager.GetReportMessageString(“IdShowAccBalZero”);//“如果起始余额不为零,则显示没有活动的帐户”;
}
其他的
{
}
lstreptdataprint.Add(item);//由jitendra添加
GroupBy(elem=>elem.fJEID);
}
}
ar.DataSource=lstreptdataprint;
ar.Run();
}


可以这样做吗?

这是使用分区报告的一个限制(在活动报告6和以下版本中,它们仅被称为活动报告)。分区报告使用“带状列表”方法,如果您愿意,在查询完成之前不允许显示报告

在Active Reports 7和更高版本中,我们引入了页面报告的概念,它允许这种行为。页面报告可以做到这一点,是因为它的设计方式(逐页方法),所以在第1页完成后,它会显示它并显示

总页数的1/#

总页数的#从1开始