xj qian
2024-06-25 46bf65da8237cb34a62bbe0d6d4b8ba2bb2dc7b1
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#pragma once
 
#include <wobject/xstring.hpp>
#include <wobject/xaserverarg.hpp>
#include <win32/win.hpp>
#include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp>
#include <wobject/xurl.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <xcontrol/xdwtable.hpp>
#include <wobject/xapp.hpp>
 
class ViewObject 
{
public:
    static int alert(HWND hWnd,string error)
    {
        return MessageBoxW(hWnd, error, L"Ìáʾ", 0);
    }
 
    static int alert(string error)
    {
        return alert(nullptr, error);
    }
    static int trace(string error)
    {
        return 1;
    }
 
    static xaserverarg MakeArg(string argName, string argValue)
    {
        xaserverarg arg;
        arg.AddArg(argName, argValue);
        return arg;
    }
 
    static xaserverarg MakeArg(string argName, string argValue, string argName1, string argValue1)
    {
        xaserverarg arg;
        arg.AddArg(argName, argValue);
        arg.AddArg(argName1, argValue1);
        return arg;
    }
 
    static string GetGuid()
    {
        return publiccode::GetGuid();
    }
 
    //»ñÈ¡ÐÐÔªËØµÄÖµ        
    static xstring GetElementString(KXMLDOMElement e, xstring name)
    {
        if (name == L"") return L"";
        if (e.selectSingleNode(name))
            return e.selectSingleNode(name).text();
        else
            return L"";
    }
 
    static string GetElementString(KXMLDOMElement e, xstring name, bool isdisplay)
    {
        if (isdisplay) name += L"/@_displaystring";
        return GetElementString(e, name);
    }
 
    static  KXMLDOMDocument RetrieveData(string queryUrl)
    {
        return RetrieveData(xapp::GetServerUrl(), queryUrl);
    }
 
    static  KXMLDOMDocument RetrieveData(string serverUrl,string queryUrl)
    {
        KXMLDOMDocument x;
        if (xurl::get(serverUrl,queryUrl, L"", x) != 1)
        {
            string error = x.text();
            trace(error);
            return 0;
        }
        return x;
    }
 
    static  KXMLDOMDocument RetrieveData( string queryUrl, string argName, string argValue)
    {
        return RetrieveData(xapp::GetServerUrl(), queryUrl, argName, argValue);
    }
    static  KXMLDOMDocument RetrieveData(string serverUrl, string queryUrl, string argName, string argValue)
    {
        KXMLDOMDocument x;
        xaserverarg arg;
        arg.AddArg(argName, argValue);
        if (xurl::get(serverUrl,queryUrl, arg.GetString(), x) != 1)
        {
            string error = x.text();
            trace(error);
            return 0;
        }
        return x;
    }
 
    static   KXMLDOMDocument RetrieveData(string queryUrl, string argName, string argValue, string argName1, string argValue1)
    {
        return RetrieveData(xapp::GetServerUrl(), queryUrl, argName, argValue, argName1, argValue1);
    }
    static   KXMLDOMDocument RetrieveData(string serverUrl, string queryUrl, string argName, string argValue, string argName1, string argValue1)
    {
        KXMLDOMDocument x;
        xaserverarg arg;
        arg.AddArg(argName, argValue);
        arg.AddArg(argName1, argValue1);
        if (xurl::get(serverUrl, queryUrl, arg.GetString(), x) != 1)
        {
            string error = x.text();
            trace(error);
            return 0;
        }
        return x;
    }
 
    static   KXMLDOMDocument RetrieveData(string queryUrl, string argName, string argValue, string argName1, string argValue1, string argName2, string argValue2)
    {
        return RetrieveData(xapp::GetServerUrl(), queryUrl, argName, argValue, argName1, argValue1, argName2, argValue2);
    }
 
    static   KXMLDOMDocument RetrieveData(string serverUrl, string queryUrl, string argName, string argValue, string argName1, string argValue1, string argName2, string argValue2)
    {
        KXMLDOMDocument x;
        xaserverarg arg;
        arg.AddArg(argName, argValue);
        arg.AddArg(argName1, argValue1);
        arg.AddArg(argName2, argValue2);
        if (xurl::get(serverUrl, queryUrl, arg.GetString(), x) != 1)
        {
            string error = x.text();
            trace(error);
            return 0;
        }
        return x;
    }
    static KXMLDOMDocument RetrieveData(string queryUrl, string argName, string argValue, string argName1, string argValue1, string argName2, string argValue2, string argName3, string argValue3)
    {
        return RetrieveData(xapp::GetServerUrl(), queryUrl, argName, argValue, argName1, argValue1, argName2, argValue3, argName2, argValue3);
    }
 
    static KXMLDOMDocument RetrieveData(string serverUrl, string queryUrl, string argName, string argValue, string argName1, string argValue1, string argName2, string argValue2, string argName3, string argValue3)
    {
        KXMLDOMDocument x;
        xaserverarg arg;
        arg.AddArg(argName, argValue);
        arg.AddArg(argName1, argValue1);
        arg.AddArg(argName2, argValue2);
        arg.AddArg(argName3, argValue3);
        if (xurl::get(serverUrl, queryUrl, arg.GetString(), x) != 1)
        {
            string error = x.text();
            trace(error);
            return 0;
        }
        return x;
    }
 
    static KXMLDOMDocument FecthData(string pUrl, string argStr)
    {
        KXMLDOMDocument x;
        if (xurl::get(xapp::GetApp()->GetServerUrl(), pUrl, argStr, x) != 1)
        {
            xstring error = x.text();
            trace(L"\r\nError fetch data:" + error + L"\r\nurl:=" + pUrl);
        }
        return x;
    }
 
    static KXMLDOMDocument FecthData(string serverUrl,string pUrl, string argStr)
    {
        KXMLDOMDocument x;
        if (xurl::get(serverUrl,pUrl, argStr, x) != 1)
        {
            xstring error = x.text();
            trace(L"\r\nError fetch data:" + error + L"\r\nurl:=" + pUrl);
        }
        return x;
    }
 
 
    static xstring AskNo(string serverUrl,string typ)
    {
        KXMLDOMDocument x;
        xaserverarg arg = MakeArg(L"type", typ);
        if (xurl::get(serverUrl,L"/sale/data/Util/askno", arg.GetString(), x) != 1)
        {
            string error = x.text();
            alert(error);
            return L"";
        }
        string no = x.text();
        return no;
    }
 
    static int TransData(string serverUrl,KXMLDOMNodeList nlist, xdwtable dwobj, int row, string column, string data)
    {
        int len = nlist.length();
        for (int i = 0; i < len; i++)
        {
            KXMLDOMElement e = nlist.item(i);
            string dataurl = e.getAttribute(L"dataurl");
            xstring columns = e.getAttribute(L"columns");
            string arg = e.getAttribute(L"arg");
            KXMLDOMDocument x = RetrieveData(serverUrl,dataurl, arg, data);
            if (!x) continue;
 
            xstring it;
            while (columns != L"")
            {
                if (columns.find(L",") > 0)
                {
                    it = columns.left(columns.find(L","));
                    columns = columns.mid(columns.find(L",") + 1, 9999);
                }
                else
                {
                    it = columns;
                    columns = L"";
                }
                KXMLDOMNode n = x.selectSingleNode(L"//" + it);
                if (n)
                {
                    dwobj.SetItemString(row, it.c_str(), xstring(n.text()).trim());
                }
                n = x.selectSingleNode(L"//" + it + L"/@_displaystring");
                if (n)
                {
                    dwobj.SetItemDisplayString(row, it.c_str(), xstring(n.text()).trim());
                }
            }
        }
        dwobj.Redraw();
        return 1;
    }
 
    static int TransData(string serverUrl, KXMLDOMNodeList nlist, xdwgrid dwobj, int row, string column, string data)
    {
        int len = nlist.length();
        for (int i = 0; i < len; i++)
        {
            KXMLDOMElement e = nlist.item(i);
            string dataurl = e.getAttribute(L"dataurl");
            xstring columns = e.getAttribute(L"columns");
            string arg = e.getAttribute(L"arg");
            KXMLDOMDocument x = RetrieveData(serverUrl, dataurl, arg, data);
            if (!x) continue;
 
            xstring it;
            while (columns != L"")
            {
                if (columns.find(L",") > 0)
                {
                    it = columns.left(columns.find(L","));
                    columns = columns.mid(columns.find(L",") + 1, 9999);
                }
                else
                {
                    it = columns;
                    columns = L"";
                }
                KXMLDOMNode n = x.selectSingleNode(L"//" + it);
                if (n)
                {
                    dwobj.SetItemString(row, it.c_str(), xstring(n.text()).trim());
                }
                n = x.selectSingleNode(L"//" + it + L"/@_displaystring");
                if (n)
                {
                    dwobj.SetItemDisplayString(row, it.c_str(), xstring(n.text()).trim());
                }
            }
        }
        dwobj.Redraw();
    }
 
    int AddMessage(string serverUrl, string Category, string Reciever, string EntityNo, string EntityID, string Subject, string Content)
    {
        KXMLDOMDocument x;
        xaserverarg arg;
        arg.setNativePointer(arg.CreateInstance());
        arg.AddArg(L"EntityNo", EntityNo);
        arg.AddArg(L"EntityID", EntityID);
        arg.AddArg(L"Subject", Subject);
        arg.AddArg(L"Category", Category);
        arg.AddArg(L"Reciever", Reciever);
        arg.AddArg(L"Content", Content);
        if (xurl::get(serverUrl,L"/sale/data/business/message/add", arg.GetString(), x) != 1)
        {
            string error = x.text();
            trace(error);
            return 0;
        }
        return 1;
    }
};