Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
1c089166
Commit
1c089166
authored
Aug 13, 2019
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开始
parent
aead617a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
1 deletions
+73
-1
performance/Performance.Api/Controllers/ValuesController.cs
+10
-0
performance/Performance.Api/Performance.Api.csproj
+5
-0
performance/Performance.Api/Startup.cs
+14
-0
performance/Performance.Services/AllotService.cs
+7
-1
performance/Performance.Services/Hubs/AllotLogHub.cs
+36
-0
performance/Performance.Services/Performance.Services.csproj
+1
-0
No files found.
performance/Performance.Api/Controllers/ValuesController.cs
View file @
1c089166
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.SignalR
;
using
Performance.Services
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -11,11 +13,19 @@ namespace Performance.Api.Controllers
[
ApiController
]
public
class
ValuesController
:
ControllerBase
{
private
readonly
IHubContext
<
AllotLogHub
>
hubContext
;
public
ValuesController
(
IHubContext
<
AllotLogHub
>
hubContext
)
{
this
.
hubContext
=
hubContext
;
}
// GET api/values
[
HttpGet
]
[
AllowAnonymous
]
public
ActionResult
<
IEnumerable
<
string
>>
Get
()
{
hubContext
.
Clients
.
Group
(
"aaaa"
).
SendAsync
(
"ReceiveMessage"
,
"绩效开始执行"
,
"绩效开始执行"
);
//var excel = _excelService.Analyze(@"C:\Users\ry\Desktop\文件\测试.xlsx");
return
new
string
[]
{
"value1"
,
"value2"
};
}
...
...
performance/Performance.Api/Performance.Api.csproj
View file @
1c089166
...
...
@@ -14,12 +14,16 @@
<ItemGroup>
<Compile Remove="aaa\**" />
<Compile Remove="Files\**" />
<Compile Remove="Hubs\**" />
<Content Remove="aaa\**" />
<Content Remove="Files\**" />
<Content Remove="Hubs\**" />
<EmbeddedResource Remove="aaa\**" />
<EmbeddedResource Remove="Files\**" />
<EmbeddedResource Remove="Hubs\**" />
<None Remove="aaa\**" />
<None Remove="Files\**" />
<None Remove="Hubs\**" />
</ItemGroup>
<ItemGroup>
...
...
@@ -41,6 +45,7 @@
<PackageReference Include="NLog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.8.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
...
...
performance/Performance.Api/Startup.cs
View file @
1c089166
...
...
@@ -147,6 +147,16 @@ public void ConfigureServices(IServiceCollection services)
});
#
endregion
services
.
AddSignalR
();
services
.
AddCors
(
options
=>
{
options
.
AddPolicy
(
"SignalrCore"
,
policy
=>
{
policy
.
SetIsOriginAllowed
(
origin
=>
true
).
AllowAnyHeader
().
AllowAnyMethod
().
AllowCredentials
();
});
});
#
region
//ef配置
services
.
AddDbContext
<
PerformanceDbContext
>(
options
=>
{
...
...
@@ -219,6 +229,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
app
.
UseHangfireDashboard
(
"/hangfire"
,
new
DashboardOptions
{
Authorization
=
new
[]
{
new
HangfireAuthorizationFilter
()
}
});
#
endregion
app
.
UseCors
(
"SignalrCore"
);
app
.
UseSignalR
(
routes
=>
routes
.
MapHub
<
AllotLogHub
>(
"/allotLogHub"
));
loggerFactory
.
CreateLogger
<
Startup
>().
LogDebug
(
env
.
EnvironmentName
);
app
.
UseMvc
();
}
...
...
performance/Performance.Services/AllotService.cs
View file @
1c089166
using
AutoMapper
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.SignalR
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Options
;
using
Performance.DtoModels
;
...
...
@@ -34,6 +35,7 @@ public class AllotService : IAutoInjection
private
PerforPeragainallotRepository
_againallotRepository
;
private
PerforLogcheckRepository
perforLogcheckRepository
;
private
readonly
PerforHospitalRepository
perforHospitalRepository
;
private
readonly
IHubContext
<
AllotLogHub
>
hubContext
;
public
AllotService
(
PerforPerallotRepository
allotRepository
,
BaiscNormService
baiscNormService
,
...
...
@@ -48,7 +50,8 @@ public class AllotService : IAutoInjection
IOptions
<
Application
>
options
,
PerforPeragainallotRepository
againallotRepository
,
PerforLogcheckRepository
perforLogcheckRepository
,
PerforHospitalRepository
perforHospitalRepository
)
PerforHospitalRepository
perforHospitalRepository
,
IHubContext
<
AllotLogHub
>
hubContext
)
{
_allotRepository
=
allotRepository
;
_againallotRepository
=
againallotRepository
;
...
...
@@ -65,6 +68,7 @@ public class AllotService : IAutoInjection
this
.
logdbug
=
logdbug
;
this
.
perforLogcheckRepository
=
perforLogcheckRepository
;
this
.
perforHospitalRepository
=
perforHospitalRepository
;
this
.
hubContext
=
hubContext
;
}
#
region
基础功能
...
...
@@ -197,6 +201,7 @@ public void UpdateAllotStates(int allotId, int states, string remark)
{
_allotRepository
.
UpdateAllotStates
(
allotId
,
states
,
remark
);
}
/// <summary>
/// 生成绩效
/// </summary>
...
...
@@ -207,6 +212,7 @@ public void Generate(per_allot allot, string mail)
DateTime
time
=
DateTime
.
Now
;
try
{
hubContext
.
Clients
.
Group
(
"aaaa"
).
SendAsync
(
"ReceiveMessage"
,
"绩效开始执行"
,
"绩效开始执行"
);
logdbug
.
Add
(
allot
.
ID
,
"绩效开始执行"
,
JsonHelper
.
Serialize
(
allot
));
configService
.
Clear
(
allot
.
ID
);
UpdateAllotStates
(
allot
.
ID
,
(
int
)
AllotStates
.
InCheckData
,
EnumHelper
.
GetDescription
(
AllotStates
.
InCheckData
));
...
...
performance/Performance.Services/Hubs/AllotLogHub.cs
0 → 100644
View file @
1c089166
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.SignalR
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Performance.Services
{
public
class
AllotLogHub
:
Hub
{
public
override
Task
OnConnectedAsync
()
{
return
base
.
OnConnectedAsync
();
}
public
override
Task
OnDisconnectedAsync
(
Exception
exception
)
{
//1 查询用户分组信息
var
groupName
=
"aaaa"
;
//2 删除数据库中用户分组数据
//3 分组中删除用户
Groups
.
RemoveFromGroupAsync
(
Context
.
ConnectionId
,
groupName
);
return
base
.
OnDisconnectedAsync
(
exception
);
}
public
async
Task
AddGroup
(
string
token
,
string
groupName
)
{
//1 向数据库中插入用户及分组信息
//2 将用户插入分组
await
Groups
.
AddToGroupAsync
(
Context
.
ConnectionId
,
groupName
);
}
}
}
performance/Performance.Services/Performance.Services.csproj
View file @
1c089166
...
...
@@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="DotNetCore.NPOI" Version="1.2.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment