Example #1
0
        protected AbstractRenderer SetupPushDataRenderer(IReportModel model,
                                                         DataTable dataTable)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (model.ReportSettings.ReportType != GlobalEnums.ReportType.DataReport)
            {
                throw new ArgumentException("SetupPushDataRenderer <No valid ReportModel>");
            }
            if (model.ReportSettings.DataModel != GlobalEnums.PushPullModel.PushData)
            {
                throw new ArgumentException("SetupPushDataRenderer <No valid ReportType>");
            }
            AbstractRenderer abstr   = null;
            IDataManager     dataMan = DataManager.CreateInstance(dataTable, model.ReportSettings);

            if (dataMan != null)
            {
                abstr                  = RendererFactory.Create(model, dataMan);
                abstr.Rendering       += new EventHandler <SectionRenderEventArgs>(OnSectionPrinting);
                abstr.SectionRendered += new EventHandler <SectionRenderEventArgs>(OnSectionPrinted);

                return(abstr);
            }
            return(null);
        }
Example #2
0
        /*
         * protected static ColumnCollection CollectFieldsFromModel(ReportModel model){
         *      if (model == null) {
         *              throw new ArgumentNullException("model");
         *      }
         *      ColumnCollection col = new ColumnCollection();
         *
         *      foreach (BaseSection section in model.SectionCollection){
         *              for (int i = 0;i < section.Items.Count ;i ++ ) {
         *                      IReportItem item = section.Items[i];
         *                      BaseDataItem baseItem = item as BaseDataItem;
         *                      if (baseItem != null) {
         *                              col.Add(new AbstractColumn(baseItem.ColumnName));
         *                      }
         *              }
         *      }
         *      return col;
         * }
         */

        /// <summary>
        /// Creates an <see cref="AbstractRenderer"></see>
        /// any Class deriving from this can be
        /// used to get a <see cref="System.Drawing.Printing.PrintDocument"></see>
        /// </summary>
        /// <param name="model"><see cref="ReportModel"></see></param>
        /// <returns></returns>


        protected AbstractRenderer SetupStandardRenderer(IReportModel model, ReportParameters parameters)
        {
            AbstractRenderer abstr = null;

            try {
                switch (model.ReportSettings.ReportType)
                {
                //FormSheets reports
                case GlobalEnums.ReportType.FormSheet:
                    abstr = RendererFactory.Create(model, null);
                    break;

                //Databased reports
                case GlobalEnums.ReportType.DataReport:
                    IDataManager dataMan = DataManagerFactory.CreateDataManager(model, parameters);
                    abstr = RendererFactory.Create(model, dataMan);
                    break;

                default:
                    throw new ReportException("SharpReportmanager:SetupRenderer -> Unknown Reporttype");
                }

                abstr.Rendering       += new EventHandler <SectionRenderEventArgs>(OnSectionPrinting);
                abstr.SectionRendered += new EventHandler <SectionRenderEventArgs>(OnSectionPrinted);
                return(abstr);
            } catch (Exception) {
                throw;
            }
        }