提交 8e63bc7d 编写于 作者: W wq1234wq

规则下发

上级 f1e55892
......@@ -164,20 +164,23 @@ namespace IoTSharp.Controllers
}
[HttpGet("[action]")]
public AppMessage<FlowRule> BindDevice (ModelRuleBind m)
public async Task<AppMessage<FlowRule>> BindDevice (ModelRuleBind m)
{
var profile = this.GetUserProfile();
var profile =await this.GetUserProfile();
if (m.dev != null)
{
m.dev.ToList().ForEach(d => {
if (_context.DeviceRules.Any(c => c.RuleId == m.rule && c.DeviceId == d)) {
var dr = new DeviceRule();
dr.DeviceId = d;
dr.ConfigDateTime=DateTime.Now;
dr.ConfigUser = profile.Id;
dr.RuleId = m.rule;
_context.DeviceRules.Add(dr);
_context.SaveChanges();
}
});
......@@ -188,7 +191,7 @@ namespace IoTSharp.Controllers
// return new AppMessage<FlowRule> { ErrType = ErrType.正常返回, Result = rule };
//}
return new AppMessage<FlowRule> { ErrType = ErrType.找不到对象, };
return new AppMessage<FlowRule> { ErrType = ErrType.参数错误, ErrMessage = "请选择下发设备"};
}
......
......@@ -201,5 +201,8 @@
<ProjectReference Include="..\IoTSharp.Data.SqlServer\IoTSharp.Data.SqlServer.csproj" />
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="ClientApp\" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties clientapp_4package_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册