Add priority
This commit is contained in:
@@ -87,6 +87,7 @@
|
||||
<Compile Include="Entities\LeafGasComparisonPhotosyntheticInfo.cs" />
|
||||
<Compile Include="Entities\LeafGasComparisonFittingInfo.cs" />
|
||||
<Compile Include="Entities\LeafGasComparison.cs" />
|
||||
<Compile Include="Entities\Priority.cs" />
|
||||
<Compile Include="Entities\LeafInputStatusType.cs" />
|
||||
<Compile Include="Entities\LeafOutputFile.cs" />
|
||||
<Compile Include="Entities\LeafOutputFileContents.cs" />
|
||||
@@ -112,6 +113,10 @@
|
||||
<Compile Include="Migrations\201605210257006_LeafOutputFileContents.Designer.cs">
|
||||
<DependentUpon>201605210257006_LeafOutputFileContents.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\201701311417095_PendingPriority.cs" />
|
||||
<Compile Include="Migrations\201701311417095_PendingPriority.Designer.cs">
|
||||
<DependentUpon>201701311417095_PendingPriority.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="Parsers\LeafGasComparisonParser.cs" />
|
||||
<Compile Include="Remote\IPiscalClient.cs" />
|
||||
@@ -172,6 +177,9 @@
|
||||
<EmbeddedResource Include="Migrations\201605210257006_LeafOutputFileContents.resx">
|
||||
<DependentUpon>201605210257006_LeafOutputFileContents.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Migrations\201701311417095_PendingPriority.resx">
|
||||
<DependentUpon>201701311417095_PendingPriority.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
|
||||
|
||||
@@ -54,6 +54,14 @@ namespace LeafWeb.Core.DAL
|
||||
return _db.LeafInputs;
|
||||
}
|
||||
|
||||
public IQueryable<LeafInput> GetLeafInputsOrdered()
|
||||
{
|
||||
return _db.LeafInputs
|
||||
.OrderByDescending(li => li.CurrentStatus == LeafInputStatusType.Pending)
|
||||
.ThenByDescending(li => li.PendingPriority)
|
||||
.ThenByDescending(li => li.Id);
|
||||
}
|
||||
|
||||
public LeafInput GetLeafInput(int id)
|
||||
{
|
||||
return _db.LeafInputs.FirstOrDefault(li => li.Id == id);
|
||||
|
||||
+42
-39
@@ -8,17 +8,53 @@ using System.Linq;
|
||||
|
||||
namespace LeafWeb.Core.Entities
|
||||
{
|
||||
public abstract class LeafInputBase
|
||||
public class LeafInput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public virtual ICollection<LeafInputFile> InputFiles { get; set; }
|
||||
public virtual ICollection<LeafInputData> LeafInputData { get; set; }
|
||||
public virtual ICollection<LeafOutputFile> OutputFiles { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Name required")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "An email address is required")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A unique identifier is required")]
|
||||
public string Identifier { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Site Id required")]
|
||||
public string SiteId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column(TypeName = "VARCHAR")]
|
||||
[StringLength(12)]
|
||||
[Index("IX_UniqueToken", 1, IsUnique = true)]
|
||||
public string UniqueToken { get; set; }
|
||||
|
||||
// [Required(ErrorMessage = "PhotosynthesisType required")]
|
||||
// http://stackoverflow.com/questions/6038541/ef-validation-failing-on-update-when-using-lazy-loaded-required-properties
|
||||
public virtual PhotosynthesisType PhotosynthesisType { get; set; }
|
||||
|
||||
[DataType(DataType.Date)]
|
||||
[Required]
|
||||
public DateTime Added { get; set; }
|
||||
|
||||
public LeafInputStatusType CurrentStatus { get; set; }
|
||||
|
||||
public virtual ICollection<LeafInputStatus> StatusHistory { get; set; }
|
||||
|
||||
public Priority PendingPriority { get; set; }
|
||||
|
||||
#region Calculated properties
|
||||
|
||||
public LeafOutputFile OutputErrorMessage => OutputFiles?.FirstOrDefault(f => f.IsErrorMessage);
|
||||
public LeafOutputFile OutputWarningMessage => OutputFiles?.FirstOrDefault(f => f.IsWarningMessage);
|
||||
public bool HasOutputFiles => OutputFiles.Any();
|
||||
public bool HasLeafChart => OutputFiles.Any(f => f.IsLeafChartFile);
|
||||
|
||||
public LeafInputStatusType CurrentStatus { get; set; }
|
||||
public virtual ICollection<LeafInputStatus> StatusHistory { get; set; }
|
||||
|
||||
public bool IsPending => CurrentStatus == LeafInputStatusType.Pending;
|
||||
public bool IsStarting => CurrentStatus == LeafInputStatusType.Starting;
|
||||
public bool IsRunning => CurrentStatus == LeafInputStatusType.Running;
|
||||
@@ -42,7 +78,6 @@ namespace LeafWeb.Core.Entities
|
||||
public bool IsDeletable => !IsInProgress;
|
||||
public bool IsAtEndState => IsComplete || IsException || IsCancelled;
|
||||
|
||||
|
||||
public DateTime? StartTime
|
||||
{
|
||||
get
|
||||
@@ -71,7 +106,7 @@ namespace LeafWeb.Core.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan TotalInProgressTime
|
||||
public TimeSpan TimeInProgress
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -90,40 +125,8 @@ namespace LeafWeb.Core.Entities
|
||||
return end.Value - start.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LeafInput : LeafInputBase
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public virtual ICollection<LeafInputFile> InputFiles { get; set; }
|
||||
public virtual ICollection<LeafInputData> LeafInputData { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Name required")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "An email address is required")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "A unique identifier is required")]
|
||||
public string Identifier { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "Site Id required")]
|
||||
public string SiteId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column(TypeName = "VARCHAR")]
|
||||
[StringLength(12)]
|
||||
[Index("IX_UniqueToken", 1, IsUnique = true)]
|
||||
public string UniqueToken { get; set; }
|
||||
|
||||
// [Required(ErrorMessage = "PhotosynthesisType required")]
|
||||
// http://stackoverflow.com/questions/6038541/ef-validation-failing-on-update-when-using-lazy-loaded-required-properties
|
||||
public virtual PhotosynthesisType PhotosynthesisType { get; set; }
|
||||
|
||||
[DataType(DataType.Date)]
|
||||
[Required]
|
||||
public DateTime Added { get; set; }
|
||||
#endregion
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace LeafWeb.Core.Entities
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
Normal = 0,
|
||||
Low = -1,
|
||||
High = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// <auto-generated />
|
||||
namespace LeafWeb.Core.Migrations
|
||||
{
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
[GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")]
|
||||
public sealed partial class PendingPriority : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(PendingPriority));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201701311417095_PendingPriority"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace LeafWeb.Core.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class PendingPriority : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
AddColumn("dbo.LeafInput", "PendingPriority", c => c.Int(nullable: false));
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropColumn("dbo.LeafInput", "PendingPriority");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user