当前位置: 首页>>代码示例>>C#>>正文


C# Report.GetDataSource方法代码示例

本文整理汇总了C#中Report.GetDataSource方法的典型用法代码示例。如果您正苦于以下问题:C# Report.GetDataSource方法的具体用法?C# Report.GetDataSource怎么用?C# Report.GetDataSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Report的用法示例。


在下文中一共展示了Report.GetDataSource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DanfeFrNfe

        /// <summary>
        /// Construtor da classe reponsável pela impressão do DANFE da NFe em Fast Reports
        /// </summary>
        /// <param name="proc">Objeto do tipo nfeProc</param>
        /// <param name="configuracaoDanfeNfe">Objeto do tipo configuracaoDanfeNfe contendo as definições de impressão</param>
        public DanfeFrNfe(nfeProc proc, ConfiguracaoDanfeNfe configuracaoDanfeNfe)
        {
            #region Define as varíaveis que serão usadas no relatório (dúvidas a respeito do fast reports consulte a documentação em https://www.fast-report.com/pt/product/fast-report-net/documentation/)

            Relatorio = new Report();
            Relatorio.RegisterData(new[] { proc }, "NFe", 20);
            Relatorio.GetDataSource("NFe").Enabled = true;
            Relatorio.Load(new MemoryStream(Properties.Resources.NFe));
            ((PictureObject)Relatorio.FindObject("poEmitLogo")).Image = configuracaoDanfeNfe.ObterLogo();

            #endregion
        }
开发者ID:luispelin,项目名称:Zeus.Net.NFe.NFCe,代码行数:17,代码来源:DanfeFrNfe.cs

示例2: DanfeFrNfce

        /// <summary>
        /// Construtor da classe reponsável pela impressão do DANFE da NFCe em Fast Reports
        /// </summary>
        /// <param name="proc">Objeto do tipo nfeProc</param>
        /// <param name="configuracaoDanfeNfce">Objeto do tipo ConfiguracaoDanfeNfce contendo as definições de impressão</param>
        public DanfeFrNfce(nfeProc proc, ConfiguracaoDanfeNfce configuracaoDanfeNfce)
        {
            #region Define as varíaveis que serão usadas no relatório (dúvidas a respeito do fast reports consulte a documentação em https://www.fast-report.com/pt/product/fast-report-net/documentation/)

            _relatorio = new Report();
            _relatorio.RegisterData(new[] { proc }, "NFCe", 20);
            _relatorio.GetDataSource("NFCe").Enabled = true;
            _relatorio.Load(new MemoryStream(Properties.Resources.NFCe));
            _relatorio.SetParameterValue("NfceDetalheVendaNormal", configuracaoDanfeNfce.DetalheVendaNormal);
            _relatorio.SetParameterValue("NfceDetalheVendaContigencia", configuracaoDanfeNfce.DetalheVendaContigencia);
            ((PictureObject) _relatorio.FindObject("poEmitLogo")).Image = configuracaoDanfeNfce.ObterLogo();
            ((TextObject)_relatorio.FindObject("txtUrl")).Text = EnderecadorDanfeNfce.ObterUrl(proc.NFe.infNFe.ide.tpAmb, proc.NFe.infNFe.ide.cUF, TipoUrlDanfeNfce.UrlConsulta);
            ((BarcodeObject)_relatorio.FindObject("bcoQrCode")).Text = EnderecadorDanfeNfce.ObterUrlQrCode(proc, configuracaoDanfeNfce);

            //Segundo o Manual de Padrões Padrões Técnicos do DANFE - NFC - e e QR Code, versão 3.2, página 9, nos casos de emissão em contigência deve ser impresso uma segunda cópia como via do estabelecimento
            _relatorio.PrintSettings.Copies = proc.NFe.infNFe.ide.tpEmis == TipoEmissao.teNormal ? 1 : 2;

            #endregion
        }
开发者ID:elyfran,项目名称:Zeus.Net.NFe.NFCe,代码行数:24,代码来源:DanfeFrNfce.cs

