Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for multiple statements per file #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/OFXSharp.Console/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
64 changes: 64 additions & 0 deletions source/OFXSharp.Console/OFXSharp.Console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BD64B333-EFE8-400F-B61A-F3EC0E98889B}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OFXSharp.Console</RootNamespace>
<AssemblyName>OFXSharp.Console</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OFXSharp\OFXSharp.csproj">
<Project>{7bba813d-ee93-491a-b0c7-fbd588e393cb}</Project>
<Name>OFXSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
18 changes: 18 additions & 0 deletions source/OFXSharp.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OFXSharp.Console
{
class Program
{
static void Main(string[] args)
{
var parser = new OFXDocumentParser();
var ofxDocument = parser.Import(new FileStream(@"F:\Sandboxes\TM\OFXSharp\source\OFXSharp.Tests\itau.ofx", FileMode.Open));
}
}
}
36 changes: 36 additions & 0 deletions source/OFXSharp.Console/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OFXSharp.Console")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("OFXSharp.Console")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("401deb64-26de-48e7-8f07-a64dd948dffc")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
8 changes: 7 additions & 1 deletion source/OFXSharp.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30110.0
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFXSharp", "OFXSharp\OFXSharp.csproj", "{7BBA813D-EE93-491A-B0C7-FBD588E393CB}"
EndProject
Expand All @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{4456DF
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFXSharp.Tests", "OFXSharp.Tests\OFXSharp.Tests.csproj", "{4753DE21-42DB-405F-BB2A-A3F189A62482}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OFXSharp.Console", "OFXSharp.Console\OFXSharp.Console.csproj", "{BD64B333-EFE8-400F-B61A-F3EC0E98889B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{4753DE21-42DB-405F-BB2A-A3F189A62482}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4753DE21-42DB-405F-BB2A-A3F189A62482}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4753DE21-42DB-405F-BB2A-A3F189A62482}.Release|Any CPU.Build.0 = Release|Any CPU
{BD64B333-EFE8-400F-B61A-F3EC0E98889B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD64B333-EFE8-400F-B61A-F3EC0E98889B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD64B333-EFE8-400F-B61A-F3EC0E98889B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD64B333-EFE8-400F-B61A-F3EC0E98889B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
186 changes: 94 additions & 92 deletions source/OFXSharp/Account.cs
Original file line number Diff line number Diff line change
@@ -1,94 +1,96 @@
using System;
using System.Xml;

namespace OFXSharp
{
public class Account
{
public string AccountID { get; set; }
public string AccountKey { get; set; }
public AccountType AccountType { get; set; }

#region Bank Only

private BankAccountType _BankAccountType = BankAccountType.NA;

public string BankID { get; set; }

public string BranchID { get; set; }


public BankAccountType BankAccountType
{
get
{
if (AccountType == AccountType.BANK)
return _BankAccountType;

return BankAccountType.NA;
}
set
{
_BankAccountType = AccountType == AccountType.BANK ? value : BankAccountType.NA;
}
}

#endregion

public Account(XmlNode node, AccountType type)
{
AccountType = type;

AccountID = node.GetValue("//ACCTID");
AccountKey = node.GetValue("//ACCTKEY");

switch (AccountType)
{
case AccountType.BANK:
InitializeBank(node);
break;
case AccountType.AP:
InitializeAP(node);
break;
case AccountType.AR:
InitializeAR(node);
break;
default:
break;
}
}

/// <summary>
/// Initializes information specific to bank
/// </summary>
private void InitializeBank(XmlNode node)
{
BankID = node.GetValue("//BANKID");
BranchID = node.GetValue("//BRANCHID");

using System;
using System.Xml;

namespace OFXSharp
{
public class Account
{
public string AccountID { get; set; }
public string AccountKey { get; set; }
public AccountType AccountType { get; set; }

#region Bank Only

private BankAccountType _BankAccountType = BankAccountType.NA;

public string BankID { get; set; }

public string BranchID { get; set; }


public BankAccountType BankAccountType
{
get
{
if (AccountType == AccountType.Bank)
return _BankAccountType;

return BankAccountType.NA;
}
set
{
_BankAccountType = AccountType == AccountType.Bank ? value : BankAccountType.NA;
}
}

#endregion

public Account(XmlNode node, AccountType type)
{
AccountType = type;

AccountID = node.GetValue(".//ACCTID");
AccountKey = node.GetValue(".//ACCTKEY");

switch (AccountType)
{
case AccountType.Bank:
InitializeBank(node);
break;
case AccountType.AccountsPayable:
InitializeAP(node);
break;
case AccountType.AccountsReceivable:
InitializeAR(node);
break;
default:
break;
}
}

public Account() { }

/// <summary>
/// Initializes information specific to bank
/// </summary>
private void InitializeBank(XmlNode node)
{
BankID = node.GetValue(".//BANKID");
BranchID = node.GetValue(".//BRANCHID");

//Get Bank Account Type from XML
string bankAccountType = node.GetValue("//ACCTTYPE");

//Check that it has been set
if (String.IsNullOrEmpty(bankAccountType))
throw new OFXParseException("Bank Account type unknown");

//Set bank account enum
_BankAccountType = bankAccountType.GetBankAccountType();
}

#region Account types not supported

private void InitializeAP(XmlNode node)
{
throw new OFXParseException("AP Account type not supported");
}

private void InitializeAR(XmlNode node)
{
throw new OFXParseException("AR Account type not supported");
}

#endregion
}
string bankAccountType = node.GetValue(".//ACCTTYPE");
//Check that it has been set
if (String.IsNullOrEmpty(bankAccountType))
throw new OFXParseException("Bank Account type unknown");
//Set bank account enum
_BankAccountType = bankAccountType.GetBankAccountType();
}
#region Account types not supported
private void InitializeAP(XmlNode node)
{
throw new OFXParseException("AP Account type not supported");
}
private void InitializeAR(XmlNode node)
{
throw new OFXParseException("AR Account type not supported");
}
#endregion
}
}
8 changes: 4 additions & 4 deletions source/OFXSharp/AccountType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace OFXSharp
public enum AccountType
{
[Description("Bank Account")]
BANK,
Bank,
[Description("Credit Card")]
CC,
CreditCard,
[Description("Accounts Payable")]
AP,
AccountsPayable,
[Description("Accounts Recievable")]
AR,
AccountsReceivable,
NA,
}
}
Loading