1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;
using Misc;
using System.ComponentModel;
namespace FLY.Thick.RemoteHistory
{
public class RemoteHistory_OBJProxy: FObj
{
#region 延时推送 MARKNO
const int MARKNO_PUSH_PARAMS = 1;
const int MARKNO_PUSH_STATE = 2;
#endregion
IRemoteHistory mRemoteHistory;
public RemoteHistory_OBJProxy(int objsys_idx, UInt32 objid, IRemoteHistory remotehistory)
: base(objsys_idx)
{
mRemoteHistory = remotehistory;
ID = objid;
mRemoteHistory.PropertyChanged += new PropertyChangedEventHandler(mRemoteHistory_PropertyChanged);
}
void mRemoteHistory_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if ((e.PropertyName == "KeeyDay") ||
(e.PropertyName == "SaveRows"))
{
FObjBase.PollModule.Current.Poll_JustOnce(
new PollModule.PollHandler(delegate()
{
byte[] buf;
GetValue(null, 0, REMOTEHISTORY_OBJ_INTERFACE.GET_PARAMS, out buf);
CurrObjSys.PushObjInfoEx(
this, REMOTEHISTORY_OBJ_INTERFACE.PUSH_PARAMS,
buf);
}), this, MARKNO_PUSH_PARAMS);
}
else if (
(e.PropertyName == "CurrDays")||
(e.PropertyName == "CurrRows") ||
(e.PropertyName == "CurrPath"))
{
FObjBase.PollModule.Current.Poll_JustOnce(
new PollModule.PollHandler(delegate()
{
byte[] buf;
GetValue(null, 0, REMOTEHISTORY_OBJ_INTERFACE.GET_STATE, out buf);
CurrObjSys.PushObjInfoEx(
this, REMOTEHISTORY_OBJ_INTERFACE.PUSH_STATE,
buf);
}), this, MARKNO_PUSH_STATE);
}
}
public override void CallFunction(IFConn from, UInt32 srcid, UInt32 magic, UInt16 funcid, byte[] infodata)
{
switch (funcid)
{
case REMOTEHISTORY_OBJ_INTERFACE.CALL_FLUSH:
{
mRemoteHistory.Flush();
return;
}
break;
case REMOTEHISTORY_OBJ_INTERFACE.CALL_GETPATHS:
{
REMOTEHISTORY_OBJ_INTERFACE.Pack_GetPathsRequest p = new REMOTEHISTORY_OBJ_INTERFACE.Pack_GetPathsRequest();
if (!p.TryParse(infodata))
return;
mRemoteHistory.GetPaths(p.dt_begin, p.dt_end, p.profilename,
new GetPathsReponseHandler(delegate(List<string> paths, object state)
{
ConnContext c = (ConnContext)state;
CurrObjSys.PushCallFunctionEx(c.from, c.srcid, ID, c.magic,
REMOTEHISTORY_OBJ_INTERFACE.CALL_GETPATHS,
new REMOTEHISTORY_OBJ_INTERFACE.Pack_GetPathsResponse() { paths = paths }.ToBytes());
}),
new ConnContext(from, srcid, magic));
return;
}break;
case REMOTEHISTORY_OBJ_INTERFACE.CALL_GETROOTPATH:
{
mRemoteHistory.GetRootPath(
new GetRootPathReponseHandler(delegate(string path, object state)
{
ConnContext c = (ConnContext)state;
CurrObjSys.PushCallFunctionEx(c.from, c.srcid, ID, c.magic,
REMOTEHISTORY_OBJ_INTERFACE.CALL_GETROOTPATH,
new REMOTEHISTORY_OBJ_INTERFACE.Pack_GetRootPathResponse() { rootpath = path }.ToBytes());
}),
new ConnContext(from, srcid, magic));
return;
}break;
}
return;
}
public override void GetValue(IFConn from, uint srcid, ushort memid, out byte[] infodata)
{
switch (memid)
{
case REMOTEHISTORY_OBJ_INTERFACE.GET_PARAMS:
{
REMOTEHISTORY_OBJ_INTERFACE.Pack_Params p = new REMOTEHISTORY_OBJ_INTERFACE.Pack_Params()
{
keeyday = mRemoteHistory.KeeyDay,
saverows = mRemoteHistory.SaveRows
};
infodata = p.ToBytes();
} break;
case REMOTEHISTORY_OBJ_INTERFACE.GET_STATE:
{
REMOTEHISTORY_OBJ_INTERFACE.Pack_State p = new REMOTEHISTORY_OBJ_INTERFACE.Pack_State()
{
currdays = mRemoteHistory.CurrDays,
currrows = mRemoteHistory.CurrRows,
currpath = mRemoteHistory.CurrPath
};
infodata = p.ToBytes();
}break;
default:
infodata = null;
break;
}
}
public override void SetValue(IFConn from, uint srcid, ushort memid, byte[] infodata)
{
switch (memid)
{
case REMOTEHISTORY_OBJ_INTERFACE.SET_PARAMS:
{
REMOTEHISTORY_OBJ_INTERFACE.Pack_Params p = new REMOTEHISTORY_OBJ_INTERFACE.Pack_Params();
if (p.TryParse(infodata))
{
mRemoteHistory.KeeyDay = p.keeyday;
mRemoteHistory.SaveRows = p.saverows;
}
} break;
}
}
}
}