Converting all files stored as CRLF in git to be stored as LF

LF is the git default and all new files are stored as such. Old files from the hg to git conversion however were moved over as CRLF.
This commit is contained in:
Lombiq
2015-12-13 22:21:02 +01:00
parent 1e963d4d50
commit 5406b17601
3470 changed files with 371153 additions and 371153 deletions

View File

@@ -1,23 +1,23 @@
using System;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
namespace Orchard.TaskLease {
public class TaskLeaseMigrations : DataMigrationImpl {
public int Create() {
SchemaBuilder.CreateTable("TaskLeaseRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("TaskName")
.Column<string>("MachineName")
.Column<DateTime>("UpdatedUtc")
.Column<DateTime>("ExpiredUtc")
.Column<string>("State", c => c.Unlimited())
);
return 1;
}
}
using System;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
namespace Orchard.TaskLease {
public class TaskLeaseMigrations : DataMigrationImpl {
public int Create() {
SchemaBuilder.CreateTable("TaskLeaseRecord",
table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("TaskName")
.Column<string>("MachineName")
.Column<DateTime>("UpdatedUtc")
.Column<DateTime>("ExpiredUtc")
.Column<string>("State", c => c.Unlimited())
);
return 1;
}
}
}

View File

@@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Data.Conventions;
namespace Orchard.TaskLease.Models
{
public class TaskLeaseRecord
{
public virtual int Id { get; set; }
public virtual string TaskName { get; set; }
public virtual string MachineName { get; set; }
public virtual DateTime UpdatedUtc { get; set; }
public virtual DateTime ExpiredUtc { get; set; }
[StringLengthMax]
public virtual string State { get; set; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Data.Conventions;
namespace Orchard.TaskLease.Models
{
public class TaskLeaseRecord
{
public virtual int Id { get; set; }
public virtual string TaskName { get; set; }
public virtual string MachineName { get; set; }
public virtual DateTime UpdatedUtc { get; set; }
public virtual DateTime ExpiredUtc { get; set; }
[StringLengthMax]
public virtual string State { get; set; }
}
}

View File

@@ -1,8 +1,8 @@
Name: Task Lease
AntiForgery: enabled
Author: The Orchard Team
Website: http://orchardtasklease.codeplex.com
Version: 1.9.2
OrchardVersion: 1.9
Description: Provides services to synchronize tasks in a farm environment
Name: Task Lease
AntiForgery: enabled
Author: The Orchard Team
Website: http://orchardtasklease.codeplex.com
Version: 1.9.2
OrchardVersion: 1.9
Description: Provides services to synchronize tasks in a farm environment
Category: Hosting

View File

@@ -1,147 +1,147 @@
<?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>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3F72A4E9-7B72-4260-B010-C16EC54F9BAF}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.TaskLease</RootNamespace>
<AssemblyName>Orchard.TaskLease</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkProfile />
<UseIISExpress>false</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config" />
<Content Include="Scripts\Web.config" />
<Content Include="Styles\Web.config" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>
<ItemGroup>
<Compile Include="Migrations.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Models\TaskLeaseRecord.cs" />
<Compile Include="Services\ITaskLeaseService.cs" />
<Compile Include="Services\TaskLeaseService.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Tests\" />
<Folder Include="Views\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<!-- 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" DependsOnTargets="AfterBuildCompiler">
<PropertyGroup>
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
</PropertyGroup>
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
-->
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
-->
</Target>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>45979</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<?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>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3F72A4E9-7B72-4260-B010-C16EC54F9BAF}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.TaskLease</RootNamespace>
<AssemblyName>Orchard.TaskLease</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>4.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkProfile />
<UseIISExpress>false</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\..\..\OrchardBasicCorrectness.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Content Include="Web.config" />
<Content Include="Scripts\Web.config" />
<Content Include="Styles\Web.config" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>
<ItemGroup>
<Compile Include="Migrations.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Models\TaskLeaseRecord.cs" />
<Compile Include="Services\ITaskLeaseService.cs" />
<Compile Include="Services\TaskLeaseService.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Tests\" />
<Folder Include="Views\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<!-- 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" DependsOnTargets="AfterBuildCompiler">
<PropertyGroup>
<AreasManifestDir>$(ProjectDir)\..\Manifests</AreasManifestDir>
</PropertyGroup>
<!-- If this is an area child project, uncomment the following line:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Child" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
-->
<!-- If this is an area parent project, uncomment the following lines:
<CreateAreaManifest AreaName="$(AssemblyName)" AreaType="Parent" AreaPath="$(ProjectDir)" ManifestPath="$(AreasManifestDir)" ContentFiles="@(Content)" />
<CopyAreaManifests ManifestPath="$(AreasManifestDir)" CrossCopy="false" RenameViews="true" />
-->
</Target>
<Target Name="AfterBuildCompiler" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>45979</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>
</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://orchard.codeplex.com</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -1,36 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
// 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("Orchard.TaskLease")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Orchard")]
[assembly: AssemblyCopyright("Copyright <20> .NET Foundation")]
[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("3320c438-e92b-4753-bfe5-944f29d13ded")]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.9.2")]
[assembly: AssemblyFileVersion("1.9.2")]
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
// 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("Orchard.TaskLease")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Orchard")]
[assembly: AssemblyCopyright("Copyright <20> .NET Foundation")]
[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("3320c438-e92b-4753-bfe5-944f29d13ded")]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.9.2")]
[assembly: AssemblyFileVersion("1.9.2")]

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>

View File

@@ -1,28 +1,28 @@
using System;
using Orchard.TaskLease.Models;
namespace Orchard.TaskLease.Services {
/// <summary>
/// Describes a service to save and acquire task leases. A task lease can't be acquired by two different machines,
/// for a specific amount of time. Optionnally a State can be saved along with the lease.
/// </summary>
public interface ITaskLeaseService : IDependency {
/// <summary>
/// Acquires a lease for the specified task name, and amount of time.
/// </summary>
/// <returns>The state of the lease if it was acquired, otherwise <c>null</c>.</returns>
string Acquire(string taskName, DateTime expiredUtc);
/// <summary>
/// Updates a lease for the current machine if it exists
/// </summary>
void Update(string taskName, string state);
/// <summary>
/// Updates a lease for the current machine if it exists
/// </summary>
void Update(string taskName, string state, DateTime expiredUtc);
}
using System;
using Orchard.TaskLease.Models;
namespace Orchard.TaskLease.Services {
/// <summary>
/// Describes a service to save and acquire task leases. A task lease can't be acquired by two different machines,
/// for a specific amount of time. Optionnally a State can be saved along with the lease.
/// </summary>
public interface ITaskLeaseService : IDependency {
/// <summary>
/// Acquires a lease for the specified task name, and amount of time.
/// </summary>
/// <returns>The state of the lease if it was acquired, otherwise <c>null</c>.</returns>
string Acquire(string taskName, DateTime expiredUtc);
/// <summary>
/// Updates a lease for the current machine if it exists
/// </summary>
void Update(string taskName, string state);
/// <summary>
/// Updates a lease for the current machine if it exists
/// </summary>
void Update(string taskName, string state, DateTime expiredUtc);
}
}

View File

@@ -1,95 +1,95 @@
using System;
using Orchard.Data;
using Orchard.Environment;
using Orchard.Services;
using Orchard.TaskLease.Models;
namespace Orchard.TaskLease.Services {
/// <summary>
/// Provides a database driven implementation of <see cref="ITaskLeaseService" />
/// </summary>
public class TaskLeaseService : ITaskLeaseService {
private readonly IRepository<TaskLeaseRecord> _repository;
private readonly IClock _clock;
private readonly IMachineNameProvider _machineNameProvider;
public TaskLeaseService(
IRepository<TaskLeaseRecord> repository,
IClock clock,
IMachineNameProvider machineNameProvider) {
_repository = repository;
_clock = clock;
_machineNameProvider = machineNameProvider;
}
public string Acquire(string taskName, DateTime expiredUtc) {
var machineName = _machineNameProvider.GetMachineName();
// retrieve current lease for the specified task
var taskLease = _repository.Get(x => x.TaskName == taskName);
// create a new lease if there is no current lease for this task
if (taskLease == null) {
taskLease = new TaskLeaseRecord {
TaskName = taskName,
MachineName = machineName,
State = String.Empty,
UpdatedUtc = _clock.UtcNow,
ExpiredUtc = expiredUtc
};
_repository.Create(taskLease);
_repository.Flush();
return String.Empty;
}
// lease can't be aquired only if for a different machine and it has not expired
if (taskLease.MachineName != machineName && taskLease.ExpiredUtc >= _clock.UtcNow) {
return null;
}
// otherwise update information
taskLease.MachineName = machineName;
taskLease.UpdatedUtc = _clock.UtcNow;
taskLease.ExpiredUtc = expiredUtc;
_repository.Flush();
return taskLease.State;
}
public void Update(string taskName, string state) {
var machineName = _machineNameProvider.GetMachineName();
// retrieve current lease for the specified task
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == machineName);
if (taskLease == null) {
return;
}
taskLease.State = state;
_repository.Flush();
}
public void Update(string taskName, string state, DateTime expiredUtc) {
var machineName = _machineNameProvider.GetMachineName();
// retrieve current lease for the specified task
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == machineName);
if (taskLease == null) {
return;
}
taskLease.ExpiredUtc = expiredUtc;
taskLease.State = state;
_repository.Flush();
}
}
using System;
using Orchard.Data;
using Orchard.Environment;
using Orchard.Services;
using Orchard.TaskLease.Models;
namespace Orchard.TaskLease.Services {
/// <summary>
/// Provides a database driven implementation of <see cref="ITaskLeaseService" />
/// </summary>
public class TaskLeaseService : ITaskLeaseService {
private readonly IRepository<TaskLeaseRecord> _repository;
private readonly IClock _clock;
private readonly IMachineNameProvider _machineNameProvider;
public TaskLeaseService(
IRepository<TaskLeaseRecord> repository,
IClock clock,
IMachineNameProvider machineNameProvider) {
_repository = repository;
_clock = clock;
_machineNameProvider = machineNameProvider;
}
public string Acquire(string taskName, DateTime expiredUtc) {
var machineName = _machineNameProvider.GetMachineName();
// retrieve current lease for the specified task
var taskLease = _repository.Get(x => x.TaskName == taskName);
// create a new lease if there is no current lease for this task
if (taskLease == null) {
taskLease = new TaskLeaseRecord {
TaskName = taskName,
MachineName = machineName,
State = String.Empty,
UpdatedUtc = _clock.UtcNow,
ExpiredUtc = expiredUtc
};
_repository.Create(taskLease);
_repository.Flush();
return String.Empty;
}
// lease can't be aquired only if for a different machine and it has not expired
if (taskLease.MachineName != machineName && taskLease.ExpiredUtc >= _clock.UtcNow) {
return null;
}
// otherwise update information
taskLease.MachineName = machineName;
taskLease.UpdatedUtc = _clock.UtcNow;
taskLease.ExpiredUtc = expiredUtc;
_repository.Flush();
return taskLease.State;
}
public void Update(string taskName, string state) {
var machineName = _machineNameProvider.GetMachineName();
// retrieve current lease for the specified task
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == machineName);
if (taskLease == null) {
return;
}
taskLease.State = state;
_repository.Flush();
}
public void Update(string taskName, string state, DateTime expiredUtc) {
var machineName = _machineNameProvider.GetMachineName();
// retrieve current lease for the specified task
var taskLease = _repository.Get(x => x.TaskName == taskName && x.MachineName == machineName);
if (taskLease == null) {
return;
}
taskLease.ExpiredUtc = expiredUtc;
taskLease.State = state;
_repository.Flush();
}
}
}

View File

@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<handlers accessPolicy="Script,Read">
<!--
iis7 - for any request to a file exists on disk, return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page.
-->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>

View File

@@ -1,108 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3FD9FA96-F7C9-4E98-BF17-DC75D07B7307}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.TaskLease.Tests</RootNamespace>
<AssemblyName>Orchard.TaskLease.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=2.2.4.900, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL" />
<Reference Include="NHibernate.ByteCode.Castle">
<HintPath>..\..\..\..\..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\Contrib.RewriteRules\bin\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\TaskLeaseServiceTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Orchard.Tests.Modules\Orchard.Tests.Modules.csproj">
<Project>{6CB3EB30-F725-45C0-9742-42599BA8E8D2}</Project>
<Name>Orchard.Tests.Modules</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Orchard.Tests\Orchard.Framework.Tests.csproj">
<Project>{ABC826D4-2FA1-4F2F-87DE-E6095F653810}</Project>
<Name>Orchard.Framework.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Orchard.TaskLease.csproj">
<Project>{3F72A4E9-7B72-4260-B010-C16EC54F9BAF}</Project>
<Name>Orchard.TaskLease</Name>
</ProjectReference>
</ItemGroup>
<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>
-->
<Target Name="CopySqlCeBinaries">
<ItemGroup>
<SqlCeBinariesx86 Include="$(ProjectDir)..\..\lib\sqlce\x86\**\*" />
<SqlCeBinariesx64 Include="$(ProjectDir)..\..\lib\sqlce\amd64\**\*" />
</ItemGroup>
<Copy SourceFiles="@(SqlCeBinariesx86)" DestinationFolder="$(OutputPath)\x86\%(RecursiveDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(SqlCeBinariesx64)" DestinationFolder="$(OutputPath)\amd64\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="AfterBuild">
<CallTarget Targets="CopySqlCeBinaries" />
</Target>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3FD9FA96-F7C9-4E98-BF17-DC75D07B7307}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Orchard.TaskLease.Tests</RootNamespace>
<AssemblyName>Orchard.TaskLease.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=2.2.4.900, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL" />
<Reference Include="NHibernate.ByteCode.Castle">
<HintPath>..\..\..\..\..\..\lib\fluentnhibernate\NHibernate.ByteCode.Castle.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\Contrib.RewriteRules\bin\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\TaskLeaseServiceTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Orchard.Tests.Modules\Orchard.Tests.Modules.csproj">
<Project>{6CB3EB30-F725-45C0-9742-42599BA8E8D2}</Project>
<Name>Orchard.Tests.Modules</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Orchard.Tests\Orchard.Framework.Tests.csproj">
<Project>{ABC826D4-2FA1-4F2F-87DE-E6095F653810}</Project>
<Name>Orchard.Framework.Tests</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Orchard.TaskLease.csproj">
<Project>{3F72A4E9-7B72-4260-B010-C16EC54F9BAF}</Project>
<Name>Orchard.TaskLease</Name>
</ProjectReference>
</ItemGroup>
<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>
-->
<Target Name="CopySqlCeBinaries">
<ItemGroup>
<SqlCeBinariesx86 Include="$(ProjectDir)..\..\lib\sqlce\x86\**\*" />
<SqlCeBinariesx64 Include="$(ProjectDir)..\..\lib\sqlce\amd64\**\*" />
</ItemGroup>
<Copy SourceFiles="@(SqlCeBinariesx86)" DestinationFolder="$(OutputPath)\x86\%(RecursiveDir)" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(SqlCeBinariesx64)" DestinationFolder="$(OutputPath)\amd64\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>
<Target Name="AfterBuild">
<CallTarget Targets="CopySqlCeBinaries" />
</Target>
</Project>

