#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;
|
}
|
};
|