¶Ô±ÈÐÂÎļþ |
| | |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) BugListWin : public xframe |
| | | { |
| | | public: |
| | | xdwgrid dw_list; |
| | | xnode m_agentNode; //Agent Condition |
| | | |
| | | xstring m_EntityID; |
| | | xstring m_EntityType; |
| | | |
| | | htmlctrl m_Html; |
| | | xcontrol m_Edit; |
| | | xcombobox m_cb; |
| | | public: |
| | | BugListWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static BugListWin* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | BugListWin* pWin = new BugListWin(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 OnRowChanged(TEvent* evt, int p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | |
| | | m_EntityID = dw_list.GetGuid(row); |
| | | RetrieveNote(row); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | static stdcall int GetModuleFileName(int hModule, xstring lpFileName, int nSize) native from "kernel32.dll" alias "GetModuleFileNameW"; |
| | | static stdcall int PathRemoveFileSpec(xstring lpFileName) native from "shlwapi.dll" alias "PathRemoveFileSpecW"; |
| | | |
| | | xstring GetModulePath() |
| | | { |
| | | xstring str = L""; |
| | | str = str.space(255); |
| | | GetModuleFileName(0, str, 250); |
| | | PathRemoveFileSpec(str); |
| | | return str; |
| | | } |
| | | |
| | | xstring GetModuleTmpPath() |
| | | { |
| | | xstring str = L""; |
| | | str = str.space(255); |
| | | GetModuleFileName(0, str, 250); |
| | | PathRemoveFileSpec(str); |
| | | xstring tmp = str + L"\\Temp"; |
| | | xaserver::CreateDirectory(tmp); |
| | | return tmp; |
| | | } |
| | | |
| | | int RetrieveNote(int row) |
| | | { |
| | | if (row == 0) row = dw_list.GetRow(); |
| | | if (row < 1) return 1; |
| | | |
| | | xstring EntityID = dw_list.GetGuid(row); |
| | | xml x ; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"EntityID", EntityID); |
| | | if (xurl::get(L"/sale/data/Commentary/entity/notelist", arg.GetString(), x) == 1) |
| | | { |
| | | m_Html.SetContent(x.xml()); |
| | | m_Html.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | //ç¦ç¹æ¿æ´»å¤ç彿° |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | //é置工å
·æ¡ |
| | | SetAgent(); |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤åå¸å½æ° |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"xmAdd") |
| | | { |
| | | OpenWindow(L"dev:xpage[BugMaint.Developer.hxsoft.vx]", 0); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmRetrieve") |
| | | { |
| | | OnRetrieve(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmAtt") |
| | | { |
| | | addAtt(); |
| | | } |
| | | else if (comdid == L"xmMsg") |
| | | { |
| | | OnAddItem(); |
| | | return 1; |
| | | } |
| | | else if (comdid == L"xmDelete") |
| | | { |
| | | OnDelete(); |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnDelete() |
| | | { |
| | | int row = dw_list.GetRow(); |
| | | if (row < 1) |
| | | return 1; |
| | | KXMLDOMElement ele = dw_list.GetRowElement(row); |
| | | xstring BugListID = ele.selectSingleNode(L"BugListID").text(); |
| | | xml x ; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | arg.AddArg(L"BugListID", BugListID); |
| | | if (getUrl(L"/sale/data/BugList/delete/buglist", arg.GetString(), x) != 1) |
| | | { |
| | | xstring error = x.text(); |
| | | alert(L"err:" + error); |
| | | return 1; |
| | | } |
| | | alert(x.text()); |
| | | OnRetrieve(); |
| | | return 1; |
| | | } |
| | | |
| | | int addAtt() |
| | | { |
| | | xstring guid = publiccode::GetGuid(); |
| | | xstring str = guid.left(2); |
| | | xstring ret = xaserver::UploadFile(L"attachment" + str, guid + L".jpg", GetHWND(), L"", false); |
| | | OnAddItem(ret, guid + L".jpg"); |
| | | return 1; |
| | | } |
| | | |
| | | //å½ä»¤å¤çäºä»¶ |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //ç»å®å·¥å
·æ¡ç¹å»äºä»¶ |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&BugListWin::OnXCommand); |
| | | //è·åç¦ç¹äºä»¶ï¼ç¨äºé置工å
·æ¡/sale/data/buglist/list/buglist" |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&BugListWin::OnSetFocus); |
| | | AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&BugListWin::OnRowChanged);//ç»å®è¡æ´æ¹è§¦åäºä»¶OnRowChanged |
| | | AttachEvent(L"note", L"HTC_OBJECTCLICKED", (FEvent)&BugListWin::OnHtmlClick); |
| | | return 1; |
| | | } |
| | | |
| | | 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()); |
| | | |
| | | 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); |
| | | int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file, L"", GetModuleTmpPath() + L"\\" + sfile + ext); |
| | | if (openRet < 0) |
| | | { |
| | | alert(L"æä»¶æå¼å¤±è´¥1ï¼"); |
| | | return -1; |
| | | } |
| | | openRet = ShellExecute(0, L"open", GetModuleTmpPath() + L"\\" + sfile + ext, L"", L"", 5); |
| | | if (openRet < 32) |
| | | { |
| | | alert(L"æä»¶æå¼å¤±è´¥2ï¼"); |
| | | return -1; |
| | | } |
| | | |
| | | return -1; |
| | | } |
| | | |
| | | int AppendItem(xml x, KXMLDOMElement r, xstring name, xstring value) |
| | | { |
| | | KXMLDOMElement e = x.createElement(name); |
| | | e.text() = value; |
| | | r.appendChild(e); |
| | | return 1; |
| | | } |
| | | |
| | | KXMLDOMElement getAtt(xstring source = L"", xstring file = L"") |
| | | { |
| | | xml x ; |
| | | |
| | | x.loadXML(L"<Attachment/>"); |
| | | KXMLDOMElement ele = x.documentElement(); |
| | | KXMLDOMElement e = x.createElement(L"item"); |
| | | e.setAttribute(L"name", source); |
| | | e.setAttribute(L"file", file); |
| | | ele.appendChild(e); |
| | | |
| | | return ele; |
| | | } |
| | | |
| | | int OnAddItem(xstring source = L"", xstring file = L"") |
| | | { |
| | | |
| | | xml x ; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | xstring value = m_Edit.GetText(); |
| | | if (value == L"") |
| | | { |
| | | if (source == L"") |
| | | { |
| | | alert(L"è¯·å¡«åæ¹æ³¨ï¼"); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | x.loadXML(L"<Commentary update.new='1' update.modify='1'/>"); |
| | | 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(source, file)); |
| | | |
| | | arg.AddArg(L"content", L"<root>" + (xstring)ele.xml() + L"</root>"); |
| | | |
| | | if (getUrl(L"/workflow/action/Commentary/bill.update", arg.GetString(), x) == 1) |
| | | { |
| | | m_Edit.SetText(L""); |
| | | RetrieveNote(0); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | alert(L"æ·»å 失败!"); |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | | int OnRetrieve() |
| | | { |
| | | xml x ; |
| | | |
| | | xaserverarg arg ; |
| | | |
| | | if (getUrl(L"/sale/data/BugList/list/buglist", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.Retrieve(x); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.Redraw(); |
| | | RetrieveNote(0); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | int onload() |
| | | { |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"/sale/view/Developer/bug/list"); |
| | | |
| | | m_Html = GetControl(L"note"); |
| | | m_Edit = GetControl(L"Txt"); |
| | | |
| | | m_EntityID = L""; |
| | | m_EntityType = L"BugList"; |
| | | |
| | | dw_list.SetColumnState(L"BugListID", false); |
| | | OnRetrieve(); |
| | | OnAttachEvent(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onloaded() |
| | | { |
| | | SetAgent(); |
| | | |
| | | return 1; |
| | | } |
| | | }; |