41 changed files with 1058 additions and 87 deletions
@ -0,0 +1,23 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 19:14 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Tests.Factory |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ReportingFactoryFixture |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void TestMethod() |
||||||
|
{ |
||||||
|
// TODO: Add your test.
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 19:58 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Tests.Model |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class LoadPlainModelFixture |
||||||
|
{ |
||||||
|
private const string nS = "ICSharpCode.Reporting.Tests.TestReports."; |
||||||
|
private const string reportName = "PlainModel.srd"; |
||||||
|
private Stream stream; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void CanLoadFromResource() |
||||||
|
{ |
||||||
|
Assert.IsNotNull(stream); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void LoadPlainModel() |
||||||
|
{ |
||||||
|
var rf = new ReportingFactory(); |
||||||
|
var model = rf.LoadReport(stream); |
||||||
|
Assert.IsNotNull(model); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ReportSettingsFromPlainModel() |
||||||
|
{ |
||||||
|
var rf = new ReportingFactory(); |
||||||
|
var model = rf.LoadReport(stream); |
||||||
|
Assert.That(model.ReportSettings,Is.Not.Null); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ReportSettingsReportName() |
||||||
|
{ |
||||||
|
var rf = new ReportingFactory(); |
||||||
|
var model = rf.LoadReport(stream); |
||||||
|
Assert.That(model.ReportSettings.ReportName,Is.EqualTo(Globals.GlobalValues.DefaultReportName)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ReportSettingsPageSize() |
||||||
|
{ |
||||||
|
var rf = new ReportingFactory(); |
||||||
|
var model = rf.LoadReport(stream); |
||||||
|
Assert.That(model.ReportSettings.PageSize,Is.EqualTo(Globals.GlobalValues.DefaultPageSize)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void LoadFromStream() |
||||||
|
{ |
||||||
|
System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); |
||||||
|
stream = asm.GetManifestResourceStream(nS + reportName); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 19:02 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using ICSharpCode.Reporting.Items; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Tests.Model |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ReportModelFixture |
||||||
|
{ |
||||||
|
private ReportModel model; |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void CanCreateReportModel() |
||||||
|
{ |
||||||
|
Assert.That(model,Is.Not.Null); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ModelInitializeReportSettings() |
||||||
|
{ |
||||||
|
Assert.That(model.ReportSettings,Is.Not.Null); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ModelReturnsPlainReportName() |
||||||
|
{ |
||||||
|
Assert.That(model.ReportSettings.ReportName,Is.EqualTo(Globals.GlobalValues.DefaultReportName)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void CreateModel() |
||||||
|
{ |
||||||
|
model = ReportModel.Create(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 19:10 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using ICSharpCode.Reporting.Globals; |
||||||
|
using ICSharpCode.Reporting.Items; |
||||||
|
using NUnit.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ReportSettingsFixture |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void DefaultConstructureShouldReturnStandardValues() |
||||||
|
{ |
||||||
|
ReportSettings rs = new ReportSettings(); |
||||||
|
Assert.IsNotNull(rs,"Should not be 'null'"); |
||||||
|
Assert.AreEqual(GlobalValues.DefaultReportName,rs.ReportName); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DefaultPageSize () |
||||||
|
{ |
||||||
|
ReportSettings rs = new ReportSettings(); |
||||||
|
Assert.AreEqual(GlobalValues.DefaultPageSize,rs.PageSize); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,86 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<ReportModel> |
||||||
|
<ReportSettings> |
||||||
|
<ReportSettings> |
||||||
|
<DefaultFont>Microsoft Sans Serif, 10pt</DefaultFont> |
||||||
|
<DataModel>FormSheet</DataModel> |
||||||
|
<FileName>D:\SharpDevelop3.0_CHECKOUT\SharpDevelop\bin\Raaaaaeport1.srd</FileName> |
||||||
|
<RightMargin>50</RightMargin> |
||||||
|
<UseStandardPrinter>True</UseStandardPrinter> |
||||||
|
<SortColumnCollection /> |
||||||
|
<AvailableFieldsCollection /> |
||||||
|
<NoDataMessage>No Data for this Report</NoDataMessage> |
||||||
|
<LeftMargin>50</LeftMargin> |
||||||
|
<PageSize>827, 1169</PageSize> |
||||||
|
<Padding>5, 5, 5, 5</Padding> |
||||||
|
<BottomMargin>50</BottomMargin> |
||||||
|
<CommandType>Text</CommandType> |
||||||
|
<ParameterCollection /> |
||||||
|
<Landscape>False</Landscape> |
||||||
|
<ReportName>Report1</ReportName> |
||||||
|
<TopMargin>50</TopMargin> |
||||||
|
<GroupColumnsCollection /> |
||||||
|
<GraphicsUnit>Millimeter</GraphicsUnit> |
||||||
|
<CommandText /> |
||||||
|
<ReportType>FormSheet</ReportType> |
||||||
|
<ConnectionString /> |
||||||
|
</ReportSettings> |
||||||
|
</ReportSettings> |
||||||
|
<SectionCollection> |
||||||
|
<BaseSection> |
||||||
|
<Size>727, 60</Size> |
||||||
|
<Name>ReportHeader</Name> |
||||||
|
<PageBreakAfter>False</PageBreakAfter> |
||||||
|
<SectionMargin>0</SectionMargin> |
||||||
|
<SectionOffset>0</SectionOffset> |
||||||
|
<BackColor>White</BackColor> |
||||||
|
<Items /> |
||||||
|
<Location>50, 50</Location> |
||||||
|
<DrawBorder>False</DrawBorder> |
||||||
|
</BaseSection> |
||||||
|
<BaseSection> |
||||||
|
<Size>727, 60</Size> |
||||||
|
<Name>ReportPageHeader</Name> |
||||||
|
<PageBreakAfter>False</PageBreakAfter> |
||||||
|
<SectionMargin>0</SectionMargin> |
||||||
|
<SectionOffset>0</SectionOffset> |
||||||
|
<BackColor>White</BackColor> |
||||||
|
<Items /> |
||||||
|
<Location>50, 125</Location> |
||||||
|
<DrawBorder>False</DrawBorder> |
||||||
|
</BaseSection> |
||||||
|
<BaseSection> |
||||||
|
<Size>727, 60</Size> |
||||||
|
<Name>ReportDetail</Name> |
||||||
|
<PageBreakAfter>False</PageBreakAfter> |
||||||
|
<SectionMargin>0</SectionMargin> |
||||||
|
<SectionOffset>0</SectionOffset> |
||||||
|
<BackColor>White</BackColor> |
||||||
|
<Items /> |
||||||
|
<Location>50, 200</Location> |
||||||
|
<DrawBorder>False</DrawBorder> |
||||||
|
</BaseSection> |
||||||
|
<BaseSection> |
||||||
|
<Size>727, 60</Size> |
||||||
|
<Name>ReportPageFooter</Name> |
||||||
|
<PageBreakAfter>False</PageBreakAfter> |
||||||
|
<SectionMargin>0</SectionMargin> |
||||||
|
<SectionOffset>0</SectionOffset> |
||||||
|
<BackColor>White</BackColor> |
||||||
|
<Items /> |
||||||
|
<Location>50, 275</Location> |
||||||
|
<DrawBorder>False</DrawBorder> |
||||||
|
</BaseSection> |
||||||
|
<BaseSection> |
||||||
|
<Size>727, 60</Size> |
||||||
|
<Name>ReportFooter</Name> |
||||||
|
<PageBreakAfter>False</PageBreakAfter> |
||||||
|
<SectionMargin>0</SectionMargin> |
||||||
|
<SectionOffset>0</SectionOffset> |
||||||
|
<BackColor>White</BackColor> |
||||||
|
<Items /> |
||||||
|
<Location>50, 350</Location> |
||||||
|
<DrawBorder>False</DrawBorder> |
||||||
|
</BaseSection> |
||||||
|
</SectionCollection> |
||||||
|
</ReportModel> |
@ -0,0 +1,13 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 16.03.2013 |
||||||
|
* Time: 20:24 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System.Security; |
||||||
|
|
||||||
|
[assembly: SecurityRules(SecurityRuleSet.Level1)] |
||||||
|
|
||||||
|
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ICSharpCode.Reporting.Tests")] |
@ -0,0 +1,69 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||||
|
<PropertyGroup> |
||||||
|
<ProjectGuid>{40CA84D4-ACFC-4646-9CDD-B87262D34093}</ProjectGuid> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<RootNamespace>ICSharpCode.Reporting</RootNamespace> |
||||||
|
<AssemblyName>ICSharpCode.Reporting</AssemblyName> |
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||||
|
<DebugSymbols>True</DebugSymbols> |
||||||
|
<DebugType>Full</DebugType> |
||||||
|
<Optimize>False</Optimize> |
||||||
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||||
|
<OutputPath>bin\Release\</OutputPath> |
||||||
|
<DebugSymbols>False</DebugSymbols> |
||||||
|
<DebugType>None</DebugType> |
||||||
|
<Optimize>True</Optimize> |
||||||
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="NUnit.Framework"> |
||||||
|
<HintPath>$(SharpDevelopBinPath)\Tools\NUnit\NUnit.Framework.dll</HintPath> |
||||||
|
</Reference> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Core"> |
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
<Reference Include="System.Drawing" /> |
||||||
|
<Reference Include="System.Xml" /> |
||||||
|
<Reference Include="System.Xml.Linq"> |
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||||
|
<Compile Include="Src\Items\BaseSection.cs" /> |
||||||
|
<Compile Include="Src\Globals\GlobalEnums.cs" /> |
||||||
|
<Compile Include="Src\Globals\GlobalValues.cs" /> |
||||||
|
<Compile Include="Src\Interfaces\IReportModel.cs" /> |
||||||
|
<Compile Include="Src\Items\ReportModel.cs" /> |
||||||
|
<Compile Include="Src\Items\ReportSettings.cs" /> |
||||||
|
<Compile Include="Src\ReportingFactory.cs" /> |
||||||
|
<Compile Include="Src\Xml\ModelLoader.cs" /> |
||||||
|
<Compile Include="Src\Xml\MycroParser.cs" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Folder Include="Src\Model" /> |
||||||
|
<Folder Include="Src\Interfaces" /> |
||||||
|
<Folder Include="Src\Globals" /> |
||||||
|
<Folder Include="Src" /> |
||||||
|
<Folder Include="Src" /> |
||||||
|
<Folder Include="Src\Items" /> |
||||||
|
<Folder Include="Src\Xml" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||||
|
</Project> |
@ -0,0 +1,26 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 17.03.2013 |
||||||
|
* Time: 17:30 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Globals |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of GlobalEnums.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class GlobalEnums |
||||||
|
{ |
||||||
|
internal enum ReportSection { |
||||||
|
ReportHeader, |
||||||
|
ReportPageHeader, |
||||||
|
ReportDetail, |
||||||
|
ReportPageFooter, |
||||||
|
ReportFooter |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 17.03.2013 |
||||||
|
* Time: 17:57 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
namespace ICSharpCode.Reporting.Globals |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of GlobalValues.
|
||||||
|
/// </summary>
|
||||||
|
public static class GlobalValues |
||||||
|
{ |
||||||
|
public static string ReportExtension {get {return ".srd";}} |
||||||
|
|
||||||
|
public static string DefaultReportName {get { return "Report1";}} |
||||||
|
|
||||||
|
public static Size DefaultPageSize {get {return new Size(827,1169);}} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 17.03.2013 |
||||||
|
* Time: 17:20 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Interfaces |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of IReportModel.
|
||||||
|
/// </summary>
|
||||||
|
public interface IReportModel |
||||||
|
{ |
||||||
|
/* |
||||||
|
BaseSection ReportHeader {get;} |
||||||
|
BaseSection PageHeader {get;} |
||||||
|
BaseSection DetailSection {get;} |
||||||
|
BaseSection PageFooter {get;} |
||||||
|
BaseSection ReportFooter {get;} |
||||||
|
ReportSettings ReportSettings {get;set;} |
||||||
|
GlobalEnums.PushPullModel DataModel {get;} |
||||||
|
ReportSectionCollection SectionCollection {get;} |
||||||
|
*/ |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 20:19 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Items |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of BaseSection.
|
||||||
|
/// </summary>
|
||||||
|
public class BaseSection |
||||||
|
{ |
||||||
|
public BaseSection() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,100 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 17.03.2013 |
||||||
|
* Time: 17:18 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using ICSharpCode.Reporting.Globals; |
||||||
|
using ICSharpCode.Reporting.Interfaces; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Items |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of ReportModel.
|
||||||
|
/// </summary>
|
||||||
|
public class ReportModel :IReportModel |
||||||
|
{ |
||||||
|
|
||||||
|
// ReportSectionCollection sectionCollection;
|
||||||
|
|
||||||
|
|
||||||
|
public static ReportModel Create() |
||||||
|
{ |
||||||
|
var model = new ReportModel(); |
||||||
|
// foreach (GlobalEnums.ReportSection sec in Enum.GetValues(typeof(GlobalEnums.ReportSection))) {
|
||||||
|
// m.SectionCollection.Add (SectionFactory.Create(sec.ToString()));
|
||||||
|
// }
|
||||||
|
return model; |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
public static ReportModel Create(GraphicsUnit graphicsUnit) |
||||||
|
{ |
||||||
|
ReportModel m = Create(); |
||||||
|
m.ReportSettings.GraphicsUnit = graphicsUnit; |
||||||
|
return m; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#region Sections
|
||||||
|
|
||||||
|
public BaseSection ReportHeader |
||||||
|
{ |
||||||
|
get { |
||||||
|
return (BaseSection)sectionCollection[0]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public BaseSection PageHeader |
||||||
|
{ |
||||||
|
get { |
||||||
|
return (BaseSection)sectionCollection[1]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public BaseSection DetailSection |
||||||
|
{ |
||||||
|
get { |
||||||
|
return (BaseSection)sectionCollection[2]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public BaseSection PageFooter |
||||||
|
{ |
||||||
|
get { |
||||||
|
return (BaseSection)sectionCollection[3]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public BaseSection ReportFooter |
||||||
|
{ |
||||||
|
get { |
||||||
|
return (BaseSection)sectionCollection[4]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion
|
||||||
|
*/ |
||||||
|
|
||||||
|
ReportSettings reportSettings ; |
||||||
|
|
||||||
|
public ReportSettings ReportSettings |
||||||
|
{ |
||||||
|
get { |
||||||
|
if (this.reportSettings == null) { |
||||||
|
this.reportSettings = new ReportSettings(); |
||||||
|
} |
||||||
|
return reportSettings; |
||||||
|
} |
||||||
|
set { |
||||||
|
reportSettings = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,80 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 17.03.2013 |
||||||
|
* Time: 17:41 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Items |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of ReportSettings.
|
||||||
|
/// </summary>
|
||||||
|
public class ReportSettings |
||||||
|
{ |
||||||
|
|
||||||
|
|
||||||
|
public ReportSettings() |
||||||
|
{ |
||||||
|
this.PageSize = Globals.GlobalValues.DefaultPageSize; |
||||||
|
BaseValues(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void BaseValues() |
||||||
|
{ |
||||||
|
|
||||||
|
// this.UseStandardPrinter = true;
|
||||||
|
// this.GraphicsUnit = GraphicsUnit.Pixel;
|
||||||
|
// this.Padding = new Padding(5);
|
||||||
|
// this.DefaultFont = GlobalValues.DefaultFont;
|
||||||
|
// this.ReportType = GlobalEnums.ReportType.FormSheet;
|
||||||
|
//
|
||||||
|
// this.DataModel = GlobalEnums.PushPullModel.FormSheet;
|
||||||
|
//
|
||||||
|
// this.CommandType = System.Data.CommandType.Text;
|
||||||
|
// this.ConnectionString = String.Empty;
|
||||||
|
// this.CommandText = String.Empty;
|
||||||
|
//
|
||||||
|
// this.TopMargin = GlobalValues.DefaultPageMargin.Left;
|
||||||
|
// this.BottomMargin = GlobalValues.DefaultPageMargin.Bottom;
|
||||||
|
// this.LeftMargin = GlobalValues.DefaultPageMargin.Left;
|
||||||
|
// this.RightMargin = GlobalValues.DefaultPageMargin.Right;
|
||||||
|
//
|
||||||
|
// this.availableFields = new AvailableFieldsCollection();
|
||||||
|
// this.groupingsCollection = new GroupColumnCollection();
|
||||||
|
// this.sortingCollection = new SortColumnCollection();
|
||||||
|
// this.sqlParameters = new SqlParameterCollection();
|
||||||
|
// this.parameterCollection = new ParameterCollection();
|
||||||
|
// this.NoDataMessage = "No Data for this Report";
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private string reportName; |
||||||
|
|
||||||
|
// [Category("Base Settings")]
|
||||||
|
// [DefaultValueAttribute ("")]
|
||||||
|
public string ReportName |
||||||
|
{ |
||||||
|
get { |
||||||
|
if (string.IsNullOrEmpty(reportName)) { |
||||||
|
reportName = Globals.GlobalValues.DefaultReportName; |
||||||
|
} |
||||||
|
return reportName; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (reportName != value) { |
||||||
|
reportName = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// [Category("Page Settings")]
|
||||||
|
public Size PageSize {get;set;} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 17.03.2013 |
||||||
|
* Time: 17:09 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Xml; |
||||||
|
|
||||||
|
using ICSharpCode.Reporting.Items; |
||||||
|
using ICSharpCode.Reporting.Xml; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of Reporting.
|
||||||
|
/// </summary>
|
||||||
|
public class ReportingFactory |
||||||
|
{ |
||||||
|
public ReportingFactory() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public ReportModel LoadReport (Stream stream) |
||||||
|
{ |
||||||
|
Console.WriteLine("ReportEngine:LoadReportModel_2"); |
||||||
|
var doc = new XmlDocument(); |
||||||
|
doc.Load(stream); |
||||||
|
var rm = LoadModel(doc); |
||||||
|
return rm; |
||||||
|
} |
||||||
|
|
||||||
|
static ReportModel LoadModel(XmlDocument doc) |
||||||
|
{ |
||||||
|
Console.WriteLine("ReportEngine:LoadModel"); |
||||||
|
var loader = new ModelLoader(); |
||||||
|
object root = loader.Load(doc.DocumentElement); |
||||||
|
|
||||||
|
var model = root as ReportModel; |
||||||
|
if (model == null) { |
||||||
|
// throw new IllegalFileFormatException("ReportModel");
|
||||||
|
} |
||||||
|
return model; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 20:13 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using ICSharpCode.Reporting.Items; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Xml |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of ModelLoader.
|
||||||
|
/// </summary>
|
||||||
|
public class ModelLoader: MycroParser |
||||||
|
{ |
||||||
|
|
||||||
|
protected override Type GetTypeByName(string ns, string name) |
||||||
|
{ |
||||||
|
// var b = typeof(BaseSection).Assembly.GetType("ICSharpCode.Reporting.Items" + "." + name);
|
||||||
|
var s = typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); |
||||||
|
Console.WriteLine("getTypeByname <{0}>",s.Name); |
||||||
|
return typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,235 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 19.03.2013 |
||||||
|
* Time: 20:14 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Xml; |
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
namespace ICSharpCode.Reporting.Xml |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of MycroParser.
|
||||||
|
/// </summary>
|
||||||
|
public interface IMycroXaml |
||||||
|
{ |
||||||
|
void Initialize(object parent); |
||||||
|
object ReturnedObject |
||||||
|
{ |
||||||
|
get; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// See http://www.codeproject.com/dotnet/MycroXaml.asp
|
||||||
|
/// </summary>
|
||||||
|
public abstract class MycroParser |
||||||
|
{ |
||||||
|
public object Load(XmlElement element) |
||||||
|
{ |
||||||
|
return ProcessNode(element, null); |
||||||
|
} |
||||||
|
|
||||||
|
protected abstract Type GetTypeByName(string ns, string name); |
||||||
|
|
||||||
|
protected object ProcessNode(XmlNode node, object parent) |
||||||
|
{ |
||||||
|
object ret=null; |
||||||
|
if (node is XmlElement) |
||||||
|
{ |
||||||
|
// instantiate the class
|
||||||
|
string ns=node.Prefix; |
||||||
|
string cname=node.LocalName; |
||||||
|
Console.WriteLine ("ProcessNode(XmlNode node, object parent) {0}",cname); |
||||||
|
Type t=GetTypeByName(ns, cname); |
||||||
|
if (t == null) { |
||||||
|
Console.WriteLine("\t Not found {0}",t.FullName); |
||||||
|
// t = GetTypeByName (ns,"ErrorItem");
|
||||||
|
} |
||||||
|
|
||||||
|
Trace.Assert(t != null, "Type "+cname+" could not be determined."); |
||||||
|
// Debug.WriteLine("Looking for " + cname + " and got " + t.FullName);
|
||||||
|
Console.WriteLine("Looking for " + cname + " and got " + t.FullName); |
||||||
|
try |
||||||
|
{ |
||||||
|
ret=Activator.CreateInstance(t); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
Trace.Fail("Type "+cname+" could not be instantiated:\r\n"+e.Message); |
||||||
|
} |
||||||
|
|
||||||
|
// support the ISupportInitialize interface
|
||||||
|
if (ret is ISupportInitialize) { |
||||||
|
((ISupportInitialize)ret).BeginInit(); |
||||||
|
} |
||||||
|
|
||||||
|
// If the instance implements the IMicroXaml interface, then it may need
|
||||||
|
// access to the parser.
|
||||||
|
if (ret is IMycroXaml) { |
||||||
|
((IMycroXaml)ret).Initialize(parent); |
||||||
|
} |
||||||
|
|
||||||
|
// implements the class-property-class model
|
||||||
|
ProcessAttributes(node, ret, t); |
||||||
|
ProcessChildProperties(node, ret); |
||||||
|
|
||||||
|
// support the ISupportInitialize interface
|
||||||
|
if (ret is ISupportInitialize) { |
||||||
|
((ISupportInitialize)ret).EndInit(); |
||||||
|
} |
||||||
|
|
||||||
|
// If the instance implements the IMicroXaml interface, then it has the option
|
||||||
|
// to return an object that replaces the instance created by the parser.
|
||||||
|
if (ret is IMycroXaml) { |
||||||
|
ret=((IMycroXaml)ret).ReturnedObject; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
return ret; |
||||||
|
} |
||||||
|
|
||||||
|
protected void ProcessChildProperties(XmlNode node, object parent) |
||||||
|
{ |
||||||
|
Type t=parent.GetType(); |
||||||
|
|
||||||
|
// children of a class must always be properties
|
||||||
|
foreach(XmlNode child in node.ChildNodes) |
||||||
|
{ |
||||||
|
if (child is XmlElement) |
||||||
|
{ |
||||||
|
string pname=child.LocalName; |
||||||
|
PropertyInfo pi=t.GetProperty(pname); |
||||||
|
|
||||||
|
if (pi==null) |
||||||
|
{ |
||||||
|
// Special case--we're going to assume that the child is a class instance
|
||||||
|
// not associated with the parent object
|
||||||
|
// Trace.Fail("Unsupported property: "+pname);
|
||||||
|
System.Console.WriteLine("Unsupported property: "+pname); |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
// a property can only have one child node unless it's a collection
|
||||||
|
foreach(XmlNode grandChild in child.ChildNodes) |
||||||
|
{ |
||||||
|
if (grandChild is XmlText) { |
||||||
|
SetPropertyToString(parent, pi, child.InnerText); |
||||||
|
break; |
||||||
|
} |
||||||
|
else if (grandChild is XmlElement) |
||||||
|
{ |
||||||
|
object propObject=pi.GetValue(parent, null); |
||||||
|
object obj=ProcessNode(grandChild, propObject); |
||||||
|
|
||||||
|
// A null return is valid in cases where a class implementing the IMicroXaml interface
|
||||||
|
// might want to take care of managing the instance it creates itself. See DataBinding
|
||||||
|
if (obj != null) |
||||||
|
{ |
||||||
|
|
||||||
|
// support for ICollection objects
|
||||||
|
if (propObject is ICollection) |
||||||
|
{ |
||||||
|
MethodInfo mi=t.GetMethod("Add", new Type[] {obj.GetType()}); |
||||||
|
if (mi != null) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
mi.Invoke(obj, new object[] {obj}); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
Trace.Fail("Adding to collection failed:\r\n"+e.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
else if (propObject is IList) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
((IList)propObject).Add(obj); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
Trace.Fail("List/Collection add failed:\r\n"+e.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else if (!pi.CanWrite) { |
||||||
|
Trace.Fail("Unsupported read-only property: "+pname); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
// direct assignment if not a collection
|
||||||
|
try |
||||||
|
{ |
||||||
|
pi.SetValue(parent, obj, null); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
Trace.Fail("Property setter for "+pname+" failed:\r\n"+e.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected void ProcessAttributes(XmlNode node, object ret, Type type) |
||||||
|
{ |
||||||
|
// process attributes
|
||||||
|
foreach(XmlAttribute attr in node.Attributes) |
||||||
|
{ |
||||||
|
string pname=attr.Name; |
||||||
|
string pvalue=attr.Value; |
||||||
|
|
||||||
|
// it's either a property or an event
|
||||||
|
PropertyInfo pi=type.GetProperty(pname); |
||||||
|
|
||||||
|
if (pi != null) |
||||||
|
{ |
||||||
|
// it's a property!
|
||||||
|
SetPropertyToString(ret, pi, pvalue); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
// who knows what it is???
|
||||||
|
Trace.Fail("Failed acquiring property information for "+pname); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void SetPropertyToString(object obj, PropertyInfo pi, string value) |
||||||
|
{ |
||||||
|
Console.WriteLine("MP - SetPropertyToString {0} - {1}",pi.Name,value.ToString()); |
||||||
|
// it's string, so use a type converter.
|
||||||
|
TypeConverter tc=TypeDescriptor.GetConverter(pi.PropertyType); |
||||||
|
try |
||||||
|
{ |
||||||
|
if (tc.CanConvertFrom(typeof(string))) |
||||||
|
{ |
||||||
|
object val=tc.ConvertFromInvariantString(value); |
||||||
|
pi.SetValue(obj, val, null); |
||||||
|
} else if (pi.PropertyType == typeof(Type)) { |
||||||
|
pi.SetValue(obj, Type.GetType(value), null); |
||||||
|
} |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
String s = String.Format("Property setter for {0} failed {1}\r\n",pi.Name, |
||||||
|
e.Message); |
||||||
|
System.Console.WriteLine("MycroParser : {0}",s); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue