Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
73ced6fb
Commit
73ced6fb
authored
Aug 05, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增CAP
parent
84fdcc16
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
84 additions
and
105 deletions
+84
-105
Config.cs
Mall.Common/Config.cs
+1
-1
Mall.ThirdCore.csproj
Mall.ThirdCore/Mall.ThirdCore.csproj
+0
-1
RabbitConfig.cs
Mall.ThirdCore/Mq/RabbitConfig.cs
+0
-44
RabbitMQService.cs
Mall.ThirdCore/Mq/RabbitMQService.cs
+0
-55
TestController.cs
Mall.WebApi/Controllers/CAP/TestController.cs
+52
-0
ERPOrderCommissionController.cs
...ebApi/Controllers/Finance/ERPOrderCommissionController.cs
+1
-1
Mall.WebApi.csproj
Mall.WebApi/Mall.WebApi.csproj
+3
-0
Mall.WebApi.csproj.user
Mall.WebApi/Mall.WebApi.csproj.user
+1
-1
Startup.cs
Mall.WebApi/Startup.cs
+26
-2
No files found.
Mall.Common/Config.cs
View file @
73ced6fb
...
...
@@ -161,7 +161,7 @@ namespace Mall.Common
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
p
rivate
static
string
ReadConfigKey
(
string
key
)
p
ublic
static
string
ReadConfigKey
(
string
key
)
{
try
{
...
...
Mall.ThirdCore/Mall.ThirdCore.csproj
View file @
73ced6fb
...
...
@@ -8,7 +8,6 @@
<PackageReference Include="Aliyun.Net.SDK.Core" Version="1.0.3" />
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RabbitMQ.Client" Version="6.0.0" />
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.10" />
</ItemGroup>
...
...
Mall.ThirdCore/Mq/RabbitConfig.cs
deleted
100644 → 0
View file @
84fdcc16
using
Aliyun.Acs.Core
;
using
Aliyun.Acs.Core.Exceptions
;
using
Aliyun.Acs.Core.Profile
;
using
Aliyun.Acs.Dysmsapi.Model.V20170525
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
Mall.ThirdCore.Commom
;
using
System
;
using
System.Threading
;
using
Mall.ThirdCore.Message
;
namespace
Mall.ThirdCore.Mq
{
/// <summary>
/// 消息队列配置文件
/// </summary>
public
class
RabbitConfig
{
/// <summary>
/// 主机名:ip地址
/// </summary>
public
string
HostName
{
get
;
set
;
}
/// <summary>
/// 端口
/// </summary>
public
int
Port
{
get
;
set
;
}
/// <summary>
/// 用户名
/// </summary>
public
string
UserName
{
get
;
set
;
}
/// <summary>
/// 密码
/// </summary>
public
string
Password
{
get
;
set
;
}
/// <summary>
/// 队列名称
/// </summary>
public
string
QueenName
{
get
;
set
;
}
}
}
Mall.ThirdCore/Mq/RabbitMQService.cs
deleted
100644 → 0
View file @
84fdcc16
using
RabbitMQ.Client
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.ThirdCore.Mq
{
/// <summary>
/// 消息队列帮助类
/// </summary>
public
class
RabbitMQService
{
/// <summary>
/// 获取连接
/// </summary>
/// <param name="rabbitConfig">连接配置实体</param>
/// <returns></returns>
public
static
ConnectionFactory
GetConnectionFactory
(
RabbitConfig
rabbitConfig
)
{
ConnectionFactory
factory
=
new
ConnectionFactory
{
HostName
=
rabbitConfig
.
HostName
,
//默认端口
Port
=
rabbitConfig
.
Port
,
UserName
=
rabbitConfig
.
UserName
,
Password
=
rabbitConfig
.
Password
};
return
factory
;
}
/// <summary>
/// 发送信息
/// </summary>
/// <param name="rabbitConfig"></param>
/// <param name="message"></param>
public
static
void
SendMessage
(
RabbitConfig
rabbitConfig
,
string
message
)
{
using
(
IConnection
conn
=
GetConnectionFactory
(
rabbitConfig
).
CreateConnection
())
{
using
(
IModel
channel
=
conn
.
CreateModel
())
{
//在MQ上定义一个持久化队列,如果名称相同不会重复创建
channel
.
QueueDeclare
(
rabbitConfig
.
QueenName
,
true
,
false
,
false
,
null
);
byte
[]
buffer
=
Encoding
.
UTF8
.
GetBytes
(
message
);
IBasicProperties
properties
=
channel
.
CreateBasicProperties
();
properties
.
DeliveryMode
=
2
;
channel
.
BasicPublish
(
""
,
rabbitConfig
.
QueenName
,
properties
,
buffer
);
}
}
}
}
}
Mall.WebApi/Controllers/CAP/TestController.cs
0 → 100644
View file @
73ced6fb
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Mall.Common.API
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
namespace
Mall.WebApi.Controllers.CAP
{
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
TestController
:
BaseController
{
private
readonly
DotNetCore
.
CAP
.
ICapPublisher
_capBus
;
public
TestController
(
DotNetCore
.
CAP
.
ICapPublisher
capPublisher
)
{
this
.
_capBus
=
capPublisher
;
}
[
HttpPost
]
[
AllowAnonymous
]
public
ApiResult
Get
()
{
ApiResult
apiResult
=
new
ApiResult
()
{
message
=
"操作成功"
,
resultCode
=
1
,
data
=
DateTime
.
Now
};
_capBus
.
Publish
(
"show.time"
,
Common
.
Plugin
.
JsonHelper
.
Serialize
(
apiResult
));
return
apiResult
;
}
[
NonAction
]
[
AllowAnonymous
]
[
DotNetCore
.
CAP
.
CapSubscribe
(
"show.time"
)]
public
void
CheckReceiveMessage
(
string
result
)
{
string
str
=
""
;
Console
.
WriteLine
(
result
);
}
}
}
\ No newline at end of file
Mall.WebApi/Controllers/Finance/ERPOrderCommissionController.cs
View file @
73ced6fb
...
...
@@ -244,7 +244,7 @@ namespace Mall.WebApi.Controllers.Finance
}
else
{
string
msg
=
userModule
.
SetRecommendOrdersBillRemit
(
BillId
,
TenantId
,
MallBaseId
,
0
,
,
"单据审核通过,已自动打款"
);
string
msg
=
userModule
.
SetRecommendOrdersBillRemit
(
BillId
,
TenantId
,
MallBaseId
,
0
,
"单据审核通过,已自动打款"
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
...
...
Mall.WebApi/Mall.WebApi.csproj
View file @
73ced6fb
...
...
@@ -9,6 +9,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotNetCore.CAP" Version="3.0.0" />
<PackageReference Include="DotNetCore.CAP.MySql" Version="3.0.0" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="3.0.0" />
<PackageReference Include="JWT" Version="5.3.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
...
...
Mall.WebApi/Mall.WebApi.csproj.user
View file @
73ced6fb
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<Controller_SelectedScaffolderID>
Mvc
ControllerEmptyScaffolder
</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderID>
Api
ControllerEmptyScaffolder
</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>
root/Controller
</Controller_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ControllerDialogWidth>
600
</WebStackScaffolding_ControllerDialogWidth>
<WebStackScaffolding_IsLayoutPageSelected>
True
</WebStackScaffolding_IsLayoutPageSelected>
...
...
Mall.WebApi/Startup.cs
View file @
73ced6fb
...
...
@@ -5,6 +5,7 @@ using System.Linq;
using
System.Text.Encodings.Web
;
using
System.Text.Unicode
;
using
System.Threading.Tasks
;
using
DotNetCore.CAP.Messages
;
using
Mall.ThirdCore.Message
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Builder
;
...
...
@@ -56,11 +57,34 @@ namespace Mall.WebApi
"http://yx.oytour.com"
,
"http://mall.oytour.com"
,
"http://testmall.oytour.com"
,
"http://yx.oytour.com"
,
};
services
.
AddCors
(
options
=>
options
.
AddPolicy
(
"AllowCors"
,
policy
=>
policy
.
AllowAnyHeader
().
AllowAnyMethod
().
AllowCredentials
().
WithOrigins
(
corsArray
.
ToArray
())));
services
.
AddCap
(
x
=>
{
x
.
UseMySql
(
config
=>
{
config
.
ConnectionString
=
"server=192.168.2.214;user id=reborn;password=Reborn@2018;database=cap;CharSet=utf8; Convert Zero Datetime=true;"
;
});
x
.
UseRabbitMQ
(
cfg
=>
{
cfg
.
HostName
=
"47.96.25.130"
;
cfg
.
VirtualHost
=
"/"
;
cfg
.
Port
=
Convert
.
ToInt32
(
5672
);
cfg
.
UserName
=
"guest"
;
cfg
.
Password
=
"viitto2019"
;
});
//失败后的重试次数,默认50次;在FailedRetryInterval默认60秒的情况下,即默认重试50*60秒(50分钟)之后放弃失败重试
x
.
FailedRetryCount
=
10
;
//失败后的重拾间隔,默认60秒
x
.
FailedRetryInterval
=
10
;
//设置成功信息的删除时间默认24*3600秒
x
.
SucceedMessageExpiredAfter
=
3600
;
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public
void
Configure
(
IApplicationBuilder
app
,
IWebHostEnvironment
env
,
IHostApplicationLifetime
appLifetime
)
...
...
@@ -78,12 +102,12 @@ namespace Mall.WebApi
app
.
UseAuthorization
();
app
.
UseEndpoints
(
endpoints
=>
{
endpoints
.
MapControllers
();
});
System
.
WebHttpContext
.
HttpContext
.
Configure
(
app
.
ApplicationServices
.
GetRequiredService
<
Microsoft
.
AspNetCore
.
Http
.
IHttpContextAccessor
>());
//启动信息发送
Task
.
Run
(()
=>
MessageCore
.
Init
());
...
...
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