using Newtonsoft.Json;
using FreeSql.DataAnnotations;
using System;

namespace Txgy.EWS.Client.Entity
{
    [JsonObject(MemberSerialization.OptIn), Table(Name = "postproeventresult")]
    public class LocalPostproResultEntity
    {
        [JsonProperty, Column(DbType = "varchar(254)")]
        public string EventTime { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int LocSta { get; set; }

        [JsonProperty]
        public double ML { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int MLSta { get; set; }

        [JsonProperty, Column(DbType = "varchar(254)")]
        public string OriginTime { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int PostEventID { get; set; }

        [JsonProperty]
        public double RMS { get; set; }

        [JsonProperty, Column(DbType = "int")]
        public int WorkAreaID { get; set; }

        [JsonProperty]
        public double X { get; set; }

        [JsonProperty]
        public double Y { get; set; }

        [JsonProperty]
        public double Z { get; set; }
        [Column(IsIgnore = true)]
        public double Energy { get; set; }
        public void SetEnergy()
        {
            Energy = Math.Round(63000.0 * Math.Pow(10, 1.47 * ML), 2);
        }
        public LocalPostproResultEntity(RemotePostproResultEntity rpr)
        {
            this.PostEventID = rpr.PostEventID;
            this.WorkAreaID = rpr.WorkAreaID;
            this.EventTime = rpr.EventTime;
            this.OriginTime = rpr.OriginTime;
            this.ML = rpr.ML;
            this.X = rpr.X;
            this.Y = rpr.Y;
            this.Z = rpr.Z;
            this.RMS = Math.Round(rpr.RMS, 3);
            this.LocSta = rpr.LocSta;
            this.MLSta = rpr.MLSta;
            this.Energy = rpr.Energy;
        }
    }
}
