Former-commit-id: c181872a59e5ee8f7ae7e168f5d9edab10ad67c6
Former-commit-id: 09fb3a5a8cc2764d0119b9dce959a8cdd2d98b18
1.0
wanggang 5 years ago
parent 63aa6a8979
commit bad856647d

@ -71,9 +71,13 @@
{ {
continue; continue;
} }
if(scope=="Organ"&&item.Name=="OrganId") if (item.CustomAttributes.Any(o => o.AttributeType == typeof(SkipListAttribute)))
{ {
continue; continue;
}
if (scope=="Organ"&&item.Name=="OrganId")
{
continue;
} }
<th style="white-space: nowrap;">@item.GetDisplayName()</th> <th style="white-space: nowrap;">@item.GetDisplayName()</th>
} }

@ -1,6 +1,7 @@
@using System.Reflection @using System.Reflection
@using Microsoft.AspNetCore.Mvc.Controllers @using Microsoft.AspNetCore.Mvc.Controllers
@using Infrastructure.Web.Mvc @using Infrastructure.Web.Mvc
@using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata
@{ @{
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope; var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit).ToList(); var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit).ToList();
@ -14,7 +15,11 @@
Html.Hidden(prop.PropertyName); Html.Hidden(prop.PropertyName);
continue; continue;
} }
if (prop.PropertyName == "Id" || prop.PropertyName == "DisplayOrder" || prop.PropertyName == "Cron" || uihit == "ImageUrl" || uihit == "MultiSelectList" || uihit=="ImageUrl") if ((prop as DefaultModelMetadata).Attributes.Attributes.Any(o => o.GetType() == typeof(SkipSearchAttribute)))
{
continue;
}
if (prop.PropertyName == "Id" || prop.PropertyName == "DisplayOrder" || prop.PropertyName == "Cron" || uihit == "ImageUrl" || uihit == "MultiSelectList" || uihit == "ImageUrl")
{ {
continue; continue;
} }