示例3: DanfeFrNfce

        /// <summary>
        /// Construtor da classe reponsável pela impressão do DANFE da NFCe em Fast Reports
        /// </summary>
        /// <param name="proc">Objeto do tipo nfeProc</param>
        /// <param name="configuracaoDanfeNfce">Objeto do tipo ConfiguracaoDanfeNfce contendo as definições de impressão</param>
        /// <param name="cIdToken">Identificador do CSC – Código de Segurança do Contribuinte no Banco de Dados da SEFAZ</param>
        /// <param name="csc">Código de Segurança do Contribuinte(antigo Token)</param>
        public DanfeFrNfce(nfeProc proc, ConfiguracaoDanfeNfce configuracaoDanfeNfce, string cIdToken, string csc)
        {
            #region Define as varíaveis que serão usadas no relatório (dúvidas a respeito do fast reports consulte a documentação em https://www.fast-report.com/pt/product/fast-report-net/documentation/)

            Relatorio = new Report();
            Relatorio.RegisterData(new[] { proc }, "NFCe", 20);
            Relatorio.GetDataSource("NFCe").Enabled = true;
            Relatorio.Load(new MemoryStream(Properties.Resources.NFCe));
            Relatorio.SetParameterValue("NfceDetalheVendaNormal", configuracaoDanfeNfce.DetalheVendaNormal);
            Relatorio.SetParameterValue("NfceDetalheVendaContigencia", configuracaoDanfeNfce.DetalheVendaContigencia);
            Relatorio.SetParameterValue("NfceImprimeDescontoItem", configuracaoDanfeNfce.ImprimeDescontoItem);
            Relatorio.SetParameterValue("NfceModoImpressao", configuracaoDanfeNfce.ModoImpressao);
            ((ReportPage) Relatorio.FindObject("PgNfce")).LeftMargin = configuracaoDanfeNfce.MargemEsquerda;
            ((ReportPage)Relatorio.FindObject("PgNfce")).RightMargin = configuracaoDanfeNfce.MargemDireita;
            ((PictureObject) Relatorio.FindObject("poEmitLogo")).Image = configuracaoDanfeNfce.ObterLogo();
            ((TextObject)Relatorio.FindObject("txtUrl")).Text = proc.NFe.infNFeSupl.ObterUrl(proc.NFe.infNFe.ide.tpAmb, proc.NFe.infNFe.ide.cUF, TipoUrlConsultaPublica.UrlConsulta);
            ((BarcodeObject)Relatorio.FindObject("bcoQrCode")).Text = proc.NFe.infNFeSupl  == null ? proc.NFe.infNFeSupl.ObterUrlQrCode(proc.NFe, cIdToken, csc) : proc.NFe.infNFeSupl.qrCode;

            //Segundo o Manual de Padrões Padrões Técnicos do DANFE - NFC - e e QR Code, versão 3.2, página 9, nos casos de emissão em contigência deve ser impresso uma segunda cópia como via do estabelecimento
            Relatorio.PrintSettings.Copies = (proc.NFe.infNFe.ide.tpEmis == TipoEmissao.teNormal | (proc.protNFe != null && proc.protNFe.infProt != null && NfeSituacao.Autorizada(proc.protNFe.infProt.cStat))
                /*Se a NFe for autorizada, mesmo que seja em contingência, imprime somente uma via*/ ) ? 1 : 2;

            #endregion
        }
开发者ID:luispelin,项目名称:Zeus.Net.NFe.NFCe,代码行数:31,代码来源:DanfeFrNfce.cs

示例4: PrepareReport

        public Report PrepareReport(Entity.Resume resume)
        {
            Report report = new Report();

            DataTable personInfo = getResumeInfo(resume);
            DataTable expect = getExpert(resume);
            DataTable eduback = getEduBack(resume);

            report.Load(Environment.CurrentDirectory + @"\Templates\大众通用.frx");
            TextObject txtTitle = report.FindObject("txtTitle") as TextObject;
            txtTitle.Text = resume.ResumeName + "的个人资料";
            PictureObject pictureHead = report.FindObject("pictureHead") as PictureObject;
            pictureHead.ImageLocation = Environment.CurrentDirectory + @"\Templates\logo.png";

            TextObject gender = report.FindObject("gender") as TextObject;
            gender.Text = (personInfo.Rows[0]["person_gender"].ToString() == "0") ? "男" : "女";

            TextObject birth =report.FindObject("birthday")as TextObject;
            IFormatProvider provider = new CultureInfo("zh-CN",true);
            birth.Text = DateTime.Parse(personInfo.Rows[0]["person_birthday"].ToString(),provider).ToShortDateString().ToString();

            report.RegisterData(personInfo, "person_info");
            report.RegisterData(expect, "expect");
            report.RegisterData(eduback, "education_background");
            DataBand db = report.FindObject("Data1") as DataBand;
            db.DataSource = report.GetDataSource("education_background");

            TextObject expectarea = report.FindObject("expectarea") as TextObject;
            expectarea.Text = getAreaByAreaCode(expect.Rows[0]["expect_area1"].ToString()).Rows[0]["area_name"].ToString();

            TextObject living = report.FindObject("living") as TextObject;
            living.Text = getAreaByAreaCode(personInfo.Rows[0]["person_living_area"].ToString()).Rows[0]["area_name"].ToString();

            TextObject belong = report.FindObject("belong")as TextObject;
            belong.Text = getAreaByAreaCode(personInfo.Rows[0]["person_born_area"].ToString()).Rows[0]["area_name"].ToString();

            report.Prepare();
            return report;
        }
