public void Apply() { ICustomReportItem cri = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); foreach (XmlNode node in _ReportItems) { cri.SetPropertiesInstance(_Draw.GetNamedChildNode(node, "CustomProperties"), pgProps.SelectedObject); } } catch { return; } finally { if (cri != null) { cri.Dispose(); } } return; }
public void EvaluateGeneratedReportItemInstance() { Global.Tracer.Assert(this.m_generatedReportItem.CriGenerationPhase == CriGenerationPhases.None); this.m_generatedReportItem.CriGenerationPhase = CriGenerationPhases.Instance; try { if (!this.LoadGeneratedReportItemInstance()) { try { ICustomReportItem controlInstance = base.RenderingContext.OdpContext.CriProcessingControls.GetControlInstance(this.CriDef.Type, base.RenderingContext.OdpContext.ExtFactory); Global.Tracer.Assert(null != controlInstance, "(null != control)"); controlInstance.EvaluateReportItemInstance(this); this.m_generatedReportItem.CompleteCriGeneratedInstanceEvaluation(); } catch (Exception innerException) { throw new RenderingObjectModelException(ErrorCode.rsCRIProcessingError, innerException, this.Name, this.Type); } goto end_IL_0024; } return; end_IL_0024 :; } finally { this.m_generatedReportItem.CriGenerationPhase = CriGenerationPhases.None; } this.SaveGeneratedReportItemInstance(); }
internal void EvaluateGeneratedReportItemInstance() { Global.Tracer.Assert(m_generatedReportItem.CriGenerationPhase == CriGenerationPhases.None); m_generatedReportItem.CriGenerationPhase = CriGenerationPhases.Instance; try { if (LoadGeneratedReportItemInstance()) { return; } try { ICustomReportItem controlInstance = base.RenderingContext.OdpContext.CriProcessingControls.GetControlInstance(CriDef.Type, base.RenderingContext.OdpContext.ExtFactory); Global.Tracer.Assert(controlInstance != null, "(null != control)"); controlInstance.EvaluateReportItemInstance(this); m_generatedReportItem.CompleteCriGeneratedInstanceEvaluation(); } catch (Exception innerException) { throw new RenderingObjectModelException(ErrorCode.rsCRIProcessingError, innerException, Name, Type); } } finally { m_generatedReportItem.CriGenerationPhase = CriGenerationPhases.None; } SaveGeneratedReportItemInstance(); }
override internal void Run(IPresent ip, Row row) { Report rpt = ip.Report(); ICustomReportItem cri = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); Type a = cri.GetType(); Bitmap bm = null; SetProperties(rpt, row, cri); int width = WidthCalc(rpt, null) - (Style == null ? 0 : (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row))); int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) - (Style == null ? 0 : (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row))); bm = new Bitmap(width, height); cri.DrawImage(ref bm); MemoryStream ostrm = new MemoryStream(); // 06122007AJM Changed to use high quality JPEG encoding //bm.Save(ostrm, IMAGEFORMAT); // generate a jpeg TODO: get png to work with pdf System.Drawing.Imaging.ImageCodecInfo[] info; info = ImageCodecInfo.GetImageEncoders(); EncoderParameters encoderParameters; encoderParameters = new EncoderParameters(1); // 20022008 AJM GJL - Using centralised image quality encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.CustomImageQuality); System.Drawing.Imaging.ImageCodecInfo codec = null; for (int i = 0; i < info.Length; i++) { if (info[i].FormatDescription == "JPEG") { codec = info[i]; break; } } bm.Save(ostrm, codec, encoderParameters); ip.Image(new Image(rpt.ReportDefinition, this, xNode), row, null, ostrm); ostrm.Close(); } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in CustomReportItem handling.\n{0}\n{1}", ex.Message, ex.StackTrace)); } finally { if (cri != null) { cri.Dispose(); } } return; }
public static ICustomReportItem CreateCustomReportItem(string friendlyTypeName) { CustomReportItemEntry crie = null; if (!CustomReportItemEntries.TryGetValue(friendlyTypeName, out crie)) { throw new Exception(string.Format("{0} is not a known CustomReportItem type", friendlyTypeName)); } if (crie.Type == null) { throw new Exception(crie.ErrorMsg ?? string.Format("{0} is not a known CustomReportItem type", friendlyTypeName)); } ICustomReportItem item = (ICustomReportItem)Activator.CreateInstance(crie.Type); return(item); }
private void GenerateReportItemDefinition() { this.m_generatedReportItem = null; ICustomReportItem controlInstance = base.RenderingContext.OdpContext.CriProcessingControls.GetControlInstance(this.CriDef.Type, base.RenderingContext.OdpContext.ExtFactory); if (controlInstance != null) { try { controlInstance.GenerateReportItemDefinition(this); } catch (Exception ex) { base.RenderingContext.ErrorContext.Register(ProcessingErrorCode.rsCRIProcessingError, Severity.Warning, this.Name, this.Type); Global.Tracer.TraceException(TraceLevel.Error, RPRes.rsCRIProcessingError(this.Name, this.Type) + " " + ex.ToString()); return; } if (this.m_generatedReportItem == null) { base.RenderingContext.ErrorContext.Register(ProcessingErrorCode.rsCRIRenderItemNull, Severity.Warning, this.CriDef.ObjectType, this.Name, this.Type); } else { this.m_generatedReportItem.ConstructReportItemDefinition(); this.m_generatedReportItem.CriGenerationPhase = CriGenerationPhases.None; string text = CustomReportItem.CreateChunkName(); OnDemandProcessingContext odpContext = base.RenderingContext.OdpContext; AspNetCore.ReportingServices.ReportIntermediateFormat.ReportSnapshot reportSnapshot = odpContext.OdpMetadata.ReportSnapshot; IChunkFactory chunkFactory = odpContext.ChunkFactory; using (Stream stream = chunkFactory.CreateChunk(text, AspNetCore.ReportingServices.ReportProcessing.ReportProcessing.ReportChunkTypes.GeneratedReportItems, null)) { IntermediateFormatWriter intermediateFormatWriter = new IntermediateFormatWriter(stream, odpContext.GetActiveCompatibilityVersion()); AspNetCore.ReportingServices.ReportIntermediateFormat.Visibility visibility = this.m_generatedReportItem.ReportItemDef.Visibility; this.m_generatedReportItem.ReportItemDef.Visibility = null; intermediateFormatWriter.Write(this.m_generatedReportItem.ReportItemDef); this.m_generatedReportItem.ReportItemDef.Visibility = visibility; stream.Flush(); } reportSnapshot.AddGeneratedReportItemChunkName(this.GetGeneratedDefinitionChunkKey(), text); } } }
void SetProperties(Report rpt, Row row, ICustomReportItem cri) { if (_Properties == null || _Properties.Count == 0) // Any properties specified? { return; } System.Collections.Generic.Dictionary <string, object> dict = new Dictionary <string, object>(_Properties.Count); foreach (CustomProperty cp in _Properties) { string name = cp.Name.EvaluateString(rpt, row); object val = cp.Value.Evaluate(rpt, row); try { dict.Add(name, val); } catch { rpt.rl.LogError(4, string.Format("Property {0} has already been set. New value {1} ignored.", name, val)); } } cri.SetProperties(dict); }
private void InitValues() { ICustomReportItem cri = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); object props = cri.GetPropertiesInstance(_Draw.GetNamedChildNode(_ReportItems[0], "CustomProperties")); pgProps.SelectedObject = props; } catch { return; } finally { if (cri != null) { cri.Dispose(); } } }
override internal void Run(IPresent ip, Row row) { Report rpt = ip.Report(); ICustomReportItem cri = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in CustomReportItem handling.\n{0}\n{1}", ex.Message, ex.StackTrace)); } finally { if (cri != null) { cri.Dispose(); } } return; }
override internal void FinalPass() { base.FinalPass(); // this handles the finalpass of the AltReportItems // Handle the final pass for the Custom Properties if (_Properties != null) { foreach (CustomProperty cp in _Properties) { cp.Name.FinalPass(); cp.Value.FinalPass(); } } // Find out whether the type is known ICustomReportItem cri = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); } catch (Exception ex) { // Not an error since we'll simply use the ReportItems OwnerReport.rl.LogError(4, string.Format("CustomReportItem load of {0} failed: {1}", _Type, ex.Message)); } finally { if (cri != null) { cri.Dispose(); } } return; }
private void SetCustomReportItem(PropertyDescriptorCollection pdc) { ICustomReportItem cri = null; try { string t = _Draw.GetElementValue(this.Node, "Type", ""); cri = RdlEngineConfig.CreateCustomReportItem(t); _custom = cri.GetPropertiesInstance(_Draw.GetNamedChildNode(this.Node, "CustomProperties")); TypeDescriptor.CreateAssociation(this, _custom); PropertyDescriptorCollection bProps = TypeDescriptor.GetProperties(_custom, true); foreach (PropertyDescriptor p in bProps) { // create our custom property descriptor and add it to the collection pdc.Add(p); } } catch { } finally { if (cri != null) { cri.Dispose(); } } return; }
override internal void RunPage(Pages pgs, Row row) { Report rpt = pgs.Report; if (IsHidden(pgs.Report, row)) { return; } SetPagePositionBegin(pgs); // Build the Chart bitmap, along with data regions Page p = pgs.CurrentPage; ICustomReportItem cri = null; Bitmap bm = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); SetProperties(pgs.Report, row, cri); int width = WidthCalc(rpt, pgs.G) - (Style == null? 0 : (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row))); int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) - (Style == null? 0 : (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row))); bm = new Bitmap(width, height); cri.DrawImage(ref bm); MemoryStream ostrm = new MemoryStream(); // 06122007AJM Changed to use high quality JPEG encoding //bm.Save(ostrm, IMAGEFORMAT); // generate a jpeg TODO: get png to work with pdf System.Drawing.Imaging.ImageCodecInfo[] info; info = ImageCodecInfo.GetImageEncoders(); EncoderParameters encoderParameters; encoderParameters = new EncoderParameters(1); // 20022008 AJM GJL - Using centralised image quality encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, ImageQualityManager.CustomImageQuality); System.Drawing.Imaging.ImageCodecInfo codec = null; for (int i = 0; i < info.Length; i++) { if (info[i].FormatDescription == "JPEG") { codec = info[i]; break; } } bm.Save(ostrm, codec, encoderParameters); byte[] ba = ostrm.ToArray(); ostrm.Close(); PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height); // Create an image pi.Sizing = ImageSizingEnum.Clip; // RunPageRegionBegin(pgs); SetPagePositionAndStyle(rpt, pi, row); if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty()) { // force page break if it doesn't fit on the page pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; if (this.YParents != null) { pi.Y = 0; } } p = pgs.CurrentPage; p.AddObject(pi); // Put image onto the current page // RunPageRegionEnd(pgs); if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt)) { float newY = pi.Y + pi.H; p.YOffset += newY; // bump the y location } SetPagePositionEnd(pgs, pi.Y + pi.H); } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in CustomReportItem handling: {0}", ex.Message)); } finally { if (cri != null) { cri.Dispose(); } } return; }
public IContentRange Fork(ICustomReportItem reportItem) { return(new RtfControlContentRange(_owner, Info)); }
public RtfControlContentRange(ICustomReportItem owner, RtfContentInfo info) { _owner = owner; Info = info; }
public IContentRange Fork(ICustomReportItem reportItem) { return(new CalendarContentRange(_staticRange, reportItem, MonthFrom, MonthTo)); }
void SetProperties(Report rpt, Row row, ICustomReportItem cri) { if (_Properties == null || _Properties.Count == 0) // Any properties specified? return; System.Collections.Generic.Dictionary<string, object> dict = new Dictionary<string, object>(_Properties.Count); foreach (CustomProperty cp in _Properties) { string name = cp.Name.EvaluateString(rpt, row); object val = cp.Value.Evaluate(rpt, row); try { dict.Add(name, val); } catch { rpt.rl.LogError(4, string.Format("Property {0} has already been set. New value {1} ignored.", name, val)); } } cri.SetProperties(dict); }
override internal void RunPage(Pages pgs, Row row) { Report rpt = pgs.Report; if (IsHidden(pgs.Report, row)) { return; } SetPagePositionBegin(pgs); // Build the Chart bitmap, along with data regions Page p = pgs.CurrentPage; ICustomReportItem cri = null; Bitmap bm = null; try { cri = RdlEngineConfig.CreateCustomReportItem(_Type); SetProperties(pgs.Report, row, cri); int width = WidthCalc(rpt, pgs.G) - (Style == null? 0 : (Style.EvalPaddingLeftPx(rpt, row) + Style.EvalPaddingRightPx(rpt, row))); int height = RSize.PixelsFromPoints(this.HeightOrOwnerHeight) - (Style == null? 0 : (Style.EvalPaddingTopPx(rpt, row) + Style.EvalPaddingBottomPx(rpt, row))); bm = new Bitmap(width, height); cri.DrawImage(bm); MemoryStream ostrm = new MemoryStream(); bm.Save(ostrm, IMAGEFORMAT); // generate a jpeg TODO: get png to work with pdf byte[] ba = ostrm.ToArray(); ostrm.Close(); PageImage pi = new PageImage(IMAGEFORMAT, ba, width, height); // Create an image pi.Sizing = ImageSizingEnum.Clip; // RunPageRegionBegin(pgs); SetPagePositionAndStyle(rpt, pi, row); if (pgs.CurrentPage.YOffset + pi.Y + pi.H >= pgs.BottomOfPage && !pgs.CurrentPage.IsEmpty()) { // force page break if it doesn't fit on the page pgs.NextOrNew(); pgs.CurrentPage.YOffset = OwnerReport.TopOfPage; if (this.YParents != null) { pi.Y = 0; } } p = pgs.CurrentPage; p.AddObject(pi); // Put image onto the current page // RunPageRegionEnd(pgs); if (!this.PageBreakAtEnd && !IsTableOrMatrixCell(rpt)) { float newY = pi.Y + pi.H; p.YOffset += newY; // bump the y location } SetPagePositionEnd(pgs, pi.Y + pi.H); } catch (Exception ex) { rpt.rl.LogError(8, string.Format("Exception in CustomReportItem handling: {0}", ex.Message)); } finally { if (cri != null) { cri.Dispose(); } } return; }