Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
WeiPanAPI
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Discuz
WeiPanAPI
Commits
89252924
Commit
89252924
authored
Feb 27, 2021
by
xiongyuwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
f3c89fa6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
311 additions
and
29 deletions
+311
-29
GetDeparmentByUserResponse.cs
...tion/WeiPan/Dto/ResponseDto/GetDeparmentByUserResponse.cs
+98
-0
IWeiPanService.cs
src/Bailun.Discuz.Application/WeiPan/IWeiPanService.cs
+2
-2
WeiPanService.cs
src/Bailun.Discuz.Application/WeiPan/WeiPanService.cs
+105
-16
Users.cs
src/Bailun.Discuz.Domain/WeiPan/Users.cs
+42
-1
WeiPanController.cs
src/Bailun.Discuz.Service/Controllers/WeiPanController.cs
+2
-2
ConsoleModule.cs
...console/Bailun.Discuz.ConsoleApp.Publish/ConsoleModule.cs
+9
-4
PublishWeiPanFourKWorker.cs
...cuz.ConsoleApp.Publish/Worker/PublishWeiPanFourKWorker.cs
+43
-0
PublishWeiPanWorker.cs
...n.Discuz.ConsoleApp.Publish/Worker/PublishWeiPanWorker.cs
+3
-3
appsettings.json
...console/Bailun.Discuz.ConsoleApp.Publish/appsettings.json
+7
-1
No files found.
src/Bailun.Discuz.Application/WeiPan/Dto/ResponseDto/GetDeparmentByUserResponse.cs
0 → 100644
View file @
89252924
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
{
public
class
ObjData
{
/// <summary>
///
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
departmentId
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
companyId
{
get
;
set
;
}
/// <summary>
/// 广州百伦供应链科技有限公司
/// </summary>
public
string
companyName
{
get
;
set
;
}
/// <summary>
/// 刊登小组
/// </summary>
public
string
name
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
code
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
parentId
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
parentName
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
sort
{
get
;
set
;
}
/// <summary>
/// 田壮虎
/// </summary>
public
string
manageUser1
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
manageUser2
{
get
;
set
;
}
}
public
class
Result
{
/// <summary>
///
/// </summary>
public
string
isSucceeded
{
get
;
set
;
}
/// <summary>
/// 操作成功!
/// </summary>
public
string
message
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
code
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
data
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
ObjData
objData
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
redirectUrl
{
get
;
set
;
}
}
public
class
GetDeparmentByUserResponse
{
/// <summary>
///
/// </summary>
public
Result
result
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
statusCode
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
message
{
get
;
set
;
}
}
}
src/Bailun.Discuz.Application/WeiPan/IWeiPanService.cs
View file @
89252924
...
@@ -51,8 +51,8 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -51,8 +51,8 @@ namespace Bailun.Discuz.Application.WeiPan
/// <returns></returns>
/// <returns></returns>
Task
<
long
>
CreateAttachment
(
long
userId
,
string
fileMd5
,
long
typeId
);
Task
<
long
>
CreateAttachment
(
long
userId
,
string
fileMd5
,
long
typeId
);
Task
<
List
<
WeiPanFileList
>>
GetFileList
();
Task
<
List
<
WeiPanFileList
>>
GetFileList
(
string
userId
);
Task
<
string
>
ProcessWeiPanWorker
();
Task
<
string
>
ProcessWeiPanWorker
(
string
userId
);
Task
<
WeiPanFileList
>
GetWeiPanFileByThreadId
(
long
threadId
);
Task
<
WeiPanFileList
>
GetWeiPanFileByThreadId
(
long
threadId
);
Task
<
WeiPanFileList
>
GetFileInfo
(
string
fileId
);
Task
<
WeiPanFileList
>
GetFileInfo
(
string
fileId
);
}
}
...
...
src/Bailun.Discuz.Application/WeiPan/WeiPanService.cs
View file @
89252924
...
@@ -53,7 +53,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -53,7 +53,7 @@ namespace Bailun.Discuz.Application.WeiPan
{
{
var
token
=
GetQYWeChatToken
(
userId
);
var
token
=
GetQYWeChatToken
(
userId
);
SpaceCreateRequest
resquest
=
new
SpaceCreateRequest
();
SpaceCreateRequest
resquest
=
new
SpaceCreateRequest
();
resquest
.
space_name
=
"
我的
微盘"
;
resquest
.
space_name
=
"
四千里
微盘"
;
resquest
.
userid
=
userId
;
resquest
.
userid
=
userId
;
var
apiUrl
=
$"https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=
{
token
}
"
;
var
apiUrl
=
$"https://qyapi.weixin.qq.com/cgi-bin/wedrive/space_create?access_token=
{
token
}
"
;
var
apiOutput
=
HttpHelper
.
PostAsync
<
SpaceCreateRequest
,
SpaceCreateResponse
>(
apiUrl
,
resquest
);
var
apiOutput
=
HttpHelper
.
PostAsync
<
SpaceCreateRequest
,
SpaceCreateResponse
>(
apiUrl
,
resquest
);
...
@@ -70,9 +70,9 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -70,9 +70,9 @@ namespace Bailun.Discuz.Application.WeiPan
var
token
=
GetQYWeChatToken
(
userId
);
var
token
=
GetQYWeChatToken
(
userId
);
string
apiUrl
=
$"https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=
{
token
}
"
;
string
apiUrl
=
$"https://qyapi.weixin.qq.com/cgi-bin/wedrive/file_create?access_token=
{
token
}
"
;
CreateSpaceFileRequest
createSpaceFileRequest
=
new
CreateSpaceFileRequest
();
CreateSpaceFileRequest
createSpaceFileRequest
=
new
CreateSpaceFileRequest
();
var
weiPanSpaceId
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:WeiPanSpaceId"
);
var
weiPanSpaceId
=
GetWeiPanSpaceId
(
userId
);
createSpaceFileRequest
.
fatherid
=
weiPanSpaceId
;
createSpaceFileRequest
.
fatherid
=
weiPanSpaceId
;
createSpaceFileRequest
.
file_name
=
"
我的
共享文件"
;
createSpaceFileRequest
.
file_name
=
"
四千里
共享文件"
;
createSpaceFileRequest
.
file_type
=
1
;
createSpaceFileRequest
.
file_type
=
1
;
createSpaceFileRequest
.
userid
=
userId
;
createSpaceFileRequest
.
userid
=
userId
;
createSpaceFileRequest
.
spaceid
=
weiPanSpaceId
;
createSpaceFileRequest
.
spaceid
=
weiPanSpaceId
;
...
@@ -149,9 +149,9 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -149,9 +149,9 @@ namespace Bailun.Discuz.Application.WeiPan
else
else
{
{
GetFileListRequest
getFileListRequest
=
new
GetFileListRequest
();
GetFileListRequest
getFileListRequest
=
new
GetFileListRequest
();
getFileListRequest
.
fatherid
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:WeiPanSpaceFileId"
);
getFileListRequest
.
fatherid
=
GetWeiPanSpaceFileId
(
userId
);
getFileListRequest
.
userid
=
userId
;
getFileListRequest
.
userid
=
userId
;
getFileListRequest
.
spaceid
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:WeiPanSpaceId"
);
getFileListRequest
.
spaceid
=
GetWeiPanSpaceId
(
userId
);
getFileListRequest
.
sort_type
=
6
;
getFileListRequest
.
sort_type
=
6
;
getFileListRequest
.
start
=
0
;
getFileListRequest
.
start
=
0
;
getFileListRequest
.
limit
=
1000
;
getFileListRequest
.
limit
=
1000
;
...
@@ -216,7 +216,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -216,7 +216,7 @@ namespace Bailun.Discuz.Application.WeiPan
GetFileListRequest
getFileListRequest
=
new
GetFileListRequest
();
GetFileListRequest
getFileListRequest
=
new
GetFileListRequest
();
getFileListRequest
.
fatherid
=
fatherid
;
;
getFileListRequest
.
fatherid
=
fatherid
;
;
getFileListRequest
.
userid
=
userId
;
getFileListRequest
.
userid
=
userId
;
getFileListRequest
.
spaceid
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:WeiPanSpaceId"
)
;
getFileListRequest
.
spaceid
=
GetWeiPanSpaceId
(
userId
);
;
getFileListRequest
.
sort_type
=
6
;
getFileListRequest
.
sort_type
=
6
;
getFileListRequest
.
start
=
start
;
getFileListRequest
.
start
=
start
;
getFileListRequest
.
limit
=
1000
;
getFileListRequest
.
limit
=
1000
;
...
@@ -528,28 +528,115 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -528,28 +528,115 @@ namespace Bailun.Discuz.Application.WeiPan
return
await
_weiPanFileListRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
FileId
==
fileId
).
FirstOrDefaultAsync
();
return
await
_weiPanFileListRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
FileId
==
fileId
).
FirstOrDefaultAsync
();
}
}
public
string
GetCompanyName
(
string
userId
)
{
var
userids
=
new
List
<
string
>();
userids
.
Add
(
userId
);
var
companyName
=
"广州百伦供应链科技有限公司"
;
var
user
=
_usersRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
UserId
==
userId
).
FirstOrDefault
();
if
(
user
!=
null
)
{
if
(
user
.
CompanyName
.
IsNullOrEmpty
())
{
var
wxUserResponse
=
CreateRealNameByUseId
(
userids
);
if
(
wxUserResponse
.
statusCode
==
200
)
{
var
oaUserIds
=
wxUserResponse
.
result
;
if
(
oaUserIds
!=
null
&&
oaUserIds
.
Count
>
0
)
{
var
oaUserId
=
oaUserIds
[
0
].
userId
;
companyName
=
GetDeparmentIdByUserId
(
oaUserId
);
//更新到用户表中
user
.
CompanyName
=
companyName
;
_usersRepository
.
UpdateCommit
(
user
);
}
}
}
else
{
companyName
=
user
.
CompanyName
;
}
}
return
companyName
;
}
public
string
GetWeiPanSpaceFileId
(
string
userId
)
{
string
companyName
=
GetCompanyName
(
userId
);
if
(
companyName
==
"广州百伦供应链科技有限公司"
)
{
return
ConfigManagerConf
.
GetValue
(
"QYWeChat:WeiPanSpaceFileId"
);
}
else
{
return
ConfigManagerConf
.
GetValue
(
"FourKQYWeChat:WeiPanSpaceFileId"
);
}
}
public
string
GetWeiPanSpaceId
(
string
userId
)
{
string
companyName
=
GetCompanyName
(
userId
);
if
(
companyName
==
"广州百伦供应链科技有限公司"
)
{
return
ConfigManagerConf
.
GetValue
(
"QYWeChat:WeiPanSpaceId"
);
}
else
{
return
ConfigManagerConf
.
GetValue
(
"FourKQYWeChat:WeiPanSpaceId"
);
}
}
private
string
GetQYWeChatToken
(
string
userId
)
private
string
GetQYWeChatToken
(
string
userId
)
{
{
var
appId
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:AppId"
);
//四千里数据科技有限公司
var
secret
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:Secret"
);
//广州百伦供应链科技有限公司
//获取用户id对应得部门
var
appId
=
""
;
var
secret
=
""
;
string
companyName
=
GetCompanyName
(
userId
);
if
(
companyName
==
"广州百伦供应链科技有限公司"
)
{
appId
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:AppId"
);
secret
=
ConfigManagerConf
.
GetValue
(
"QYWeChat:Secret"
);
}
else
{
appId
=
ConfigManagerConf
.
GetValue
(
"FourKQYWeChat:AppId"
);
secret
=
ConfigManagerConf
.
GetValue
(
"FourKQYWeChat:Secret"
);
}
var
url
=
$"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=
{
appId
}
&corpsecret=
{
secret
}
"
;
var
url
=
$"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=
{
appId
}
&corpsecret=
{
secret
}
"
;
var
response
=
HttpHelper
.
HttpGet
(
url
);
var
response
=
HttpHelper
.
HttpGet
(
url
);
var
result
=
JsonHelper
.
FromJson
<
GettokenResponse
>(
response
);
var
result
=
JsonHelper
.
FromJson
<
GettokenResponse
>(
response
);
return
result
.
access_token
;
return
result
.
access_token
;
}
}
public
string
GetDeparmentIdByUserId
(
int
userId
)
{
var
resContent
=
HttpHelper
.
HttpGet
(
$"https://saas.admin.bailuntec.com/Api/Ssoadmin/departmentmanage/getdepartmentsbyuid?uid=
{
userId
}
"
);
if
(!
resContent
.
IsNullOrEmpty
())
{
var
user
=
JsonConvert
.
DeserializeObject
<
GetDeparmentByUserResponse
>(
resContent
);
if
(
user
.
statusCode
==
200
)
{
if
(
user
.
result
.
objData
!=
null
)
{
return
user
.
result
.
objData
.
companyName
;
}
}
}
return
"广州百伦供应链科技有限公司"
;
}
/// <summary>
/// <summary>
/// 处理微盘自动发帖功能
/// 处理微盘自动发帖功能
/// </summary>
/// </summary>
public
async
Task
<
string
>
ProcessWeiPanWorker
()
public
async
Task
<
string
>
ProcessWeiPanWorker
(
string
userId
)
{
{
StringBuilder
messageSb
=
new
StringBuilder
();
;
StringBuilder
messageSb
=
new
StringBuilder
();
;
string
userId
=
"chenzekai"
;
//
string userId = "chenzekai";
List
<
WeiPanFileList
>
inserWeiPanFileList
=
new
List
<
WeiPanFileList
>();
List
<
WeiPanFileList
>
inserWeiPanFileList
=
new
List
<
WeiPanFileList
>();
//1:获取线上的所有文档数据
//1:获取线上的所有文档数据
var
filList
=
await
GetFileList
();
var
filList
=
await
GetFileList
(
userId
);
//string value = "测试数据";
//string value = "测试数据";
//RedisHelper.Set("key", filList);
//RedisHelper.Set("key", filList);
...
@@ -655,7 +742,10 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -655,7 +742,10 @@ namespace Bailun.Discuz.Application.WeiPan
/// <returns></returns>
/// <returns></returns>
public
async
Task
<
string
>
CreateUserFilesTreeRedis
()
public
async
Task
<
string
>
CreateUserFilesTreeRedis
()
{
{
var
userList
=
await
_usersRepository
.
Query
().
AsNoTracking
().
ToListAsync
();
//对推送消息进行控制,减少调用次数
var
includUsers
=
"陈泽凯,田壮虎,付典,陈琦,钟晓桐,张仲杰,冯晓茵,高得胜,李可欣,黎慧琼,赵伟铭"
;
var
userList
=
await
_usersRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
includUsers
.
Split
(
','
).
Contains
(
u
.
UserName
)||
u
.
LoginAt
>=(
DateTime
.
Now
.
AddDays
(-
8
).
Date
)).
ToListAsync
();
foreach
(
var
item
in
userList
)
foreach
(
var
item
in
userList
)
{
{
if
(
item
.
UserId
!=
null
)
if
(
item
.
UserId
!=
null
)
...
@@ -806,9 +896,8 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -806,9 +896,8 @@ namespace Bailun.Discuz.Application.WeiPan
/// <summary>
/// <summary>
/// 递归获取所有首页下的所有文件列表数据
/// 递归获取所有首页下的所有文件列表数据
/// </summary>
/// </summary>
public
async
Task
<
List
<
WeiPanFileList
>>
GetFileList
()
public
async
Task
<
List
<
WeiPanFileList
>>
GetFileList
(
string
userId
)
{
{
string
userId
=
"chenzekai"
;
List
<
WeiPanFileList
>
weiPanFileLists
=
new
List
<
WeiPanFileList
>();
List
<
WeiPanFileList
>
weiPanFileLists
=
new
List
<
WeiPanFileList
>();
List
<
ItemItem
>
itemItems
=
new
List
<
ItemItem
>();
List
<
ItemItem
>
itemItems
=
new
List
<
ItemItem
>();
var
token
=
GetQYWeChatToken
(
userId
);
var
token
=
GetQYWeChatToken
(
userId
);
...
...
src/Bailun.Discuz.Domain/WeiPan/Users.cs
View file @
89252924
...
@@ -12,7 +12,48 @@ namespace Bailun.Discuz.Domain.WeiPan
...
@@ -12,7 +12,48 @@ namespace Bailun.Discuz.Domain.WeiPan
[
Column
(
"username"
)]
public
string
UserName
{
get
;
set
;
}
[
Column
(
"username"
)]
public
string
UserName
{
get
;
set
;
}
[
Column
(
"password"
)]
public
string
PassWord
{
get
;
set
;
}
[
Column
(
"pay_password"
)]
public
string
PayPassword
{
get
;
set
;
}
[
Column
(
"mobile"
)]
public
string
Mobile
{
get
;
set
;
}
[
Column
(
"signature"
)]
public
string
Signature
{
get
;
set
;
}
[
Column
(
"last_login_ip"
)]
public
string
LstLoginIp
{
get
;
set
;
}
[
Column
(
"last_login_port"
)]
public
int
LastLoginPort
{
get
;
set
;
}
[
Column
(
"register_ip"
)]
public
string
RegisterIp
{
get
;
set
;
}
[
Column
(
"register_port"
)]
public
int
RegisterPort
{
get
;
set
;
}
[
Column
(
"register_reason"
)]
public
string
RegisterReason
{
get
;
set
;
}
[
Column
(
"username_bout"
)]
public
int
UsernameBout
{
get
;
set
;
}
[
Column
(
"thread_count"
)]
public
int
ThreadCount
{
get
;
set
;
}
[
Column
(
"follow_count"
)]
public
int
FollowCount
{
get
;
set
;
}
[
Column
(
"fans_count"
)]
public
int
FansCount
{
get
;
set
;
}
[
Column
(
"liked_count"
)]
public
int
LikedCount
{
get
;
set
;
}
[
Column
(
"question_count"
)]
public
int
QuestionCount
{
get
;
set
;
}
[
Column
(
"status"
)]
public
int
Status
{
get
;
set
;
}
[
Column
(
"avatar"
)]
public
string
Avatar
{
get
;
set
;
}
[
Column
(
"avatar_url"
)]
public
string
AvatarUrl
{
get
;
set
;
}
[
Column
(
"identity"
)]
public
string
Identity
{
get
;
set
;
}
[
Column
(
"realname"
)]
public
string
Realname
{
get
;
set
;
}
[
Column
(
"avatar_at"
)]
public
DateTime
?
AvatarAt
{
get
;
set
;
}
[
Column
(
"login_at"
)]
public
DateTime
?
LoginAt
{
get
;
set
;
}
[
Column
(
"joined_at"
)]
public
DateTime
?
JoinedAt
{
get
;
set
;
}
[
Column
(
"expired_at"
)]
public
DateTime
?
ExpiredAt
{
get
;
set
;
}
[
Column
(
"created_at"
)]
public
DateTime
CreatedAt
{
get
;
set
;
}
[
Column
(
"updated_at"
)]
public
DateTime
UpdatedAt
{
get
;
set
;
}
[
Column
(
"wechat_info"
)]
public
string
WechatInfo
{
get
;
set
;
}
[
Column
(
"department"
)]
public
string
Department
{
get
;
set
;
}
[
Column
(
"userid"
)]
public
string
UserId
{
get
;
set
;
}
[
Column
(
"userid"
)]
public
string
UserId
{
get
;
set
;
}
[
Column
(
"company_name"
)]
public
string
CompanyName
{
get
;
set
;
}
}
}
}
}
src/Bailun.Discuz.Service/Controllers/WeiPanController.cs
View file @
89252924
...
@@ -79,11 +79,11 @@ namespace Bailun.Discuz.Service.Controllers
...
@@ -79,11 +79,11 @@ namespace Bailun.Discuz.Service.Controllers
}
}
[
HttpGet
(
"ProcessWeiPanWorker"
)]
[
HttpGet
(
"ProcessWeiPanWorker"
)]
public
async
Task
<
string
>
ProcessWeiPanWorker
()
public
async
Task
<
string
>
ProcessWeiPanWorker
(
string
userId
)
{
{
RedisHelper
.
Del
(
Constants
.
File_List_Tree
);
//清除缓存
RedisHelper
.
Del
(
Constants
.
File_List_Tree
);
//清除缓存
RedisHelper
.
Del
(
Constants
.
First_File_List
);
//清除缓存
RedisHelper
.
Del
(
Constants
.
First_File_List
);
//清除缓存
return
await
_iweiPanService
.
ProcessWeiPanWorker
();
return
await
_iweiPanService
.
ProcessWeiPanWorker
(
userId
);
}
}
[
HttpGet
(
"GetFileInfo"
)]
[
HttpGet
(
"GetFileInfo"
)]
public
async
Task
<
WeiPanFileList
>
GetFileInfo
(
string
fileId
)
public
async
Task
<
WeiPanFileList
>
GetFileInfo
(
string
fileId
)
...
...
src/console/Bailun.Discuz.ConsoleApp.Publish/ConsoleModule.cs
View file @
89252924
...
@@ -76,13 +76,17 @@ namespace Bailun.Amazon.ConsoleApp.Publish
...
@@ -76,13 +76,17 @@ namespace Bailun.Amazon.ConsoleApp.Publish
public
override
void
PostInitialize
()
public
override
void
PostInitialize
()
{
{
var
workManager
=
IocManager
.
Resolve
<
IBackgroundWorkerManager
>();
var
workManager
=
IocManager
.
Resolve
<
IBackgroundWorkerManager
>();
var
taskType
=
Environment
.
GetEnvironmentVariable
(
"TaskType"
);
var
taskType
=
Environment
.
GetEnvironmentVariable
(
"TaskType"
);
Console
.
WriteLine
(
$"TaskType:
{
taskType
}
"
);
Console
.
WriteLine
(
$"TaskType:
{
taskType
}
"
);
workManager
.
Add
(
IocManager
.
Resolve
<
PublishWeiPanWorker
>());
if
(
taskType
==
"bailun"
)
{
workManager
.
Add
(
IocManager
.
Resolve
<
PublishWeiPanWorker
>());
}
if
(
taskType
==
"fourk"
)
{
workManager
.
Add
(
IocManager
.
Resolve
<
PublishWeiPanFourKWorker
>());
}
}
}
}
}
}
}
\ No newline at end of file
src/console/Bailun.Discuz.ConsoleApp.Publish/Worker/PublishWeiPanFourKWorker.cs
0 → 100644
View file @
89252924
using
Abp.Dependency
;
using
Abp.Threading.BackgroundWorkers
;
using
Abp.Threading.Timers
;
using
Bailun.Discuz.Application.Util
;
using
Bailun.Discuz.Application.WeiPan
;
using
Bailun.ServiceFabric
;
using
System
;
namespace
Bailun.Discuz.ConsoleApp.Publish.Worker
{
public
class
PublishWeiPanFourKWorker
:
PeriodicBackgroundWorkerBase
,
ISingletonDependency
{
private
readonly
IWeiPanService
_weiPanService
;
public
PublishWeiPanFourKWorker
(
AbpTimer
timer
,
IWeiPanService
weiPanService
)
:
base
(
timer
)
{
_weiPanService
=
weiPanService
;
var
minute
=
ConfigManagerConf
.
GetValue
(
"PublishWeiPanWorkerRunTime:Minute"
);
timer
.
Period
=
1000
*
60
*
Convert
.
ToInt32
(
minute
);
timer
.
RunOnStart
=
true
;
}
protected
override
void
DoWork
()
{
try
{
Timer
.
Stop
();
Timer
.
RunOnStart
=
false
;
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
:开始生成4K帖子中"
);
var
result
=
_weiPanService
.
ProcessWeiPanWorker
(
"gaodesheng"
).
GetAwaiter
().
GetResult
();
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
:生成4K帖子完毕,"
+
result
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
$"生成帖子异常:
{
ex
.
Message
}
,异常堆栈为:
{
ex
.
StackTrace
}
"
);
}
finally
{
Timer
.
Start
();
}
}
}
}
src/console/Bailun.Discuz.ConsoleApp.Publish/Worker/PublishWeiPanWorker.cs
View file @
89252924
...
@@ -27,9 +27,9 @@ namespace Bailun.Discuz.ConsoleApp.Publish.Worker
...
@@ -27,9 +27,9 @@ namespace Bailun.Discuz.ConsoleApp.Publish.Worker
{
{
Timer
.
Stop
();
Timer
.
Stop
();
Timer
.
RunOnStart
=
false
;
Timer
.
RunOnStart
=
false
;
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
:开始生成帖子中"
);
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
:开始生成
百伦
帖子中"
);
var
result
=
_weiPanService
.
ProcessWeiPanWorker
().
GetAwaiter
().
GetResult
();
var
result
=
_weiPanService
.
ProcessWeiPanWorker
(
"chenzekai"
).
GetAwaiter
().
GetResult
();
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
:生成
帖子完毕,"
+
result
);
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
:生成
百伦帖子完毕,"
+
result
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
...
src/console/Bailun.Discuz.ConsoleApp.Publish/appsettings.json
View file @
89252924
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
"Defaultdatabase"
:
1
"Defaultdatabase"
:
1
},
},
"PublishWeiPanWorkerRunTime"
:
{
"PublishWeiPanWorkerRunTime"
:
{
"Minute"
:
"60"
"Minute"
:
"
3
60"
},
},
"QYWeChat"
:
{
"QYWeChat"
:
{
"AppId"
:
"ww833808f6b8dc0745"
,
"AppId"
:
"ww833808f6b8dc0745"
,
...
@@ -17,6 +17,12 @@
...
@@ -17,6 +17,12 @@
"WeiPanSpaceId"
:
"s.ww833808f6b8dc0745.610693393XlV"
,
"WeiPanSpaceId"
:
"s.ww833808f6b8dc0745.610693393XlV"
,
"WeiPanSpaceFileId"
:
"s.ww833808f6b8dc0745.610693393XlV_d.6106935069y7b"
"WeiPanSpaceFileId"
:
"s.ww833808f6b8dc0745.610693393XlV_d.6106935069y7b"
},
},
"FourKQYWeChat"
:
{
"AppId"
:
"ww4e7dd5ae312eb101"
,
"Secret"
:
"tbiUloEtNcsbSnKRBpVjeWjlDTOR7pPAdOtmn3kfQMM "
,
"WeiPanSpaceId"
:
"s.ww4e7dd5ae312eb101.614410738dfa"
,
"WeiPanSpaceFileId"
:
"s.ww4e7dd5ae312eb101.614410738dfa_d.614411110Jd02"
},
"ApiServerUrl"
:
{
"ApiServerUrl"
:
{
"ProductUrl"
:
"http://pro.bailuntec.com"
,
"ProductUrl"
:
"http://pro.bailuntec.com"
,
"ProfitApiAddress"
:
"http://profit.bailuntec.com"
,
"ProfitApiAddress"
:
"http://profit.bailuntec.com"
,
...
...
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