开发者ID:vincentlauvlwj,项目名称:FrameDAL,代码行数:39,代码来源:CommonTemplate.cs

示例5: BindGrid


//.........这里部分代码省略.........
                        if ( attributeGuid.HasValue )
                        {
                            var attribute = AttributeCache.Read( attributeGuid.Value );
                            selectedAttributes.Add( columnIndex, attribute );

                            BoundField boundField;

                            if ( attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.BOOLEAN.AsGuid() ) )
                            {
                                boundField = new BoolField();
                            }
                            else
                            {
                                boundField = new BoundField();
                            }

                            boundField.DataField = string.Format( "Attribute_{0}_{1}", attribute.Id, columnIndex );
                            boundField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? attribute.Name : reportField.ColumnHeaderText;
                            boundField.SortExpression = null;

                            if ( attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.INTEGER.AsGuid() ) ||
                                attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.DATE.AsGuid() ) )
                            {
                                boundField.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                                boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                            }

                            boundField.Visible = reportField.ShowInGrid;
                            // NOTE:  Additional formatting for attributes is done in the gReport_RowDataBound event
                            gReport.Columns.Add( boundField );
                        }
                    }
                    else if ( reportField.ReportFieldType == ReportFieldType.DataSelectComponent )
                    {
                        selectedComponents.Add( columnIndex, reportField );

                        DataSelectComponent selectComponent = DataSelectContainer.GetComponent( reportField.DataSelectComponentEntityType.Name );
                        if ( selectComponent != null )
                        {
                            DataControlField columnField = selectComponent.GetGridField( entityType, reportField.Selection );

                            if ( columnField is BoundField )
                            {
                                ( columnField as BoundField ).DataField = string.Format( "Data_{0}_{1}", selectComponent.ColumnPropertyName, columnIndex );
                            }

                            columnField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? selectComponent.ColumnHeaderText : reportField.ColumnHeaderText;
                            columnField.SortExpression = null;
                            columnField.Visible = reportField.ShowInGrid;
                            gReport.Columns.Add( columnField );
                        }
                    }
                }

                // if no fields are specified, show the default fields (Previewable/All) for the EntityType
                var dataColumns = gReport.Columns.OfType<object>().Where(a => a.GetType() != typeof(SelectField));
                if (dataColumns.Count() == 0)
                {
                    // show either the Previewable Columns or all (if there are no previewable columns)
                    bool showAllColumns = !entityFields.Any( a => a.FieldKind == FieldKind.Property && a.IsPreviewable );
                    foreach ( var entityField in entityFields.Where(a => a.FieldKind == FieldKind.Property) )
                    {
                        columnIndex++;
                        selectedEntityFields.Add( columnIndex, entityField );

                        BoundField boundField;
                        if ( entityField.DefinedTypeGuid.HasValue )
                        {
                            boundField = new DefinedValueField();
                        }
                        else
                        {
                            boundField = Grid.GetGridField( entityField.PropertyType );
                        }

                        boundField.DataField = string.Format( "Entity_{0}_{1}", entityField.Name, columnIndex );
                        boundField.HeaderText = entityField.Name;
                        boundField.SortExpression = entityField.Name;
                        boundField.Visible = showAllColumns || entityField.IsPreviewable;
                        gReport.Columns.Add( boundField );
                    }
                }

                try
                {
                    gReport.ExportFilename = report.Name;
                    gReport.DataSource = report.GetDataSource( new RockContext(), entityType, selectedEntityFields, selectedAttributes, selectedComponents, gReport.SortProperty, out errors );
                    gReport.DataBind();
                }
                catch ( Exception ex )
                {
                    errors.Add( ex.Message );
                }

                if ( errors.Any() )
                {
                    nbEditModeMessage.Text = "INFO: There was a problem with one or more of the report's data components...<br/><br/> " + errors.AsDelimited( "<br/>" );
                }
            }
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:101,代码来源:ReportDetail.ascx.cs

