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
14a1134d
Commit
14a1134d
authored
Jul 15, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/gitlab/dev7.0-blowing' into dev7.0
parents
6644d9a9
8eaca267
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
7 deletions
+105
-7
SyncPropServiceClient.cs
...JComponents/OBJComponents/Client/SyncPropServiceClient.cs
+105
-7
No files found.
Project.FLY.OBJComponents/OBJComponents/Client/SyncPropServiceClient.cs
View file @
14a1134d
...
...
@@ -24,8 +24,21 @@ namespace FLY.OBJComponents.Client
/// <summary>
/// 当前 INotifyPropertyChanged 对象 引发了 PropertyChanged, 是由于 接收到数据导致的
/// </summary>
public
bool
IsInPushValue
{
get
;
protected
set
;
}
public
bool
IsInPushValue
{
get
;
protected
set
;
}
/// <summary>
/// 同步完成
/// </summary>
public
bool
IsSynced
{
get
;
private
set
;
}
/// <summary>
/// 缓存 发出 GetAllData指令,到收到回复 之间时段的 全部推送
/// </summary>
List
<
Dictionary
<
string
,
Dictionary
<
string
,
object
>>>
pushDataList
=
new
List
<
Dictionary
<
string
,
Dictionary
<
string
,
object
>>>();
/// <summary>
/// Add 函数, 添加的 objname, 必须等全部 都返回。 只要 addObjNameList.Count() 不为0, 也是要缓存 推送的
/// </summary>
List
<
string
>
addObjNameList
=
new
List
<
string
>();
public
SyncPropServiceClient
(
UInt32
serverID
,
Dictionary
<
string
,
INotifyPropertyChanged
>
objnames
)
{
...
...
@@ -62,6 +75,11 @@ namespace FLY.OBJComponents.Client
ObjNames
.
Add
(
objname
,
obj
);
//向服务器,只获取这个对象的数据
//暂停接收推送。。。。
IsSynced
=
false
;
addObjNameList
.
Add
(
objname
);
string
json
=
JsonConvert
.
SerializeObject
(
objname
);
FObjBase
.
FObjSys
.
Current
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
SYNCPROP_OBJ_INTERFACE
.
CALL_GET_DATA
,
Misc
.
Converter
.
StringToBytes
(
json
));
...
...
@@ -74,7 +92,8 @@ namespace FLY.OBJComponents.Client
void
Data_PropertyChanged
(
object
sender
,
System
.
ComponentModel
.
PropertyChangedEventArgs
e
)
{
PropertyInfo
property
=
sender
.
GetType
().
GetProperty
(
e
.
PropertyName
);
if
(!
property
.
CanWrite
)
{
if
(!
property
.
CanWrite
)
{
return
;
}
...
...
@@ -125,6 +144,9 @@ namespace FLY.OBJComponents.Client
{
mConn
=
from
;
IsSynced
=
false
;
pushDataList
.
Clear
();
if
(
from
.
IsConnected
)
{
CurrObjSys
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
...
...
@@ -134,8 +156,11 @@ namespace FLY.OBJComponents.Client
CurrObjSys
.
SenseConfigEx
(
mConn
,
mServerID
,
ID
,
0xffffffff
,
SENSE_CONFIG
.
ADD
);
}
}
public
override
void
PushInfo
(
IFConn
from
,
uint
srcid
,
ushort
infoid
,
byte
[]
infodata
)
{
switch
(
infoid
)
...
...
@@ -144,10 +169,19 @@ namespace FLY.OBJComponents.Client
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
Dictionary
<
string
,
Dictionary
<
string
,
object
>>
DsDso
=
JsonConvert
.
DeserializeObject
<
Dictionary
<
string
,
Dictionary
<
string
,
object
>>>(
json
);
if
(!
IsSynced
)
{
//还没同步完成,先缓存
pushDataList
.
Add
(
DsDso
);
return
;
}
IsInPushValue
=
true
;
foreach
(
var
Dso
in
DsDso
)
{
INotifyPropertyChanged
obj
=
ObjNames
[
Dso
.
Key
]
as
INotifyPropertyChanged
;
INotifyPropertyChanged
obj
=
ObjNames
[
Dso
.
Key
];
obj
.
PropertyChanged
-=
Data_PropertyChanged
;
foreach
(
var
dv
in
Dso
.
Value
)
...
...
@@ -162,12 +196,65 @@ namespace FLY.OBJComponents.Client
break
;
}
}
/// <summary>
/// 处理全部 缓存的推送数据
/// </summary>
void
DealPushDataList
()
{
IsInPushValue
=
true
;
for
(
int
i
=
0
;
i
<
pushDataList
.
Count
();
i
++)
{
var
DsDso
=
pushDataList
[
i
];
foreach
(
var
Dso
in
DsDso
)
{
INotifyPropertyChanged
obj
=
ObjNames
[
Dso
.
Key
];
obj
.
PropertyChanged
-=
Data_PropertyChanged
;
foreach
(
var
dv
in
Dso
.
Value
)
{
PropertiesManager_JSON
.
SetValue
(
obj
,
dv
.
Key
,
dv
.
Value
);
}
obj
.
PropertyChanged
+=
Data_PropertyChanged
;
}
}
IsInPushValue
=
false
;
pushDataList
.
Clear
();
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
{
switch
(
funcid
)
{
case
SYNCPROP_OBJ_INTERFACE
.
CALL_GET_ALL_DATA
:
{
//这个可能是大包来的,很慢,需要记录中途全部 push
string
json
=
Misc
.
Converter
.
BytesToString
(
retdata
);
//log.Debug("GetAllData:" +json);
Dictionary
<
string
,
Dictionary
<
string
,
object
>>
DsDso
=
JsonConvert
.
DeserializeObject
<
Dictionary
<
string
,
Dictionary
<
string
,
object
>>>(
json
);
IsInPushValue
=
true
;
foreach
(
var
Dso
in
DsDso
)
{
if
(
ObjNames
.
ContainsKey
(
Dso
.
Key
))
{
INotifyPropertyChanged
obj
=
ObjNames
[
Dso
.
Key
]
as
INotifyPropertyChanged
;
obj
.
PropertyChanged
-=
Data_PropertyChanged
;
foreach
(
var
dv
in
Dso
.
Value
)
{
PropertiesManager_JSON
.
SetValue
(
obj
,
dv
.
Key
,
dv
.
Value
);
}
obj
.
PropertyChanged
+=
Data_PropertyChanged
;
}
}
IsInPushValue
=
false
;
//完成同步
IsSynced
=
true
;
//处理之前的推送事件
DealPushDataList
();
}
break
;
case
SYNCPROP_OBJ_INTERFACE
.
CALL_GET_DATA
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
retdata
);
Dictionary
<
string
,
Dictionary
<
string
,
object
>>
DsDso
=
JsonConvert
.
DeserializeObject
<
Dictionary
<
string
,
Dictionary
<
string
,
object
>>>(
json
);
...
...
@@ -184,8 +271,19 @@ namespace FLY.OBJComponents.Client
}
obj
.
PropertyChanged
+=
Data_PropertyChanged
;
}
addObjNameList
.
Remove
(
Dso
.
Key
);
}
IsInPushValue
=
false
;
//全部接收完!!!
if
(
addObjNameList
.
Count
()
==
0
)
{
//完成同步
IsSynced
=
true
;
//处理之前的推送事件
DealPushDataList
();
}
}
break
;
}
...
...
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