Former-commit-id: 8fac41ee24044d880210917992c00c09764fd111
Former-commit-id: 4584c9a338c44797482b24fca0c21981b5556339
1.0
wanggang 5 years ago
parent 6f98007552
commit 1f19e8d5ed

@ -1,56 +0,0 @@
using Infrastructure.Application;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoT.Shared.Application.Domain.Entities;
using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
{
[Authorize]
[ApiController]
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTApiController : CrudController<IoTApi, EditApiModel>
{
private readonly AjaxBaseController _ajax;
public IoTApiController(IRepository<IoTApi> repo, AjaxBaseController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<IoTApi> Include(IQueryable<IoTApi> query)
{
return query.Include(o => o.Product);
}
public override IQueryable<IoTApi> Query(PagedListModel<EditApiModel> model, IQueryable<IoTApi> query)
{
ViewData.SelectList(o => model.Query.ProductId, () => this._ajax.GetIoTProduct(model.Query.ProductId).SelectList());
return query
.WhereIf(model.Query.ProductId.HasValue, o => o.ProductId == model.Query.ProductId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.Path), o => o.Path.Contains(model.Query.Path))
.WhereIf(!string.IsNullOrEmpty(model.Query.Command), o => o.Command.Contains(model.Query.Command))
.WhereIf(!string.IsNullOrEmpty(model.Query.Method), o => o.Method.Contains(model.Query.Method));
}
public override void ToDisplayModel(IoTApi entity, EditApiModel model)
{
ViewData.Add(model.ProductId, entity?.Product?.Name);
}
public override void ToEditModel(IoTApi entity, EditApiModel model)
{
this.ToDisplayModel(entity, model);
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProduct(model.ProductId).SelectList());
}
}
}

@ -1,64 +0,0 @@
using Infrastructure.Application;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoT.Shared.Application.Domain.Entities;
using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
{
[Authorize]
[ApiController]
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTParameterController : CrudController<IoTParameter, EditParameterModel>
{
private readonly AjaxBaseController _ajax;
public IoTParameterController(IRepository<IoTParameter> repo, AjaxBaseController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<IoTParameter> Include(IQueryable<IoTParameter> query)
{
return query.Include(o => o.Api).ThenInclude(o => o.Product);
}
public override IQueryable<IoTParameter> Query(PagedListModel<EditParameterModel> model, IQueryable<IoTParameter> query)
{
return base.Query(model, query)
.WhereIf(model.Query.Required.HasValue, o => o.Required == model.Query.Required.Value)
.WhereIf(model.Query.ProductId.HasValue, o => o.Api.ProductId == model.Query.ProductId.Value)
.WhereIf(model.Query.ApiId.HasValue, o => o.ApiId == model.Query.ApiId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Type), o => o.Type.Contains(model.Query.Type))
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.Description), o => o.Description.Contains(model.Query.Description))
.WhereIf(!string.IsNullOrEmpty(model.Query.Minimum), o => o.Minimum == model.Query.Minimum)
.WhereIf(!string.IsNullOrEmpty(model.Query.Maxinum), o => o.Maxinum == model.Query.Maxinum);
}
public override void ToDisplayModel(IoTParameter entity, EditParameterModel model)
{
model.ProductId = entity?.Api.ProductId;
ViewData.Add(model.ProductId, entity?.Api?.Product?.Name);
ViewData.Add(model.ApiId, entity?.Api?.Name);
}
public override void ToEditModel(IoTParameter entity, EditParameterModel model)
{
model.ProductId = entity?.Api?.ProductId;
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProduct(model.ProductId).SelectList());
if(model.ProductId.HasValue)
{
ViewData.SelectList(o => model.ApiId, () => this._ajax.GetIoTApi(model.ProductId.Value, model.ApiId).SelectList());
}
}
}
}

