Ejemplo n.º 1
0
 /// <summary>
 /// 添加新的主机信息
 /// </summary>
 /// <param name="cache">当前登录用户的缓存</param>
 /// <param name="belongOrganizeId">当前用户所管理的组织机构ID</param>
 /// <param name="dtos">输入主机信息实体</param>
 /// <returns></returns>
 public OperationResult AddHosts(CacheUser cache, Guid[] belongOrganizeId, params HostInputDto[] dtos) => HostRepository.Insert(dtos,
                                                                                                                                checkAction: m =>
 {
     if (!cache.IsAdministrator)
     {
         if (!belongOrganizeId.Contains(m.Organize_Id))
         {
             throw new Exception($"id:主机{m.FullName}&{m.RegPackage}归属组织机构错误!");
         }
     }
     if (HostRepository.CheckExists(a => a.RegPackage == m.RegPackage))
     {
         throw new Exception($"id:主机{m.RegPackage}已经存在");
     }
 },
                                                                                                                                updateFunc: (dto, entity) =>
 {
     entity.CreatedTime = DateTime.Now;
     entity.HostRealTimeDataMany.Add(new HostRealTimeData
     {
         //在主机实时数据表添加数据
         HostOne    = entity,
         UpdateTime = DateTime.Now,
     });
     return(entity);
 });