113 lines
4.8 KiB
C#
113 lines
4.8 KiB
C#
using System.ComponentModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace LeafWeb.WebCms.Models
|
|
{
|
|
public class LeafDataQuery
|
|
{
|
|
// https://3widgets.com/
|
|
private const string NumberRange_0_to_2000_Regex = @"^(\d|[1-9]\d{1,2}|1\d{3}|2000)(\.[0-9]+)?$";
|
|
private const string NumberRange_0_to_3000_Regex = @"^(\d|[1-9]\d{1,2}|[12]\d{3}|3000)(\.[0-9]+)?$";
|
|
private const string NumberRange_Neg20_to_50_Regex = @"^(-[1-9]|-1\d|-20|\d|[1-4]\d|50)(\.[0-9]+)?$";
|
|
private const string NumberRange_0_to_1_Regex = @"^(0?\.[0-9]+)|(0|1)?$";
|
|
|
|
/// <summary>Query</summary>
|
|
[Display(Name = "Search", Description = "General query")]
|
|
public string q { get; set; }
|
|
|
|
[Display(Name = "Site ID", Description = "The site's name/Fluxnet ID, if known")]
|
|
[RegularExpression(@".{3,}", ErrorMessage = "Specify at least three characters")]
|
|
public string siteid { get; set; }
|
|
|
|
[Display(Name = "Species Name")]
|
|
[RegularExpression(@".{3,}", ErrorMessage = "Specify at least three characters")]
|
|
public string species { get; set; }
|
|
|
|
/// <summary>Site latitude, northern hemisphere positive</summary>
|
|
[Display(Name = "Latitude")]
|
|
[RegularExpression(@"^-?([0-9]|[1-8][0-9]|90)$", ErrorMessage = "Site latitude, northern hemisphere positive, -90 – 90")]
|
|
public string lat { get; set; }
|
|
|
|
[Display(Name = "Range")]
|
|
[RegularExpression(@"^([0-9]|[1-8][0-9]|90)$", ErrorMessage = "± latitude degrees")]
|
|
public string latr { get; set; }
|
|
|
|
/// <summary>Site longitude, east positive</summary>
|
|
[Display(Name = "Longitude")]
|
|
[RegularExpression(@"^-?([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "Site longitude, east positive, -180 – 180")]
|
|
public string lon { get; set; }
|
|
|
|
[Display(Name = "Range")]
|
|
[RegularExpression(@"^([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "± longitude degrees")]
|
|
public string lonr { get; set; }
|
|
|
|
/// <summary>Sample CO2 concentration</summary>
|
|
[Display(Name = "CO2 response curves (CO2S)")]
|
|
[RegularExpression(NumberRange_0_to_2000_Regex, ErrorMessage = "Must be numeric, 0 to 2000")]
|
|
public string co2s { get; set; }
|
|
|
|
/// <summary> PAR measured by the in-chamber quantum sensor</summary>
|
|
[Display(Name = "Light response curves (PARi)")]
|
|
[RegularExpression(NumberRange_0_to_3000_Regex, ErrorMessage = "Must be numeric, 0 to 3000")]
|
|
public string pari { get; set; }
|
|
|
|
/// <summary> temperature of leaf thermocouple</summary>
|
|
[Display(Name = "Temperature response curves (Tleaf)")]
|
|
[RegularExpression(NumberRange_Neg20_to_50_Regex, ErrorMessage = "Must be numeric, -20 to 50")]
|
|
public string tleaf { get; set; }
|
|
|
|
/// <summary> DeltaF/Fm, the fraction of absorbed PSII photons that are used in photochemistry</summary>
|
|
[Display(Name = "Fluorometry measurements (PhiPS2)")]
|
|
[RegularExpression(NumberRange_0_to_1_Regex, ErrorMessage = "Must be numeric, 0 to 1")]
|
|
public string phips2 { get; set; }
|
|
|
|
[Display(Name = "Show Only Successfully Completed")]
|
|
[UIHint("Checkbox")]
|
|
public string compl { get; set; }
|
|
|
|
public bool ShowOnlySuccessfullyCompleted => !string.IsNullOrEmpty(compl);
|
|
|
|
[Display(Name = "Show Only Erred")]
|
|
[UIHint("Checkbox")]
|
|
public string erred { get; set; }
|
|
|
|
public bool ShowOnlyErred => !string.IsNullOrEmpty(erred);
|
|
|
|
[Display(Name = "Only my data")]
|
|
[UIHint("Checkbox")]
|
|
public string usr { get; set; }
|
|
|
|
public bool OnlyUserData => !string.IsNullOrEmpty(usr);
|
|
|
|
[Display(Name = "Result Type")]
|
|
//[UIHint("Radio")]
|
|
public string dsp { get; set; }
|
|
|
|
public const string LeafInputDataSearchParam = "data";
|
|
public bool ShowLeafInputData => dsp == LeafInputDataSearchParam;
|
|
|
|
public const string LeafInputSearchParam = "set";
|
|
public bool ShowLeafInput => dsp == LeafInputSearchParam;
|
|
|
|
public bool HasExtendedParameters =>
|
|
!(
|
|
string.IsNullOrEmpty(siteid)
|
|
&& string.IsNullOrEmpty(species)
|
|
&& string.IsNullOrEmpty(lat)
|
|
&& string.IsNullOrEmpty(latr)
|
|
&& string.IsNullOrEmpty(lon)
|
|
&& string.IsNullOrEmpty(lonr)
|
|
&& string.IsNullOrEmpty(co2s)
|
|
&& string.IsNullOrEmpty(pari)
|
|
&& string.IsNullOrEmpty(tleaf)
|
|
&& string.IsNullOrEmpty(phips2)
|
|
&& string.IsNullOrEmpty(compl)
|
|
&& string.IsNullOrEmpty(erred)
|
|
);
|
|
|
|
public bool HasParameters =>
|
|
HasExtendedParameters
|
|
|| !string.IsNullOrEmpty(q)
|
|
|| !string.IsNullOrEmpty(usr);
|
|
}
|
|
} |