Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
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
潘栩锋
Thick-Common
Commits
cf8b9edb
Commit
cf8b9edb
authored
Jan 11, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/gitlab/dev6.0' into feature-feng-updateMahApp-20201203
parents
e3aad027
a33ff2f8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
299 additions
and
2 deletions
+299
-2
WdGraphConfigStyle.xaml
MultiLayout/MainEdit/PgMeGraph/WdGraphConfigStyle.xaml
+1
-1
WdGraphTabItemConfigStyle.xaml
...iLayout/MainEdit/PgMeGraph/WdGraphTabItemConfigStyle.xaml
+1
-1
FLY.OBJComponents.csproj
....FLY.OBJComponents/OBJComponents/FLY.OBJComponents.csproj
+2
-0
IBulkDbSQLiteService.cs
...Components/OBJComponents/IService/IBulkDbSQLiteService.cs
+61
-0
BulkDbSQLite.cs
...ct.FLY.OBJComponents/OBJComponents/Server/BulkDbSQLite.cs
+234
-0
No files found.
MultiLayout/MainEdit/PgMeGraph/WdGraphConfigStyle.xaml
View file @
cf8b9edb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<Style.Resources>
<Style.Resources>
<Style TargetType="TextBlock" >
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Foreground" Value="
{StaticResource BlackBrush}
"/>
<Setter Property="Foreground" Value="
Black
"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</Style>
<Style TargetType="iconPacks:PackIconMaterial" >
<Style TargetType="iconPacks:PackIconMaterial" >
...
...
MultiLayout/MainEdit/PgMeGraph/WdGraphTabItemConfigStyle.xaml
View file @
cf8b9edb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<Style.Resources>
<Style.Resources>
<Style TargetType="TextBlock" >
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Foreground" Value="
{StaticResource BlackBrush}
"/>
<Setter Property="Foreground" Value="
Black
"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</Style>
<Style TargetType="iconPacks:PackIconMaterial" >
<Style TargetType="iconPacks:PackIconMaterial" >
...
...
Project.FLY.OBJComponents/OBJComponents/FLY.OBJComponents.csproj
View file @
cf8b9edb
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
<Compile
Include=
"Common\PropertiesManager.cs"
/>
<Compile
Include=
"Common\PropertiesManager.cs"
/>
<Compile
Include=
"IService\IBuffer.cs"
/>
<Compile
Include=
"IService\IBuffer.cs"
/>
<Compile
Include=
"IService\IBufferAdd.cs"
/>
<Compile
Include=
"IService\IBufferAdd.cs"
/>
<Compile
Include=
"IService\IBulkDbSQLiteService.cs"
/>
<Compile
Include=
"IService\IJsonDistService.cs"
/>
<Compile
Include=
"IService\IJsonDistService.cs"
/>
<Compile
Include=
"IService\IPLCProxySystemService.cs"
/>
<Compile
Include=
"IService\IPLCProxySystemService.cs"
/>
<Compile
Include=
"IService\IPropertyOpt.cs"
/>
<Compile
Include=
"IService\IPropertyOpt.cs"
/>
...
@@ -83,6 +84,7 @@
...
@@ -83,6 +84,7 @@
<Compile
Include=
"Server\BufferSQLite.cs"
/>
<Compile
Include=
"Server\BufferSQLite.cs"
/>
<Compile
Include=
"Server\BufferStorage.cs"
/>
<Compile
Include=
"Server\BufferStorage.cs"
/>
<Compile
Include=
"Server\BufferError.cs"
/>
<Compile
Include=
"Server\BufferError.cs"
/>
<Compile
Include=
"Server\BulkDbSQLite.cs"
/>
<Compile
Include=
"Server\ErrorConf.cs"
/>
<Compile
Include=
"Server\ErrorConf.cs"
/>
<Compile
Include=
"Server\History.cs"
/>
<Compile
Include=
"Server\History.cs"
/>
<Compile
Include=
"Server\JsonDist.cs"
/>
<Compile
Include=
"Server\JsonDist.cs"
/>
...
...
Project.FLY.OBJComponents/OBJComponents/IService/IBulkDbSQLiteService.cs
0 → 100644
View file @
cf8b9edb
using
FObjBase
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
namespace
FLY.OBJComponents.IService
{
public
interface
IBulkDbSQLiteService
:
INotifyPropertyChanged
{
/// <summary>
/// 最后一条数据Id
/// </summary>
long
LastId
{
get
;
}
/// <summary>
/// 获取纵向趋势图
/// </summary>
/// <param name="request"></param>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
void
GetTrend
(
Pack_GetTrendRequest
request
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
);
}
public
class
Pack_GetTrendRequest
{
/// <summary>
/// 最后1幅数据ID, 当-1, 从数据库最后获取
/// </summary>
public
long
Id
;
/// <summary>
/// 长度
/// </summary>
public
int
Count
;
/// <summary>
/// 间隔, 只获取 Id % Interval == 0 的数据
/// </summary>
public
int
Interval
;
/// <summary>
/// 按时间查找数据
/// </summary>
public
bool
IsSearchByTime
;
/// <summary>
/// 按时间查找数据, 获取的数据对应的时间都比Time小
/// </summary>
public
DateTime
Time
;
}
public
class
Pack_GetTrendReponse
<
T
>
{
public
Pack_GetTrendRequest
Request
;
/// <summary>
/// 数据是从尾向前排的
/// </summary>
public
List
<
T
>
Values
;
}
}
Project.FLY.OBJComponents/OBJComponents/Server/BulkDbSQLite.cs
0 → 100644
View file @
cf8b9edb
using
FLY.OBJComponents.IService
;
using
FObjBase
;
using
SQLite
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
FLY.OBJComponents.Server
{
public
class
BulkDbSQLite
<
TLc
,
TDb
>
:
IBulkDbSQLiteService
where
TLc
:
IDbBase
,
new
()
where
TDb
:
IDbBase
,
new
()
{
DBTable
<
TDb
>
dbTable
;
SQLiteHelper
sqliteHelper
;
Func
<
TLc
,
TDb
>
mapLc2Db
;
Func
<
TDb
,
TLc
>
mapDb2Lc
;
public
long
LastId
{
get
;
private
set
;
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
BulkDbSQLite
()
{
}
public
void
Init
(
DBTable
<
TDb
>
dbTable
,
Func
<
TLc
,
TDb
>
mapLc2Db
,
Func
<
TDb
,
TLc
>
mapDb2Lc
)
{
this
.
dbTable
=
dbTable
;
this
.
sqliteHelper
=
dbTable
.
sqliteHelper
;
this
.
mapLc2Db
=
mapLc2Db
;
this
.
mapDb2Lc
=
mapDb2Lc
;
//获取最后一行数据
LastId
=
dbTable
.
MaxID
;
}
public
void
Add
(
TLc
lc
)
{
//添加 数据库必要的 field
lc
.
ID
=
dbTable
.
FreeID
;
//SQLs
List
<
string
>
sqls
=
new
List
<
string
>();
sqls
.
Add
(
SQLiteHelper
.
GetInsertCommandText
(
mapLc2Db
(
lc
)));
sqliteHelper
.
QueryTranAsync
(
sqls
);
LastId
=
lc
.
ID
;
}
public
void
AddRange
(
IEnumerable
<
TLc
>
lcs
)
{
//SQLs
List
<
string
>
sqls
=
new
List
<
string
>();
foreach
(
var
lc
in
lcs
)
{
//添加 数据库必要的 field
lc
.
ID
=
dbTable
.
FreeID
;
sqls
.
Add
(
SQLiteHelper
.
GetInsertCommandText
(
mapLc2Db
(
lc
)));
}
sqliteHelper
.
QueryTranAsync
(
sqls
);
LastId
=
lcs
.
Last
().
ID
;
}
public
async
void
GetTrend
(
Pack_GetTrendRequest
request
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
Pack_GetTrendReponse
<
TLc
>
reponse
=
new
Pack_GetTrendReponse
<
TLc
>();
reponse
.
Request
=
request
;
if
(
request
.
Count
>
400
)
//数量限制,避免死机
request
.
Count
=
400
;
else
if
(
request
.
Count
<
1
)
request
.
Count
=
1
;
if
(
request
.
Interval
<
1
)
//避免 /0
request
.
Interval
=
1
;
await
Task
.
Factory
.
StartNew
(()
=>
{
List
<
TDb
>
dbs
=
null
;
if
(!
request
.
IsSearchByTime
)
{
if
(
request
.
Id
<=
0
)
dbs
=
dbTable
.
Find
(
$"WHERE (ID %
{
request
.
Interval
}
= 0)"
+
$" ORDER BY ID DESC"
+
$" LIMIT
{
request
.
Count
}
OFFSET
{-
request
.
Id
}
"
);
else
dbs
=
dbTable
.
Find
(
$"WHERE (ID <=
{
request
.
Id
}
)"
+
$" AND (ID %
{
request
.
Interval
}
= 0)"
+
$" ORDER BY ID DESC"
+
$" LIMIT
{
request
.
Count
}
"
);
}
else
{
dbs
=
dbTable
.
Find
(
$"WHERE ( Time <=
{
request
.
Time
.
ToStringOfSQLiteFieldType
()}
)"
+
$" AND ( ID %
{
request
.
Interval
}
= 0)"
+
$" ORDER BY ID DESC"
+
$" LIMIT
{
request
.
Count
}
"
);
}
if
(
dbs
.
Count
()
==
0
)
return
;
//转为 Lc_XXX
List
<
TLc
>
lcs
=
new
List
<
TLc
>();
foreach
(
var
db
in
dbs
)
{
lcs
.
Add
(
mapDb2Lc
(
db
));
}
//从尾向前排的!!!!
reponse
.
Values
=
lcs
;
});
asyncDelegate
(
asyncContext
,
reponse
);
}
}
public
class
BulkDbSQLite
<
TDb
>
:
IBulkDbSQLiteService
where
TDb
:
IDbBase
,
new
()
{
DBTable
<
TDb
>
dbTable
;
SQLiteHelper
sqliteHelper
;
public
long
LastId
{
get
;
private
set
;
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
BulkDbSQLite
()
{
}
public
void
Init
(
DBTable
<
TDb
>
dbTable
)
{
this
.
dbTable
=
dbTable
;
this
.
sqliteHelper
=
dbTable
.
sqliteHelper
;
//获取最后一行数据
LastId
=
dbTable
.
MaxID
;
}
public
void
Add
(
TDb
lc
)
{
//添加 数据库必要的 field
lc
.
ID
=
dbTable
.
FreeID
;
//SQLs
List
<
string
>
sqls
=
new
List
<
string
>();
sqls
.
Add
(
SQLiteHelper
.
GetInsertCommandText
(
lc
));
sqliteHelper
.
QueryTranAsync
(
sqls
);
LastId
=
lc
.
ID
;
}
public
void
AddRange
(
IEnumerable
<
TDb
>
lcs
)
{
//SQLs
List
<
string
>
sqls
=
new
List
<
string
>();
foreach
(
var
lc
in
lcs
)
{
//添加 数据库必要的 field
lc
.
ID
=
dbTable
.
FreeID
;
sqls
.
Add
(
SQLiteHelper
.
GetInsertCommandText
(
lc
));
}
sqliteHelper
.
QueryTranAsync
(
sqls
);
LastId
=
lcs
.
Last
().
ID
;
}
public
async
void
GetTrend
(
Pack_GetTrendRequest
request
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
Pack_GetTrendReponse
<
TDb
>
reponse
=
new
Pack_GetTrendReponse
<
TDb
>();
reponse
.
Request
=
request
;
if
(
request
.
Count
>
400
)
//数量限制,避免死机
request
.
Count
=
400
;
else
if
(
request
.
Count
<
1
)
request
.
Count
=
1
;
if
(
request
.
Interval
<
1
)
//避免 /0
request
.
Interval
=
1
;
await
Task
.
Factory
.
StartNew
(()
=>
{
List
<
TDb
>
dbs
=
null
;
if
(!
request
.
IsSearchByTime
)
{
if
(
request
.
Id
<=
0
)
dbs
=
dbTable
.
Find
(
$"WHERE (ID %
{
request
.
Interval
}
= 0)"
+
$" ORDER BY ID DESC"
+
$" LIMIT
{
request
.
Count
}
OFFSET
{-
request
.
Id
}
"
);
else
dbs
=
dbTable
.
Find
(
$"WHERE (ID <=
{
request
.
Id
}
)"
+
$" AND (ID %
{
request
.
Interval
}
= 0)"
+
$" ORDER BY ID DESC"
+
$" LIMIT
{
request
.
Count
}
"
);
}
else
{
dbs
=
dbTable
.
Find
(
$"WHERE ( Time <=
{
request
.
Time
.
ToStringOfSQLiteFieldType
()}
)"
+
$" AND ( ID %
{
request
.
Interval
}
= 0)"
+
$" ORDER BY ID DESC"
+
$" LIMIT
{
request
.
Count
}
"
);
}
if
(
dbs
.
Count
()
==
0
)
return
;
//从尾向前排的!!!!
reponse
.
Values
=
dbs
;
});
asyncDelegate
(
asyncContext
,
reponse
);
}
}
}
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