示例6: BindGrid


//.........这里部分代码省略.........
                var selectedEntityFields = new Dictionary<int,EntityField>();
                var selectedAttributes = new Dictionary<int, AttributeCache>();
                var selectedComponents = new Dictionary<int, ReportField>();

                gReport.Columns.Clear();
                int columnIndex = 0;
                foreach ( var reportField in report.ReportFields.OrderBy( a => a.Order ) )
                {
                    columnIndex++;
                    if ( reportField.ReportFieldType == ReportFieldType.Property )
                    {
                        var entityField = entityFields.FirstOrDefault( a => a.Name == reportField.Selection );
                        if ( entityField != null )
                        {
                            selectedEntityFields.Add( columnIndex, entityField );

                            if ( reportField.ShowInGrid )
                            {
                                BoundField boundField;
                                if ( entityField.DefinedTypeId.HasValue )
                                {
                                    boundField = new DefinedValueField();
                                }
                                else
                                {
                                    boundField = Grid.GetGridField( entityField.PropertyType );
                                }

                                boundField.DataField = string.Format( "Entity_{0}_{1}", entityField.Name, columnIndex );
                                boundField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? entityField.Title : reportField.ColumnHeaderText;
                                boundField.SortExpression = entityField.Name;
                                gReport.Columns.Add( boundField );
                            }
                        }
                    }
                    else if ( reportField.ReportFieldType == ReportFieldType.Attribute )
                    {
                        int? attributeId = reportField.Selection.AsInteger( false );
                        if ( attributeId.HasValue )
                        {
                            var attribute = AttributeCache.Read( attributeId.Value );
                            selectedAttributes.Add( columnIndex, attribute );

                            if ( reportField.ShowInGrid )
                            {
                                BoundField boundField;

                                if ( attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.BOOLEAN.AsGuid() ) )
                                {
                                    boundField = new BoolField();
                                }
                                else
                                {
                                    boundField = new BoundField();
                                }

                                boundField.DataField = string.Format( "Attribute_{0}_{1}", attribute.Id, columnIndex );
                                boundField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? attribute.Name : reportField.ColumnHeaderText;
                                boundField.SortExpression = null;

                                if ( attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.INTEGER.AsGuid() ) ||
                                    attribute.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.DATE.AsGuid() ) )
                                {
                                    boundField.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
                                    boundField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                                }

                                // NOTE:  Additional formatting for attributes is done in the gReport_RowDataBound event
                                gReport.Columns.Add( boundField );
                            }
                        }
                    }
                    else if ( reportField.ReportFieldType == ReportFieldType.DataSelectComponent )
                    {
                        selectedComponents.Add( columnIndex, reportField );
                        if ( reportField.ShowInGrid )
                        {
                            DataSelectComponent selectComponent = DataSelectContainer.GetComponent( reportField.DataSelectComponentEntityType.Name );
                            if ( selectComponent != null )
                            {
                                var boundField = Grid.GetGridField( selectComponent.ColumnFieldType );
                                boundField.DataField = string.Format( "Data_{0}_{1}", selectComponent.ColumnPropertyName, columnIndex );
                                boundField.HeaderText = string.IsNullOrWhiteSpace( reportField.ColumnHeaderText ) ? selectComponent.ColumnHeaderText : reportField.ColumnHeaderText;
                                boundField.SortExpression = null;
                                gReport.Columns.Add( boundField );
                            }
                        }
                    }
                }

                gReport.DataSource = report.GetDataSource( new RockContext(), entityType, selectedEntityFields, selectedAttributes, selectedComponents, gReport.SortProperty, out errors );

                if ( errors.Any() )
                {
                    nbEditModeMessage.Text = "INFO: There was a problem with one or more of the report's data components...<br/><br/> " + errors.AsDelimited( "<br/>" );
                }

                gReport.DataBind();
            }
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:101,代码来源:ReportDetail.ascx.cs

示例7: Report


