/
agontar
/
TOROS
Обзор
Документация
Войти
/
agontar
/
TOROS
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Webapplication_new/Models/SetTresholds.cs
108 строк
3 KB
gav
initial upload
17 сен 2024, 16:04
17 сен 2024, 16:04
356ccc9
Код
Авторство
О чём код?
using Newtonsoft.Json; using WebApplication1.Services; namespace WebApplication1.Models { public class SetTresholds { /*string wwwPath; string path; IWebHostEnvironment Environment; public SetTresholds(IWebHostEnvironment environment) { Environment = environment; wwwPath = Environment.WebRootPath; path = Path.Combine(wwwPath, "Zones", "Class1.json"); }*/ public EqnClass SelectClass { get; set; } public string Amax { get; set; } = string.Empty; public string Bmax { get; set; } = string.Empty; public string Cmax { get; set; } = string.Empty; public string Dmax { get; set; } = string.Empty; public string Amin { get; set; } = string.Empty; public string Bmin { get; set; } = string.Empty; public string Cmin { get; set; } = string.Empty; public string Dmin { get; set; } = string.Empty; public float amax; public float bmax; public float cmax; public float dmax; public float amin; public float bmin; public float cmin; public float dmin; public List<Zones> AllZones { get; set; } = new List<Zones>(); public List<Zones[]> AllZonesParam { get; set; } = new List<Zones[]>(); public int ParamSelect { get; set; } public void SetFloatValues() { try { Amax = Amax.Replace(".", ","); float.TryParse(Amax, out amax); Bmax = Bmax.Replace(".", ","); float.TryParse(Bmax, out bmax); Cmax = Cmax.Replace(".", ","); float.TryParse(Cmax, out cmax); Dmax = Dmax.Replace(".", ","); float.TryParse(Dmax, out dmax); Amin = Amin.Replace(".", ","); float.TryParse(Amin, out amin); Bmin = Bmin.Replace(".", ","); float.TryParse(Bmin, out bmin); Cmin = Cmin.Replace(".", ","); float.TryParse(Cmin, out cmin); Dmin = Dmin.Replace(".", ","); float.TryParse(Dmin, out dmin); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return; } } public int GetZone(Zones zones, float v) { int zone = 0; if (v >= zones.Amin && v <= zones.Amax) { zone = 1; } else if (v >= zones.Bmin && v <= zones.Bmax) { zone = 2; } else if (v >= zones.Cmin && v <= zones.Cmax) { zone = 3; } else if (v >= zones.Dmin && v <= zones.Dmax) { zone = 4; } return zone; } /* public void GetZones() { for (int i = 0; i < 4; i++) { string path = Path.Combine(wwwPath, "Zones", "Class" + (i + 1).ToString() + ".json"); WriteRead read = new WriteRead(); string json = read.ReadText(path); Zones z = JsonConvert.DeserializeObject<Zones>(json); AllZones.Add(z); Console.WriteLine(json); } }*/ } }