#include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include "xcontrol/xshtml.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) BugMaintWin : public xframe { public: xdwtable dw_base; xnode m_agentNode; //Agent Condition xstring m_EntityID; xstring m_EntityType; xstring m_EntityConnect; xstring m_ConnectID; xcontrol m_Edit; xshtml m_Html; xcombobox m_cb; public: BugMaintWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd), m_Edit(nullptr){} public: static BugMaintWin* CreateInstance(void* implPtr, void* hWnd) { BugMaintWin* pWin = new BugMaintWin(implPtr, (HWND)hWnd); return pWin; } 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 OnSave() { xaserverarg arg ; xml xbase ; dw_base.AcceptText(); dw_base.DwUpdateAllTo(xbase); arg.AddArg(L"content",xbase.xml()); if(getUrl(L"/workflow/action/BugList/bill.update",arg.GetString(),xbase) == 1) { dw_base.ResetUpdateStatus(); alert(L"±£´æ³É¹¦!"); m_EntityID = dw_base.GetGuid(1); return 1; } else { alert(L"Ìí¼Óʧ°Ü!"); return -1; } return 1; } int AppendItem(xml x,KXMLDOMElement r,xstring name, xstring value) { KXMLDOMElement e = x.createElement(name); e.settext(value); r.appendChild(e); return 1; } int Init() { if(m_EntityID == L"") return -1; xml x ; xaserverarg arg ; arg.AddArg(L"EntityID",m_EntityID); arg.AddArg(L"EntityType",m_EntityType); arg.AddArg(L"EntityConnect",m_EntityConnect); if(xurl::get(L"/sale/data/Commentary/entity/notelist",arg.GetString(),x) == 1) { m_Html.SetContent(x.xml()); m_Html.Redraw(); } return 1; } int showAtt() { xnode anode =GetAgentNode(L"att"); int s = m_cb.GetCount(); xml x ; x.loadXML(L""); KXMLDOMElement ele = x.documentElement(); int i=0; for(i=0; i"); KXMLDOMElement ele = x.documentElement(); int i=0; for(i=0; ixcommand.pStrID); } //ÃüÁî·¢²¼º¯Êý int OnCmdDispatch(xstring comdid) { if(comdid==L"xmOK") { if(m_EntityID == L"") return 1; //trace(L"id:"+m_EntityID); xml x ; xaserverarg arg ; xstring value = m_Edit.GetText(); if(value == L"") { alert(L"ÇëÌîдÅú×¢£¡"); return 1; } x.loadXML(L""); KXMLDOMElement ele = x.documentElement(); AppendItem(x, ele, L"CommentaryID", publiccode::GetGuid()); AppendItem(x, ele, L"EntityID", m_EntityID); AppendItem(x, ele, L"EntityType", m_EntityType); AppendItem(x, ele, L"Remark", value); AppendItem(x, ele, L"ParentConnect", m_EntityConnect); AppendItem(x, ele, L"ParentCommentaryID", m_ConnectID); AppendItem(x, ele, L"CreatorID", xaserver::GetUserId()); ele.appendChild(getAtt()); arg.AddArg(L"content", L""+(xstring)ele.xml()+L""); if(getUrl(L"/workflow/action/Commentary/bill.update",arg.GetString(),x) == 1) { m_Edit.SetText(L""); m_cb.ResetContent(); Init(); showAtt(); return 1; } else { alert(L"Ìí¼Óʧ°Ü!"); return -1; } } else if(comdid==L"xmAtt") { addAtt(); } else if(comdid.left(4)==L"att_") { delAtt(comdid.right(comdid.length() - 4)); } else if(comdid==L"xmClose") { CloseWindow(); return 1; } else if(comdid==L"xmSave") { return OnSave(); } return 0; } int OnHtmlClick(TEvent* evt, int p) { ref HTMLNMHDR p = evt.pnmh; 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.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"",L"C:/Temp/"+sfile+ext); if(openRet < 0) { alert(L"Îļþ´ò¿ªÊ§°Ü1£¡"); return -1; } //openRet = ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5); openRet = ShellExecute(0,L"open",L"C:/Temp/"+sfile+ext,L"",L"",5); if(openRet < 32) { alert(L"Îļþ´ò¿ªÊ§°Ü2£¡"); return -1; } return -1; } int OnAttachEvent() { //°ó¶¨¹¤¾ßÌõµã»÷ʼþ AttachEvent(L"WM_XCOMMAND", (FEvent)&BugMaintWin::OnXCommand); AttachEvent(L"note",L"HTC_OBJECTCLICKED", (FEvent)&BugMaintWin::OnHtmlClick); return 1; } /* int OnRetrieve() { xml x ; xaserverarg arg ; arg.AddArg(L"xxx",L"xxx"); if (getUrl(L"",arg.GetString(),x)!=1) { trace(x.text()); return -1; }else { //dw_list.Retrieve(x); //dw_list.Redraw(); } return 1; } */ int onload() { SetArg(); dw_base = GetControl(L"dw_base"); dw_base.openUrl(L"/sale/view/Developer/bug/maint"); dw_base.SetColHeaderHeight(0); dw_base.SetRowSelectorWidth(0); dw_base.SetHScrollState(false); dw_base.SetVScrollState(false); OnAttachEvent(); m_Edit = GetControl(L"Txt"); m_Html = GetControl(L"note"); m_cb = GetControl(L"attlist"); m_EntityID = L""; m_EntityType = L"BugList"; m_EntityConnect = L""; m_ConnectID = L""; xstring Reciever = publiccode::GetUser().name; dw_base.SetItemString(1,L"Reciever",Reciever); if(GetWinParam()) { xaserverarg arg=GetArg() ; m_EntityID = arg.GetArgString(L"EntityID"); m_EntityType = arg.GetArgString(L"m_EntityType"); m_EntityConnect = arg.GetArgString(L"m_EntityConnect"); } Init(); return 1; } int onloaded() { //SetAgent(); return 1; } };