Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Biz.Samples.V4.5
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.Samples.V4.5
Commits
a885acfd
Commit
a885acfd
authored
Mar 01, 2024
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
f6b484f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
2 deletions
+79
-2
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+2
-2
RestfulSample.cs
Src/Transforms/RestfulSample.cs
+77
-0
No files found.
Src/Properties/AssemblyInfo.cs
View file @
a885acfd
...
...
@@ -37,5 +37,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.202
3.100
80")]
[assembly: AssemblyFileVersion("5.4.202
3.100
80")]
[assembly: AssemblyVersion("5.4.202
4.22
80")]
[assembly: AssemblyFileVersion("5.4.202
4.22
80")]
Src/Transforms/RestfulSample.cs
View file @
a885acfd
...
...
@@ -4,6 +4,7 @@ using Kivii.Web;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data.Common
;
using
System.Linq
;
using
System.Linq.Expressions
;
using
System.Security.Policy
;
...
...
@@ -813,4 +814,80 @@ namespace Kivii.Samples.Transforms
}
}
[
RequiresAnyRole
(
SystemRoles
.
Everyone
)]
[
Api
(
Description
=
"样品联合路由查询"
)]
public
class
SampleQueryEx
:
RestfulExecution
<
Sample
>
{
#
region
QueryArgs
//public virtual int? Skip { get; set; }
//public virtual int? Take { get; set; }
public
virtual
string
OrderBy
{
get
;
set
;
}
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
Guid
LocationKvid
{
get
;
set
;
}
public
string
LocationInternalCode
{
get
;
set
;
}
public
DateTime
RouteBeginTime
{
get
;
set
;
}
public
DateTime
RouteEndTime
{
get
;
set
;
}
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
int
monthDay
=
DateTime
.
DaysInMonth
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
);
if
(
RouteBeginTime
==
DateTime
.
MinValue
)
RouteBeginTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
1
);
if
(
RouteEndTime
==
DateTime
.
MinValue
)
RouteEndTime
=
new
DateTime
(
DateTime
.
Now
.
Year
,
DateTime
.
Now
.
Month
,
monthDay
);
var
beginTime
=
DateTime
.
Parse
(
RouteBeginTime
.
ToString
(
"yyyy-MM-dd"
));
var
endTime
=
DateTime
.
Parse
(
RouteEndTime
.
ToString
(
"yyyy-MM-dd"
));
if
(
endTime
<
beginTime
)
throw
new
Exception
(
"查询结束日期不可小于开始日期!"
);
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Sample
>();
Location
location
=
null
;
if
(
LocationKvid
!=
Guid
.
Empty
)
location
=
conn
.
SingleById
<
Location
>(
LocationKvid
);
if
(
location
==
null
)
{
if
(!
LocationInternalCode
.
IsNullOrEmpty
())
location
=
conn
.
Single
<
Location
>(
o
=>
o
.
InternalCode
==
LocationInternalCode
);
//location.ThrowIfNull("未找到指定的地点信息!");
}
var
dynamicParams
=
Request
.
GetRequestParams
();
var
autoQuery
=
Request
.
TryResolve
<
IAutoQueryDb
>();
autoQuery
.
IncludeTotal
=
true
;
var
request
=
new
RestfulQuery
<
Sample
>();
request
=
request
.
PopulateWith
(
this
);
var
sqlExpress
=
autoQuery
.
CreateQuery
(
Request
,
conn
,
request
,
dynamicParams
);
sqlExpress
.
Rows
=
null
;
sqlExpress
.
LeftJoin
<
Route
>((
s
,
r
)
=>
s
.
Kvid
==
r
.
SampleKvid
);
if
(
location
!=
null
)
sqlExpress
.
Where
<
Route
>(
o
=>
o
.
CurrentLocationKvid
==
location
.
Kvid
);
if
(
beginTime
!=
DateTime
.
MinValue
)
sqlExpress
.
Where
<
Route
>(
o
=>
o
.
OperateTime
>=
beginTime
);
if
(
endTime
!=
DateTime
.
MinValue
)
sqlExpress
.
Where
<
Route
>(
o
=>
o
.
OperateTime
<
endTime
);
sqlExpress
.
Select
<
Route
,
Sample
>((
r
,
s
)
=>
new
{
BizId
=
r
.
BizId
,
s
.
DealTime
,
s
.
DeadTime
,
Name
=
r
.
SampleName
,
PackageName
=
r
.
Title
,
OperateTime
=
r
.
OperateTime
,
Summary
=
r
.
Summary
,
s
.
Kvid
});
var
rtns
=
autoQuery
.
Execute
(
Request
,
conn
,
request
,
sqlExpress
);
return
rtns
;
}
}
}
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