Browse Source

EventLogger goes directly to pdf

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5662 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Peter Forstmeier 16 years ago
parent
commit
99cacb8221
  1. 67
      samples/SharpDevelopReports/SampleReports/Customized/EventLog.srd
  2. 71
      samples/SharpDevelopReports/src/SharpReportSamples/EventLogger.cs
  3. 55
      samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs
  4. 2
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/BaseExportColumn.cs
  5. 1
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportImage.cs
  6. 4
      src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Printing/Graphics/Border.cs

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

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
</ReportSettings>
<SectionCollection>
<BaseSection>
<Size>727, 82</Size>
<Size>727, 91</Size>
<Name>ReportHeader</Name>
<PageBreakAfter>False</PageBreakAfter>
<SectionMargin>0</SectionMargin>
@ -53,12 +53,12 @@ @@ -53,12 +53,12 @@
<ContentAlignment>TopCenter</ContentAlignment>
<Visible>True</Visible>
<DrawBorder>False</DrawBorder>
<Font>Microsoft Sans Serif, 8.25pt</Font>
<Font>Microsoft Sans Serif, 15pt</Font>
<CanGrow>False</CanGrow>
<FormatString />
<Name>BaseTextItem2147483643</Name>
<FrameColor>White</FrameColor>
<Size>568, 20</Size>
<Size>568, 33</Size>
<ForeColor>ControlText</ForeColor>
</BaseTextItem>
</Items>
@ -74,20 +74,37 @@ @@ -74,20 +74,37 @@
<BackColor>White</BackColor>
<Items>
<BaseRowItem>
<Location>12, 13</Location>
<Location>12, 3</Location>
<AlternateBackColor />
<Name>BaseRowItem2</Name>
<Items>
<BaseTextItem>
<BackColor>White</BackColor>
<CanShrink>False</CanShrink>
<StringTrimming>None</StringTrimming>
<Text>Image</Text>
<Location>20, 7</Location>
<ContentAlignment>TopCenter</ContentAlignment>
<Visible>True</Visible>
<DrawBorder>False</DrawBorder>
<Font>Microsoft Sans Serif, 12pt</Font>
<CanGrow>False</CanGrow>
<FormatString />
<Name>BaseTextItem2147483642</Name>
<FrameColor>White</FrameColor>
<Size>100, 20</Size>
<ForeColor>ControlText</ForeColor>
</BaseTextItem>
<BaseTextItem>
<BackColor>White</BackColor>
<CanShrink>False</CanShrink>
<StringTrimming>None</StringTrimming>
<Text>EntryType</Text>
<Location>135, 7</Location>
<ContentAlignment>TopLeft</ContentAlignment>
<ContentAlignment>TopCenter</ContentAlignment>
<Visible>True</Visible>
<DrawBorder>False</DrawBorder>
<Font>Microsoft Sans Serif, 8.25pt</Font>
<Font>Microsoft Sans Serif, 12pt</Font>
<CanGrow>False</CanGrow>
<FormatString />
<Name>BaseTextItem2147483644</Name>
@ -101,10 +118,10 @@ @@ -101,10 +118,10 @@
<StringTrimming>None</StringTrimming>
<Text>DateWritten</Text>
<Location>261, 7</Location>
<ContentAlignment>TopLeft</ContentAlignment>
<ContentAlignment>TopCenter</ContentAlignment>
<Visible>True</Visible>
<DrawBorder>False</DrawBorder>
<Font>Microsoft Sans Serif, 8.25pt</Font>
<Font>Microsoft Sans Serif, 12pt</Font>
<CanGrow>False</CanGrow>
<FormatString />
<Name>BaseTextItem2147483645</Name>
@ -121,7 +138,7 @@ @@ -121,7 +138,7 @@
<ContentAlignment>TopLeft</ContentAlignment>
<Visible>True</Visible>
<DrawBorder>False</DrawBorder>
<Font>Microsoft Sans Serif, 8.25pt</Font>
<Font>Microsoft Sans Serif, 12pt</Font>
<CanGrow>False</CanGrow>
<FormatString />
<Name>BaseTextItem2147483646</Name>
@ -133,13 +150,13 @@ @@ -133,13 +150,13 @@
<DrawBorder>False</DrawBorder>
<ChangeBackColorEveryNRow>0</ChangeBackColorEveryNRow>
<FrameColor>White</FrameColor>
<Size>697, 30</Size>
<Size>697, 44</Size>
<BackColor>White</BackColor>
<Visible>True</Visible>
<ForeColor>Black</ForeColor>
</BaseRowItem>
</Items>
<Location>50, 147</Location>
<Location>50, 156</Location>
<DrawBorder>False</DrawBorder>
</BaseSection>
<BaseSection>
@ -156,7 +173,7 @@ @@ -156,7 +173,7 @@
<Name>BaseRowItem1</Name>
<Items>
<BaseImageItem>
<ImageSource>File</ImageSource>
<ImageSource>Database</ImageSource>
<Location>20, 7</Location>
<Name>BaseImageItem1</Name>
<Size>75, 53</Size>
@ -228,7 +245,7 @@ @@ -228,7 +245,7 @@
<ForeColor>Black</ForeColor>
</BaseRowItem>
</Items>
<Location>50, 222</Location>
<Location>50, 231</Location>
<DrawBorder>False</DrawBorder>
</BaseSection>
<BaseSection>
@ -238,8 +255,26 @@ @@ -238,8 +255,26 @@
<SectionMargin>0</SectionMargin>
<SectionOffset>0</SectionOffset>
<BackColor>White</BackColor>
<Items />
<Location>50, 327</Location>
<Items>
<BaseTextItem>
<BackColor>White</BackColor>
<CanShrink>False</CanShrink>
<StringTrimming>None</StringTrimming>
<Text>='Page (' + Globals!PageNumber + ') of ( ' + Globals!TotalPages + ' ) Pages'</Text>
<Location>403, 21</Location>
<ContentAlignment>TopLeft</ContentAlignment>
<Visible>True</Visible>
<DrawBorder>False</DrawBorder>
<Font>Microsoft Sans Serif, 8.25pt</Font>
<CanGrow>False</CanGrow>
<FormatString />
<Name>='Page ' + Global!PageNumber + 'of ' + Global!Pages + 'Pages'</Name>
<FrameColor>White</FrameColor>
<Size>166, 20</Size>
<ForeColor>ControlText</ForeColor>
</BaseTextItem>
</Items>
<Location>50, 336</Location>
<DrawBorder>False</DrawBorder>
</BaseSection>
<BaseSection>
@ -250,7 +285,7 @@ @@ -250,7 +285,7 @@
<SectionOffset>0</SectionOffset>
<BackColor>White</BackColor>
<Items />
<Location>50, 402</Location>
<Location>50, 411</Location>
<DrawBorder>False</DrawBorder>
</BaseSection>
</SectionCollection>

