提交 4edc910a 编写于 作者: 麦壳饼's avatar 麦壳饼

调整引用等。

上级 bd463aab
......@@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MQTTnet" Version="3.0.14-rc4" />
<PackageReference Include="MQTTnet" Version="3.0.14-rc5" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
......
......@@ -21,6 +21,8 @@ using Microsoft.Extensions.Logging;
using IoTSharp.Storage;
using k8s.Models;
using Newtonsoft.Json.Linq;
using MQTTnet.AspNetCoreEx;
using MQTTnet.Server.Status;
namespace IoTSharp.Controllers
{
......@@ -38,9 +40,10 @@ namespace IoTSharp.Controllers
private readonly SignInManager<IdentityUser> _signInManager;
private readonly ILogger _logger;
private readonly IStorage _storage;
private readonly IMqttServerEx _serverEx;
public DevicesController(UserManager<IdentityUser> userManager,
SignInManager<IdentityUser> signInManager, ILogger<DevicesController> logger, ApplicationDbContext context, IMqttClientOptions mqtt,IStorage storage)
SignInManager<IdentityUser> signInManager, ILogger<DevicesController> logger, IMqttServerEx serverEx, ApplicationDbContext context, IMqttClientOptions mqtt,IStorage storage)
{
_context = context;
_mqtt = mqtt;
......@@ -48,6 +51,7 @@ namespace IoTSharp.Controllers
_signInManager = signInManager;
_logger = logger;
_storage = storage;
_serverEx = serverEx;
}
/// <summary>
......@@ -539,5 +543,32 @@ namespace IoTSharp.Controllers
return Ok(new ApiResult<Dic>(result.ret > 0 ? ApiCode.Success : ApiCode.NothingToDo, result.ret > 0 ? "OK" : "No Attribute save", new Dic(result.exceptions?.Select(f => new DicKV(f.Key, f.Value.Message)))));
}
}
/// <summary>
/// SessionStatus
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
[Authorize(Roles = nameof(UserRole.NormalUser))]
[HttpGet("SessionStatus")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesDefaultResponseType]
public async Task<ActionResult<IList<IMqttSessionStatus>>> GetSessionStatus(Guid deviceId)
{
return Ok( new ApiResult<IList<IMqttSessionStatus>>( ApiCode.Success,"OK", await _serverEx.GetSessionStatusAsync()));
}
/// <summary>
/// SessionStatus
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
[Authorize(Roles = nameof(UserRole.NormalUser))]
[HttpGet("ClientStatus")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesDefaultResponseType]
public async Task<ActionResult<IList<IMqttClientStatus>>> GetClientStatus(Guid deviceId)
{
return Ok(new ApiResult<IList<IMqttClientStatus>>(ApiCode.Success, "OK", await _serverEx.GetClientStatusAsync()));
}
}
}
\ No newline at end of file
......@@ -13,6 +13,10 @@ RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib n
RUN curl -o TDengine-client.tar.gz "https://www.taosdata.com/download/download-gettingStarted.php?pkg=tdengine_linux&pkgName=TDengine-client-2.0.12.0-Linux-x64.tar.gz" && \
tar -xzvf TDengine-client.tar.gz && rm TDengine-client.tar.gz -f && cd $(ls TDengine-client* -d) && ./install_client.sh && \
rm $(pwd) -rf
RUN echo "fs.file-max=6553500" >> /etc/sysctl.conf && \
echo "* soft nofile 65535" >> /etc/security/limits.conf && \
echo "* hard nofile 65535" >> /etc/security/limits.conf && \
echo "session required pam_limits.so" >> /etc/security/limits.conf
WORKDIR /app
EXPOSE 80
EXPOSE 1883
......
......@@ -88,9 +88,9 @@
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.1" />
<PackageReference Include="MQTTnet" Version="3.0.14-rc4" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.0.14-rc4" />
<PackageReference Include="MQTTnet.Extensions.Rpc" Version="3.0.14-rc4" />
<PackageReference Include="MQTTnet" Version="3.0.14-rc5" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.0.14-rc5" />
<PackageReference Include="MQTTnet.Extensions.Rpc" Version="3.0.14-rc5" />
<PackageReference Include="NetMQ" Version="4.0.1.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.1" />
<PackageReference Include="NSwag.AspNetCore" Version="13.9.4" />
......@@ -114,7 +114,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="MQTTnet.AspNetCoreEx" Version="3.0.13" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="3.0.14-rc4" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="3.0.14-rc5" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Migrations\**" />
......
......@@ -282,6 +282,20 @@
<param name="attributes">attributes</param>
<returns></returns>
</member>
<member name="M:IoTSharp.Controllers.DevicesController.GetSessionStatus(System.Guid)">
<summary>
SessionStatus
</summary>
<param name="deviceId"></param>
<returns></returns>
</member>
<member name="M:IoTSharp.Controllers.DevicesController.GetClientStatus(System.Guid)">
<summary>
SessionStatus
</summary>
<param name="deviceId"></param>
<returns></returns>
</member>
<member name="T:IoTSharp.Controllers.InstallerController">
<summary>
安装
......
......@@ -72,7 +72,7 @@ namespace IoTSharp
{
Configuration.Bind(setting);
}));
services.AddDbContextPool<ApplicationDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("IoTSharp")), poolSize: settings.DbContextPoolSize);
services.AddDbContextPool<ApplicationDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("IoTSharp")), poolSize: settings.DbContextPoolSize);
services.AddIdentity<IdentityUser, IdentityRole>()
.AddRoles<IdentityRole>()
.AddRoleManager<RoleManager<IdentityRole>>()
......@@ -168,7 +168,7 @@ namespace IoTSharp
healthChecks.AddRedis(settings.CachingUseRedisHosts,name: _hc_Caching);
break;
case CachingUseIn.LiteDB:
options.UseLiteDB(cfg => cfg.DBConfig = new EasyCaching.LiteDB.LiteDBDBOptions() { });
options.UseLiteDB(cfg => cfg.DBConfig = new EasyCaching.LiteDB.LiteDBDBOptions() { },name: "iotsharp");
break;
case CachingUseIn.InMemory:
default:
......@@ -242,9 +242,25 @@ namespace IoTSharp
{
case EventBusMQ.RabbitMQ:
var url = new Uri(Configuration.GetConnectionString("EventBusMQ"));
x.UseRabbitMQ(url);
x.UseRabbitMQ(cfg=>
{
cfg.ConnectionFactoryOptions = cf =>
{
cf.AutomaticRecoveryEnabled = true;
cf.Uri = new Uri(Configuration.GetConnectionString("EventBusMQ"));
};
});
//amqp://guest:guest@localhost:5672
healthChecks.AddRabbitMQ(url);
healthChecks.AddRabbitMQ( connectionFactory=>
{
var factory = new ConnectionFactory()
{
Uri = new Uri(Configuration.GetConnectionString("EventBusMQ")),
AutomaticRecoveryEnabled = true
};
return factory.CreateConnection();
}, _hc_EventBusMQ);
break;
case EventBusMQ.Kafka:
x.UseKafka(Configuration.GetConnectionString("EventBusMQ"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册