using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Txgy.EWS.Client.Models
{
    /// <summary>
    /// 报表事件等级
    /// </summary>
    public class ReportEventLevel
    {
        /// <summary>
        /// 级别
        /// </summary>
        public int level { get; set; }
        /// <summary>
        /// 上限
        /// </summary>
        public double upperbound { get; set; }
        /// <summary>
        /// 下限
        /// </summary>
        public double lowerbound { get; set; }
        /// <summary>
        /// 负0.5级以上
        /// </summary>
        public string describe { get; set; }
        /// <summary>
        /// 颜色字符
        /// </summary>
        public string color { get; set; }

        public static List<ReportEventLevel> CreateFromJson(string jsonFile)
        {
            List<ReportEventLevel> reportEventLevels = new List<ReportEventLevel>();
            StreamReader streamReader = new StreamReader(jsonFile);
            string jsonRoot = streamReader.ReadToEnd();  //读全部json        
                                                         //jsonRoot.Dump();
            JArray jA = JArray.Parse(jsonRoot);
            foreach (var element in jA)
            {
                ReportEventLevel la = JsonConvert.DeserializeObject<ReportEventLevel>(element.ToString());
                reportEventLevels.Add(la);
            }
            return reportEventLevels;
        }
    }
}