71
samples/SharpDevelopReports/src/SharpReportSamples/EventLogger.cs

@ -11,21 +11,11 @@ using System.Collections; @@ -11,21 +11,11 @@ using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Management;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Reports.Core;
//using System.Collections.Generic;
namespace SharpReportSamples
{
// public class EventList: List<EventLogEntry>{
// }
//
//
/// <summary>
/// Description of EventLogger.
/// </summary>
@ -45,30 +35,16 @@ namespace SharpReportSamples @@ -45,30 +35,16 @@ namespace SharpReportSamples
EventLog ev = new EventLog();
ev.Log = "System";
ev.MachineName = "."; // Lokale Maschine
FillImageList();
// EventLog dosn't implement IList, so we have to convert it to the 'cheapest'
// IList implementaion
//
ArrayList ar = new ArrayList();
foreach (System.Diagnostics.EventLogEntry entry in ev.Entries)
{
if (entry.TimeWritten > DateTime.Now.AddDays(-1))
{
// Console.WriteLine ("{0} {1}",entry.TimeWritten,entry.Message);
ar.Add(entry);
}
}
this.EventLog = ar;
// ReportEngine engine = new ReportEngine();
// engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting);
// engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(PushPrinted);
// engine.PreviewPushDataReport(fileName,ar,null);
}
@ -76,53 +52,20 @@ namespace SharpReportSamples @@ -76,53 +52,20 @@ namespace SharpReportSamples
// using (var provider = ProfilingDataSQLiteProvider.FromFile("ProfilingSession.sdps"))
// var functions = provider.GetFunctions(0, provider.DataSets.Count - 1);
// foreach (CallTreeNode n in functions) Console.WriteLine("{0}: {1} calls, {2:f2}ms", n.Name, n.CallCount, n.TimeSpent);
private void filter (EventLog e)
{
/*
int i = 0;
foreach (System.Diagnostics.EventLogEntry entry in e.Entries)
{
if (entry.TimeWritten > DateTime.Now.AddDays(-1))
{
Console.WriteLine ("{0} {1}",entry.TimeWritten,entry.Message);
i++;
}
}
*/
//http://blog-mstechnology.blogspot.com/2009/08/filter-eventlog-entries-thru-c-code.html
/*
string SomeDateTime = "20100324000000.000000+000";
string Query = String.Format("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND TimeGenerated > '{0}'", SomeDateTime);
ManagementObjectSearcher mos = new ManagementObjectSearcher(Query);
object o;
foreach (ManagementObject mo in mos.Get())
{
foreach (PropertyData pd in mo.Properties)
{
o = mo[pd.Name];
if (o != null)
{
// listBox1.Items.Add(String.Format("{0}: {1}", pd.Name,mo[pd.Name].ToString()));
}
}
}
*/
}
private void FillImageList() {
string ns = this.GetType().Namespace;
System.Console.WriteLine("{0}",ns);
// System.Console.WriteLine("{0}",ns);
Assembly a = Assembly.GetExecutingAssembly();
string [] resNames = a.GetManifestResourceNames();
foreach(string s in resNames)
{
System.Console.WriteLine("{0}",s);
}
// foreach(string s in resNames)
// {
// System.Console.WriteLine("{0}",s);
// }
this.imageList = new ImageList();
@ -135,11 +78,13 @@ namespace SharpReportSamples @@ -135,11 +78,13 @@ namespace SharpReportSamples
imgStream = a.GetManifestResourceStream("SharpReportSamples.Resources.Warning.png");
this.imageList.Images.Add(Image.FromStream(imgStream));
System.Console.WriteLine("imagelist contains {0} images",this.imageList.Images.Count);
// System.Console.WriteLine("imagelist contains {0} images",this.imageList.Images.Count);
}
public ArrayList EventLog {get;set;}
public ImageList Images
{
get {return this.imageList;}

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

@ -101,7 +101,7 @@ namespace SharpReportSamples @@ -101,7 +101,7 @@ namespace SharpReportSamples
} else if (s == "NoConnectionReport") {
this.RunProviderIndependent(reportName);
} else if (s =="EventLog")
this.RunEventLogger(reportName);
this.RunEventLogger(reportName);
// this.RunEventLogger_Pdf(reportName);
else {
@ -169,20 +169,22 @@ namespace SharpReportSamples @@ -169,20 +169,22 @@ namespace SharpReportSamples
{
this.previewControl1.RunReport(model,dataManager);
};
this.previewControl1.RunReport(model,dataManager);
}
private void RunEventLogger_Pdf (string fileName)
{
EventLogger eLog = new EventLogger(fileName);
Cursor.Current = Cursors.WaitCursor;
EventLogger eventLogger = new EventLogger(fileName);
Cursor.Current = Cursors.Default;
this.imageList = eventLogger.Images;
ReportModel model = ReportEngine.LoadReportModel(fileName);
IReportCreator creator = ReportEngine.CreatePageBuilder(model,eLog.EventLog,null);
IReportCreator creator = ReportEngine.CreatePageBuilder(model,eventLogger.EventLog,null);
creator.SectionRendering += PushPrinting;
creator.BuildExportList();
using (PdfRenderer pdfRenderer = PdfRenderer.CreateInstance(creator,SelectFilename(),true))
{
@ -192,24 +194,18 @@ namespace SharpReportSamples @@ -192,24 +194,18 @@ 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;
}
}
}
private void RunEventLogger (string fileName)
{
/*
using (var provider = ProfilingDataSQLiteProvider.FromFile("ProfilingSession.sdps")){
var functions = provider.GetFunctions(0, provider.DataSets.Count - 1);
foreach (CallTreeNode n in functions) {
Console.WriteLine("{0}: {1} calls, {2:f2}ms", n.Name, n.CallCount, n.TimeSpent);
}
}
*/
Cursor.Current = Cursors.WaitCursor;
EventLogger eLog = new EventLogger(fileName);
Cursor.Current = Cursors.Default;
@ -309,6 +305,21 @@ namespace SharpReportSamples @@ -309,6 +305,21 @@ 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;
}
}
}
#endregion

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

@ -137,8 +137,6 @@ namespace ICSharpCode.Reports.Core.Exporter @@ -137,8 +137,6 @@ namespace ICSharpCode.Reports.Core.Exporter
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) {
Border b = this.CreateDefaultBorder();
b.DrawBorder(graphics,this.styleDecorator.DisplayRectangle);

1
src/AddIns/Misc/SharpReport/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportImage.cs

@ -61,7 +61,6 @@ namespace ICSharpCode.Reports.Core.Exporter @@ -61,7 +61,6 @@ namespace ICSharpCode.Reports.Core.Exporter
{
base.DrawItem(pdfWriter, converter);
iTextSharp.text.Image im = iTextSharp.text.Image.GetInstance(image,null,false);
iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle();

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

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

Loading…
Cancel
Save