Add Api Endpoint to save/retrieve the active policy.Policy

Add SQLite code to save the policy html/markdown scripts from the user
#94
This commit is contained in:
chris.watts90@outlook.com 2019-10-18 09:30:57 +01:00
parent f286498540
commit dc2210b5b3
9 changed files with 376 additions and 234 deletions

View File

@ -112,5 +112,9 @@ namespace Interfaces
OperationResponse DeleteLog(TimeLog log); OperationResponse DeleteLog(TimeLog log);
OperationResponse CreateLog(TimeLog log); OperationResponse CreateLog(TimeLog log);
OperationResponse UpdateLog(TimeLog log); OperationResponse UpdateLog(TimeLog log);
Policy GetPolicy();
void SavePolicy(Policy policy);
} }
} }

View File

@ -1,87 +1,88 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B7347B72-E208-423A-9D99-723B558EA3D7}</ProjectGuid> <ProjectGuid>{B7347B72-E208-423A-9D99-723B558EA3D7}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Interfaces</RootNamespace> <RootNamespace>Interfaces</RootNamespace>
<AssemblyName>Interfaces</AssemblyName> <AssemblyName>Interfaces</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugInstallers|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugInstallers|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\DebugInstallers\</OutputPath> <OutputPath>bin\DebugInstallers\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseInstallers|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseInstallers|AnyCPU'">
<OutputPath>bin\ReleaseInstallers\</OutputPath> <OutputPath>bin\ReleaseInstallers\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AppDetails.cs" /> <Compile Include="AppDetails.cs" />
<Compile Include="DailyLogs.cs" /> <Compile Include="DailyLogs.cs" />
<Compile Include="EventLogResponse.cs" /> <Compile Include="EventLogResponse.cs" />
<Compile Include="Group.cs" /> <Compile Include="Group.cs" />
<Compile Include="GroupList.cs" /> <Compile Include="GroupList.cs" />
<Compile Include="ILogger.cs" /> <Compile Include="ILogger.cs" />
<Compile Include="IRepository.cs" /> <Compile Include="IRepository.cs" />
<Compile Include="Identifier.cs" /> <Compile Include="Identifier.cs" />
<Compile Include="IdentifierList.cs" /> <Compile Include="IdentifierList.cs" />
<Compile Include="ManualLog.cs" /> <Compile Include="ManualLog.cs" />
<Compile Include="OperationResponse.cs" /> <Compile Include="OperationResponse.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Policy.cs" />
<Compile Include="TimeLog.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TimeLogList.cs" /> <Compile Include="TimeLog.cs" />
<Compile Include="User.cs" /> <Compile Include="TimeLogList.cs" />
<Compile Include="UserList.cs" /> <Compile Include="User.cs" />
</ItemGroup> <Compile Include="UserList.cs" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Interfaces
{
public class Policy
{
public DateTime ChangeDate { get; set; }
public string ChangeDescription { get; set; }
public string ChangeAuthor { get; set; }
public string Version { get; set; }
public string Markdown { get; set; }
public string Html { get; set; }
}
}

View File