@ -1,6 +1,7 @@
@using System.Reflection @using System.Reflection
@using Microsoft.AspNetCore.Mvc.Controllers @using Microsoft.AspNetCore.Mvc.Controllers
@using Infrastructure.Web.Mvc @using Infrastructure.Web.Mvc
@using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
@{ @{
var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope; var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute<ControllerScopeAttribute>()?.Scope;
var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml && !pm.IsComplexType && !pm.IsCollectionType); var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml && !pm.IsComplexType && !pm.IsCollectionType);
@ -8,10 +9,15 @@
@{ @{
foreach (var prop in props) foreach (var prop in props)
{ {
var metadata = prop as DefaultModelMetadata;
if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId") if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId")
{ {
continue; continue;
} }
if (metadata.Attributes.Attributes.Any(o => o.GetType() == typeof(SkipListAttribute)))
{
continue;
}
var templateName = prop.DataTypeName ?? prop.TemplateHint ?? (prop.ModelType == typeof(string) ? typeof(string).Name : null); var templateName = prop.DataTypeName ?? prop.TemplateHint ?? (prop.ModelType == typeof(string) ? typeof(string).Name : null);
<td style="white-space: nowrap;text-overflow:ellipsis;overflow: hidden;max-width:10em;" data-ext="@templateName"> <td style="white-space: nowrap;text-overflow:ellipsis;overflow: hidden;max-width:10em;" data-ext="@templateName">
@Html.Display(prop.PropertyName, templateName) @Html.Display(prop.PropertyName, templateName)

@ -0,0 +1,6 @@
namespace System.ComponentModel.DataAnnotations
{
public class SkipListAttribute : Attribute
{
}
}

@ -0,0 +1,6 @@
namespace System.ComponentModel.DataAnnotations
{
public class SkipSearchAttribute : Attribute
{
}
}

@ -10,7 +10,7 @@ namespace IoT.Shared.Application.Models
[ReadOnlyForEdit] [ReadOnlyForEdit]
[Display(Name = "产品")] [Display(Name = "产品")]
[SelectList] [SelectList]
public Guid? ProductId { get; set; } public Guid? IoTProductId { get; set; }
[ReadOnlyForEdit] [ReadOnlyForEdit]
[SelectList] [SelectList]
@ -40,6 +40,8 @@ namespace IoT.Shared.Application.Models
[Display(Name = "用户名")] [Display(Name = "用户名")]
public string UserName { get; set; } public string UserName { get; set; }
[SkipSearch]
[SkipList]
[Display(Name = "密码")] [Display(Name = "密码")]
public string Password { get; set; } public string Password { get; set; }
@ -48,6 +50,7 @@ namespace IoT.Shared.Application.Models
[Required(ErrorMessage = nameof(RequiredAttribute))] [Required(ErrorMessage = nameof(RequiredAttribute))]
public string Number { get; set; } public string Number { get; set; }
[SkipSearch]
[Display(Name = "图标")] [Display(Name = "图标")]
public string Icon { get; set; } public string Icon { get; set; }
@ -55,6 +58,8 @@ namespace IoT.Shared.Application.Models
[Display(Name = "在线状态")] [Display(Name = "在线状态")]
public bool? IsOnline { get; set; } public bool? IsOnline { get; set; }
[SkipSearch]
[SkipList]
[Display(Name = "连接Id")] [Display(Name = "连接Id")]
[ReadOnlyForEdit] [ReadOnlyForEdit]
public string ConnectId { get; set; } public string ConnectId { get; set; }

@ -25,6 +25,7 @@ namespace IoT.Shared.Application.Models
[ReadOnlyForEdit] [ReadOnlyForEdit]
public string Path { get; set; } public string Path { get; set; }
[SkipList]
[Display(Name = "ApiJson")] [Display(Name = "ApiJson")]
[DataType(DataType.MultilineText)] [DataType(DataType.MultilineText)]
[ReadOnlyForEdit] [ReadOnlyForEdit]

@ -35,17 +35,14 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
{ {
return query return query
.WhereIf(model.Query.IoTGatewayId.HasValue, o => o.IoTGatewayId == model.Query.IoTGatewayId.Value) .WhereIf(model.Query.IoTGatewayId.HasValue, o => o.IoTGatewayId == model.Query.IoTGatewayId.Value)
.WhereIf(model.Query.ProductId.HasValue, o => o.IoTProductId == model.Query.ProductId.Value) .WhereIf(model.Query.IoTProductId.HasValue, o => o.IoTProductId == model.Query.IoTProductId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name)) .WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.DisplayName), o => o.DisplayName.Contains(model.Query.DisplayName)) .WhereIf(!string.IsNullOrEmpty(model.Query.DisplayName), o => o.DisplayName.Contains(model.Query.DisplayName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Gateway), o => o.Gateway.Contains(model.Query.Gateway)) .WhereIf(!string.IsNullOrEmpty(model.Query.Gateway), o => o.Gateway.Contains(model.Query.Gateway))
.WhereIf(!string.IsNullOrEmpty(model.Query.Tag), o => o.Tag.Contains(model.Query.Tag)) .WhereIf(!string.IsNullOrEmpty(model.Query.Tag), o => o.Tag.Contains(model.Query.Tag))
.WhereIf(!string.IsNullOrEmpty(model.Query.Ip), o => o.Ip.Contains(model.Query.Ip)) .WhereIf(!string.IsNullOrEmpty(model.Query.Ip), o => o.Ip.Contains(model.Query.Ip))
.WhereIf(!string.IsNullOrEmpty(model.Query.UserName), o => o.UserName.Contains(model.Query.UserName)) .WhereIf(!string.IsNullOrEmpty(model.Query.UserName), o => o.UserName.Contains(model.Query.UserName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Password), o => o.Password.Contains(model.Query.Password))
.WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number)) .WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number))
.WhereIf(!string.IsNullOrEmpty(model.Query.Icon), o => o.Icon.Contains(model.Query.Icon))
.WhereIf(!string.IsNullOrEmpty(model.Query.ConnectId), o => o.ConnectId.Contains(model.Query.ConnectId))
.WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value) .WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value)
.WhereIf(model.Query.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value); .WhereIf(model.Query.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value);
} }
@ -53,13 +50,13 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
public override void ToDisplayModel(IoTDevice entity, EditIoTDeviceModel model) public override void ToDisplayModel(IoTDevice entity, EditIoTDeviceModel model)
{ {
ViewData.Add(model.IoTGatewayId, entity?.IoTGateway?.Name); ViewData.Add(model.IoTGatewayId, entity?.IoTGateway?.Name);
ViewData.Add(model.ProductId, entity?.IoTProduct?.Name); ViewData.Add(model.IoTProductId, entity?.IoTProduct?.Name);
} }
public override void ToEditModel(IoTDevice entity, EditIoTDeviceModel model) public override void ToEditModel(IoTDevice entity, EditIoTDeviceModel model)
{ {
ViewData.SelectList(o => model.IoTGatewayId, () => this._ajax.GetIoTGateway(model.IoTGatewayId).SelectList()); ViewData.SelectList(o => model.IoTGatewayId, () => this._ajax.GetIoTGateway(model.IoTGatewayId).SelectList());
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProduct(model.ProductId).SelectList()); ViewData.SelectList(o => model.IoTProductId, () => this._ajax.GetIoTProduct(model.IoTProductId).SelectList());
} }
} }
} }

@ -60,6 +60,10 @@
{ {
continue; continue;
} }
if (item.CustomAttributes.Any(o => o.AttributeType == typeof(SkipListAttribute)))
{
continue;
}
if (scope == "Organ" && item.Name == "OrganId") if (scope == "Organ" && item.Name == "OrganId")
{ {
continue; continue;

@ -20,7 +20,7 @@ namespace Platform.Application.Models.IoTCenter
[Display(Name = "分类")] [Display(Name = "分类")]
[ReadOnlyForEdit] [ReadOnlyForEdit]
[SelectList(nameof(ProductId), nameof(AjaxController.GetIoTProductByCategory))] [SelectList(nameof(IoTProductId), nameof(AjaxController.GetIoTProductByCategory))]
public Guid? CategoryId { get; set; } public Guid? CategoryId { get; set; }
} }
} }