//.........这里部分代码省略.........
                              as_ = a.As,
                              sb = a.Sb,
                              s = a.S,
                              ca = a.Ca,
                              fe = a.Fe,
                              ag = a.Ag,
                              c = a.C,
                              end_date = a.END_DATE.ToShortDateString(),
                              blank = a.REESTR_VEDOMOSTEI.BLANK_ID ?? "не определено",
                              journal = a.JOURNAL1.JOURNAL_NAME ?? "не определено",
                              geologist = a.GEOLOGIST1.GEOLOGIST_NAME ?? "не определено",
                              pit = a.PIT,
                              lastUserID = "не определено",
                              lastDT = a.LastDT
                          };

                var avgVes1 = (from a in _assaysModel.Get()
                               join c in _collarModel.Get()
                               on a.BHID equals c.ID
                               where c.GORIZONT.BENCH_NAME.ToString() == bench
                                    && a.VES_SAMPLE != null
                               select (double)a.VES_SAMPLE);
                if (avgVes1.Count() != 0)
                {
                    avgVes = avgVes1.Sum() / avgVes1.Count();
                }

                var avgAu1 = (from a in _assaysModel.Get()
                              join c in _collarModel.Get()
                              on a.BHID equals c.ID
                              where c.GORIZONT.BENCH_NAME.ToString() == bench
                              && a.VES_SAMPLE != null && a.Au != null
                              group a by a into g
                              select g);
                if (avgAu1.Sum(x => x.Key.VES_SAMPLE) != 0)
                {
                    avgAu = (double)(avgAu1.Sum(x => x.Key.Au * x.Key.VES_SAMPLE) / avgAu1.Sum(x => x.Key.VES_SAMPLE));
                }

                var avgAu_cut1 = (from a in _assaysModel.Get()
                                  join c in _collarModel.Get()
                                  on a.BHID equals c.ID
                                  where c.GORIZONT.BENCH_NAME.ToString() == bench
                                  && a.VES_SAMPLE != null && a.Au != null
                                  group a by a into g
                                  select g);
                if (avgAu1.Sum(x => x.Key.VES_SAMPLE) != 0)
                {
                    avgAu_cut = (double)(avgAu1.Sum(x => x.Key.Au_cut * x.Key.VES_SAMPLE) / avgAu1.Sum(x => x.Key.VES_SAMPLE));
                }
            }

            var report = new Report();

            Assembly assem = Assembly.GetExecutingAssembly();
            Stream stream = assem.GetManifestResourceStream("GeoDB.Resources.rptDrillHoles.frx");
            report.Load(stream);
            report.RegisterData(samples, "SAMPLES");
            report.GetDataSource("SAMPLES").Enabled = true;

            FastReport.DataBand band = ((FastReport.DataBand)report.FindObject("Data1"));
            band.DataSource = report.GetDataSource("SAMPLES");

            FastReport.TextObject field;

            field = ((FastReport.TextObject)report.FindObject("Cell_avgVes"));
            if (field != null) field.Text = Math.Round(avgVes,3).ToString();
            field = ((FastReport.TextObject)report.FindObject("Cell_avgAu"));
            if (field != null) field.Text = Math.Round(avgAu,3).ToString();
            field = ((FastReport.TextObject)report.FindObject("Cell_avgAuC"));
            if (field != null) field.Text = Math.Round(avgAu_cut, 3).ToString();

            field = ((FastReport.TextObject)report.FindObject("tTittle"));
            if (field != null) field.Text = tTittleText;

            field = ((FastReport.TextObject)report.FindObject("Bhid"));
            if (field != null) field.Text = "[SAMPLES.bhid]";
            field = ((FastReport.TextObject)report.FindObject("Sample"));
            if (field != null) field.Text = "[SAMPLES.sample]";
            field = ((FastReport.TextObject)report.FindObject("sampleLength"));
            if (field != null) field.Text = "[SAMPLES.length]";
            field = ((FastReport.TextObject)report.FindObject("Zblock"));
            if (field != null) field.Text = "[SAMPLES.zblock]";
            field = ((FastReport.TextObject)report.FindObject("Rang"));
            if (field != null) field.Text = "[SAMPLES.rang]";
            field = ((FastReport.TextObject)report.FindObject("Ves"));
            if (field != null) field.Text = "[SAMPLES.ves]";
            field = ((FastReport.TextObject)report.FindObject("Au"));
            if (field != null) field.Text = "[SAMPLES.au]";
            field = ((FastReport.TextObject)report.FindObject("Au_cut"));
            if (field != null) field.Text = "[SAMPLES.au_cut]";
            field = ((FastReport.TextObject)report.FindObject("Date"));
            if (field != null) field.Text = "[SAMPLES.end_date]";
            field = ((FastReport.TextObject)report.FindObject("Blank"));
            if (field != null) field.Text = "[SAMPLES.blank]";
            field = ((FastReport.TextObject)report.FindObject("Pit"));
            if (field != null) field.Text = "[SAMPLES.pit]";

            report.Show();
        }
