using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FMSAdmin.Entities {
    public partial class CmFacility {
        public CmFacility() {
            BemsAlarmSetting = new HashSet<BemsAlarmSetting>();
            BemsFormulaParameter = new HashSet<BemsFormulaParameter>();
            BemsMonitoringPoint = new HashSet<BemsMonitoringPoint>();
            BemsPeakFacility = new HashSet<BemsPeakFacility>();
            CmFacilityFile = new HashSet<CmFacilityFile>();
            FmsFacilityManual = new HashSet<FmsFacilityManual>();
            FmsWorkOrderToFacility = new HashSet<FmsWorkOrderToFacility>();
            FmsWorkRequestToFacility = new HashSet<FmsWorkRequestToFacility>();
            FmsWorkResultCheckItem = new HashSet<FmsWorkResultCheckItem>();
            FmsWorkResultToFacility = new HashSet<FmsWorkResultToFacility>();
            FmsWorkScheduleToFacility = new HashSet<FmsWorkScheduleToFacility>();
            InverseCmFacilityNavigation = new HashSet<CmFacility>();
            FmsAlarmPointList = new HashSet<FmsAlarmPoint>();
            FmsAlarmLogList = new HashSet<FmsAlarmLog>();
            BemsReportFormatToFacility = new HashSet<BemsReportFormatToFacility>();
        }

        [Display(Name = "현장 고유번호"), Key]
        public int SiteId { get; set; }
        [Display(Name = "설비타입")]
        public int FacilityTypeId { get; set; }
        [Display(Name = "설비코드"), Key]
        public int FacilityCode { get; set; }
        [Display(Name = "설비 대분류 코드")]
        public int? FirstClassId { get; set; }
        [Display(Name = "설비 중분류 코드")]
        public int? SecondClassId { get; set; }
        [Display(Name = "설비 소분류 코드")]
        public int? ThirdClassId { get; set; }
        [Display(Name = "설비 종류")]
        [StringLength(48, ErrorMessage = "시설종류는 최대 48자까지 입력 가능합니다.")]
        public string DeviceType { get; set; }
        [Display(Name = "상위 설비 코드")]
        public int? ParentFacilityCode { get; set; }
        [Display(Name = "설비 명칭"), Required]
        [StringLength(80, ErrorMessage = "시설명칭은 최대 80자까지 입력 가능합니다.")]
        public string Name { get; set; }
        [Display(Name = "설비 별칭")]
        [StringLength(40, ErrorMessage = "시설별칭은 최대 40자까지 입력 가능합니다.")]
        public string Nickname { get; set; }
        [Display(Name = "QR 코드")]
        [StringLength(52, ErrorMessage = "QR코드는 최대 52자까지 입력 가능합니다.")]
        public string Rfid { get; set; }
        [Display(Name = "제조업체명")]
        [StringLength(40, ErrorMessage = "제조업체명은 최대 40자까지 입력 가능합니다.")]
        public string Manufacturer { get; set; }
        [Display(Name = "제조일")]
        [Column(TypeName = "date")]
        public DateTime? ManufactureDate { get; set; }
        [Display(Name = "제조번호")]
        [StringLength(20, ErrorMessage = "제조번호는 최대 20자까지 입력 가능합니다.")]
        public string ManufactureSerial { get; set; }
        [Display(Name = "모델명")]
        [StringLength(40, ErrorMessage = "모델명은 최대 40자까지 입력 가능합니다.")]
        public string ManufactureModel { get; set; }
        [Display(Name = "납품업체 명")]
        [StringLength(40, ErrorMessage = "납품업체명은 최대 40자까지 입력 가능합니다.")]
        public string Supplier { get; set; }
        [Display(Name = "납품업체 연락처")]
        [StringLength(20, ErrorMessage = "납품업체 연락처는 최대 20자까지 입력 가능합니다.")]
        public string SupplierPhoneNo { get; set; }
        [Display(Name = "빌딩 고유번호")]
        public int? BuildingId { get; set; }
        [Display(Name = "설치 위치(층)")]
        public int? FloorId { get; set; }
        [Display(Name = "설비 위치(존)")]
        public int? ZoneId { get; set; }
        [Display(Name = "설치 일자")]
        [Column(TypeName = "date")]
        public DateTime? InstallDate { get; set; }
        [Display(Name = "운전 시작일")]
        [Column(TypeName = "date")]
        public DateTime? OperationStartDate { get; set; }
        [Display(Name = "설비 용량")]
        [StringLength(40, ErrorMessage = "시설용량은 최대 40자까지 입력 가능합니다.")]
        public string FacilityCapacity { get; set; }
        [Display(Name = "시설 비용")]
        public int? FacilityCost { get; set; }
        [Display(Name = "설비 댓수")]
        public int? FacilityCount { get; set; }
        [Display(Name = "내용 연수")]
        public int? FacilitySeviceLifeYear { get; set; }
        [Display(Name = "설비 용도")]
        [StringLength(80, ErrorMessage = "시설용도는 최대 80자까지 입력 가능합니다.")]
        public string FacilityUsage { get; set; }
        [Display(Name = "정격소비용량")]
        [StringLength(40, ErrorMessage = "정격소비용량은 최대 40자까지 입력 가능합니다.")]
        public string RatedPowerConsumption { get; set; }
        [Display(Name = "정격 COP")]
        [Column("RatedCOP")]
        public double? RatedCop { get; set; }
        [Display(Name = "주 담당자")]
        [StringLength(24, ErrorMessage = "주 담당자는명은 최대 24자까지 입력 가능합니다.")]
        public string MainContactorUserId { get; set; }
        [Display(Name = "부 담당자")]
        [StringLength(24, ErrorMessage = "부 담당자명은 최대 24자까지 입력 가능합니다.")]
        public string SubContactorUserId { get; set; }
        [Display(Name = "비고")]
        [StringLength(1024, ErrorMessage = "비고는 최대 1024자까지 입력 가능합니다.")]
        public string Note { get; set; }
        [Display(Name = "예비 1")]
        [StringLength(64)]
        public string Reserved1 { get; set; }
        [Display(Name = "예비 2")]
        [StringLength(64)]
        public string Reserved2 { get; set; }
        [Display(Name = "사용 유무")]
        public bool? IsUse { get; set; }
        [Display(Name = "파일 고유번호")]
        public int? FileId { get; set; }
        [Display(Name = "가상시설 유무"), Required]
        public bool IsVirtualFacility { get; set; }
        [Display(Name = "연료유형")]
        public short? FuelTypeId { get; set; }
        [Display(Name = "에너지 계약 유형")]
        public short? ContractType { get; set; }
        [Display(Name = "배수")]
        public double Multiple { get; set; }
        [NotMapped]
        [Display(Name = "엑셀행번호")]
        public int ExcelRowNum { get; set; }
        [NotMapped]
        [Display(Name = "설비명 분리 Sort1")]
        public string Sort1 {
            get {
                return Name.Substring(0, Name.IndexOf("-") != -1 ? Name.IndexOf("-") : Name.Length);
            }
            set { }
        }
        [NotMapped]
        [Display(Name = "설비명 분리 Sort2")]
        public string Sort2 {
            get {
                return System.Text.RegularExpressions.Regex.Replace(Name, @"[^0-9]", "").PadLeft(3, '0');
            }
            set { }
        }

        [ForeignKey("SiteId")]
        public virtual CmSite CmSite { get; set; }
        [ForeignKey("SiteId,FileId")]
        public virtual CmFile CmFile { get; set; }

        [ForeignKey("FacilityTypeId")]
        public virtual BemsFacilityType BemsFacilityType { get; set; }

        [ForeignKey("SiteId,ParentFacilityCode")]
        public virtual CmFacility CmFacilityNavigation { get; set; }
        [InverseProperty("CmFacility")]
        public virtual BemsEnergyCost BemsEnergyCost { get; set; }
        [InverseProperty("CmFacility")]
        public virtual CmFacilityTempSet CmFacilityTempSet { get; set; }
        [InverseProperty("CmFacility")]
        public virtual FmsFacilityOperationItem FmsFacilityOperationItem { get; set; }

        [ForeignKey("FirstClassId")]
        public virtual FmsFacilityCodeClass FmsFacilityCodeClass { get; set; }
        [ForeignKey("SecondClassId")]
        public virtual FmsFacilityCodeClass FmsFacilityCodeClass1 { get; set; }
        [ForeignKey("ThirdClassId")]
        public virtual FmsFacilityCodeClass FmsFacilityCodeClass2 { get; set; }

        [ForeignKey("SiteId,BuildingId")]
        public virtual CmBuilding CmBuilding { get; set; }
        [ForeignKey("SiteId,BuildingId,FloorId")]
        public virtual CmFloor CmFloor { get; set; }
        [ForeignKey("SiteId,BuildingId,FloorId,ZoneId")]
        public virtual CmZone CmZone { get; set; }

        [ForeignKey("MainContactorUserId")]
        public virtual CmUser MainContactor { get; set; }
        [ForeignKey("SubContactorUserId")]
        public virtual CmUser SubContactor { get; set; }

        [ForeignKey("FuelTypeId")]
        public virtual BemsFuelType BemsFuelType { get; set; }

        [ForeignKey("FuelTypeId,ContractType")]
        public virtual BemsNoticePriceContractType BemsNoticePriceContractType { get; set; }

        /*
        [ForeignKey("SiteId,ContractType")]
        public virtual FmsContractType FmsContractType { get; set; }
        */

        [InverseProperty("CmFacility")]
        public virtual ICollection<BemsAlarmSetting> BemsAlarmSetting { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<BemsFormulaParameter> BemsFormulaParameter { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<BemsMonitoringPoint> BemsMonitoringPoint { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<BemsPeakFacility> BemsPeakFacility { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<CmFacilityFile> CmFacilityFile { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<FmsFacilityManual> FmsFacilityManual { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<FmsWorkOrderToFacility> FmsWorkOrderToFacility { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<FmsWorkRequestToFacility> FmsWorkRequestToFacility { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<FmsWorkResultCheckItem> FmsWorkResultCheckItem { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<FmsWorkResultToFacility> FmsWorkResultToFacility { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<FmsWorkScheduleToFacility> FmsWorkScheduleToFacility { get; set; }
        [InverseProperty("CmFacilityNavigation")]
        public virtual ICollection<CmFacility> InverseCmFacilityNavigation { get; set; }

        [InverseProperty("Facility")]
        public virtual ICollection<FmsAlarmPoint> FmsAlarmPointList { get; set; }
        [InverseProperty("Facility")]
        public virtual ICollection<FmsAlarmLog> FmsAlarmLogList { get; set; }
        [InverseProperty("CmFacility")]
        public virtual ICollection<BemsReportFormatToFacility> BemsReportFormatToFacility { get; set; }

    }
}
