/// <summary>
        /// Makes object render itself as an RDL Footer type to an XmlWriter instance.
        /// </summary>
        /// <param name="xmlWriter">The XMLWriter to be rendered to.</param>
        public void Render2010(XmlWriter xmlWriter)
        {
            //TODO: Code Review Issue 11/05/05: indent the code as in XML to increase readability
            // Done 24/05/2005

            ReportingServicesStyle _textboxStyle10pt = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.TabularReport10pt);

            //RdlRender.AddLine(xmlWriter, "RepeatOnNewPage", "true");
            //Report Description
            xmlWriter.WriteStartElement("TablixRow");
            RdlRender.AddLine(xmlWriter, "Height", ".25in");
            xmlWriter.WriteStartElement("TablixCells");
            xmlWriter.WriteStartElement("TablixCell");
            xmlWriter.WriteStartElement("CellContents");
            xmlWriter.WriteStartElement("ColSpan");
            xmlWriter.WriteString(_colSpan);
            xmlWriter.WriteEndElement();//ColSpan
            RdlRender.AddTextbox2010(xmlWriter, "reportDescription", _reportDescription, _textboxStyle10pt, "", "0.25cm", "15.00cm", "3.00cm", "true", "0.5cm", "1",
                                     "", "", "", "", "", "", "", "");
            xmlWriter.WriteEndElement(); //CellContents
            xmlWriter.WriteEndElement(); //TablixCell
            for (int x = 0; x < (int.Parse(_colSpan) - 1); x++)
            {
                xmlWriter.WriteStartElement("TablixCell");
                xmlWriter.WriteEndElement(); //TablixCell
            }
            xmlWriter.WriteEndElement();     //TablixCells
            xmlWriter.WriteEndElement();     //TablixRow



            //Report Filters
            foreach (ReportFilterBusinessObject _CurrentFilter in _filterItemList)
            {
                FilterCount++;
                _Filter = "Filter" + FilterCount.ToString();
                xmlWriter.WriteStartElement("TablixRow");
                RdlRender.AddLine(xmlWriter, "Height", ".25in");
                xmlWriter.WriteStartElement("TablixCells");
                xmlWriter.WriteStartElement("TablixCell");
                xmlWriter.WriteStartElement("CellContents");
                xmlWriter.WriteStartElement("ColSpan");
                xmlWriter.WriteString(_colSpan);
                xmlWriter.WriteEndElement();//ColSpan
                _FilterDescription = "Data Filter Applied : " + _CurrentFilter.DataItemCaption + " " + _CurrentFilter.Operand + " " + _CurrentFilter.FilterValue;
                RdlRender.AddTextbox2010(xmlWriter, _Filter, _FilterDescription, _textboxStyle10pt, "", "0.25cm", "15.00cm", "3.00cm", "true", "0.5cm", "1",
                                         "", "", "", "", "", "", "", "");
                xmlWriter.WriteEndElement(); //CellContents
                xmlWriter.WriteEndElement(); //TablixCell
                for (int x = 0; x < (int.Parse(_colSpan) - 1); x++)
                {
                    xmlWriter.WriteStartElement("TablixCell");
                    xmlWriter.WriteEndElement(); //TablixCell
                }
                xmlWriter.WriteEndElement();     //TablixCells
                xmlWriter.WriteEndElement();     //TablixRow
            }
        }
 /// <summary>
 /// Generates a table details text box rendered in RDL for
 /// use in a TabularReport object.
 /// </summary>
 /// <param name="name">Name of this textbox.</param>
 /// <param name="isEmpty">Denotes if this field is empty.</param>
 /// <param name="dataType">Data type of this data item.</param>
 public TableDetailsTextBox(string name, bool isEmpty, string dataType, string hyperlink = null)
 {
     _name         = name;
     _isEmpty      = isEmpty;
     _dataType     = dataType;
     _hyperlink    = hyperlink;
     _textboxStyle = new ReportingServicesStyle(
         ReportingServicesStyle.TextBoxStyle.TableDetailsTextBox);
 }
Example #3
0
        /// <summary>
        /// Constructs a new MatrixStaticRow.
        /// </summary>
        /// <param name="name">Name of this static row.</param>
        /// <param name="Item">The data item represented in this row.</param>
        public MatrixStaticRow(string name, DataItem Item, DataModel currentDataModel)
        {
            CurrentDataModel = currentDataModel;

            _name = name;

            // 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 == Item.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(Item.DataTableCode);
            string    TableName     = ThisDataTable.Name;

            _fieldName = Item.Caption;            //TableName + Item.Name;

            _textboxStyle = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.MatrixRow);
        }
Example #4
0
        /// <summary>
        /// Generates a table group text box rendered in RDL for
        /// use in a TabularReport object.
        /// </summary>
        /// <param name="dataItem">The data item being represented in this textbox.</param>
        /// <param name="isEmpty">Denotes whether this textbox is empty.</param>
        /// <param name="groupName">Name of the grouping to which this data item belongs.</param>
        public TableGroupTextBox(DataItem dataItem, bool isEmpty,
                                 string groupName, List <DataItem> newGroupList, DataItem groupByItem, DataModel currentDataModel, string hyperlink = null)
        {
            CurrentDataModel = currentDataModel;
            _hyperlink       = hyperlink;
            // To ensure textbox name is unique in case of data items with same name,
            // concatenate the tablename and itemname
            DataTable ThisDataTable = CurrentDataModel.DataTables.Single(x => x.Code == dataItem.DataTableCode);//DataAccessUtilities.RepositoryLocator<IDataTableRepository>().GetByCode(dataItem.DataTableCode);
            string    TableName     = ThisDataTable.Name;

            // If this textbox is empty, its name should be random but unique
            if (isEmpty)
            {
                string GuidName = Guid.NewGuid().ToString();
                GuidName = GuidName.Replace("-", "");
                _name    = GuidName;
            }
            else
            {
                _name = TableName + dataItem.Name;
            }

            _isEmpty    = isEmpty;
            _itemName   = TableName + dataItem.Name;
            _isSummable = dataItem.IsSummable;
            _dataType   = dataItem.DataType;
            _groupName  = groupName;

            if (newGroupList != null)
            {
                _newGroupListIndex = newGroupList.IndexOf(groupByItem) + 1;
            }

            if (_isSummable)
            {
                _groupingLevel = dataItem.GroupingLevel;
            }

            _textboxStyle = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.TableGroupTextBox);
        }
