LiFan
9 天以前 63eebabbfee1bc84850b36967ecac5116a28b73f
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
#include <wobject/xwin.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <xcontrol/xflowchart.hpp>
#include <xcontrol/ximageview.hpp>
#include <xcontrol/ximageview.hpp>
#include <xcontrol/xhtml.hpp>
#include <xcontrol/xexcel.hpp>
#include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp>
 
using xml = KXMLDOMDocument;
class __declspec(dllexport) DataVanalysisWin : public xwin
{
public:
    DataVanalysisWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd),dw_data(0){}
    static DataVanalysisWin* CreateInstance(void* implPtr, void* hWnd)
    {
        return new DataVanalysisWin(implPtr, (HWND)hWnd);
    }
public:
    xhtml    ole_html;
    xdwgrid*  dw_data;
    xnode    m_agentNode;    //Agent Condition
    xstring   htmlStr;
    xexcel   excel;
 
    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, int param)
    {
        //ÖØÖù¤¾ßÌõ
        SetAgent();
        return 1;
    }
 
    //ÃüÁî·¢²¼º¯Êý
    int OnCmdDispatch(xstring comdid)
    {
        HCURSOR hCursor = xutil::SetCursorWait();
        if (comdid == L"xmConfig")
        {
            xstring str = dw_data->DataAnalysis(L"");
            if (str != L"")
            {
                ole_html.LoadHtml(str);
                htmlStr = str;
            }
            return 1;
        }
        else if (comdid == L"xmCopy")
        {
            ole_html.ExecWB(12, 0); //OLECMDID_COPY
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        else if (comdid == L"xmSelectAll")
        {
            ole_html.ExecWB(17, 0); //OLECMDID_SELECTALL
            xutil::RestoreCursor(hCursor);
            return 1;
        }
        else if (comdid == L"xmToExecl")
        {
            if (!excel.GetNativePtr())
            {
                alert(L"²»ÄÜÁ¬½ÓExcel");
                return 1;
            }
 
            xaserver::CreateDirectory(L"C:\\Temp");
            xstring gid = publiccode::GetGuid();
            xutil::SaveToFile(L"C:\\Temp\\" + gid + L".html", htmlStr, L"", L"");
            excel.OpenDocument(L"C:\\Temp\\" + gid + L".html");
            excel.put_Visible(true);
            return 1;
        }
 
        xutil::RestoreCursor(hCursor);
        return 0;
    }
 
    //ÃüÁî´¦Àíʼþ
    int OnXCommand(TEvent* evt, int param)
    {
        return OnCmdDispatch(evt->xcommand.pStrID);
    }
 
    int OnAttachEvent()
    {
        //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
        AttachEvent(L"WM_XCOMMAND", (FEvent)&DataVanalysisWin::OnXCommand);
        //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
        AttachEvent(L"WM_SETFOCUS", (FEvent)&DataVanalysisWin::OnSetFocus);
 
        return 1;
    }
 
    int onload()
    {
        htmlStr = L"";
        ole_html = GetControl(L"ole_1");
        if (!GetWinParam()) return 1;
        SetArg();
        xaserverarg arg = GetArg();
        xstring str = arg.GetArgString(L"html");
        if (str != L"")
        {
            htmlStr = str;
            ole_html.LoadHtml(str);
        }
        dw_data = (xdwgrid*)arg.GetParam(L"obj");
 
        OnAttachEvent();
 
        return 1;
    }
 
    int onloaded()
    {
        SetAgent();
 
        return 1;
    }
};