Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Biz.EmailPools
Project
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
陶然
Kivii.Biz.EmailPools
Commits
3294a1c2
Commit
3294a1c2
authored
Jun 19, 2024
by
Neo Turing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
b52c479f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
344 deletions
+107
-344
Configs.cs
Src/Configs.cs
+1
-5
EmailPool.cs
Src/Entities/EmailPool.cs
+3
-29
SmtpConfig.cs
Src/Entities/SmtpConfig.cs
+0
-59
Extensions.cs
Src/Extensions.cs
+0
-160
Kivii.Biz.EmailPools.V4.5.csproj
Src/Kivii.Biz.EmailPools.V4.5.csproj
+0
-2
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+3
-3
RestfulEmailPool.cs
Src/Transforms/RestfulEmailPool.cs
+100
-86
No files found.
Src/Configs.cs
View file @
3294a1c2
...
...
@@ -8,10 +8,6 @@ namespace Kivii.EmailPools
{
internal
class
Configs
{
public
const
string
TableNameEmailPool
=
"EML_EmailPools"
;
public
const
string
TableNameSmtpConfig
=
"EML_SmtpConfigs"
;
public
const
string
EmailPoolDbFolderPath
=
"/EmailPools/Files"
;
public
const
string
TableNamePrefixEmailPool
=
"Emls"
;
}
}
Src/Entities/EmailPool.cs
View file @
3294a1c2
...
...
@@ -7,35 +7,13 @@ using System.Threading.Tasks;
namespace
Kivii.EmailPools.Entities
{
/// <summary>
/// 发送状态
/// </summary>
public
enum
SendStatus
[
Api
(
Description
=
"邮箱池"
)]
[
Alias
(
Configs
.
TableNamePrefixEmailPool
)]
public
class
EmailPool
<
T
>
:
EmailPoolBase
,
IEntityInGenericTypeDb
,
IEntityHasRemark
,
IEntity
,
IEntityHasCreator
,
IHasCreator
,
IEntityHasUpdater
,
IHasUpdater
{
/// <summary>
/// 待发
/// </summary>
Sending
,
/// <summary>
/// 完成
/// </summary>
Complete
,
/// <summary>
/// 取消
/// </summary>
Cancel
,
/// <summary>
/// 失败
/// </summary>
Fail
}
[
Api
(
Description
=
"邮箱池"
)]
[
Alias
(
Configs
.
TableNameEmailPool
)]
public
class
EmailPool
:
EmailPoolBase
,
IEntityInAssemblyDb
,
IEntityHasRemark
,
IEntityHasCreator
,
IEntityHasUpdater
...
...
@@ -86,10 +64,6 @@ namespace Kivii.EmailPools.Entities
[
InternalSetter
]
public
bool
IsSended
{
get
;
set
;
}
[
ApiMember
(
Description
=
"发送状态"
)]
public
SendStatus
SendStatus
{
get
;
set
;
}
[
ApiMember
(
Description
=
"附件地址"
)]
[
StringLength
(
1000
)]
public
string
FilePath
{
get
;
set
;
}
...
...
Src/Entities/SmtpConfig.cs
deleted
100644 → 0
View file @
b52c479f
using
Kivii.DataAnnotations
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.EmailPools.Entities
{
[
Api
(
Description
=
"邮箱配置"
)]
[
Alias
(
Configs
.
TableNameSmtpConfig
)]
public
class
SmtpConfig
:
EntityWithMetadata
,
IEntityInAssemblyDb
{
[
ApiMember
(
Description
=
"配置名称"
)]
[
StringLength
(
200
)]
public
string
Title
{
get
;
set
;
}
[
ApiMember
(
Description
=
"内部编码"
)]
[
Unique
]
[
StringLength
(
200
)]
public
string
InternalCode
{
get
;
set
;
}
[
ApiMember
(
Description
=
"默认配置"
)]
public
bool
IsDefault
{
get
;
set
;
}
[
ApiMember
(
Description
=
"描述"
)]
[
StringLength
(
500
)]
public
string
Description
{
get
;
set
;
}
[
ApiMember
(
Description
=
"smtp服务地址"
)]
[
StringLength
(
300
)]
public
string
SmtpUrl
{
get
;
set
;
}
[
ApiMember
(
Description
=
"邮箱地址"
)]
[
Unique
]
[
StringLength
(
300
)]
public
string
Address
{
get
;
set
;
}
[
ApiMember
(
Description
=
"邮箱友好名称"
)]
[
StringLength
(
300
)]
public
string
Name
{
get
;
set
;
}
[
ApiMember
(
Description
=
"邮箱账号"
)]
[
StringLength
(
300
)]
public
string
UserId
{
get
;
set
;
}
[
ApiMember
(
Description
=
"邮箱密码"
)]
[
StringLength
(
300
)]
public
string
Password
{
get
;
set
;
}
[
ApiMember
(
Description
=
"摘要"
)]
[
StringLength
(
1000
)]
public
string
Summary
{
get
;
set
;
}
[
ApiMember
(
Description
=
"备注"
)]
[
StringLength
(
2000
)]
public
string
Remark
{
get
;
set
;
}
}
}
Src/Extensions.cs
deleted
100644 → 0
View file @
b52c479f
using
Kivii.EmailPools.Entities
;
using
Kivii.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Mail
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.EmailPools
{
public
static
class
Extensions
{
private
static
Dictionary
<
string
,
SmtpConfig
>
_smtpConfigs
=
new
Dictionary
<
string
,
SmtpConfig
>();
/// <summary>
/// 获取Smtp配置
/// </summary>
/// <param name="FromAddress"></param>
/// <returns></returns>
public
static
SmtpConfig
GetSmtpConfig
(
this
string
FromAddress
)
{
//默认key
var
key
=
"default"
;
if
(!
FromAddress
.
IsNullOrEmpty
())
{
try
{
//验证传入的邮箱地址格式是否正确,正确就赋值key,不正确key取默认值
var
addr
=
new
System
.
Net
.
Mail
.
MailAddress
(
FromAddress
);
key
=
FromAddress
;
}
catch
{
}
}
if
(
_smtpConfigs
.
ContainsKey
(
key
))
{
return
_smtpConfigs
[
key
];
}
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
SmtpConfig
>();
var
smtpConfigs
=
conn
.
Select
<
SmtpConfig
>();
if
(!
smtpConfigs
.
IsNullOrEmpty
())
{
var
defaultConfig
=
smtpConfigs
.
FirstOrDefault
(
o
=>
o
.
IsDefault
);
if
(
defaultConfig
==
null
)
defaultConfig
=
smtpConfigs
.
FirstOrDefault
();
_smtpConfigs
[
"default"
]
=
defaultConfig
;
foreach
(
var
item
in
smtpConfigs
)
{
_smtpConfigs
[
item
.
Address
]
=
item
;
}
}
if
(
_smtpConfigs
.
ContainsKey
(
key
))
{
return
_smtpConfigs
[
key
];
}
return
null
;
}
/// <summary>
/// 通过emialPool找到对应的附件
/// </summary>
/// <param name="pool"></param>
/// <returns></returns>
public
static
List
<
Attachment
>
GetAttachments
(
this
EmailPool
pool
)
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
query
=
conn
.
From
<
EntityDbFile
<
EmailPool
>>();
query
.
Where
(
o
=>
o
.
ParentKvid
==
Guid
.
Empty
&&
o
.
DbFolderPath
==
Configs
.
EmailPoolDbFolderPath
&&
o
.
OwnerKvid
==
pool
.
Kvid
);
var
dbFiles
=
conn
.
Select
(
query
);
if
(
dbFiles
.
IsNullOrEmpty
())
return
null
;
var
rtns
=
new
List
<
Attachment
>();
foreach
(
var
dbFile
in
dbFiles
)
{
//获取到文件的实际存储路径
var
physicalStorageFilePath
=
dbFile
.
GetPhysicalPath
();
if
(!
File
.
Exists
(
physicalStorageFilePath
))
continue
;
//判断此文件是否存在,不存在就跳过
var
attach
=
new
Attachment
(
physicalStorageFilePath
);
rtns
.
Add
(
attach
);
}
return
rtns
;
}
/// <summary>
/// 发送email
/// </summary>
/// <param name="pool"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public
static
EmailPool
Sending
(
this
EmailPool
pool
)
{
var
config
=
pool
.
FromAddress
.
GetSmtpConfig
();
if
(
config
==
null
)
throw
new
Exception
(
"未找到指定SMTP配置,请先配置SMTP服务信息"
);
MailAddress
from
=
null
;
MailAddress
to
=
null
;
try
{
from
=
new
MailAddress
(
config
.
Address
,
config
.
Name
);
}
catch
{
throw
new
Exception
(
$"发送地址
{
config
.
Address
}
,格式错误"
);
}
try
{
to
=
new
MailAddress
(
pool
.
ToAddress
,
pool
.
ToName
);
}
catch
{
throw
new
Exception
(
$"收件地址
{
pool
.
ToAddress
}
,格式错误"
);
}
SmtpClient
smtp
=
new
SmtpClient
(
config
.
SmtpUrl
);
smtp
.
UseDefaultCredentials
=
false
;
smtp
.
Credentials
=
new
NetworkCredential
(
config
.
UserId
,
config
.
Password
);
smtp
.
DeliveryMethod
=
SmtpDeliveryMethod
.
Network
;
smtp
.
EnableSsl
=
true
;
MailMessage
msg
=
new
MailMessage
();
msg
.
From
=
from
;
msg
.
To
.
Add
(
to
);
msg
.
BodyEncoding
=
Encoding
.
UTF8
;
msg
.
Body
=
pool
.
Body
;
msg
.
Subject
=
pool
.
Subject
;
msg
.
IsBodyHtml
=
pool
.
IsBodyHtml
;
var
attachs
=
pool
.
GetAttachments
();
if
(!
attachs
.
IsNullOrEmpty
())
{
foreach
(
var
attach
in
attachs
)
{
msg
.
Attachments
.
Add
(
attach
);
}
}
try
{
smtp
.
Send
(
msg
);
pool
.
SendStatus
=
SendStatus
.
Complete
;
pool
.
AddOnlyProperties
(
o
=>
o
.
SendStatus
);
}
catch
(
SmtpException
ex
)
{
pool
.
SendStatus
=
SendStatus
.
Fail
;
pool
.
AddOnlyProperties
(
o
=>
o
.
SendStatus
);
pool
.
Remark
=
ex
.
Message
;
pool
.
AddOnlyProperties
(
o
=>
o
.
Remark
);
}
finally
{
pool
.
IsSended
=
true
;
pool
.
AddOnlyProperties
(
o
=>
o
.
IsSended
);
}
return
pool
;
}
}
}
Src/Kivii.Biz.EmailPools.V4.5.csproj
View file @
3294a1c2
...
...
@@ -52,8 +52,6 @@
<ItemGroup>
<Compile
Include=
"Configs.cs"
/>
<Compile
Include=
"Entities\EmailPool.cs"
/>
<Compile
Include=
"Entities\SmtpConfig.cs"
/>
<Compile
Include=
"Extensions.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Transforms\RestfulEmailPool.cs"
/>
</ItemGroup>
...
...
Src/Properties/AssemblyInfo.cs
View file @
3294a1c2
...
...
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2024.4090")]
[assembly: AssemblyFileVersion("5.4.2023.4090")]
\ No newline at end of file
[assembly: AssemblyVersion("5.4.2024.6190")]
[assembly: AssemblyFileVersion("5.4.2023.6190")]
\ No newline at end of file
Src/Transforms/RestfulEmailPool.cs
View file @
3294a1c2
...
...
@@ -14,21 +14,21 @@ namespace Kivii.EmailPools.Transforms
{
[
Api
(
Description
=
"邮箱池创建"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolCreate
:
RestfulExecution
<
EmailPool
>
public
class
EmailPoolCreate
:
RestfulExecution
Generic
<
EmailPool
>
{
public
EmailPool
Item
{
get
;
set
;
}
public
List
<
EmailPool
>
Items
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
Generic
<
G
>
(
IRequest
req
,
IResponse
res
)
{
(
Item
==
null
&&
Items
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"Need Item Or Items!"
);
if
(
Items
.
IsNullOrEmpty
())
Items
=
new
List
<
EmailPool
>();
if
(
Item
!=
null
)
Items
.
Add
(
Item
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
rtns
=
new
RestfulCreateResponse
<
EmailPool
>();
rtns
.
Results
=
new
List
<
EmailPool
>();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>
>();
var
rtns
=
new
RestfulCreateResponse
<
EmailPool
<
G
>
>();
rtns
.
Results
=
new
List
<
EmailPool
<
G
>
>();
foreach
(
var
item
in
Items
)
{
...
...
@@ -50,8 +50,10 @@ namespace Kivii.EmailPools.Transforms
{
throw
new
Exception
(
$"收件地址
{
item
.
ToAddress
}
,格式错误"
);
}
conn
.
Insert
(
item
);
rtns
.
Results
.
Add
(
item
);
EmailPool
<
G
>
emailPool
=
new
EmailPool
<
G
>();
emailPool
.
PopulateWith
(
item
);
conn
.
Insert
(
emailPool
);
rtns
.
Results
.
Add
(
emailPool
);
}
catch
{
...
...
@@ -64,27 +66,36 @@ namespace Kivii.EmailPools.Transforms
[
Api
(
Description
=
"邮箱池更新"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolUpdate
:
RestfulUpdate
<
EmailPool
>
{
public
override
bool
OnPreRestfulUpdate
(
IRequest
req
,
IResponse
res
,
IDbConnection
dbConnection
,
IRestfulUpdateResponse
<
EmailPool
>
rtns
)
public
class
EmailPoolUpdate
:
RestfulExecutionGeneric
<
EmailPool
>
{
var
kvids
=
Items
.
ConvertAll
(
p
=>
p
.
Kvid
);
if
(
dbConnection
.
Exists
<
EmailPool
>(
o
=>
o
.
IsSended
&&
Sql
.
In
(
o
.
Kvid
,
kvids
)))
throw
new
Exception
(
"存在已发送的数据,无法更新数据!"
);
public
EmailPool
Item
{
get
;
set
;
}
foreach
(
var
item
in
Items
)
{
if
(
item
.
OnlyPropertiesIsExist
(
o
=>
o
.
FromAddress
))
{
try
public
List
<
EmailPool
>
Items
{
get
;
set
;
}
public
override
object
OnExecutionGeneric
<
G
>(
IRequest
req
,
IResponse
res
)
{
var
from
=
new
MailAddress
(
item
.
FromAddress
,
item
.
FromAddress
);
}
catch
(
Item
==
null
&&
Items
.
IsNullOrEmpty
()).
ThrowIfTrue
(
"Need Item Or Items!"
);
if
(
Items
.
IsNullOrEmpty
())
Items
=
new
List
<
EmailPool
>();
if
(
Item
!=
null
)
Items
.
Add
(
Item
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>>();
var
emailPools
=
conn
.
SelectByIds
<
EmailPool
<
G
>>(
Items
.
ConvertAll
(
o
=>
o
.
Kvid
));
emailPools
.
ThrowIfNullOrEmpty
(
"未找到要更新的数据!"
);
if
(
emailPools
.
Exists
(
o
=>
o
.
IsSended
))
{
throw
new
Exception
(
$"发送地址
{
item
.
FromAddress
}
,格式错误"
);
}
throw
new
Exception
(
"存在已发送的数据,无法更新数据!"
);
}
var
rtns
=
new
RestfulUpdateResponse
<
EmailPool
<
G
>>();
rtns
.
Results
=
new
List
<
EmailPool
<
G
>>();
foreach
(
var
item
in
Items
)
{
var
emailPool
=
emailPools
.
FirstOrDefault
(
o
=>
o
.
Kvid
==
item
.
Kvid
);
if
(
emailPool
!=
null
)
{
if
(
item
.
OnlyPropertiesIsExist
(
o
=>
o
.
ToAddress
))
{
try
...
...
@@ -95,60 +106,69 @@ namespace Kivii.EmailPools.Transforms
{
throw
new
Exception
(
$"收件地址
{
item
.
ToAddress
}
,格式错误"
);
}
emailPool
.
ToAddress
=
item
.
ToAddress
;
emailPool
.
AddOnlyProperties
(
o
=>
o
.
ToAddress
);
conn
.
UpdateOnly
(
emailPool
);
rtns
.
Results
.
Add
(
emailPool
);
}
}
return
base
.
OnPreRestfulUpdate
(
req
,
res
,
dbConnection
,
rtns
);
}
return
rtns
;
}
}
[
Api
(
Description
=
"邮箱池查询"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolQuery
:
Restful
Query
<
EmailPool
>
public
class
EmailPoolQuery
:
Restful
ExecutionGeneric
<
EmailPool
>
{
#
region
QueryArgs
public
virtual
int
?
Skip
{
get
;
set
;
}
}
public
virtual
int
?
Take
{
get
;
set
;
}
[
Api
(
Description
=
"未发送邮箱池"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolPreSending
:
RestfulExecution
<
EmailPool
>
{
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
pools
=
conn
.
Select
<
EmailPool
>(
o
=>
o
.
IsSended
==
false
);
public
virtual
string
OrderBy
{
get
;
set
;
}
var
rtns
=
new
RestfulQueryResponse
<
EmailPool
>();
rtns
.
Results
=
new
List
<
EmailPool
>();
rtns
.
Results
.
AddRange
(
pools
);
rtns
.
Total
=
rtns
.
Results
.
Count
;
public
string
OrderByDesc
{
get
;
set
;
}
public
virtual
string
Include
{
get
;
set
;
}
public
virtual
string
Fields
{
get
;
set
;
}
public
string
QueryKeys
{
get
;
set
;
}
public
string
QueryValues
{
get
;
set
;
}
#
endregion
public
override
object
OnExecutionGeneric
<
G
>(
IRequest
req
,
IResponse
res
)
{
Console
.
WriteLine
(
"---------------Start:Query----------------"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>>();
var
dynamicParams
=
Request
.
GetRequestParams
();
var
autoQuery
=
Request
.
TryResolve
<
IAutoQueryDb
>();
autoQuery
.
IncludeTotal
=
true
;
var
request
=
new
RestfulQuery
<
EmailPool
<
G
>>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
Console
.
WriteLine
(
$"---------------Query:
{
rtns
.
Total
}
----------------"
);
Console
.
WriteLine
(
"---------------End:Query----------------"
);
return
rtns
;
}
}
[
Api
(
Description
=
"
发送邮箱
"
)]
[
Api
(
Description
=
"
未发送邮箱池
"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPool
Sending
:
RestfulExecution
<
EmailPool
>
public
class
EmailPool
PreSending
:
RestfulExecutionGeneric
<
EmailPool
>
{
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecutionGeneric
<
G
>(
IRequest
req
,
IResponse
res
)
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
>(
Kvids
);
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
>();
rtns
.
Results
=
new
List
<
EmailPool
>();
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>>();
var
pools
=
conn
.
Select
<
EmailPool
<
G
>>(
o
=>
o
.
IsSended
==
false
);
if
(
pools
.
IsNullOrEmpty
())
return
rtns
;
foreach
(
var
item
in
pools
)
{
var
result
=
item
.
Sending
();
conn
.
UpdateOnly
(
result
);
rtns
.
Results
.
Add
(
result
);
}
var
rtns
=
new
RestfulQueryResponse
<
EmailPool
<
G
>>();
rtns
.
Results
=
new
List
<
EmailPool
<
G
>>();
rtns
.
Results
.
AddRange
(
pools
);
rtns
.
Total
=
rtns
.
Results
.
Count
;
return
rtns
;
}
...
...
@@ -156,29 +176,27 @@ namespace Kivii.EmailPools.Transforms
[
Api
(
Description
=
"标记发送完成"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolComplete
:
RestfulExecution
<
EmailPool
>
public
class
EmailPoolComplete
:
RestfulExecution
Generic
<
EmailPool
>
{
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
string
OperatorName
{
get
;
set
;
}
public
Guid
OperatorKvid
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
Generic
<
G
>
(
IRequest
req
,
IResponse
res
)
{
Kvids
.
ThrowIfNullOrEmpty
(
"Need Kvids"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
>(
Kvids
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
<
G
>
>(
Kvids
);
pools
.
ThrowIfNullOrEmpty
(
$"EmailPool Not Found:Kvid=
{
Kvids
}
"
);
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
>();
rtns
.
Results
=
new
List
<
EmailPool
>();
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
<
G
>
>();
rtns
.
Results
=
new
List
<
EmailPool
<
G
>
>();
foreach
(
var
item
in
pools
)
{
item
.
IsSended
=
true
;
item
.
AddOnlyProperties
(
o
=>
o
.
IsSended
);
item
.
SendStatus
=
SendStatus
.
Complete
;
item
.
AddOnlyProperties
(
o
=>
o
.
SendStatus
);
item
.
OperatorName
=
OperatorName
;
item
.
AddOnlyProperties
(
o
=>
o
.
OperatorName
);
item
.
OperatorKvid
=
OperatorKvid
;
...
...
@@ -190,11 +208,11 @@ namespace Kivii.EmailPools.Transforms
conn
.
UpdateOnly
(
item
);
rtns
.
Results
.
Add
(
item
);
var
log
=
new
EntityLog
<
EmailPool
>();
var
log
=
new
EntityLog
<
EmailPool
<
G
>
>();
log
.
OwnerKvid
=
item
.
OwnerKvid
;
log
.
BizId
=
item
.
OwnerName
;
log
.
BizKvid
=
item
.
OwnerKvid
;
log
.
BizType
=
typeof
(
EmailPool
).
FullName
;
log
.
BizType
=
typeof
(
G
).
FullName
;
log
.
Type
=
"电子邮箱"
;
log
.
Title
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
log
.
Summary
=
"电子邮箱发送完成"
;
...
...
@@ -208,23 +226,23 @@ namespace Kivii.EmailPools.Transforms
[
Api
(
Description
=
"标记发送失败"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolFail
:
RestfulExecution
<
EmailPool
>
public
class
EmailPoolFail
:
RestfulExecution
Generic
<
EmailPool
>
{
public
List
<
EmailPool
>
Items
{
get
;
set
;
}
public
string
OperatorName
{
get
;
set
;
}
public
Guid
OperatorKvid
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
Generic
<
G
>
(
IRequest
req
,
IResponse
res
)
{
Items
.
ThrowIfNullOrEmpty
(
"Need Kvids"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
>(
Items
.
ConvertAll
(
p
=>
p
.
Kvid
));
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
<
G
>
>(
Items
.
ConvertAll
(
p
=>
p
.
Kvid
));
pools
.
ThrowIfNullOrEmpty
(
$"EmailPools Not Found!"
);
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
>();
rtns
.
Results
=
new
List
<
EmailPool
>();
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
<
G
>
>();
rtns
.
Results
=
new
List
<
EmailPool
<
G
>
>();
foreach
(
var
item
in
pools
)
{
...
...
@@ -232,8 +250,6 @@ namespace Kivii.EmailPools.Transforms
if
(
current
==
null
)
continue
;
item
.
IsSended
=
true
;
item
.
AddOnlyProperties
(
o
=>
o
.
IsSended
);
item
.
SendStatus
=
SendStatus
.
Fail
;
item
.
AddOnlyProperties
(
o
=>
o
.
SendStatus
);
item
.
OperatorName
=
OperatorName
;
item
.
AddOnlyProperties
(
o
=>
o
.
OperatorName
);
item
.
OperatorKvid
=
OperatorKvid
;
...
...
@@ -245,11 +261,11 @@ namespace Kivii.EmailPools.Transforms
conn
.
UpdateOnly
(
item
);
rtns
.
Results
.
Add
(
item
);
var
log
=
new
EntityLog
<
EmailPool
>();
var
log
=
new
EntityLog
<
EmailPool
<
G
>
>();
log
.
OwnerKvid
=
item
.
OwnerKvid
;
log
.
BizId
=
item
.
OwnerName
;
log
.
BizKvid
=
item
.
OwnerKvid
;
log
.
BizType
=
typeof
(
EmailPool
).
FullName
;
log
.
BizType
=
typeof
(
G
).
FullName
;
log
.
Type
=
"电子邮箱"
;
log
.
Title
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
log
.
Summary
=
"电子邮箱发送失败"
;
...
...
@@ -263,28 +279,26 @@ namespace Kivii.EmailPools.Transforms
[
Api
(
Description
=
"取消发送"
)]
[
RequiresAnyRole
(
MemberRoles
.
Everyone
)]
public
class
EmailPoolCancel
:
RestfulExecution
<
EmailPool
>
public
class
EmailPoolCancel
:
RestfulExecution
Generic
<
EmailPool
>
{
public
List
<
Guid
>
Kvids
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
public
override
object
OnExecution
Generic
<
G
>
(
IRequest
req
,
IResponse
res
)
{
Kvids
.
ThrowIfNullOrEmpty
(
"Need Kvids"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
>(
Kvids
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
EmailPool
<
G
>
>();
var
pools
=
conn
.
SelectByIds
<
EmailPool
<
G
>
>(
Kvids
);
pools
.
ThrowIfNullOrEmpty
(
$"EmailPools Not Found!"
);
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
>();
rtns
.
Results
=
new
List
<
EmailPool
>();
var
rtns
=
new
RestfulExecutionResponse
<
EmailPool
<
G
>
>();
rtns
.
Results
=
new
List
<
EmailPool
<
G
>
>();
foreach
(
var
item
in
pools
)
{
if
(
item
.
IsSended
)
continue
;
item
.
IsSended
=
true
;
item
.
AddOnlyProperties
(
o
=>
o
.
IsSended
);
item
.
SendStatus
=
SendStatus
.
Cancel
;
item
.
AddOnlyProperties
(
o
=>
o
.
SendStatus
);
item
.
OperatorName
=
KiviiContext
.
CurrentMember
.
FullName
;
item
.
AddOnlyProperties
(
o
=>
o
.
OperatorName
);
item
.
OperatorKvid
=
KiviiContext
.
CurrentMember
.
Kvid
;
...
...
@@ -294,11 +308,11 @@ namespace Kivii.EmailPools.Transforms
conn
.
UpdateOnly
(
item
);
rtns
.
Results
.
Add
(
item
);
var
log
=
new
EntityLog
<
EmailPool
>();
var
log
=
new
EntityLog
<
EmailPool
<
G
>
>();
log
.
OwnerKvid
=
item
.
OwnerKvid
;
log
.
BizId
=
item
.
OwnerName
;
log
.
BizKvid
=
item
.
OwnerKvid
;
log
.
BizType
=
typeof
(
EmailPool
).
FullName
;
log
.
BizType
=
typeof
(
G
).
FullName
;
log
.
Type
=
"电子邮箱"
;
log
.
Title
=
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
);
log
.
Summary
=
"取消电子邮箱发送"
;
...
...
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