Example #5
0
        /// <summary>
        /// Constructs a new MatrixRow.
        /// </summary>
        /// <param name="name">Name of this row.</param>
        /// <param name="Item">The data item represented on this row.</param>
        public MatrixRow(string name, DataItem Item, DataModel currentDataModel)
        {
            CurrentDataModel = currentDataModel;

            _name = name;

            // To ensure the textbox referes to a field whose name 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;

            _fieldName = TableName + Item.Name;

            _dataType   = Item.DataType;
            _isSummable = Item.IsSummable;

            if (_isSummable)
            {
                _groupingLevel = Item.GroupingLevel;
            }

            _textboxStyle = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.MatrixRow);
        }
        /// <summary>
        /// Renders this MatrixReport in RDL.
        /// </summary>
        /// <returns>A Byte array containing the raw RDL data.</returns>
        public Byte[] Render()
        {
            //TODO: Code Review Issue 11/05/05: Add necessary comment on each code block and
            //indent the code as in XML where possible to increase readability
            // Done 24/05/2005
            _xmlWriter.WriteStartDocument();

            _xmlWriter.WriteStartElement("Report");
            _xmlWriter.WriteAttributeString("xmlns",
                                            "http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition");

            RdlRender.AddLine(_xmlWriter, "Width", "1in");
            RdlRender.AddLine(_xmlWriter, "PageWidth", "11.5in");
            RdlRender.AddLine(_xmlWriter, "TopMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "BottomMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "LeftMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "RightMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "PageHeight", "7.9375in");

            _xmlWriter.WriteStartElement("PageHeader");
            _xmlWriter.WriteStartElement("ReportItems");
            RdlRender.AddImage(_xmlWriter, "Image1", "2.59259cm", "3.8cm",
                               "1.0cm", "Embedded", "Esf", "AutoSize");
            RdlRender.AddTextbox(_xmlWriter, "TitleTextbox", "DWP Small Systems Ad Hoc Reporting System",
                                 _textboxStyle, "Left", "0.3cm", "5.0cm", "10cm", "true", "0.95cm", "2", "",
                                 "", "", "", "", "", "", "");
            RdlRender.AddTextbox(_xmlWriter, "PageHeader", "=Globals!ReportName",
                                 _textboxStyle, "Left", "2.85714cm", "1.26984cm", "14.92063cm", "true",
                                 "", "", "", "", "", "", "", "", "", "");


            foreach (String _parameterName in _parameterList)
            {
                _parameterCount++;

                RdlRender.AddTextbox(_xmlWriter, "Parameter" + _parameterCount.ToString(), _parameterName, _textboxStyle,
                                     "Left", "2.85714cm", "1.26984cm", "14.92063cm", "true", "", "", "", "",
                                     "", "", "", "", "", "");
            }
            _xmlWriter.WriteEndElement();                     // ReportItems
            RdlRender.AddLine(_xmlWriter, "PrintOnLastPage", "true");
            RdlRender.AddLine(_xmlWriter, "PrintOnFirstPage", "true");
            RdlRender.AddLine(_xmlWriter, "Height", "1.375in");
            _xmlWriter.WriteEndElement();                     // PageHeader

            _xmlWriter.WriteStartElement("Body");

            RdlRender.AddLine(_xmlWriter, "Height", "5in");
            _xmlWriter.WriteStartElement("ReportItems");

            // Add table of keys to dynamic rows/columns
            ReportingServicesStyle BoldBorderedTextBoxStyle = new ReportingServicesStyle(ReportingServicesStyle.TextBoxStyle.BoldBordered);
//						"", "Solid", "Black", "", "", "", "", "10pt", "Bold", "", "", "", "");
            ReportingServicesStyle PlainBorderedTextBoxStyle = new ReportingServicesStyle(ReportingServicesStyle.TextBoxStyle.PlainBordered);

//						"", "Solid", "Black", "", "", "", "", "10pt", "", "", "", "", "");

            // Table's header
            _xmlWriter.WriteStartElement("Table");
            _xmlWriter.WriteAttributeString("Name", "KeyTable");
            RdlRender.AddLine(_xmlWriter, "Left", "1.26984cm");

            RdlRender.AddLine(_xmlWriter, "DataSetName", _matrixDataSetName + "DataSet");
            _xmlWriter.WriteStartElement("Style");
            _xmlWriter.WriteStartElement("BorderStyle");
            RdlRender.AddLine(_xmlWriter, "Default", PlainBorderedTextBoxStyle.BorderStyle);
            _xmlWriter.WriteEndElement();                                     // BorderStyle
            _xmlWriter.WriteEndElement();                                     // Style
            _xmlWriter.WriteStartElement("Header");
            _xmlWriter.WriteStartElement("TableRows");
            _xmlWriter.WriteStartElement("TableRow");
            RdlRender.AddLine(_xmlWriter, "Height", "1cm");
            _xmlWriter.WriteStartElement("TableCells");
            _xmlWriter.WriteStartElement("TableCell");
            _xmlWriter.WriteStartElement("ReportItems");
            RdlRender.AddTextbox(_xmlWriter, "KeyTableRows", "Dynamic Rows",
                                 BoldBorderedTextBoxStyle, "Center", "", "", "", "", "", "", "", "", "",
                                 "", "", "", "", "");
            _xmlWriter.WriteEndElement();                                                                     // ReportItems
            _xmlWriter.WriteEndElement();                                                                     // TableCell
            _xmlWriter.WriteStartElement("TableCell");
            _xmlWriter.WriteStartElement("ReportItems");
            RdlRender.AddTextbox(_xmlWriter, "KeyTableColumns", "Dynamic Columns",
                                 BoldBorderedTextBoxStyle, "Center", "", "", "", "", "", "", "", "", "",
                                 "", "", "", "", "");
            _xmlWriter.WriteEndElement();                                             // ReportItems
            _xmlWriter.WriteEndElement();                                             // TableCell
            _xmlWriter.WriteEndElement();                                             // TableCells
            _xmlWriter.WriteEndElement();                                             // TableRow

            // Add the names of the rows and columns to the table
            for (int RowNum = 0;
                 RowNum < _columnTotalDataItemList.Count && RowNum < _rowTotalDataItemList.Count;
                 RowNum++)
            {
                string ColumnItem = _columnTotalDataItemList[RowNum] != null ?
                                    (_columnTotalDataItemList[RowNum]).Caption : "";
                string RowItem = _rowTotalDataItemList[RowNum] != null ?
                                 (_rowTotalDataItemList[RowNum]).Caption : "";

                _xmlWriter.WriteStartElement("TableRow");
                RdlRender.AddLine(_xmlWriter, "Height", "0.8cm");
                _xmlWriter.WriteStartElement("TableCells");
                _xmlWriter.WriteStartElement("TableCell");
                _xmlWriter.WriteStartElement("ReportItems");

                // Column text box
                RdlRender.AddTextbox(_xmlWriter, "KeyTableRow" + RowNum, RowItem,
                                     PlainBorderedTextBoxStyle, "", "", "", "", "", "", "", "", "", "", "",
                                     "", "", "", "");

                _xmlWriter.WriteEndElement();                                                                 // ReportItems
                _xmlWriter.WriteEndElement();                                                                 // TableCell
                _xmlWriter.WriteStartElement("TableCell");
                _xmlWriter.WriteStartElement("ReportItems");

                // Row text box
                RdlRender.AddTextbox(_xmlWriter, "KeyTableColumn" + RowNum, ColumnItem,
                                     PlainBorderedTextBoxStyle, "", "", "", "", "", "", "", "", "", "", "",
                                     "", "", "", "");

                _xmlWriter.WriteEndElement();                                                 // ReportItems
                _xmlWriter.WriteEndElement();                                                 // TableCell
                _xmlWriter.WriteEndElement();                                                 // TableCells
                _xmlWriter.WriteEndElement();                                                 // TableRow
            }

            _xmlWriter.WriteEndElement();                                     // TableRows
            _xmlWriter.WriteEndElement();                                     // Header
            _xmlWriter.WriteStartElement("TableColumns");
            _xmlWriter.WriteStartElement("TableColumn");
            RdlRender.AddLine(_xmlWriter, "Width", "5.0cm");
            _xmlWriter.WriteEndElement();                                             // TableColumn
            _xmlWriter.WriteStartElement("TableColumn");
            RdlRender.AddLine(_xmlWriter, "Width", "5.0cm");
            _xmlWriter.WriteEndElement();                             // TableColumn
            _xmlWriter.WriteEndElement();                             // TableColumns
            _xmlWriter.WriteEndElement();                             // Table

            // End of table of keys rendering


            _xmlWriter.WriteStartElement("Matrix");
            _xmlWriter.WriteAttributeString("Name", "Matrix1");
            RdlRender.AddLine(_xmlWriter, "DataSetName", _matrixDataSetName + "DataSet");
            RdlRender.AddLine(_xmlWriter, "Top", "2.5cm");
            RdlRender.AddLine(_xmlWriter, "Left", ".5in");
            RdlRender.AddLine(_xmlWriter, "Height", ".5in");
            RdlRender.AddLine(_xmlWriter, "Width", "6in");

            _xmlWriter.WriteStartElement("Corner");
            _xmlWriter.WriteStartElement("ReportItems");

            RdlRender.AddTextbox(_xmlWriter, "CornerTextbox", "", _cornerTextboxStyle,
                                 "", "", "", "", "true", "", "", "", "", "", "", "", "", "", "");

            _xmlWriter.WriteEndElement();                                     // ReportItems
            _xmlWriter.WriteEndElement();                                     // Corner


            // Render MatrixRows
            _xmlWriter.WriteStartElement("MatrixRows");
            foreach (MatrixRow CurrentRow in _matrixRowList)
            {
                CurrentRow.Render(_xmlWriter);
            }
            _xmlWriter.WriteEndElement();                                     // MatrixRows

            _xmlWriter.WriteStartElement("MatrixColumns");
            _xmlWriter.WriteStartElement("MatrixColumn");
            RdlRender.AddLine(_xmlWriter, "Width", "3.25cm");
            _xmlWriter.WriteEndElement();                             // MatrixColumns
            _xmlWriter.WriteEndElement();                             // MatrixColumn


            // Render ColumnGroupings
            _xmlWriter.WriteStartElement("ColumnGroupings");
            foreach (MatrixDynamicColumnGrouping CurrentColGroup in _dynamicColumnGroupingList)
            {
                CurrentColGroup.Render(_xmlWriter);
            }
            _xmlWriter.WriteEndElement();


            // Render RowGroupings
            _xmlWriter.WriteStartElement("RowGroupings");
            foreach (MatrixDynamicRowGrouping CurrentRowGroup in _dynamicRowGroupingList)
            {
                CurrentRowGroup.Render(_xmlWriter);
            }

            _xmlWriter.WriteStartElement("RowGrouping");
            RdlRender.AddLine(_xmlWriter, "Width", "3.5cm");
            _xmlWriter.WriteStartElement("StaticRows");
            foreach (MatrixStaticRow CurrentRow in _matrixStaticRowList)
            {
                CurrentRow.Render(_xmlWriter);
            }
            _xmlWriter.WriteEndElement();                     // StaticRows
            _xmlWriter.WriteEndElement();                     // RowGrouping
            _xmlWriter.WriteEndElement();                     // RowGroupings
            RdlRender.AddLine(_xmlWriter, "NoRows", Resource.GetString("RES_REPORT_NOROWSRETURNED"));
            _xmlWriter.WriteEndElement();                     // Matrix
            _xmlWriter.WriteEndElement();                     // ReportItems

            RdlRender.AddLine(_xmlWriter, "ColumnSpacing", "1cm");

            _xmlWriter.WriteEndElement();                     // Body


            // DataSources
            _xmlWriter.WriteStartElement("DataSources");
            _xmlWriter.WriteStartElement("DataSource");
            _xmlWriter.WriteAttributeString("Name", "DataSource1");
            //		_xmlWriter.WriteStartElement("ConnectionProperties");
            RdlRender.AddLine(_xmlWriter, "DataSourceReference", "/" + _dataSource);

            //					RdlRender.AddLine(_xmlWriter, "DataProvider", "SQL");
            //					RdlRender.AddLine(_xmlWriter, "ConnectString", _dbConnectionString);
            //					RdlRender.AddLine(_xmlWriter, "IntegratedSecurity", "false");
            //					RdlRender.AddLine(_xmlWriter, "Prompt", "false");

            //				_xmlWriter.WriteEndElement(); // ConnectionProperties
            _xmlWriter.WriteEndElement();                     // DataSource
            _xmlWriter.WriteEndElement();                     // DataSources


            // Datasets
            _xmlWriter.WriteStartElement("DataSets");
            foreach (Dataset CurrentDataset in _datasetList)
            {
                CurrentDataset.Render(_xmlWriter);
            }
            _xmlWriter.WriteEndElement();

            // ReportParameters
            if (_reportParameterList != null && _reportParameterList.Count > 0)
            {
                _xmlWriter.WriteStartElement("ReportParameters");
                foreach (ReportParameter CurrentParameter in _reportParameterList)
                {
                    CurrentParameter.Render(_xmlWriter);
                }
                _xmlWriter.WriteEndElement();
            }

            // EmbeddedImages
            _xmlWriter.WriteStartElement("EmbeddedImages");
            _xmlWriter.WriteStartElement("EmbeddedImage");
            _xmlWriter.WriteAttributeString("Name", "Esf");
            RdlRender.AddLine(_xmlWriter, "MIMEType", "image/bmp");
            _xmlWriter.WriteStartElement("ImageData");

            // Image data
            FileStream ImageStream = new FileStream(HttpContext.Current.Server.MapPath(
                                                        ConfigurationManager.AppSettings["SmallSystemsLogoImage"]), FileMode.Open, FileAccess.Read);

            byte[] ImageByteArray = new Byte[ImageStream.Length];
            ImageStream.Read(ImageByteArray, 0, (int)ImageStream.Length);
            ImageStream.Close();
            _xmlWriter.WriteBase64(ImageByteArray, 0, ImageByteArray.Length);

            _xmlWriter.WriteEndElement();                     // ImageData
            _xmlWriter.WriteEndElement();                     // EmbeddedImage
            _xmlWriter.WriteEndElement();                     // EmbeddedImages


            // Report footer
            _xmlWriter.WriteStartElement("PageFooter");
            RdlRender.AddLine(_xmlWriter, "Height", "1.0cm");
            RdlRender.AddLine(_xmlWriter, "PrintOnFirstPage", "true");
            RdlRender.AddLine(_xmlWriter, "PrintOnLastPage", "true");
            _xmlWriter.WriteStartElement("ReportItems");

            RdlRender.AddTextbox(_xmlWriter, "ReportDescriptionTextBox", _reportDescription,
                                 BoldBorderedTextBoxStyle, "", "0.25cm", "1.0cm", "16.00cm", "true", "0.5cm", "1",
                                 "", "", "", "", "", "", "", "");


            //Report Filters

            foreach (ReportFilterBusinessObject _CurrentFilter in _filterItemList)
            {
                FilterCount++;
                _Filter = "Filter" + FilterCount.ToString();

                _FilterDescription = "Data Filter Applied : " + _CurrentFilter.DataItemCaption + " " + _CurrentFilter.Operand + " " + _CurrentFilter.FilterValue;
                RdlRender.AddTextbox(_xmlWriter, _Filter, _FilterDescription, BoldBorderedTextBoxStyle, "", "0.25cm", "1.00cm", "16.00cm", "true", "0.5cm", "1",
                                     "", "", "", "", "", "", "", "");
            }


            _xmlWriter.WriteEndElement();             // Report
            _xmlWriter.WriteEndDocument();
            _xmlWriter.Flush();

            _memoryStream.Close();
            return(_memoryStream.GetBuffer());

            //_stream.Close();
            //return new byte[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);
        }