@ -1,7 +0,0 @@
@inherits Infrastructure.Web.Mvc.Razor.MyRazorPage<TModel>
@using Infrastructure.Application
@using Infrastructure.Extensions
@using Infrastructure.Data
@using IoT.Shared.Application.Domain.Entities
@using IoT.Shared.Application.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@ -0,0 +1,66 @@
using Infrastructure.Application;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoT.Shared.Application.Domain.Entities;
using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
{
[Authorize]
[ApiController]
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTDataController : CrudController<IoTData, EditDataModel>
{
private readonly AjaxBaseController _ajax;
public IoTDataController(IRepository<IoTData> repo, AjaxBaseController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<IoTData> Include(IQueryable<IoTData> query)
{
return query.Include(o => o.Device).ThenInclude(o => o.Node);
}
public override IQueryable<IoTData> Query(PagedListModel<EditDataModel> model, IQueryable<IoTData> query)
{
return query.WhereIf(model.Query.NodeId.HasValue, o => o.Device.NodeId == model.Query.NodeId.Value)
.WhereIf(model.Query.DeviceId.HasValue, o => o.DeviceId == model.Query.DeviceId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.Key), o => o.Key.Contains(model.Query.Key))
.WhereIf(!string.IsNullOrEmpty(model.Query.Value), o => o.Value.Contains(model.Query.Value))
.WhereIf(model.Query.Type.HasValue, o => o.Type == model.Query.Type.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Unit), o => o.Unit.Contains(model.Query.Unit))
.WhereIf(!string.IsNullOrEmpty(model.Query.Description), o => o.Description.Contains(model.Query.Description))
.WhereIf(model.Query.Timestamp.HasValue, o => o.Timestamp == model.Query.Timestamp.Value)
.WhereIf(model.Query.Hidden.HasValue, o => o.Hidden == model.Query.Hidden.Value)
.OrderBy(o => o.Device.ProductId).ThenBy(o => o.Device.NodeId).ThenBy(o => o.DeviceId);
}
public override void ToDisplayModel(IoTData entity, EditDataModel model)
{
model.NodeId = entity?.Device?.NodeId;
ViewData.Add(model.DeviceId, entity?.Device?.Name);
ViewData.Add(model.NodeId, entity?.Device?.Node?.Name);
}
public override void ToEditModel(IoTData entity, EditDataModel model)
{
model.NodeId = entity?.Device?.NodeId;
ViewData.SelectList(o => model.NodeId, () => this._ajax.GetIoTGateway(model.NodeId).SelectList());
if (model.NodeId.HasValue)
{
ViewData.SelectList(o => model.DeviceId, () => this._ajax.GetIoTDevice(model.NodeId.Value, model.DeviceId).SelectList());
}
}
}
}

@ -0,0 +1,65 @@
using Infrastructure.Application;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Infrastructure.Web.Mvc;
using IoT.Shared.Application.Domain.Entities;
using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
{
[Authorize]
[ApiController]
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTDeviceController : CrudController<IoTDevice, EditDeviceModel>
{
private readonly AjaxBaseController _ajax;
public IoTDeviceController(IRepository<IoTDevice> repo, AjaxBaseController ajax) : base(repo)
{
this._ajax = ajax;
}
public override IQueryable<IoTDevice> Include(IQueryable<IoTDevice> query)
{
return query.Include(o => o.Product).Include(o => o.Node);
}
public override IQueryable<IoTDevice> Query(PagedListModel<EditDeviceModel> model, IQueryable<IoTDevice> query)
{
return query
.WhereIf(model.Query.NodeId.HasValue, o => o.NodeId == model.Query.NodeId.Value)
.WhereIf(model.Query.ProductId.HasValue, o => o.ProductId == model.Query.ProductId.Value)
.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.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.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.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.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.Disabled.HasValue, o => o.Disabled == model.Query.Disabled.Value);
}
public override void ToDisplayModel(IoTDevice entity, EditDeviceModel model)
{
ViewData.Add(model.NodeId, entity?.Node?.Name);
ViewData.Add(model.ProductId, entity?.Product?.Name);
}
public override void ToEditModel(IoTDevice entity, EditDeviceModel model)
{
ViewData.SelectList(o => model.NodeId, () => this._ajax.GetIoTGateway(model.NodeId).SelectList());
ViewData.SelectList(o => model.ProductId, () => this._ajax.GetIoTProduct(model.ProductId).SelectList());
}
}
}

