You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.6 KiB

3 years ago
using EC.Entity.CameraInfo;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Threading.Tasks;
#nullable disable
namespace EC.Service.CameraInfo
{
public class NvrInfoContext : BaseDbContext<NvrInfo>
{
public NvrInfoContext()
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<NvrInfo>(entity =>
{
entity.HasKey(e => e.NvrId);
entity.ToTable("NvrInfo");
entity.Property(e => e.NvrId).HasColumnName("NvrID");
entity.Property(e => e.NvrAddr).HasColumnType("VARCHAR (100)");
entity.Property(e => e.NvrEnable)
.IsRequired()
.HasColumnType("VARCHAR (2)");
entity.Property(e => e.NvrIp)
.IsRequired()
.HasColumnType("VARCHAR (18)")
.HasColumnName("NvrIP");
entity.Property(e => e.NvrName)
.IsRequired()
.HasColumnType("VARCHAR (30)");
entity.Property(e => e.NvrType).HasColumnType("VARCHAR (20)");
entity.Property(e => e.UserName).HasColumnType("VARCHAR (20)");
entity.Property(e => e.UserPwd).HasColumnType("VARCHAR (20)");
});
OnModelCreatingPartial(modelBuilder);
}
#region Operate
public List<string> GetNvrDeviceList()
{
List<string> list = new() { "海康", "大华", "宇视", "深广", "泰杰", "其它" };
return list;
}
public async Task<List<string>> GetNvrNameListAsync()
{
List<string> list = new();
List<NvrInfo> infos = await GetListAsync();
foreach (NvrInfo info in infos)
{
if (!list.Contains(info.NvrName))
{
list.Add(info.NvrName);
}
}
return list;
}
#endregion Operate
}
}