@ -54,17 +54,14 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
.WhereIf(model.Query.BuildingId.HasValue, o => o.IoTGateway.BuildingId == model.Query.BuildingId.Value) .WhereIf(model.Query.BuildingId.HasValue, o => o.IoTGateway.BuildingId == model.Query.BuildingId.Value)
.WhereIf(model.Query.IoTGatewayId.HasValue, o => o.IoTGatewayId == model.Query.IoTGatewayId.Value) .WhereIf(model.Query.IoTGatewayId.HasValue, o => o.IoTGatewayId == model.Query.IoTGatewayId.Value)
.WhereIf(model.Query.CategoryId.HasValue, o => o.IoTProduct.IoTProductCategoryId == model.Query.CategoryId.Value) .WhereIf(model.Query.CategoryId.HasValue, o => o.IoTProduct.IoTProductCategoryId == model.Query.CategoryId.Value)
.WhereIf(model.Query.ProductId.HasValue, o => o.IoTProductId == model.Query.ProductId.Value) .WhereIf(model.Query.IoTProductId.HasValue, o => o.IoTProductId == model.Query.IoTProductId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name)) .WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.DisplayName), o => o.DisplayName.Contains(model.Query.DisplayName)) .WhereIf(!string.IsNullOrEmpty(model.Query.DisplayName), o => o.DisplayName.Contains(model.Query.DisplayName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Gateway), o => o.Gateway.Contains(model.Query.Gateway)) .WhereIf(!string.IsNullOrEmpty(model.Query.Gateway), o => o.Gateway.Contains(model.Query.Gateway))
.WhereIf(!string.IsNullOrEmpty(model.Query.Tag), o => o.Tag.Contains(model.Query.Tag)) .WhereIf(!string.IsNullOrEmpty(model.Query.Tag), o => o.Tag.Contains(model.Query.Tag))
.WhereIf(!string.IsNullOrEmpty(model.Query.Ip), o => o.Ip.Contains(model.Query.Ip)) .WhereIf(!string.IsNullOrEmpty(model.Query.Ip), o => o.Ip.Contains(model.Query.Ip))
.WhereIf(!string.IsNullOrEmpty(model.Query.UserName), o => o.UserName.Contains(model.Query.UserName)) .WhereIf(!string.IsNullOrEmpty(model.Query.UserName), o => o.UserName.Contains(model.Query.UserName))
.WhereIf(!string.IsNullOrEmpty(model.Query.Password), o => o.Password.Contains(model.Query.Password))
.WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number)) .WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number))
.WhereIf(!string.IsNullOrEmpty(model.Query.Icon), o => o.Icon.Contains(model.Query.Icon))
.WhereIf(!string.IsNullOrEmpty(model.Query.ConnectId), o => o.ConnectId.Contains(model.Query.ConnectId))
.WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value) .WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value)
.WhereIf(model.Query.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value); .WhereIf(model.Query.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value);
} }
@ -108,9 +105,9 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
.FirstOrDefault(o => o.Id == model.CategoryId.Value)?.GetDisplayName(); .FirstOrDefault(o => o.Id == model.CategoryId.Value)?.GetDisplayName();
ViewData.Add(model.CategoryId, name); ViewData.Add(model.CategoryId, name);
} }
if (model.ProductId.HasValue) if (model.IoTProductId.HasValue)
{ {
ViewData.Add(model.ProductId, entity.IoTProduct.Name); ViewData.Add(model.IoTProductId, entity.IoTProduct.Name);
} }
if (model.IoTGatewayId.HasValue) if (model.IoTGatewayId.HasValue)
{ {
@ -123,7 +120,7 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
ViewData.SelectList(o => model.OrganId, () => this._ajax.GetOrgan(model.OrganId).SelectList()); ViewData.SelectList(o => model.OrganId, () => this._ajax.GetOrgan(model.OrganId).SelectList());
ViewData.SelectList(o => model.BuildingId, () => this._ajax.GetBuilding(model.OrganId.Value, model.BuildingId).SelectList(), model.OrganId.HasValue); ViewData.SelectList(o => model.BuildingId, () => this._ajax.GetBuilding(model.OrganId.Value, model.BuildingId).SelectList(), model.OrganId.HasValue);
ViewData.SelectList(o => model.CategoryId, () => this._ajax.GetIoTProductCategory(model.CategoryId).SelectList()); ViewData.SelectList(o => model.CategoryId, () => this._ajax.GetIoTProductCategory(model.CategoryId).SelectList());
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProductByCategory(model.CategoryId.Value, model.ProductId).SelectList(), model.CategoryId.HasValue); ViewData.SelectList(o => model.IoTProductId, () => this._ajax.GetIoTProductByCategory(model.CategoryId.Value, model.IoTProductId).SelectList(), model.CategoryId.HasValue);
} }
public override string GetNodeNumber(EditPlatformIoTDeviceModel model) public override string GetNodeNumber(EditPlatformIoTDeviceModel model)

Loading…
Cancel
Save