From 961b8ca44057298551291ca4d14280a0ac7bc753 Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期三, 17 七月 2024 17:50:37 +0800 Subject: [PATCH] Merge branch 'master' of http://116.62.18.175:6699/r/mis-prj --- jrj/project/business/SystemSettings/Buglist.Developer.hxsoft.cpp | 333 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 333 insertions(+), 0 deletions(-) diff --git a/jrj/project/business/SystemSettings/Buglist.Developer.hxsoft.cpp b/jrj/project/business/SystemSettings/Buglist.Developer.hxsoft.cpp new file mode 100644 index 0000000..3624178 --- /dev/null +++ b/jrj/project/business/SystemSettings/Buglist.Developer.hxsoft.cpp @@ -0,0 +1,333 @@ +#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; + } + }; \ No newline at end of file -- Gitblit v1.9.3