Example #8
0
 /// <summary>
 /// Constructs a new MatrixDynamicRowSubtotal
 /// </summary>
 /// <param name="name">Name of this subtotal.</param>
 public MatrixDynamicRowSubTotal(string name)
 {
     _name         = name;
     _textboxStyle = new ReportingServicesStyle(
         ReportingServicesStyle.TextBoxStyle.MatrixDynamic);
 }
Example #9
0
        /// <summary>
        /// Makes this object render itself as an RDL Report type to an XmlWriter instance.
        /// It calls upon all objects immediately beneath it (TableHeader, TableGroup,
        /// TableDetails, Datasets, ReportParameters) to render themselves also.
        /// </summary>
        /// <returns>A Byte array containing the raw RDL data.</returns>
        public Byte[] Render2010()
        {
            // Styles for the textboxes
            ReportingServicesStyle _textboxStyle14pt = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.TabularReport14pt);
            ReportingServicesStyle _textboxStyle10pt = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.TabularReport10pt);

            _xmlWriter.WriteStartDocument();

            _xmlWriter.WriteStartElement("Report");
            _xmlWriter.WriteAttributeString("xmlns",
                                            "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition");
            _xmlWriter.WriteAttributeString("xmlns:cl",
                                            "http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition");

            RdlRender.AddLine(_xmlWriter, "AutoRefresh", "0");
            // DataSources
            _xmlWriter.WriteStartElement("DataSources");
            _xmlWriter.WriteStartElement("DataSource");
            _xmlWriter.WriteAttributeString("Name", "DataSource1");
            RdlRender.AddLine(_xmlWriter, "DataSourceReference", "/" + _dataSource);

            /*_xmlWriter.WriteStartElement("ConnectionProperties");
             * RdlRender.AddLine( _xmlWriter, "DataProvider", "SQL");
             * RdlRender.AddLine( _xmlWriter, "ConnectString", _dbConnectionString);
             * RdlRender.AddLine( _xmlWriter, "IntegratedSecurity", "false");
             * RdlRender.AddLine( _xmlWriter, "Prompt", "false");
             * _xmlWriter.WriteEndElement(); // ConnectionProperties */
            _xmlWriter.WriteEndElement(); // DataSource
            _xmlWriter.WriteEndElement(); // DataSources

            // Datasets
            _xmlWriter.WriteStartElement("DataSets");
            foreach (Dataset CurrentDataSet in _datasetList)
            {
                CurrentDataSet.Render2010(_xmlWriter);
            }
            _xmlWriter.WriteEndElement(); //DataSets

            //ReportSections
            _xmlWriter.WriteStartElement("ReportSections");
            //ReportSection
            _xmlWriter.WriteStartElement("ReportSection");



            _xmlWriter.WriteStartElement("Body");
            RdlRender.AddLine(_xmlWriter, "Height", "5in");

            _xmlWriter.WriteStartElement("ReportItems");
            _xmlWriter.WriteStartElement("Tablix");
            _xmlWriter.WriteAttributeString("Name", "Table1");
            RdlRender.AddLine(_xmlWriter, "DataSetName", "TableDataSet");
            RdlRender.AddLine(_xmlWriter, "NoRowsMessage", Resource.GetString("RES_REPORT_NOROWSRETURNED"));
            RdlRender.AddLine(_xmlWriter, "Top", "0in");
            RdlRender.AddLine(_xmlWriter, "Left", ".5in");
            RdlRender.AddLine(_xmlWriter, "Height", "0in");
            RdlRender.AddLine(_xmlWriter, "Width", "6in");

            _xmlWriter.WriteStartElement("TablixBody");

            // Write table columns
            _xmlWriter.WriteStartElement("TablixColumns");
            for (int i = 0; i < _fieldDataItems.Count; i++)
            {
                _xmlWriter.WriteStartElement("TablixColumn");
                RdlRender.AddLine(_xmlWriter, "Width", "1.5in");
                _xmlWriter.WriteEndElement(); // TablixColumn
            }
            _xmlWriter.WriteEndElement();     // TablixColumns

            // Write table rows
            _xmlWriter.WriteStartElement("TablixRows");

            // TableHeader
            _tableHeader.Render2010(_xmlWriter);

            // TableGroups
            if (_tableGroupList != null && _tableGroupList.Count > 0)
            {
                foreach (TableGroup group in _tableGroupList)
                {
                    group.Render2010(_xmlWriter);
                }
            }

            // TableDetails
            if (_isSummaryReport == false)
            {
                _tableDetails.Render2010(_xmlWriter);
            }



            // TableFooter
            _tableFooter.Render2010(_xmlWriter);

            _xmlWriter.WriteEndElement(); // TablixRows

            _xmlWriter.WriteEndElement(); // TablixBody
            _xmlWriter.WriteStartElement("TablixColumnHierarchy");
            _xmlWriter.WriteStartElement("TablixMembers");
            for (int i = 0; i < _fieldDataItems.Count; i++)
            {
                _xmlWriter.WriteStartElement("TablixMember");
                _xmlWriter.WriteEndElement(); // TablixMember
            }
            _xmlWriter.WriteEndElement();     // TablixMembers

            _xmlWriter.WriteEndElement();     // TablixColumnHierarchy


            _xmlWriter.WriteStartElement("TablixRowHierarchy");
            _xmlWriter.WriteStartElement("TablixMembers");

            //Add Header row member
            _xmlWriter.WriteStartElement("TablixMember");
            RdlRender.AddLine(_xmlWriter, "KeepWithGroup", "After");
            RdlRender.AddLine(_xmlWriter, "FixedData", "true");
            RdlRender.AddLine(_xmlWriter, "RepeatOnNewPage", "true");
            RdlRender.AddLine(_xmlWriter, "KeepTogether", "true");
            _xmlWriter.WriteEndElement(); // TablixMember

            //Add Group and details hierarchy members
            if (_tableGroupList != null && _tableGroupList.Count > 0)
            {
                for (int i = 0; i < _tableGroupList.Count; i++)//
                {
                    _xmlWriter.WriteStartElement("TablixMember");
                    _xmlWriter.WriteStartElement("Group");
                    _xmlWriter.WriteAttributeString("Name", "Grouping" + _tableGroupList[i].Name);
                    if (_tableGroupList[i].IsDataMapDisplayedGroup) // check if data map neds displaying
                    {
                        RdlRender.AddLine(_xmlWriter, "DocumentMapLabel", "=Fields!" + _tableGroupList[i].Name + ".Value");
                    }
                    if (_isPageOnFirstItem && i == 0)
                    {
                        _xmlWriter.WriteStartElement("PageBreak");
                        RdlRender.AddLine(_xmlWriter, "BreakLocation", "Between");
                        _xmlWriter.WriteEndElement(); // PageBreak
                    }

                    _xmlWriter.WriteStartElement("GroupExpressions");
                    RdlRender.AddLine(_xmlWriter, "GroupExpression", "=Fields!" + _tableGroupList[i].Name + ".Value");
                    _xmlWriter.WriteEndElement(); // GroupExpressions
                    _xmlWriter.WriteEndElement(); // Group

                    _xmlWriter.WriteStartElement("SortExpressions");
                    _xmlWriter.WriteStartElement("SortExpression");

                    RdlRender.AddLine(_xmlWriter, "Value", "=Fields!" + _tableGroupList[i].Name + ".Value");
                    //RdlRender.AddLine(xmlWriter, "Direction", "Ascending");
                    _xmlWriter.WriteEndElement(); // SortExpression
                    _xmlWriter.WriteEndElement(); // SortExpressions
                    _xmlWriter.WriteStartElement("TablixMembers");
                    _xmlWriter.WriteStartElement("TablixMember");
                    if (i > 0 && _isDrillDown)
                    {
                        _xmlWriter.WriteStartElement("Visibility");
                        RdlRender.AddLine(_xmlWriter, "Hidden", "true");
                        RdlRender.AddLine(_xmlWriter, "ToggleItem", "Group" + _tableGroupList[i - 1].Name);
                        _xmlWriter.WriteEndElement(); // Visibility
                    }
                    RdlRender.AddLine(_xmlWriter, "KeepWithGroup", "After");
                    RdlRender.AddLine(_xmlWriter, "KeepTogether", "true");
                    _xmlWriter.WriteEndElement(); // TablixMember
                }
            }

            // TableDetails
            if (_isSummaryReport == false)
            {
                _xmlWriter.WriteStartElement("TablixMember");
                _xmlWriter.WriteStartElement("Group");
                _xmlWriter.WriteAttributeString("Name", "Table1_Details_Group");
                //if (_isDataMapDisplayedGroup == true) // check if data map neds displaying
                //{
                //    RdlRender.AddLine(xmlWriter, "Label", "=Fields!" + _name + ".Value");
                //}
                RdlRender.AddLine(_xmlWriter, "DataElementName", "Detail");
                _xmlWriter.WriteEndElement(); // Group


                _xmlWriter.WriteStartElement("TablixMembers");
                _xmlWriter.WriteStartElement("TablixMember");
                if (_isDrillDown)
                {
                    _xmlWriter.WriteStartElement("Visibility");
                    RdlRender.AddLine(_xmlWriter, "Hidden", "true");
                    RdlRender.AddLine(_xmlWriter, "ToggleItem", "Group" + _tableGroupList[_tableGroupList.Count - 1].Name);
                    _xmlWriter.WriteEndElement(); // Visibility
                }
                _xmlWriter.WriteEndElement();     // TablixMember
                _xmlWriter.WriteEndElement();     // TablixMembers
                RdlRender.AddLine(_xmlWriter, "DataElementName", "Detail_Collection");
                RdlRender.AddLine(_xmlWriter, "DataElementOutput", "Output");
                RdlRender.AddLine(_xmlWriter, "KeepTogether", "true");
                _xmlWriter.WriteEndElement(); // TablixMember
            }

            //Close down the group hierarchies
            if (_tableGroupList != null && _tableGroupList.Count > 0)
            {
                for (int i = 0; i < _tableGroupList.Count; i++) //
                {
                    _xmlWriter.WriteEndElement();               // TablixMembers
                    _xmlWriter.WriteEndElement();               // TablixMember
                }
            }

            //Add Footer report name member
            _xmlWriter.WriteStartElement("TablixMember");
            RdlRender.AddLine(_xmlWriter, "KeepWithGroup", "Before");
            RdlRender.AddLine(_xmlWriter, "RepeatOnNewPage", "true");
            RdlRender.AddLine(_xmlWriter, "KeepTogether", "true");
            _xmlWriter.WriteEndElement(); // TablixMember

            //Add Footer filter selections
            for (int i = 0; i < _noOfFilters; i++)
            {
                _xmlWriter.WriteStartElement("TablixMember");
                RdlRender.AddLine(_xmlWriter, "KeepWithGroup", "Before");
                RdlRender.AddLine(_xmlWriter, "RepeatOnNewPage", "true");
                RdlRender.AddLine(_xmlWriter, "KeepTogether", "true");
                _xmlWriter.WriteEndElement(); // TablixMember
            }

            _xmlWriter.WriteEndElement(); // TablixMembers
            _xmlWriter.WriteEndElement(); // TablixRowHierarchy



            _xmlWriter.WriteStartElement("Style");
            _xmlWriter.WriteEndElement();



            _xmlWriter.WriteEndElement(); // Tablix

            foreach (Chart currentChart in _chartList)
            {
                currentChart.Render2010(_xmlWriter);
            }

            _xmlWriter.WriteEndElement(); // ReportItems
            _xmlWriter.WriteEndElement(); // Body

            RdlRender.AddLine(_xmlWriter, "Width", (_selectedDataItems.Count * 1.5 < 11.5)?"11.5in":(_selectedDataItems.Count * 1.5).ToString() + "in");



            _xmlWriter.WriteStartElement("Page");
            _xmlWriter.WriteStartElement("PageHeader");


            _xmlWriter.WriteStartElement("ReportItems");

            RdlRender.AddTextbox2010(_xmlWriter, "TitleTextbox", "DWP Small Systems Ad Hoc Reporting System",
                                     _textboxStyle14pt, "Left", "0.3cm", "2in", "6in", "true", "0.95cm", "2", "",
                                     "", "", "", "", "", "", "");

            RdlRender.AddTextbox2010(_xmlWriter, "PageHeader", "=Globals!ReportName", _textboxStyle14pt,
                                     "Left", "2.85714cm", "0.5in", "6in", "true", "1cm", "", "", "",
                                     "", "", "", "", "", "");

            RdlRender.AddImage2010(_xmlWriter, "Image1", "2.59259cm", "1.5in",
                                   "0.5in", "Embedded", "Esf", "AutoSize");
            int    ParameterCount = 0;
            int    X = 0;
            string ParameterHeight = "";

            foreach (String _parameterName in _parameterList)
            {
                ParameterCount++;
                X = ParameterCount;
                X = X + 3;
                ParameterHeight = X.ToString() + "cm";
                RdlRender.AddTextbox2010(_xmlWriter, "Parameter" + ParameterCount.ToString(), _parameterName, _textboxStyle14pt,
                                         "Left", ParameterHeight, "0.5in", "6in", "true", "1cm", "", "", "",
                                         "", "", "", "", "", "");
            }
            _xmlWriter.WriteEndElement(); // ReportItems
            X = ParameterCount;
            X = X + 4;
            ParameterHeight = X.ToString() + ".8cm";
            RdlRender.AddLine(_xmlWriter, "PrintOnLastPage", "true");
            RdlRender.AddLine(_xmlWriter, "PrintOnFirstPage", "true");
            RdlRender.AddLine(_xmlWriter, "Height", ParameterHeight);
            _xmlWriter.WriteEndElement(); // PagHeader


            // Report footer
            _xmlWriter.WriteStartElement("PageFooter");
            RdlRender.AddLine(_xmlWriter, "Height", "1.0cm");
            RdlRender.AddLine(_xmlWriter, "PrintOnFirstPage", "true");
            RdlRender.AddLine(_xmlWriter, "PrintOnLastPage", "true");
            _xmlWriter.WriteStartElement("ReportItems");

            RdlRender.AddTextbox2010(_xmlWriter, "UserTextBox", "=Parameters!ReportUserName.Value",
                                     _textboxStyle10pt, "", "0.25cm", "1.0cm", "6.00cm", "true", "0.5cm", "1",
                                     "", "", "", "", "", "", "", "");
            RdlRender.AddTextbox2010(_xmlWriter, "ExecutionTimeTextBox", "=Globals!ExecutionTime",
                                     _textboxStyle10pt, "", "0.25cm", "7.00cm", "6.00cm", "true", "0.5cm", "1",
                                     "", "", "", "", "", "", "", "");
            RdlRender.AddTextbox2010(_xmlWriter, "PageNumberTextBox", "=Globals!PageNumber",
                                     _textboxStyle10pt, "", "0.25cm", "15.00cm", "3.00cm", "true", "0.5cm", "1",
                                     "", "", "", "", "", "", "", "");

            _xmlWriter.WriteEndElement(); // ReportItems
            _xmlWriter.WriteEndElement(); // PageFooter


            _xmlWriter.WriteEndElement(); // Page

            _xmlWriter.WriteEndElement(); // RepoetSection
            _xmlWriter.WriteEndElement(); // ReportSections


            //Add a report parameter for user id

            _xmlWriter.WriteStartElement("ReportParameters");


            _xmlWriter.WriteStartElement("ReportParameter");
            _xmlWriter.WriteAttributeString("Name", "ReportUserName");
            // Render relevant data type
            RdlRender.AddLine(_xmlWriter, "DataType", "String");
            RdlRender.AddLine(_xmlWriter, "Prompt", "User Name");
            RdlRender.AddLine(_xmlWriter, "Hidden", "true");
            _xmlWriter.WriteEndElement(); // ReportParameter

            _xmlWriter.WriteStartElement("ReportParameter");
            _xmlWriter.WriteAttributeString("Name", "ReportUserCode");
            // Render relevant data type
            RdlRender.AddLine(_xmlWriter, "DataType", "String");
            RdlRender.AddLine(_xmlWriter, "Prompt", "User Name");
            RdlRender.AddLine(_xmlWriter, "Hidden", "true");
            _xmlWriter.WriteEndElement(); // ReportParameter

            // ReportParameters
            if (_reportParametersList != null && _reportParametersList.Count > 0)
            {
                foreach (ReportParameter CurrentParameter in _reportParametersList)
                {
                    CurrentParameter.Render2010(_xmlWriter);
                }
            }
            _xmlWriter.WriteEndElement();



            // EmbeddedImages
            _xmlWriter.WriteStartElement("EmbeddedImages");
            _xmlWriter.WriteStartElement("EmbeddedImage");
            _xmlWriter.WriteAttributeString("Name", "Esf");
            RdlRender.AddLine(_xmlWriter, "MIMEType", "image/bmp");
            _xmlWriter.WriteStartElement("ImageData");

            // Image data
            FileStream ImageStream = new FileStream(
                HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["SmallSystemsLogoImage"]), FileMode.Open, FileAccess.Read);

            byte[] ImageByteArray = new byte[ImageStream.Length];
            ImageStream.Read(ImageByteArray, 0, (int)ImageStream.Length);
            ImageStream.Close();
            _xmlWriter.WriteBase64(ImageByteArray, 0, ImageByteArray.Length);

            _xmlWriter.WriteEndElement(); // ImageData
            _xmlWriter.WriteEndElement(); // EmbeddedImage
            _xmlWriter.WriteEndElement(); // EmbeddedImages

            RdlRender.AddLine(_xmlWriter, "ConsumeContainerWhitespace", "true");
            _xmlWriter.WriteEndElement(); // Report
            _xmlWriter.WriteEndDocument();
            //****TESTING*************
            // _xmlWriter.Flush();
            // XmlDocument doc = RdlRender.CreateXmlDocument(_memoryStream);
            //*****************/
            _xmlWriter.Flush();

            _memoryStream.Close();
            return(_memoryStream.ToArray());// GetBuffer();

            //_stream.Close();
            // return new byte[0];
        }
