コード例 #1
0
        /// <summary>
        /// Generates a table Footer for use in a TabularReport object.
        /// </summary>
        /// <param name="fieldList">List of selected data items.</param>
        public MatrixFooter(string reportDescription, string colSpan, List <ReportFilterBusinessObject> filterList, DataModel currentDataModel)
        {
            CurrentDataModel   = currentDataModel;
            _reportDescription = "Report Description : " + reportDescription;
            _colSpan           = colSpan;

            foreach (ReportFilterBusinessObject CurrentFilter in filterList)
            {
                //TODO: Code Review Issue 11/05/05: Do not use 'my' in variable names.
                //Choose a meaningful name. Pascal casing for variables.
                // Done 24/05/2005

                Guid DataItemCode = Guid.Parse(CurrentFilter.DataItemCode);

                DataItem CurrentItem = CurrentDataModel.DataTables.SelectMany(x => x.DataItems).Single(y => y.Code == DataItemCode); //DataAccessUtilities.RepositoryLocator<IDataItemRepository>().GetByCode((CurrentFilter.DataItemCode));

                DataTable CurrentTable = CurrentDataModel.DataTables.Single(x => x.Code == CurrentItem.Code);                        //DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(CurrentItem.DataTableCode);

                //25/08/05 LL - TIR0289 convert 'Current Month' to appropriate data format
                if (CurrentFilter.FilterValue == CURRENTMONTH)
                {
                    CurrentFilter.FilterValue = DateUtility.GetCurrentYearMonth();
                }
                ReportFilterBusinessObject ReportFilter = new ReportFilterBusinessObject();
                ReportFilter.DataItemCaption = CurrentItem.Caption;
                ReportFilter.Operand         = CurrentFilter.Operand;
                ReportFilter.FilterValue     = CurrentFilter.FilterValue;
                _filterItemList.Add(ReportFilter);
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructs a MatrixReport
        /// </summary>
        /// <param name="reportConstituents">A ReportDefinitionBusinessObject
        /// encapsulating the input parameters.</param>
        public MatrixReport(ReportDefinitionBusinessObject reportConstituents, string modelDataSource)
        {
            _dataSource = modelDataSource;
            //switch (model)
            //{
            //    case "INES":
            //        _dataSource = "ESF2007";
            //        break;
            //    case "MI Participant":
            //        _dataSource = "ESFMIBUSINESSDATA";
            //        break;
            //    case "Managing Authority":
            //        _dataSource = "MANAGINGAUTHORITYDATA";
            //        break;

            //}
            //_dbConnectionString
            //    = ConfigurationManager.ConnectionStrings["BusinessDataConnectionString"].ConnectionString;
            CurrentDataModel = DataAccessUtilities.RepositoryLocator <IDataModelRepository>().Single(x => x.DatasourceName == _dataSource,
                                                                                                     "DataTables",
                                                                                                     "DataTables.DataItems",
                                                                                                     "DataCategories",
                                                                                                     "DataTableJoins",
                                                                                                     "DataTableJoins.DataTableRelationshipJoins",
                                                                                                     "DataTableJoins.DataTableRelationshipJoins.DataTableRelashionship",
                                                                                                     "DataTableJoins.DataTableRelationshipJoins.DataTableRelashionship.DataTable",
                                                                                                     "DataTableJoins.DataTableRelationshipJoins.DataTableRelashionship.DataTable1");
            _textboxStyle = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.MatrixReport);

            _cornerTextboxStyle = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.MatrixReportCorner);

            _columnTotalDataItemList = reportConstituents.ColumnTotalDataItems;
            _rowTotalDataItemList    = reportConstituents.RowTotalDataItems;

            if (reportConstituents.IsOuterJoin == false)
            {
                _joinMethod = " FULL OUTER JOIN ";
            }
            else
            {
                _joinMethod = " INNER JOIN ";
            }


            // Temporary ArrayList used when instantiating the Dataset
            List <DataItem> TempGroupList = new List <DataItem>(reportConstituents.RowTotalDataItems);

            TempGroupList.AddRange(reportConstituents.ColumnTotalDataItems);

            // Initialise the querywrappers
            _mainQueryWrapper = new QueryWrapper(reportConstituents.SelectedDataItems, TempGroupList,
                                                 reportConstituents.FilterList, reportConstituents.ParameterDataItems, false, reportConstituents.JoinList, CurrentDataModel);

            //30/06/05 LL - TIR0163 Parameter query needs to be build for each data item
            foreach (DataItem CurrentParameter in reportConstituents.ParameterDataItems)
            {
                if (!CurrentParameter.IsValueType)
                {
                    List <DataItem> ParameterList = new List <DataItem>();
                    ParameterList.Add(CurrentParameter);
                    _parameterQueryWrapperArrayList.Add(new QueryWrapper(ParameterList,
                                                                         null, null, null, true, null, CurrentDataModel));
                }
            }

            // Iteration counter used in MatrixRow and MatrixStaticRow instantiations
            int MatrixRowCount = 0;

            /* Used when instantiating ColumnGroup and RowGroup lists:
             * The bools Denote if current item is first in list, so should be set to
             * false after first item dealt with.
             * The PrevItemName is the name of the item previous to the current item.
             */
            bool   IsFirstInColGroupList = true, IsFirstInRowGroupList = true;
            string PrevItemName = "";

            // MatrixRow
            foreach (DataItem SelectedItem in reportConstituents.SelectedDataItems)
            {
                if (!reportConstituents.RowTotalDataItems.Contains(SelectedItem) &&
                    !reportConstituents.ColumnTotalDataItems.Contains(SelectedItem))
                {
                    _matrixRowList.Add(
                        new MatrixRow("MatrixRowTextBox" + MatrixRowCount, SelectedItem, CurrentDataModel));
                }

                MatrixRowCount++;
            }

            // MatrixDynamicColumnGrouping
            foreach (DataItem ColumnItem in reportConstituents.ColumnTotalDataItems)
            {
                if (IsFirstInColGroupList)
                {
                    // To ensure drilldown groupname is unique in case of data items with same name,
                    // concatenate the tablename and itemname
                    DataTable SubtotalDataTable
                        = CurrentDataModel.DataTables.Single(x => x.Code == ColumnItem.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(ColumnItem.DataTableCode);
                    string SubtotalTableName = SubtotalDataTable.Name;
                    string SubtotalName      = SubtotalTableName + ColumnItem.Name + "Subtotal";

                    _dynamicColumnGroupingList.Add(
                        new MatrixDynamicColumnGrouping(ColumnItem, SubtotalName, true, CurrentDataModel));
                    IsFirstInColGroupList = false;
                }
                else
                {
                    _dynamicColumnGroupingList.Add(
                        new MatrixDynamicColumnGrouping(ColumnItem, PrevItemName, false, CurrentDataModel));
                }

                // To ensure field name is unique in case of data items with same name,
                // concatenate the tablename and itemname
                DataTable ThisDataTable = CurrentDataModel.DataTables.Single(x => x.Code == ColumnItem.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(ColumnItem.DataTableCode);
                string    TableName     = ThisDataTable.Name;
                PrevItemName = TableName + ColumnItem.Name;
            }

            // MatrixDynamicRowGrouping
            foreach (DataItem RowItem in reportConstituents.RowTotalDataItems)
            {
                if (IsFirstInRowGroupList)
                {
                    // To ensure drilldown groupname is unique in case of data items with same name,
                    // concatenate the tablename and itemname
                    DataTable SubtotalDataTable
                        = CurrentDataModel.DataTables.Single(x => x.Code == RowItem.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(RowItem.DataTableCode);
                    string SubtotalTableName = SubtotalDataTable.Name;
                    string SubtotalName      = SubtotalTableName + RowItem.Name + "Subtotal";

                    _dynamicRowGroupingList.Add(
                        new MatrixDynamicRowGrouping(RowItem, SubtotalName, true, CurrentDataModel));
                    IsFirstInRowGroupList = false;
                }
                else
                {
                    _dynamicRowGroupingList.Add(
                        new MatrixDynamicRowGrouping(RowItem, PrevItemName, false, CurrentDataModel));
                }

                // To ensure field name is unique in case of data items with same name,
                // concatenate the tablename and itemname
                DataTable ThisDataTable = CurrentDataModel.DataTables.Single(x => x.Code == RowItem.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(RowItem.DataTableCode);
                string    TableName     = ThisDataTable.Name;
                PrevItemName = TableName + RowItem.Name;
            }

            // MatrixStaticRow
            MatrixRowCount = 0;
            foreach (DataItem SelectedItem in reportConstituents.SelectedDataItems)
            {
                if (!(reportConstituents.RowTotalDataItems.Contains(SelectedItem)) &&
                    !(reportConstituents.ColumnTotalDataItems.Contains(SelectedItem)))
                {
                    _matrixStaticRowList.Add(new MatrixStaticRow(
                                                 "MatrixStaticRowTextBox" + MatrixRowCount, SelectedItem, CurrentDataModel));
                }

                MatrixRowCount++;
            }

            // Dataset
            _datasetList.Add(new Dataset(reportConstituents.SelectedDataItems, _matrixDataSetName,
                                         _mainQueryWrapper, CurrentDataModel));

            //30/06/05 LL - TIR0163 Parameter query needs to be build for each data item
            int i = 0;

            foreach (DataItem Item in reportConstituents.ParameterDataItems)
            {
                if (!Item.IsValueType)
                {
                    // We only require a query for the current data item, so put it into
                    // an arraylist to pass to the Dataset constructor.
                    List <DataItem> ParameterList = new List <DataItem>();
                    ParameterList.Add(Item);

                    // To ensure this parameter's datasetname is unique in case of data items
                    // with same name, concatenate the tablename and itemname
                    DataTable ThisDataTable = CurrentDataModel.DataTables.Single(x => x.Code == Item.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(Item.DataTableCode);
                    string    TableName     = ThisDataTable.Name;

                    _datasetList.Add(new Dataset(ParameterList, TableName + Item.Name + "Parameter",
                                                 (QueryWrapper)_parameterQueryWrapperArrayList[i], CurrentDataModel));
                    _parameterName    = TableName + Item.Name;
                    _parameterCaption = Item.Caption;
                    _parameterName    = "=\"Selected " + _parameterCaption + " :\"+Parameters!" + _parameterName + ".Value";
                    _parameterList.Add(_parameterName);
                    i++;
                }
            }


            // ReportParameter
            foreach (DataItem ParameterItem in reportConstituents.ParameterDataItems)
            {
                _reportParameterList.Add(new ReportParameter(ParameterItem, CurrentDataModel));
            }

            //Report Description DBS
            _reportDescription = "Report Description : " + reportConstituents.ReportDescription + " . Show only data with a common denominator = " + reportConstituents.IsOuterJoin.ToString();

            foreach (ReportFilterBusinessObject CurrentFilter in reportConstituents.FilterList)
            {
                //TODO: Code Review Issue 11/05/05: Do not use 'my' in variable names.
                //Choose a meaningful name. Pascal casing for variables.
                // Done 24/05/2005
                Guid     DataItemCode = Guid.Parse(CurrentFilter.DataItemCode);
                DataItem CurrentItem  = CurrentDataModel.DataTables.SelectMany(x => x.DataItems).Single(y => y.Code == DataItemCode); //DataAccessUtilities.RepositoryLocator<IDataItemRepository>().GetByCode((CurrentFilter.DataItemCode));

                DataTable CurrentTable = CurrentDataModel.DataTables.Single(x => x.Code == CurrentItem.DataTableCode);                //DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(CurrentItem.DataTableCode);

                //25/08/05 LL - TIR0289 convert 'Current Month' to appropriate data format
                if (CurrentFilter.FilterValue == CURRENTMONTH)
                {
                    CurrentFilter.FilterValue = DateUtility.GetCurrentYearMonth();
                }
                ReportFilterBusinessObject ReportFilter = new ReportFilterBusinessObject();
                ReportFilter.DataItemCaption = CurrentItem.Caption;
                ReportFilter.Operand         = CurrentFilter.Operand;
                ReportFilter.FilterValue     = CurrentFilter.FilterValue;
                _filterItemList.Add(ReportFilter);
            }

            // Initialise the MemoryStream and the XmlWriter
            _memoryStream = new MemoryStream();
            _xmlWriter    = new XmlTextWriter(
                _memoryStream, Encoding.UTF8);
            // Either of the lines below may be used as alternative outputs for debugging
            //_stream, Encoding.UTF8);
            // Console.Out);
        }