@ -6,6 +6,7 @@ using IoT.Shared.Application.Domain.Entities;
using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
@ -15,22 +16,20 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
[Route("IoTCenter/[controller]/[action]")]
[Area("IoTCenter")]
[ControllerScope(ControllerScopeType.Platform)]
public class IoTProductController : CrudController<IoTProduct, EditProductModel>
public class IoTGatewayController : CrudController<IoTGateway, EditIoTGatewayModel>
{
public IoTProductController(IRepository<IoTProduct> repo) : base(repo)
public IoTGatewayController(IRepository<IoTGateway> repo) : base(repo)
{
}
public override IQueryable<IoTProduct> Query(PagedListModel<EditProductModel> model, IQueryable<IoTProduct> query)
public override IQueryable<IoTGateway> Query(PagedListModel<EditIoTGatewayModel> model, IQueryable<IoTGateway> query)
{
return base.Query(model, query)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.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.Path), o => o.Path.Contains(model.Query.Path))
.WhereIf(!string.IsNullOrEmpty(model.Query.Path), o => o.Path.Contains(model.Query.Path))
.WhereIf(!string.IsNullOrEmpty(model.Query.ApiJson), o => o.ApiJson.Contains(model.Query.ApiJson))
.OrderBy(o => o.Number);
.WhereIf(!string.IsNullOrEmpty(model.Query.Version), o => o.Version.Contains(model.Query.Version))
.WhereIf(model.Query.IsOnline.HasValue, o => o.IsOnline == model.Query.IsOnline.Value)
.WhereIf(model.Query.Hidden.HasValue, o => o.Hidden == model.Query.Hidden.Value);
}
}
}

@ -15,7 +15,7 @@ namespace IoTNode.Services
IEventHander<EntityInsertedEvent<IoTParameter>>,
IEventHander<EntityUpdatedEvent<IoTParameter>>,
IEventHander<EntityDeletedEvent<IoTParameter>>,
IEventHander<EntityUpdatedEvent<IoT.Shared.Application.Domain.Entities.IoTGateway>>,
IEventHander<EntityUpdatedEvent<IoTGateway>>,
IEventHander<EntityInsertedEvent<IoTDevice>>,
IEventHander<EntityUpdatedEvent<IoTDevice>>,
IEventHander<EntityDeletedEvent<IoTDevice>>,
@ -105,7 +105,7 @@ namespace IoTNode.Services
this.ClientToServer(message);
}
public void Handle(EntityUpdatedEvent<IoT.Shared.Application.Domain.Entities.IoTGateway> message)
public void Handle(EntityUpdatedEvent<IoTGateway> message)
{
this.ClientToServer(message);
}

@ -7,7 +7,6 @@ using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
namespace IoT.Shared.Areas.IoTCenter.Controlls
@ -39,30 +38,5 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
{
return model.Number;
}
public override IActionResult Delete(List<Guid> list)
{
if (this.isPlatform)
{
foreach (var id in list)
{
try
{
this.Repo.Delete(this.Repo.Table().FirstOrDefault(o => o.Id == id));
this.Repo.SaveChanges();
}
catch (Exception ex)
{
ex.PrintStack();
return Error(ex.Message);
}
}
return Success();
}
else
{
return base.Delete(list);
}
}
}
}

@ -0,0 +1,10 @@
<script>
$('#Query_NodeId').change(function () {
var id = $(this).find(':selected').val();
update('@Url.Action("GetIoTDevice", "Ajax",new { area=""})', id, "#Query_DeviceId");
});
$('#NodeId').change(function () {
var id = $(this).find(':selected').val();
update('@Url.Action("GetIoTDevice", "Ajax",new { area=""})', id, "#DeviceId");
});
</script>

@ -0,0 +1,10 @@
<script>
$('#Query_ProductId').change(function () {
var id = $(this).find(':selected').val();
update('@Url.Action("GetIoTApi", "Ajax",new { area=""})', id, "#Query_ApiId");
});
$('#ProductId').change(function () {
var id = $(this).find(':selected').val();
update('@Url.Action("GetIoTApi", "Ajax",new { area=""})', id, "#ApiId");
});
</script>
Loading…
Cancel
Save