Example #10
0
        //TODO: Code Review Issue 11/05/05: Give a more detailed summary.
        // Done 24/05/2005
        /// <summary>
        /// Makes this object render itself as an RDL Report type to an XmlWriter instance.
        /// It calls upon all objects immediately beneath it (TableHeader, TableGroup,
        /// TableDetails, Datasets, ReportParameters) to render themselves also.
        /// </summary>
        /// <returns>A Byte array containing the raw RDL data.</returns>
        public Byte[] Render()
        {
            // Styles for the textboxes
            ReportingServicesStyle _textboxStyle14pt = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.TabularReport14pt);
            ReportingServicesStyle _textboxStyle10pt = new ReportingServicesStyle(
                ReportingServicesStyle.TextBoxStyle.TabularReport10pt);

            _xmlWriter.WriteStartDocument();

            _xmlWriter.WriteStartElement("Report");
            _xmlWriter.WriteAttributeString("xmlns",
                                            "http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition");

            RdlRender.AddLine(_xmlWriter, "Width", "1.0in");
            RdlRender.AddLine(_xmlWriter, "PageWidth", "11.5in");
            RdlRender.AddLine(_xmlWriter, "TopMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "BottomMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "LeftMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "RightMargin", "0.25in");
            RdlRender.AddLine(_xmlWriter, "PageHeight", "7.9375in");
            RdlRender.AddLine(_xmlWriter, "Language", "en-GB");

            _xmlWriter.WriteStartElement("PageHeader");
            _xmlWriter.WriteStartElement("ReportItems");

            RdlRender.AddTextbox(_xmlWriter, "TitleTextbox", "DWP Small Systems Ad Hoc Reporting System",
                                 _textboxStyle14pt, "Left", "0.3cm", "5.0cm", "10cm", "true", "0.95cm", "2", "",
                                 "", "", "", "", "", "", "");

            RdlRender.AddTextbox(_xmlWriter, "PageHeader", "=Globals!ReportName", _textboxStyle14pt,
                                 "Left", "2.85714cm", "1.26984cm", "14.92063cm", "true", "1cm", "", "", "",
                                 "", "", "", "", "", "");

            RdlRender.AddImage(_xmlWriter, "Image1", "2.59259cm", "3.8cm",
                               "1.0cm", "Embedded", "Esf", "AutoSize");
            int    ParameterCount = 0;
            int    X = 0;
            string ParameterHeight = "";

            foreach (String _parameterName in _parameterList)
            {
                ParameterCount++;
                X = ParameterCount;
                X = X + 3;
                ParameterHeight = X.ToString() + "cm";
                RdlRender.AddTextbox(_xmlWriter, "Parameter" + ParameterCount.ToString(), _parameterName, _textboxStyle14pt,
                                     "Left", ParameterHeight, "1.26984cm", "14.92063cm", "true", "1cm", "", "", "",
                                     "", "", "", "", "", "");
            }
            _xmlWriter.WriteEndElement();             // ReportItems
            X = ParameterCount;
            X = X + 4;
            ParameterHeight = X.ToString() + ".8cm";
            RdlRender.AddLine(_xmlWriter, "PrintOnLastPage", "true");
            RdlRender.AddLine(_xmlWriter, "PrintOnFirstPage", "true");
            RdlRender.AddLine(_xmlWriter, "Height", ParameterHeight);
            _xmlWriter.WriteEndElement();             // PagHeader

            _xmlWriter.WriteStartElement("Body");
            RdlRender.AddLine(_xmlWriter, "Height", "5in");

            _xmlWriter.WriteStartElement("ReportItems");
            _xmlWriter.WriteStartElement("Table");
            _xmlWriter.WriteAttributeString("Name", "Table1");
            RdlRender.AddLine(_xmlWriter, "DataSetName", "TableDataSet");
            RdlRender.AddLine(_xmlWriter, "Top", "0in");
            RdlRender.AddLine(_xmlWriter, "Left", ".5in");
            RdlRender.AddLine(_xmlWriter, "Height", "0in");
            RdlRender.AddLine(_xmlWriter, "Width", "6in");

            // TableHeader
            _tableHeader.Render(_xmlWriter);

            // TableGroups
            if (_tableGroupList == null || _tableGroupList.Count > 0)
            {
                _xmlWriter.WriteStartElement("TableGroups");

                foreach (TableGroup group in _tableGroupList)
                {
                    group.Render(_xmlWriter);
                }

                _xmlWriter.WriteEndElement();                 // TableGroups
            }

            _xmlWriter.WriteStartElement("Style");
            _xmlWriter.WriteEndElement();

            // Write table columns
            _xmlWriter.WriteStartElement("TableColumns");
            for (int i = 0; i < _selectedDataItems.Count; i++)
            {
                _xmlWriter.WriteStartElement("TableColumn");
                RdlRender.AddLine(_xmlWriter, "Width", "1.5in");
                _xmlWriter.WriteEndElement();
            }
            _xmlWriter.WriteEndElement();             // TableColumns


            // TableDetails
            if (_isSummaryReport == false)
            {
                _tableDetails.Render(_xmlWriter);
            }
            RdlRender.AddLine(_xmlWriter, "NoRows", Resource.GetString("RES_REPORT_NOROWSRETURNED"));
            // TableFooter
            _tableFooter.Render(_xmlWriter);

            _xmlWriter.WriteEndElement();             // Table
            _xmlWriter.WriteEndElement();             // ReportItems
            _xmlWriter.WriteEndElement();             // Body

            // DataSources
            _xmlWriter.WriteStartElement("DataSources");
            _xmlWriter.WriteStartElement("DataSource");
            _xmlWriter.WriteAttributeString("Name", "DataSource1");
            RdlRender.AddLine(_xmlWriter, "DataSourceReference", "/" + _dataSource);

            /*_xmlWriter.WriteStartElement("ConnectionProperties");
             * RdlRender.AddLine( _xmlWriter, "DataProvider", "SQL");
             * RdlRender.AddLine( _xmlWriter, "ConnectString", _dbConnectionString);
             * RdlRender.AddLine( _xmlWriter, "IntegratedSecurity", "false");
             * RdlRender.AddLine( _xmlWriter, "Prompt", "false");
             * _xmlWriter.WriteEndElement(); // ConnectionProperties */
            _xmlWriter.WriteEndElement();             // DataSource
            _xmlWriter.WriteEndElement();             // DataSources

            // Datasets
            _xmlWriter.WriteStartElement("DataSets");
            foreach (Dataset CurrentDataSet in _datasetList)
            {
                CurrentDataSet.Render(_xmlWriter);
            }
            _xmlWriter.WriteEndElement();

            // ReportParameters
            if (_reportParametersList != null && _reportParametersList.Count > 0)
            {
                _xmlWriter.WriteStartElement("ReportParameters");
                foreach (ReportParameter CurrentParameter in _reportParametersList)
                {
                    CurrentParameter.Render(_xmlWriter);
                }
                _xmlWriter.WriteEndElement();
            }

            // EmbeddedImages
            _xmlWriter.WriteStartElement("EmbeddedImages");
            _xmlWriter.WriteStartElement("EmbeddedImage");
            _xmlWriter.WriteAttributeString("Name", "Esf");
            RdlRender.AddLine(_xmlWriter, "MIMEType", "image/bmp");
            _xmlWriter.WriteStartElement("ImageData");

            // Image data
            FileStream ImageStream = new FileStream(
                ConfigurationManager.AppSettings["SmallSystemsLogoImage"], FileMode.Open, FileAccess.Read);

            byte[] ImageByteArray = new byte[ImageStream.Length];
            ImageStream.Read(ImageByteArray, 0, (int)ImageStream.Length);
            ImageStream.Close();
            _xmlWriter.WriteBase64(ImageByteArray, 0, ImageByteArray.Length);

            _xmlWriter.WriteEndElement();             // ImageData
            _xmlWriter.WriteEndElement();             // EmbeddedImage
            _xmlWriter.WriteEndElement();             // EmbeddedImages


            // Report footer
            _xmlWriter.WriteStartElement("PageFooter");
            RdlRender.AddLine(_xmlWriter, "Height", "1.0cm");
            RdlRender.AddLine(_xmlWriter, "PrintOnFirstPage", "true");
            RdlRender.AddLine(_xmlWriter, "PrintOnLastPage", "true");
            _xmlWriter.WriteStartElement("ReportItems");

            RdlRender.AddTextbox(_xmlWriter, "UserTextBox", "=User!UserID",
                                 _textboxStyle10pt, "", "0.25cm", "1.0cm", "6.00cm", "true", "0.5cm", "1",
                                 "", "", "", "", "", "", "", "");
            RdlRender.AddTextbox(_xmlWriter, "ExecutionTimeTextBox", "=Globals!ExecutionTime",
                                 _textboxStyle10pt, "", "0.25cm", "7.00cm", "6.00cm", "true", "0.5cm", "1",
                                 "", "", "", "", "", "", "", "");
            RdlRender.AddTextbox(_xmlWriter, "PageNumberTextBox", "=Globals!PageNumber",
                                 _textboxStyle10pt, "", "0.25cm", "15.00cm", "3.00cm", "true", "0.5cm", "1",
                                 "", "", "", "", "", "", "", "");

            _xmlWriter.WriteEndElement(); // ReportItems
            _xmlWriter.WriteEndElement(); // PageFooter

            _xmlWriter.WriteEndElement(); // Report
            _xmlWriter.WriteEndDocument();

            _xmlWriter.Flush();

            _memoryStream.Close();
            return(_memoryStream.GetBuffer());

            //_stream.Close();
            // return new byte[0];
        }
 /// <summary>
 /// Constructs a new MatrixDynamicColumnTextBox.
 /// </summary>
 /// <param name="name">Name of this textbox.</param>
 public MatrixDynamicColumnTextBox(string name)
 {
     _name         = name;
     _textboxStyle = new ReportingServicesStyle(
         ReportingServicesStyle.TextBoxStyle.MatrixDynamic);
 }