@ -0,0 +1,35 @@
using Interfaces;
namespace SQLiteRepository.Converters
{
static class PolicyConverter
{
public static Policy ConvertToPolicyDto(PolicyDb policyDb)
{
if (policyDb == null) return null;
return new Policy
{
ChangeDescription = policyDb.ChangeDescription,
ChangeDate = policyDb.ChangeDate.UtcDateTime,
Html = policyDb.Html,
Version = policyDb.Version,
ChangeAuthor = policyDb.ChangeAuthor,
Markdown = policyDb.Markdown
};
}
public static PolicyDb ConvertFromPolicyDto(Policy policy)
{
if (policy == null) return null;
return new PolicyDb
{
ChangeDescription = policy.ChangeDescription,
ChangeDate = policy.ChangeDate,
Html = policy.Html,
Version = policy.Version,
ChangeAuthor = policy.ChangeAuthor,
Markdown = policy.Markdown
};
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SQLite.Net.Attributes;
namespace SQLiteRepository
{
internal class PolicyDb
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public DateTimeOffset ChangeDate { get; set; }
public string ChangeDescription { get; set; }
public string ChangeAuthor { get; set; }
public string Version { get; set; }
public string Markdown { get; set; }
public string Html { get; set; }
}
}

View File

@ -38,6 +38,8 @@ namespace SQLiteRepository
_connection.CreateTable<GroupDb>(); _connection.CreateTable<GroupDb>();
_connection.CreateTable<UserGroupJoinDb>(); _connection.CreateTable<UserGroupJoinDb>();
_connection.CreateTable<DbVersion>(); _connection.CreateTable<DbVersion>();
_connection.CreateTable<PolicyDb>();
_logger.Trace("Initialised SQLite Repository"); _logger.Trace("Initialised SQLite Repository");
_logger.Trace("Checking For Upgrades"); _logger.Trace("Checking For Upgrades");
CheckForDbUpgrade(); CheckForDbUpgrade();
@ -519,7 +521,35 @@ namespace SQLiteRepository
return OperationResponse.UPDATED; return OperationResponse.UPDATED;
} }
public Policy GetPolicy()
{
var query = $"select * from {nameof(PolicyDb)}";
var policies = _connection.Query<PolicyDb>(query);
return PolicyConverter.ConvertToPolicyDto(policies.OrderByDescending(x => x.Version).FirstOrDefault());
}
public void SavePolicy(Policy policy)
{
if (string.IsNullOrEmpty(policy.Version))
{
policy.Version = (GetNextPolicyVersion()+1).ToString();
}
var policyDb = PolicyConverter.ConvertFromPolicyDto(policy);
_connection.Insert(policyDb);
}
private int GetNextPolicyVersion()
{
var query = $"select Max({nameof(PolicyDb.Id)}) from {nameof(PolicyDb)}";
var id = _connection.ExecuteScalar<int>(query);
return id;
}
private int GetUserCount() private int GetUserCount()
{ {
return _connection.ExecuteScalar<int>(SQLiteProcedures.GET_TOTAL_USER_COUNT); return _connection.ExecuteScalar<int>(SQLiteProcedures.GET_TOTAL_USER_COUNT);

View File

@ -1,129 +1,131 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B3510C81-F069-48A2-B826-EBE0CE7AB0B2}</ProjectGuid> <ProjectGuid>{B3510C81-F069-48A2-B826-EBE0CE7AB0B2}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SQLiteRepository</RootNamespace> <RootNamespace>SQLiteRepository</RootNamespace>
<AssemblyName>SQLiteRepository</AssemblyName> <AssemblyName>SQLiteRepository</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugInstallers|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugInstallers|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\DebugInstallers\</OutputPath> <OutputPath>bin\DebugInstallers\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseInstallers|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseInstallers|AnyCPU'">
<OutputPath>bin\ReleaseInstallers\</OutputPath> <OutputPath>bin\ReleaseInstallers\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SQLite.Net, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="SQLite.Net, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath> <HintPath>..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="SQLite.Net.Platform.Generic, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="SQLite.Net.Platform.Generic, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll</HintPath> <HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="SQLite.Net.Platform.Win32, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="SQLite.Net.Platform.Win32, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll</HintPath> <HintPath>..\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.104.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> <Reference Include="System.Data.SQLite, Version=1.0.104.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net451\System.Data.SQLite.dll</HintPath> <HintPath>..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net451\System.Data.SQLite.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CardUniqueId.cs" /> <Compile Include="CardUniqueId.cs" />
<Compile Include="Converters\LogDirectionConverter.cs" /> <Compile Include="Converters\LogDirectionConverter.cs" />
<Compile Include="Converters\LogSourceConverter.cs" /> <Compile Include="Converters\LogSourceConverter.cs" />
<Compile Include="Converters\TimeLogConverter.cs" /> <Compile Include="Converters\PolicyConverter.cs" />
<Compile Include="Converters\UserConverter.cs" /> <Compile Include="Converters\TimeLogConverter.cs" />
<Compile Include="DBVersion.cs" /> <Compile Include="Converters\UserConverter.cs" />
<Compile Include="Extensions\Extensions.cs" /> <Compile Include="DBVersion.cs" />
<Compile Include="GroupDb.cs" /> <Compile Include="Extensions\Extensions.cs" />
<Compile Include="LogSourceDb.cs" /> <Compile Include="GroupDb.cs" />
<Compile Include="SQLiteRepository.cs" /> <Compile Include="LogSourceDb.cs" />
<Compile Include="Constants.cs" /> <Compile Include="PolicyDb.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="SQLiteRepository.cs" />
<Compile Include="SQLiteProcedures.cs" /> <Compile Include="Constants.cs" />
<Compile Include="LogDirectionDb.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TimeLogDb.cs" /> <Compile Include="SQLiteProcedures.cs" />
<Compile Include="UserGroupJoinDb.cs" /> <Compile Include="LogDirectionDb.cs" />
<Compile Include="UserIdentity.cs" /> <Compile Include="TimeLogDb.cs" />
</ItemGroup> <Compile Include="UserGroupJoinDb.cs" />
<ItemGroup> <Compile Include="UserIdentity.cs" />
<ProjectReference Include="..\ConfigurationHandler\ConfigurationHandler.csproj"> </ItemGroup>
<Project>{115250F6-F8C4-4F9B-A15F-251EA258D963}</Project> <ItemGroup>
<Name>ConfigurationHandler</Name> <ProjectReference Include="..\ConfigurationHandler\ConfigurationHandler.csproj">
</ProjectReference> <Project>{115250F6-F8C4-4F9B-A15F-251EA258D963}</Project>
<ProjectReference Include="..\Interfaces\Interfaces.csproj"> <Name>ConfigurationHandler</Name>
<Project>{B7347B72-E208-423A-9D99-723B558EA3D7}</Project> </ProjectReference>
<Name>Interfaces</Name> <ProjectReference Include="..\Interfaces\Interfaces.csproj">
</ProjectReference> <Project>{B7347B72-E208-423A-9D99-723B558EA3D7}</Project>
</ItemGroup> <Name>Interfaces</Name>
<ItemGroup> </ProjectReference>
<None Include="packages.config" /> </ItemGroup>
</ItemGroup> <ItemGroup>
<ItemGroup> <EmbeddedResource Include="UpgradeScripts\0.2.sql" />
<EmbeddedResource Include="UpgradeScripts\0.2.sql" /> </ItemGroup>
</ItemGroup> <ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <None Include="packages.config" />
<Import Project="..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets')" /> </ItemGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <Import Project="..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets')" />
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
</PropertyGroup> <PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets'))" /> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</Target> </PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.104.0\build\net451\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="net452" /> <package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="net452" />
<package id="SQLite.Net-PCL" version="3.1.1" targetFramework="net452" /> <package id="SQLite.Net-PCL" version="3.1.1" targetFramework="net452" />
<package id="System.Data.SQLite.Core" version="1.0.104.0" targetFramework="net452" /> <package id="System.Data.SQLite.Core" version="1.0.104.0" targetFramework="net452" />
</packages> </packages>

View File

@ -1,26 +1,51 @@
using System.Reflection; using System.Reflection;
using System.Web.Http; using System.Web.Http;
using Interfaces; using WindowsDataCenter.Helpers;
using Interfaces;
namespace WindowsDataCenter
{ namespace WindowsDataCenter
[RoutePrefix("api/app")] {
public class ApplicationController:ApiController [RoutePrefix("api/app")]
{ public class ApplicationController:ApiController
[Route("")] {
public IHttpActionResult GetAppDetails() private IRepository _repo;
{ public ApplicationController(IRepository repo)
var ninjectHelper = NinjectHelper.GetInstance(); {
var appDetails = new AppDetails _repo = repo;
{ }
ApplicationName = "Flexitime Tracker",
DataBaseProvider = ninjectHelper.Get<IRepository>().GetType().ToString(), [Route("")]
LoggerProvider = ninjectHelper.Get<ILogger>().GetType().ToString(), public IHttpActionResult GetAppDetails()
Version = Assembly.GetEntryAssembly().GetName().Version.ToString(), {
ErrorEmailAddress = ConfigurationHandler.ConfigurationHandler.GetConfiguration("BugSubmissionEmailAddress") ?? "NONE" var ninjectHelper = NinjectHelper.GetInstance();
}; var appDetails = new AppDetails
{
return Ok(appDetails); ApplicationName = "Flexitime Tracker",
} DataBaseProvider = ninjectHelper.Get<IRepository>().GetType().ToString(),
} LoggerProvider = ninjectHelper.Get<ILogger>().GetType().ToString(),
} Version = Assembly.GetEntryAssembly().GetName().Version.ToString(),
ErrorEmailAddress = ConfigurationHandler.ConfigurationHandler.GetConfiguration("BugSubmissionEmailAddress") ?? "NONE"
};
return Ok(appDetails);
}
[Route("policy")]
[HttpGet]
[CacheControl(MaxAge = 0)]
public IHttpActionResult GetPolicy()
{
Policy policy = _repo.GetPolicy();
return Json(policy);
}
[Route("policy")]
[HttpPost]
[CacheControl(MaxAge = 0)]
public IHttpActionResult SavePolicy(Policy policy)
{
_repo.SavePolicy(policy);
return Ok(new {}); //empty to ensure ajax triggers Success..
}
}
}