View File

@@ -1,36 +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("Orchard.TaskLease.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Orchard.TaskLease.Tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[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("0435ceba-eada-4dc4-aa03-74a68ccca515")]
// 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")]
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("Orchard.TaskLease.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Orchard.TaskLease.Tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[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("0435ceba-eada-4dc4-aa03-74a68ccca515")]
// 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")]

View File

@@ -1,97 +1,97 @@
using System;
using System.Collections.Generic;
using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.TaskLease.Models;
using Orchard.TaskLease.Services;
using Orchard.Tests.Modules;
namespace Orchard.TaskLease.Tests.Services
{
[TestFixture]
public class TaskLeaseServiceTests : DatabaseEnabledTestsBase
{
private ITaskLeaseService _service;
private Mock<IMachineNameProvider> _machineNameProvider;
protected override IEnumerable<Type> DatabaseTypes
{
get
{
return new[] {
typeof (TaskLeaseRecord)
};
}
}
public override void Register(ContainerBuilder builder)
{
builder.RegisterType<TaskLeaseService>().As<ITaskLeaseService>();
builder.RegisterInstance((_machineNameProvider = new Mock<IMachineNameProvider>()).Object);
_machineNameProvider.Setup(x => x.GetMachineName()).Returns("SkyNet");
}
public override void Init()
{
base.Init();
_service = _container.Resolve<ITaskLeaseService>();
}
[Test]
public void AcquireShouldSucceedIfNoTask()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
}
[Test]
public void AcquireShouldSucceedIfTaskBySameMachine()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
}
[Test]
public void AcquireShouldNotSucceedIfTaskByOtherMachine()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
_machineNameProvider.Setup(x => x.GetMachineName()).Returns("TheMatrix");
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(null));
}
[Test]
public void ShouldUpdateTask()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
_service.Update("Foo", "Other");
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo("Other"));
}
[Test]
public void AcquireShouldSucceedIfTaskByOtherMachineAndExpired()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
_machineNameProvider.Setup(x => x.GetMachineName()).Returns("TheMatrix");
_clock.Advance(new TimeSpan(2,0,0,0));
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
}
}
using System;
using System.Collections.Generic;
using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.TaskLease.Models;
using Orchard.TaskLease.Services;
using Orchard.Tests.Modules;
namespace Orchard.TaskLease.Tests.Services
{
[TestFixture]
public class TaskLeaseServiceTests : DatabaseEnabledTestsBase
{
private ITaskLeaseService _service;
private Mock<IMachineNameProvider> _machineNameProvider;
protected override IEnumerable<Type> DatabaseTypes
{
get
{
return new[] {
typeof (TaskLeaseRecord)
};
}
}
public override void Register(ContainerBuilder builder)
{
builder.RegisterType<TaskLeaseService>().As<ITaskLeaseService>();
builder.RegisterInstance((_machineNameProvider = new Mock<IMachineNameProvider>()).Object);
_machineNameProvider.Setup(x => x.GetMachineName()).Returns("SkyNet");
}
public override void Init()
{
base.Init();
_service = _container.Resolve<ITaskLeaseService>();
}
[Test]
public void AcquireShouldSucceedIfNoTask()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
}
[Test]
public void AcquireShouldSucceedIfTaskBySameMachine()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
}
[Test]
public void AcquireShouldNotSucceedIfTaskByOtherMachine()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
_machineNameProvider.Setup(x => x.GetMachineName()).Returns("TheMatrix");
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(null));
}
[Test]
public void ShouldUpdateTask()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
_service.Update("Foo", "Other");
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo("Other"));
}
[Test]
public void AcquireShouldSucceedIfTaskByOtherMachineAndExpired()
{
var state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
_machineNameProvider.Setup(x => x.GetMachineName()).Returns("TheMatrix");
_clock.Advance(new TimeSpan(2,0,0,0));
state = _service.Acquire("Foo", _clock.UtcNow.AddDays(1));
Assert.That(state, Is.EqualTo(String.Empty));
}
}
}

View File

@@ -1,54 +1,54 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<remove name="host"/>
<remove name="pages"/>
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Web.WebPages"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
<add namespace="Orchard.Mvc.Html"/>
</namespaces>
</pages>
</system.web.webPages.razor>
<system.web>
<compilation targetFramework="4.5.1">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>
<runtime>
<!-- NOTE: These binding redirects have no runtime effect; they are only here to avoid build warnings. -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.4000" newVersion="4.0.0.4000"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Iesi.Collections" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863AF14B0044DA" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<remove name="host"/>
<remove name="pages"/>
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Web.WebPages"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
<add namespace="Orchard.Mvc.Html"/>
</namespaces>
</pages>
</system.web.webPages.razor>
<system.web>
<compilation targetFramework="4.5.1">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>
<runtime>
<!-- NOTE: These binding redirects have no runtime effect; they are only here to avoid build warnings. -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.4000" newVersion="4.0.0.4000"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Iesi.Collections" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863AF14B0044DA" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>