1.0.0.803d1

Former-commit-id: 48c052b7e1625c4d34ad0f37b8cd15359e86f3ad
Former-commit-id: 211e3201b85656cba047eeccc1e6817295ec04c1
TSXN
wanggang 5 years ago
parent 1f023e20e4
commit 8ebe8810d1

@ -45,5 +45,6 @@ namespace Application.Domain.Entities
public List<Device> Devices { get; set; } = new List<Device>(); public List<Device> Devices { get; set; } = new List<Device>();
public List<Scene> Scenes { get; set; } = new List<Scene>(); public List<Scene> Scenes { get; set; } = new List<Scene>();
public List<OrganNode> OrganNodes { get; set; } = new List<OrganNode>();
} }
} }

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace IoTCenter.Application.Domain namespace Application.Domain.Entities
{ {
[Display(Name = "节点类型")] [Display(Name = "节点类型")]
public class NodeCategory : BaseEntity public class NodeCategory : BaseEntity

@ -1,9 +1,8 @@
using Application.Domain.Entities; using Infrastructure.Domain;
using Infrastructure.Domain;
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace IoTCenter.Application.Domain namespace Application.Domain.Entities
{ {
[Display(Name = "节点分类")] [Display(Name = "节点分类")]
public class NodeCategoryNode : BaseEntity public class NodeCategoryNode : BaseEntity

@ -3,7 +3,7 @@ using Infrastructure.Web.Mvc;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace IoTCenter.Application.Domain namespace Application.Domain.Entities
{ {
[GeneratedController] [GeneratedController]
[Display(Name = "机构")] [Display(Name = "机构")]

@ -1,9 +1,8 @@
using Application.Domain.Entities; using Infrastructure.Domain;
using Infrastructure.Domain;
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace IoTCenter.Application.Domain namespace Application.Domain.Entities
{ {
[Display(Name = "机构节点")] [Display(Name = "机构节点")]
public class OrganNode : BaseEntity public class OrganNode : BaseEntity

@ -1,9 +1,8 @@
using Application.Domain.Entities; using Infrastructure.Domain;
using Infrastructure.Domain;
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace IoTCenter.Application.Domain namespace Application.Domain.Entities
{ {
[Display(Name = "机构用户")] [Display(Name = "机构用户")]
public class OrganUser : BaseEntity public class OrganUser : BaseEntity

@ -14,5 +14,6 @@ namespace Application.Domain.Entities
public string PasswordHash { get; set; } public string PasswordHash { get; set; }
public string Email { get; set; } public string Email { get; set; }
public List<UserRole> UserRoles { get; set; } = new List<UserRole>(); public List<UserRole> UserRoles { get; set; } = new List<UserRole>();
public List<OrganUser> OrganUsers { get; set; } = new List<OrganUser>();
} }
} }

@ -1,5 +1,4 @@
using Infrastructure.Application; using Infrastructure.Application;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;

@ -8,11 +8,16 @@ namespace Application.Models
public class EditSceneModel : EditModel public class EditSceneModel : EditModel
{ {
[DataType("SelectList")] [DataType("SelectList")]
[Display(Name = "场景节点")] [Display(Name = "机构")]
[Required(ErrorMessage = nameof(RequiredAttribute))]
public Guid? OrganId { get; set; }
[DataType("SelectList")]
[Display(Name = "节点")]
[Required(ErrorMessage = nameof(RequiredAttribute))] [Required(ErrorMessage = nameof(RequiredAttribute))]
public Guid? NodeId { get; set; } public Guid? NodeId { get; set; }
[Display(Name = "场景名称")] [Display(Name = "名称")]
[MaxLength(24, ErrorMessage = "{0}最大长度为{1}")] [MaxLength(24, ErrorMessage = "{0}最大长度为{1}")]
[Required(ErrorMessage = nameof(RequiredAttribute))] [Required(ErrorMessage = nameof(RequiredAttribute))]
public string Name { get; set; } public string Name { get; set; }

@ -22,6 +22,7 @@
/// hex /// hex
/// </summary> /// </summary>
public string Message { get; set; } public string Message { get; set; }
public int Order { get; set; } public int Order { get; set; }
} }
} }

@ -1,5 +1,4 @@
using Application.Domain.Entities; using Infrastructure.Application;
using Infrastructure.Application;
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;

@ -48,7 +48,7 @@ namespace IoT.Shared.Areas.Admin.Controlls
{ {
try try
{ {
this.Repo.Delete(this.Repo.Table().Include(o => o.Scenes).FirstOrDefault(o => o.Id == id)); this.Repo.Delete(this.Repo.Table().FirstOrDefault(o => o.Id == id));
this.Repo.SaveChanges(); this.Repo.SaveChanges();
} }
catch (Exception ex) catch (Exception ex)

@ -42,12 +42,26 @@ namespace IoT.Shared
modelBuilder.Entity<Data>().HasOne(o => o.Device).WithMany(o => o.Data).HasForeignKey(o => o.DeviceId); modelBuilder.Entity<Data>().HasOne(o => o.Device).WithMany(o => o.Data).HasForeignKey(o => o.DeviceId);
// //
modelBuilder.Entity<Command>().HasOne(o => o.Api).WithMany(o => o.Commands).HasForeignKey(o => o.ApiId); modelBuilder.Entity<Command>().HasOne(o => o.Api).WithMany(o => o.Commands).HasForeignKey(o => o.ApiId);
modelBuilder.Entity<Scene>().HasOne(o => o.Node).WithMany(o => o.Scenes).HasForeignKey(o => o.NodeId); modelBuilder.Entity<Scene>().HasOne(o => o.Node).WithMany(o => o.Scenes).HasForeignKey(o => o.NodeId).OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<SceneCommand>().HasOne(o => o.Scene).WithMany(o => o.SceneCommands).HasForeignKey(o => o.SceneId); modelBuilder.Entity<SceneCommand>().HasOne(o => o.Scene).WithMany(o => o.SceneCommands).HasForeignKey(o => o.SceneId);
modelBuilder.Entity<SceneCommand>().HasOne(o => o.Command).WithMany(o => o.SceneCommands).HasForeignKey(o => o.CommandId); modelBuilder.Entity<SceneCommand>().HasOne(o => o.Command).WithMany(o => o.SceneCommands).HasForeignKey(o => o.CommandId);
modelBuilder.Entity<SceneTimer>().HasOne(o => o.Scene).WithMany(o => o.SceneTimers).HasForeignKey(o => o.SceneId); modelBuilder.Entity<SceneTimer>().HasOne(o => o.Scene).WithMany(o => o.SceneTimers).HasForeignKey(o => o.SceneId);
modelBuilder.Entity<SceneTigger>().HasOne(o => o.Scene).WithMany(o => o.SceneTiggers).HasForeignKey(o => o.SceneId); modelBuilder.Entity<SceneTigger>().HasOne(o => o.Scene).WithMany(o => o.SceneTiggers).HasForeignKey(o => o.SceneId);
modelBuilder.Entity<SceneTigger>().HasOne(o => o.Data).WithMany(o => o.Tiggers).HasForeignKey(o => o.DataId); modelBuilder.Entity<SceneTigger>().HasOne(o => o.Data).WithMany(o => o.Tiggers).HasForeignKey(o => o.DataId);
//
modelBuilder.Entity<NodeCategory>().HasIndex(o => o.Name).IsUnique();
modelBuilder.Entity<NodeCategoryNode>().HasOne(o => o.Node).WithMany().HasForeignKey(o => o.NodeId);
modelBuilder.Entity<NodeCategoryNode>().HasOne(o => o.Category).WithMany(o => o.CategoryNodes).HasForeignKey(o => o.CategoryId);
modelBuilder.Entity<NodeCategoryNode>().HasIndex(o => new { o.CategoryId, o.NodeId }).IsUnique();
modelBuilder.Entity<Organ>().Property(o => o.Number).IsRequired();
modelBuilder.Entity<Organ>().HasIndex(o => o.Number).IsUnique();
modelBuilder.Entity<OrganUser>().HasOne(o => o.Organ).WithMany(o => o.OrganUsers).HasForeignKey(o => o.OrganId);
modelBuilder.Entity<OrganUser>().HasOne(o => o.User).WithMany(o => o.OrganUsers).HasForeignKey(o => o.UserId);
modelBuilder.Entity<OrganUser>().HasIndex(o => new { o.OrganId, o.UserId }).IsUnique();
modelBuilder.Entity<OrganNode>().HasOne(o => o.Organ).WithMany(o => o.OrganNodes).HasForeignKey(o => o.OrganId);
modelBuilder.Entity<OrganNode>().HasOne(o => o.Organ).WithMany(o => o.OrganNodes).HasForeignKey(o => o.OrganId);
modelBuilder.Entity<OrganNode>().HasOne(o => o.Node).WithMany(o => o.OrganNodes).HasForeignKey(o => o.NodeId);
modelBuilder.Entity<OrganNode>().HasIndex(o => new { o.OrganId, o.NodeId }).IsUnique();
} }
public static void Seed(DbContext db) public static void Seed(DbContext db)

@ -3,7 +3,6 @@ using Application.Models;
using Infrastructure.Application.Services.Settings; using Infrastructure.Application.Services.Settings;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using IoTCenter.Application.Domain;
using IoTCenter.Services; using IoTCenter.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;

@ -2,7 +2,6 @@
using Infrastructure.Application.Services.Settings; using Infrastructure.Application.Services.Settings;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using IoTCenter.Application.Domain;
using IoTCenter.Services; using IoTCenter.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;

@ -1,7 +1,6 @@
using Application.Domain.Entities; using Application.Domain.Entities;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using IoTCenter.Application.Domain;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;

@ -1,7 +1,6 @@
using Application.Domain.Entities; using Application.Domain.Entities;
using Infrastructure.Application; using Infrastructure.Application;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Events;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using Infrastructure.Web.Mvc; using Infrastructure.Web.Mvc;
using IoT.Shared.Areas.Admin.Controlls; using IoT.Shared.Areas.Admin.Controlls;

@ -1,4 +1,4 @@
using IoTCenter.Application.Domain; using Application.Domain.Entities;
using Infrastructure.Application; using Infrastructure.Application;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions; using Infrastructure.Extensions;

@ -1,9 +1,9 @@
using Application.Domain.Entities;
using Infrastructure.Application; using Infrastructure.Application;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using Infrastructure.Web.Mvc; using Infrastructure.Web.Mvc;
using IoT.Shared.Areas.Admin.Controlls; using IoT.Shared.Areas.Admin.Controlls;
using IoTCenter.Application.Domain;
using IoTCenter.Application.Models; using IoTCenter.Application.Models;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;

@ -1,5 +1,4 @@
using Application.Domain.Entities; using System.Collections.Generic;
using System.Collections.Generic;
namespace IoTCenter.Areas.Admin.ViewModels namespace IoTCenter.Areas.Admin.ViewModels
{ {

@ -1,16 +1,9 @@
using Application.Domain.Entities; using Application.Domain.Entities;
using Infrastructure.Data; using Infrastructure.Data;
using Infrastructure.Extensions;
using IoTCenter.Application.Domain;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using Vibrant.InfluxDB.Client;
using Vibrant.InfluxDB.Client.Rows;
namespace IoTCenter.Controllers namespace IoTCenter.Controllers
{ {

@ -28,18 +28,6 @@ namespace IoTCenter
{ {
IoTSharedDbConfig.OnModelCreating(modelBuilder); IoTSharedDbConfig.OnModelCreating(modelBuilder);
modelBuilder.Entity<LiveRecord>().Property(o => o.DeviceNumber).IsRequired(); modelBuilder.Entity<LiveRecord>().Property(o => o.DeviceNumber).IsRequired();
modelBuilder.Entity<NodeCategory>().HasIndex(o => o.Name).IsUnique();
modelBuilder.Entity<NodeCategoryNode>().HasOne(o => o.Node).WithMany().HasForeignKey(o => o.NodeId);
modelBuilder.Entity<NodeCategoryNode>().HasOne(o => o.Category).WithMany(o => o.CategoryNodes).HasForeignKey(o => o.CategoryId);
modelBuilder.Entity<NodeCategoryNode>().HasIndex(o => new { o.CategoryId, o.NodeId }).IsUnique();
modelBuilder.Entity<Organ>().Property(o => o.Number).IsRequired();
modelBuilder.Entity<Organ>().HasIndex(o => o.Number).IsUnique();
modelBuilder.Entity<OrganUser>().HasOne(o => o.Organ).WithMany(o => o.OrganUsers).HasForeignKey(o => o.OrganId);
modelBuilder.Entity<OrganUser>().HasOne(o => o.User).WithMany().HasForeignKey(o => o.UserId);
modelBuilder.Entity<OrganUser>().HasIndex(o => new { o.OrganId, o.UserId }).IsUnique();
modelBuilder.Entity<OrganNode>().HasOne(o => o.Organ).WithMany(o => o.OrganNodes).HasForeignKey(o => o.OrganId);
modelBuilder.Entity<OrganNode>().HasOne(o => o.Node).WithMany().HasForeignKey(o => o.NodeId);
modelBuilder.Entity<OrganNode>().HasIndex(o => new { o.OrganId, o.NodeId }).IsUnique();
} }
public void Seed(DbContext db) public void Seed(DbContext db)

@ -5,7 +5,6 @@ using Infrastructure.Data;
using Infrastructure.Events; using Infrastructure.Events;
using Infrastructure.Extensions; using Infrastructure.Extensions;
using IoT.Shared.Services.IoTCenter; using IoT.Shared.Services.IoTCenter;
using IoTCenter.Application.Domain;
using Jint; using Jint;
using Jint.Native; using Jint.Native;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;

Loading…
Cancel
Save