开发者ID:AleksanderGalkin,项目名称:GeoDb,代码行数:101,代码来源:PDrillHoles2PrintSet.cs

示例8: BindGrid


//.........这里部分代码省略.........
                        }
                    }
                }

                // if no fields are specified, show the default fields (Previewable/All) for the EntityType
                var dataColumns = gReport.Columns.OfType<object>().Where( a => a.GetType() != typeof( SelectField ) );
                if ( dataColumns.Count() == 0 )
                {
                    // show either the Previewable Columns or all (if there are no previewable columns)
                    bool showAllColumns = !entityFields.Any( a => a.FieldKind == FieldKind.Property && a.IsPreviewable );
                    foreach ( var entityField in entityFields.Where( a => a.FieldKind == FieldKind.Property ) )
                    {
                        columnIndex++;
                        selectedEntityFields.Add( columnIndex, entityField );

                        BoundField boundField;
                        if ( entityField.FieldType.Guid.Equals( Rock.SystemGuid.FieldType.DEFINED_VALUE.AsGuid() ) )
                        {
                            boundField = new DefinedValueField();
                        }
                        else
                        {
                            boundField = Grid.GetGridField( entityField.PropertyType );
                        }

                        boundField.DataField = string.Format( "Entity_{0}_{1}", entityField.Name, columnIndex );
                        boundField.HeaderText = entityField.Name;
                        boundField.SortExpression = boundField.DataField;
                        boundField.Visible = showAllColumns || entityField.IsPreviewable;
                        gReport.Columns.Add( boundField );
                    }
                }

                try
                {
                    gReport.Visible = true;
                    gReport.ExportFilename = report.Name;
                    SortProperty sortProperty = gReport.SortProperty;
                    if ( sortProperty == null )
                    {
                        var reportSort = new SortProperty();
                        var sortColumns = new Dictionary<string, SortDirection>();
                        foreach ( var reportField in report.ReportFields.Where( a => a.SortOrder.HasValue ).OrderBy( a => a.SortOrder.Value ) )
                        {
                            if ( reportFieldSortExpressions.ContainsKey( reportField.Guid ) )
                            {
                                var sortField = reportFieldSortExpressions[reportField.Guid];
                                if ( !string.IsNullOrWhiteSpace( sortField ) )
                                {
                                    sortColumns.Add( sortField, reportField.SortDirection );
                                }
                            }
                        }

                        if ( sortColumns.Any() )
                        {
                            reportSort.Property = sortColumns.Select( a => a.Key + ( a.Value == SortDirection.Descending ? " desc" : string.Empty ) ).ToList().AsDelimited( "," );
                            sortProperty = reportSort;
                        }
                    }

                    gReport.DataSource = report.GetDataSource( entityType, selectedEntityFields, selectedAttributes, selectedComponents, sortProperty, GetAttributeValue( "DatabaseTimeout" ).AsIntegerOrNull() ?? 180, out errors );
                    gReport.DataBind();
                }
                catch ( Exception ex )
                {
                    Exception exception = ex;
                    this.LogException( ex );
                    while ( exception != null )
                    {
                        if ( exception is System.Data.SqlClient.SqlException )
                        {
                            // if there was a SQL Server Timeout, have the warning be a friendly message about that.
                            if ( ( exception as System.Data.SqlClient.SqlException ).Number == -2 )
                            {
                                nbEditModeMessage.NotificationBoxType = NotificationBoxType.Warning;
                                nbEditModeMessage.Text = "This report did not complete in a timely manner. You can try again or adjust the timeout setting of this block.";
                                return;
                            }
                            else
                            {
                                errors.Add( exception.Message );
                                exception = exception.InnerException;
                            }
                        }
                        else
                        {
                            errors.Add( exception.Message );
                            exception = exception.InnerException;
                        }
                    }
                }

                if ( errors.Any() )
                {
                    nbEditModeMessage.NotificationBoxType = NotificationBoxType.Warning;
                    nbEditModeMessage.Text = "INFO: There was a problem with one or more of the report's data components...<br/><br/> " + errors.AsDelimited( "<br/>" );
                }
            }
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:101,代码来源:ReportDetail.ascx.cs


注:本文中的Report.GetDataSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。