コード例 #1
0
ファイル: UtilReport.cs プロジェクト: jimidzj/Inspect
        private void AddFixedRows(ref HtmlReport _reportStruct, ref ReportDataSetConvertor _convert)
        {
            for (int i = 0; i < _convert.FixedRows.Count; i++)
            {
                HtmlRow row = new HtmlRow();
                row.Header.HeaderText = _convert.FixedRows[i].RowText;
                row.Header.HeaderValue = _convert.FixedRows[i].RowValue;
                row.RowSpan = _convert.FixedRows[i].ChildCount;

                _reportStruct.Rows.Add(row);
            }
        }
コード例 #2
0
ファイル: UtilReport.cs プロジェクト: jimidzj/Inspect
        private void SortReportStruct(ref HtmlReport _reportStruct, ref ReportDataSetConvertor _convert)
        {
            HtmlReport leftReport = new HtmlReport();
            HtmlReport rightReport = new HtmlReport();

            //处理排序的列
            for (int i = 0; i < _convert.ColumnOrder.Count; i++)
            {
                for (int j = 0; j < _reportStruct.Columns.Count; j++)
                {
                    if (_reportStruct.Columns[j].Header.HeaderValue.Trim().Equals(_convert.ColumnOrder[i].Trim()))
                    {
                        leftReport.Columns.Add(_reportStruct.Columns[j]);
                        _reportStruct.Columns.RemoveAt(j);
                        break;
                    }
                }
            }

            //处理排在最后的列
            for (int i = 0; i < _convert.ColumnOrder.Count; i++)
            {
                for (int j = 0; j < _reportStruct.Columns.Count; j++)
                {
                    if (_reportStruct.Columns[j].Header.HeaderValue.Trim().Equals("->" + _convert.ColumnOrder[i].Trim()))
                    {
                        rightReport.Columns.Add(_reportStruct.Columns[j]);
                        _reportStruct.Columns.RemoveAt(j);
                        break;
                    }
                }
            }

            //处理余下的列
            for (int i = 0; i < _reportStruct.Columns.Count; i++)
            {
                leftReport.Columns.Add(_reportStruct.Columns[i]);
            }

            //处理排在尾部的列
            for (int i = 0; i < rightReport.Columns.Count; i++)
            {
                leftReport.Columns.Add(rightReport.Columns[i]);
            }

            _reportStruct.Columns.Clear();

            for (int i = 0; i < leftReport.Columns.Count; i++)
            {
                _reportStruct.Columns.Add(leftReport.Columns[i]);
            }
        }
コード例 #3
0
ファイル: UtilReport.cs プロジェクト: jimidzj/Inspect
        public void BuildCustomColumns(ref HtmlReportGenerator _generator,ref ReportDataSetConvertor _convert)
        {
            try
            {
                HtmlReport reportStruct = _generator.ParseXml();
                //get data to build htmlreport
                for (int i = 0; i < _convert.DynamicColumns.Count; i++)
                {
                    HtmlColumn parentColumn = new HtmlColumn();
                    parentColumn.Header.HeaderText = _convert.DynamicColumns[i].ColumnText;
                    parentColumn.Header.HeaderValue = _convert.DynamicColumns[i].ColumnValue;
                    parentColumn.ChildColumns = new List<HtmlColumn>();

                    for (int j = 0; j < _convert.DynamicColumnsPatterns.Count; j++)
                    {
                        ColumnPattern pat = _convert.DynamicColumnsPatterns[j];

                        if (pat.IncludeCondition == "*")
                        {
                            //该模式针对所有列都有效
                            string[] arrCondition = pat.ExcludeCondition.Split(',');
                            if (!arrCondition.Contains(_convert.DynamicColumns[i].ColumnText))
                            {
                                HtmlColumn childColumn = new HtmlColumn();
                                childColumn.Header.HeaderText = pat.ColumnText;
                                childColumn.Header.HeaderValue = pat.ColumnText;
                                childColumn.IsLeaf = true;
                                childColumn.RowSpan = 1;
                                parentColumn.ChildColumns.Add(childColumn);
                            }
                        }
                        else
                        {
                            //该模式针对部分列都有效,不判断排它列表
                            string[] arrCondition = pat.IncludeCondition.Split(',');
                            if (arrCondition.Contains(_convert.DynamicColumns[i].ColumnText))
                            {
                                HtmlColumn childColumn = new HtmlColumn();
                                childColumn.Header.HeaderText = pat.ColumnText;
                                childColumn.Header.HeaderValue = pat.ColumnText;
                                childColumn.IsLeaf = true;
                                childColumn.RowSpan = 1;
                                parentColumn.ChildColumns.Add(childColumn);
                            }
                        }
                    }

                    if (parentColumn.ChildColumns.Count > 0)
                        parentColumn.IsLeaf = false;
                    else
                    {
                        parentColumn.IsLeaf = true;
                    }

                    //判断是否有上层节点
                    HtmlColumn pcolumn = FindColumn(reportStruct.Columns, _convert.DynamicColumns[i].ParentValue);

                    if (pcolumn == null)
                    {
                        reportStruct.Columns.Add(parentColumn);
                    }
                    else
                    {
                        pcolumn.ChildColumns.Add(parentColumn);
                        pcolumn.IsLeaf = false;
                    }
                }

                //Sort
                SortReportStruct(ref reportStruct, ref _convert);

                //Add Fixed rows
                AddFixedRows(ref reportStruct,ref  _convert);

                _generator.report = reportStruct;

                //DataSet ds = localDal.GetCustomColumns(_year, _period, Costing_Reporting_SearchType.FE.ToString());
                //HtmlReport reportStruct = _generator.ParseXml();

                //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    HtmlColumn column = new HtmlColumn();
                //    column.Header.HeaderText = ds.Tables[0].Rows[i]["wcid"].ToString();
                //    column.ChildColumns = new List<HtmlColumn>();

                //    HtmlColumn childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Std";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Var";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    reportStruct.Columns.Add(column);
                //}

                //return reportStruct;
                ////get data to build htmlreport
                //DataSet ds = localDal.GetCustomColumns(_year, _period,Costing_Reporting_SearchType.FE.ToString());
                //HtmlReport reportStruct = _generator.ParseXml();

                //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    HtmlColumn column = new HtmlColumn();
                //    column.Header.HeaderText = ds.Tables[0].Rows[i]["wcid"].ToString();
                //    column.ChildColumns = new List<HtmlColumn>();

                //    HtmlColumn childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Std";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Var";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    reportStruct.Columns.Add(column);
                //}

                //return reportStruct;
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }