LiFan
2025-04-24 9b3b2eb20b09e13da837a28f16e552ba70a090c4
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
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <xcontrol/xlayersheet.hpp>
#include <xcontrol/xcell.hpp>
#include <xcontrol/xlistview.hpp>
 
#include "vbusiness/vframe/maint.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
 
using xml = KXMLDOMDocument;
class __declspec(dllexport) HelpDocWin : public xframe
{
public:
    HelpDocWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
public:
    static HelpDocWin* CreateInstance(void* implPtr, void* hWnd)
    {
        return  new HelpDocWin(implPtr, (HWND)hWnd);
    }
 
public:
    //xdwgrid    dw_list;
    xlistview  lv_view;
    xnode    m_agentNode;    //Agent Condition
    int columnCount;
 
    int SetAgent()
    {
        xstring xfNodeAgentArea = L"agentarea";
        xnode anode = GetAgentNode(xfNodeAgentArea);
        if (m_agentNode)
        {
            SetAgentNode(anode, m_agentNode);
        }
        else
        {
            KXMLDOMElement xframeElement = GetElement();
            KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*");
            if (agent)
            {
                xstring s = agent.xml();
                m_agentNode = SetAgentNode(anode, s);
            }
        }
        return 1;
    }
 
    //½¹µã¼¤»î´¦Àíº¯Êý
    int OnSetFocus(TEvent* evt,LPARAM param)
    {
        //ÖØÖù¤¾ßÌõ
        SetAgent();
        return 1;
    }
 
    int OnListViewDoubleClicked(TEvent* evt,LPARAM param)
    {
        //ÖØÖù¤¾ßÌõ
        //SetAgent();
        OnDocumentOpen();
        CloseWindow();
        return 1;
    }
 
    int OnDocumentOpen()
    {
        int  LVNI_ALL = 0x0000;
        int  LVNI_FOCUSED = 0x0001;
        int  LVNI_SELECTED = 0x0002;
        int  LVNI_CUT = 0x0004;
        int  LVNI_DROPHILITED = 0x0008;
 
        int nItem = lv_view.GetNextItem( -1, LVNI_FOCUSED);
        if (nItem < 0) return 1;
 
        int LVIF_PARAM = 0x0004;
 
        lvitem lvItem;
        lvItem.iItem = nItem;
        lvItem.iSubItem = 0;
        lvItem.mask = LVIF_PARAM;
 
        lv_view.GetItem( lvItem);
        KXMLDOMElement ele = lvItem.lParam;
 
        xstring src = ele.getAttribute(L"url");
        xstring file = L"";
        if (src.find(L"/file/") > 0) file = src.mid(src.find(L"/file/") + 6, 9999);
        if (file.find(L"/file/") >= 0) file = file.mid(file.find(L"/file/") + 6, 9999);
        if (file.find(L"file/") >= 0) file = file.mid(file.find(L"file/") + 5, 9999);
        if (file == L"") return 1;
        //alert(file);
        xstring name = ele.getAttribute(L"caption");
        /*
        const xstring d = m_Html.GetData(p.object);
        if(d == L"") return -1;
        xstring file = d.mid(0, d.find(L"|##@@|",0));
        xstring name = d.mid(d.find(L"|##@@|",0)+6, d.length());
        */
 
        xaserver::CreateDirectory(L"C:/Temp");
        xstring str = file.left(2);
        xstring ext = L"";
        if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length());
        xstring sfile = file;// file.left(file.length() - 4);
        //trace(L"--"+ext +L" " + L"/business/attachment/"+str+L"/"+ file);
        //int openRet = xaserver::DownLoadFile(GetServerUrl(),L"/business/attachment/"+str+L"/"+ file,name,L"C:/Temp/"+name);
        int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file + L".jpg", L"", L"C:/Temp/" + sfile + ext);
 
        //alert(L"/business/attachment/"+str+L"/"+ file+L".jpg");
        if (openRet < 0)
        {
            alert(L"Îļþ´ò¿ªÊ§°Ü1£¡");
            return -1;
        }
        //openRet = win32::ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5);    
        openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5);
        if (openRet < 32)
        {
            alert(L"Îļþ´ò¿ªÊ§°Ü2£¡");
            return -1;
        }
 
        return -1;
    }
 
 
    //ÃüÁî·¢²¼º¯Êý
    int OnCmdDispatch(xstring comdid)
    {
        return 0;
    }
 
    //ÃüÁî´¦Àíʼþ
    int OnXCommand(TEvent* evt, int param)
    {
        return OnCmdDispatch(evt->xcommand.pStrID);
    }
 
    int OnAttachEvent()
    {
        //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
        AttachEvent(L"WM_XCOMMAND", (FEvent)&HelpDocWin::OnXCommand);
        //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
        AttachEvent(L"WM_SETFOCUS", (FEvent)&HelpDocWin::OnSetFocus);
        return 1;
    }
 
    /*
    int  OnRetrieve()
    {
        xml x = new xml;
        x.setNativePointer(xml::CreateInstance());
        xaserverarg arg = new xaserverarg;
        arg.setNativePointer(arg.CreateInstance());
        arg.AddArg(L"xxx",L"xxx");
        if (getUrl(L"",arg.GetString(),x)!=1)
        {
            trace(x.GetXmlDoc().text);
            return -1;
        }else
        {
            //dw_list.Retrieve(x);
            //dw_list.Redraw();
        }
        return 1;
    }
    */
 
    int SetListViewHeaderColumn(xstring Url)
    {
        const int LVCFMT_LEFT = 0;
        for (int i = 0; i < 3; i++)  lv_view.DeleteColumn( 1);
        //if(Url==L"")
        //{
        lv_view.InsertColumn( 0, L"´´½¨ÈÕÆÚ", LVCFMT_LEFT, 80, 0);
        lv_view.InsertColumn( 0, L"´´½¨ÈËÔ±", LVCFMT_LEFT, 80, 0);
        lv_view.InsertColumn( 0, L"Ãû³Æ", 0, 180, 0);
        columnCount = 3;
        //}
        return 1;
    }
 
    int Retrieve()
    {
        xstring src = L"object/knowledge";
        //xstring src=L"data/SettleExchange";
        xml x = ViewObject::RetrieveData(L"/sale/data/TDocument3/FolderListHelp");
        if (x)
        {
            //alert(x.GetXml());
            KXMLDOMElement ele = x.documentElement();
            KXMLDOMNodeList nlist = ele.selectNodes(L"*");
            int s = nlist.length();
            if (s > 0)
            {
                for (int i = 0; i < s; i++)
                {
                    KXMLDOMElement e = nlist.item(i);
                    xstring name = e.getAttribute(L"caption");
                    int nItem = lv_view.InsertItemEx( 0, name, 14, e);
 
                    lv_view.SetItemText( nItem, 1, e.getAttribute(L"Creator"));
                    lv_view.SetItemText( nItem, 2, e.getAttribute(L"CreateDate"));
 
                }
            }
        }
        return 1;
    }
 
    int onload()
    {
        //dw_list = GetControl(L"xxx");
        //dw_list.openUrl(L"xxx");
        lv_view = GetControl(L"lv_view");
 
        columnCount = 0;
        SetListViewHeaderColumn(L"");
 
        AttachEvent(L"lv_view", L"NM_DBLCLK", (FEvent)&HelpDocWin::OnListViewDoubleClicked);
 
        Retrieve();
 
        return 1;
    }
 
    int onloaded()
    {
        SetAgent();
 
        return 1;
    }
};