Browse Source

EventLog Report

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5660 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Peter Forstmeier 15 years ago
parent
commit
a6e86a9505
  1. 10
      samples/SharpDevelopReports/SampleReports/Customized/EventLog.srd
  2. 139
      samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs
  3. 6
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseRowItem.cs
  4. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/BaseExportColumn.cs
  5. 4
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/Graphics/BaseLine.cs
  6. 4
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/Graphics/Border.cs

10
samples/SharpDevelopReports/SampleReports/Customized/EventLog.srd

@ -36,18 +36,20 @@
<Items> <Items>
<BaseImageItem> <BaseImageItem>
<ImageSource>File</ImageSource> <ImageSource>File</ImageSource>
<Location>12, 26</Location> <Location>83, 13</Location>
<Name>BaseImageItem2</Name> <Name>BaseImageItem2</Name>
<Size>75, 23</Size> <Size>568, 36</Size>
<ScaleImageToSize>False</ScaleImageToSize> <ScaleImageToSize>False</ScaleImageToSize>
<BackColor>White</BackColor> <BackColor>White</BackColor>
<RelativeFileName>..\Logos\Bannerbeige2.gif</RelativeFileName>
<ImageFileName>D:\SharpDevelop3.0_WorkingCopy\SharpDevelop\samples\SharpDevelopReports\SampleReports\Logos\Bannerbeige2.gif</ImageFileName>
</BaseImageItem> </BaseImageItem>
<BaseTextItem> <BaseTextItem>
<BackColor>Silver</BackColor> <BackColor>Silver</BackColor>
<CanShrink>False</CanShrink> <CanShrink>False</CanShrink>
<StringTrimming>None</StringTrimming> <StringTrimming>None</StringTrimming>
<Text>System - Eventlog</Text> <Text>System - Eventlog</Text>
<Location>83, 26</Location> <Location>83, 55</Location>
<ContentAlignment>TopCenter</ContentAlignment> <ContentAlignment>TopCenter</ContentAlignment>
<Visible>True</Visible> <Visible>True</Visible>
<DrawBorder>False</DrawBorder> <DrawBorder>False</DrawBorder>
@ -134,7 +136,7 @@
<Size>697, 30</Size> <Size>697, 30</Size>
<BackColor>White</BackColor> <BackColor>White</BackColor>
<Visible>True</Visible> <Visible>True</Visible>
<ForeColor>ControlText</ForeColor> <ForeColor>Black</ForeColor>
</BaseRowItem> </BaseRowItem>
</Items> </Items>
<Location>50, 147</Location> <Location>50, 147</Location>

139
samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs

@ -15,6 +15,7 @@ using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Reports.Core; using ICSharpCode.Reports.Core;
using ICSharpCode.Reports.Core.Exporter.ExportRenderer;
namespace SharpReportSamples namespace SharpReportSamples
{ {
@ -29,7 +30,7 @@ namespace SharpReportSamples
private TreeNode iListNode; private TreeNode iListNode;
private TreeNode providerIndependent; private TreeNode providerIndependent;
private TreeNode customized; private TreeNode customized;
private ImageList imageList;
public MainForm() public MainForm()
{ {
@ -40,14 +41,6 @@ namespace SharpReportSamples
InitTree(); InitTree();
UpdateStatusbar (Application.StartupPath); UpdateStatusbar (Application.StartupPath);
this.previewControl1.Messages = new ReportViewerMessagesProvider(); this.previewControl1.Messages = new ReportViewerMessagesProvider();
/*
EventLog ev = new EventLog();
ev.Log = "System";
ev.MachineName = "."; // Lokale Maschine
ArrayList ar = new ArrayList();
ar.AddRange(ev.Entries);
*/
} }
@ -57,10 +50,9 @@ namespace SharpReportSamples
string startupPath = Application.StartupPath; string startupPath = Application.StartupPath;
string samplesDir = @"SharpDevelopReports\"; string samplesDir = @"SharpDevelopReports\";
int y = startupPath.IndexOf(samplesDir); int i = startupPath.IndexOf(samplesDir);
string startPath = startupPath.Substring(0,y + samplesDir.Length) + @"SampleReports\"; string startPath = startupPath.Substring(0,i + samplesDir.Length) + @"SampleReports\";
//D:\Reporting3.0_branches\SharpDevelop\samples\SharpDevelopReports\SampleReports
string pathToFormSheet = startPath + formSheetDir; string pathToFormSheet = startPath + formSheetDir;
@ -75,9 +67,9 @@ namespace SharpReportSamples
AddNodesToTree (this.iListNode,startPath + @"IList\" ); AddNodesToTree (this.iListNode,startPath + @"IList\" );
AddNodesToTree (this.providerIndependent,startPath + @"ProviderIndependent\" ); AddNodesToTree (this.providerIndependent,startPath + @"ProviderIndependent\" );
AddNodesToTree (this.customized,startPath + @"Customized\" ); AddNodesToTree (this.customized,startPath + @"Customized\" );
} }
private void AddNodesToTree (TreeNode parent,string path) private void AddNodesToTree (TreeNode parent,string path)
{ {
if (!Directory.Exists(path)) { if (!Directory.Exists(path)) {
@ -109,7 +101,8 @@ namespace SharpReportSamples
} else if (s == "NoConnectionReport") { } else if (s == "NoConnectionReport") {
this.RunProviderIndependent(reportName); this.RunProviderIndependent(reportName);
} else if (s =="EventLog") } else if (s =="EventLog")
this.RunEventlogger(reportName); this.RunEventLogger(reportName);
// this.RunEventLogger_Pdf(reportName);
else { else {
ReportParameters parameters = ReportEngine.LoadParameters(reportName); ReportParameters parameters = ReportEngine.LoadParameters(reportName);
@ -182,11 +175,45 @@ namespace SharpReportSamples
ImageList imageList;
private void RunEventlogger (string fileName)
private void RunEventLogger_Pdf (string fileName)
{
EventLogger eLog = new EventLogger(fileName);
ReportModel model = ReportEngine.LoadReportModel(fileName);
IReportCreator creator = ReportEngine.CreatePageBuilder(model,eLog.EventLog,null);
creator.BuildExportList();
using (PdfRenderer pdfRenderer = PdfRenderer.CreateInstance(creator,SelectFilename(),true))
{
pdfRenderer.Start();
pdfRenderer.RenderOutput();
pdfRenderer.End();
}
}
private string SelectFilename()
{
using (SaveFileDialog saveDialog = new SaveFileDialog()){
saveDialog.FileName = "_pdf";
saveDialog.DefaultExt = "PDF";
saveDialog.ValidateNames = true;
if(saveDialog.ShowDialog() == DialogResult.OK){
return saveDialog.FileName;
} else {
return String.Empty;
}
}
}
private void RunEventLogger (string fileName)
{ {
Cursor.Current = Cursors.WaitCursor;
EventLogger eLog = new EventLogger(fileName); EventLogger eLog = new EventLogger(fileName);
Cursor.Current = Cursors.Default;
this.imageList = eLog.Images; this.imageList = eLog.Images;
ReportModel model = ReportEngine.LoadReportModel(fileName); ReportModel model = ReportEngine.LoadReportModel(fileName);
@ -204,51 +231,76 @@ namespace SharpReportSamples
//Handles SectionRenderEvent //Handles SectionRenderEvent
int hour = 0;
private void PushPrinting (object sender, SectionRenderEventArgs e ) private void PushPrinting (object sender, SectionRenderEventArgs e )
{ {
string sectionName = e.Section.Name; string sectionName = e.Section.Name;
if (sectionName == ReportSectionNames.ReportHeader) { if (sectionName == ReportSectionNames.ReportHeader) {
Console.WriteLine("xx " + ReportSectionNames.ReportHeader); Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportHeader);
} }
else if (sectionName == ReportSectionNames.ReportPageHeader) { else if (sectionName == ReportSectionNames.ReportPageHeader) {
Console.WriteLine("xx " +ReportSectionNames .ReportPageHeader); Console.WriteLine("PushPrinting :" +ReportSectionNames .ReportPageHeader);
} }
else if (sectionName == ReportSectionNames.ReportDetail){ else if (sectionName == ReportSectionNames.ReportDetail){
Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportDetail);
// TimeWritten
BaseDataItem time = e.Section.FindItem("BaseDataItem1") as BaseDataItem;
if (time != null) {
DateTime dateTime = Convert.ToDateTime(time.DBValue);
int newhour = dateTime.Hour;
if (hour != newhour) {
hour = newhour;
e.Section.Items[0].DrawBorder = true;
e.Section.Items[0].FrameColor = Color.Black;
// e.Section.Items[0].BackColor = Color.LightGray;
time.DBValue = dateTime.Hour.ToString();
time.ContentAlignment = ContentAlignment.MiddleLeft;
} else {
time.DrawBorder = false;
e.Section.Items[0].FrameColor = Color.White;
// e.Section.Items[0].BackColor = Color.White;
time.DBValue = dateTime.Minute.ToString() + ":" + dateTime.Second.ToString();
time.ContentAlignment = ContentAlignment.MiddleRight;
}
}
BaseDataItem item = e.Section.FindItem("EntryType") as BaseDataItem; // Image
if (item != null) { BaseDataItem dataItem = e.Section.FindItem("EntryType") as BaseDataItem;
string s = item.DBValue; if (dataItem != null) {
Image im = null; string str = dataItem.DBValue;
if (s == "Information") { Image image = null;
im = this.imageList.Images[1]; if (str == "Information") {
} else if (s == "Warning") { image = this.imageList.Images[1];
im = this.imageList.Images[2]; } else if (str == "Warning") {
} else if (s == "Error") image = this.imageList.Images[2];
} else if (str == "Error")
{ {
im = this.imageList.Images[0]; image = this.imageList.Images[0];
} }
if (im != null) if (image != null)
{ {
BaseImageItem bi = e.Section.FindItem("BaseImageItem1") as BaseImageItem; BaseImageItem imageItem = e.Section.FindItem("BaseImageItem1") as BaseImageItem;
if (bi != null) { if (imageItem != null) {
bi.Image = im; imageItem.Image = image;
} }
} }
} }
} }
else if (sectionName == ReportSectionNames.ReportPageFooter){ else if (sectionName == ReportSectionNames.ReportPageFooter){
Console.WriteLine("xx " + ReportSectionNames.ReportPageFooter); Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportPageFooter);
} }
else if (sectionName == ReportSectionNames.ReportFooter){ else if (sectionName == ReportSectionNames.ReportFooter){
Console.WriteLine("xx " + ReportSectionNames.ReportFooter); Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportFooter);
} }
else{ else{
@ -294,21 +346,6 @@ namespace SharpReportSamples
} }
} }
private string SelectFilename()
{
using (SaveFileDialog saveDialog = new SaveFileDialog()){
saveDialog.FileName = "_pdf";
saveDialog.DefaultExt = "PDF";
saveDialog.ValidateNames = true;
if(saveDialog.ShowDialog() == DialogResult.OK){
return saveDialog.FileName;
} else {
return String.Empty;
}
}
}
*/ */
} }
} }

6
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/BaseItems/BaseRowItem.cs

@ -74,8 +74,10 @@ namespace ICSharpCode.Reports.Core{
if (this.BackColor != GlobalValues.DefaultBackColor) { if (this.BackColor != GlobalValues.DefaultBackColor) {
base.FillBackground(rpea.PrintPageEventArgs.Graphics); base.FillBackground(rpea.PrintPageEventArgs.Graphics);
} }
Border b = new Border(new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1));
Border b = new Border(new BaseLine (this.FrameColor,System.Drawing.Drawing2D.DashStyle.Solid,1));
base.DrawFrame (rpea.PrintPageEventArgs.Graphics,b); base.DrawFrame (rpea.PrintPageEventArgs.Graphics,b);
this.Location = new Point(base.DrawingRectangle.Left,this.Location.Y); this.Location = new Point(base.DrawingRectangle.Left,this.Location.Y);

2
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/BaseExportColumn.cs

@ -137,6 +137,8 @@ namespace ICSharpCode.Reports.Core.Exporter
private void DrawFrame (Graphics graphics) private void DrawFrame (Graphics graphics)
{ {
System.Diagnostics.Trace.WriteLine("draw border {0}",this.styleDecorator.DrawBorder.ToString());
System.Console.WriteLine("draw border {0}",this.styleDecorator.DrawBorder);
if (this.styleDecorator.DrawBorder) { if (this.styleDecorator.DrawBorder) {
Border b = this.CreateDefaultBorder(); Border b = this.CreateDefaultBorder();
b.DrawBorder(graphics,this.styleDecorator.DisplayRectangle); b.DrawBorder(graphics,this.styleDecorator.DisplayRectangle);

4
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/Graphics/BaseLine.cs

@ -40,6 +40,10 @@ namespace ICSharpCode.Reports.Core
public BaseLine(Color color, DashStyle dashStyle,float thickness, LineCap startLineCap, LineCap endLineCap, DashCap dashLineCap) public BaseLine(Color color, DashStyle dashStyle,float thickness, LineCap startLineCap, LineCap endLineCap, DashCap dashLineCap)
{ {
if (color == Color.White) {
this.color = Color.Black;
}
this.color = color; this.color = color;
this.dashStyle = dashStyle; this.dashStyle = dashStyle;
this.thickness = thickness; this.thickness = thickness;

4
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/Graphics/Border.cs

@ -34,6 +34,7 @@ namespace ICSharpCode.Reports.Core {
this.top = baseLine; this.top = baseLine;
this.right = baseLine; this.right = baseLine;
this.bottom = baseLine; this.bottom = baseLine;
System.Console.WriteLine("baseline color {0}",baseline.Color);
} }
@ -41,7 +42,10 @@ namespace ICSharpCode.Reports.Core {
if (graphics == null) { if (graphics == null) {
throw new ArgumentNullException("graphics"); throw new ArgumentNullException("graphics");
} }
System.Console.WriteLine("drawBorder color {0}",baseline.Color);
using (Pen p = baseline.CreatePen(baseline.Thickness)) { using (Pen p = baseline.CreatePen(baseline.Thickness)) {
Console.WriteLine("pen {0}",p.Color);
Rectangle r = System.Drawing.Rectangle.Inflate(rectangle,1,1); Rectangle r = System.Drawing.Rectangle.Inflate(rectangle,1,1);
graphics.DrawRectangle (p,rectangle); graphics.DrawRectangle (p,rectangle);
} }

Loading…
Cancel
Save