| | |
| | | use "xcontrol.vframe.vbusiness.vd" |
| | | use "xbase.vframe.vbusiness.vd" |
| | | use "publiccode.vutil.vbusiness.vd" |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | |
| | | unit business |
| | | [ |
| | | class CommentaryEx : public xframe |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | #include "xcontrol/xshtml.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) CommentaryEx : public xframe |
| | | { |
| | | public: |
| | | CommentaryEx(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd), m_Edit(nullptr) {} |
| | | public: |
| | | static CommentaryEx* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | string m_EntityID; |
| | | string m_EntityType; |
| | | string m_EntityConnect; |
| | | string m_ConnectID; |
| | | CommentaryEx* pWin = new CommentaryEx(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | public: |
| | | xstring m_EntityID; |
| | | xstring m_EntityType; |
| | | xstring m_EntityConnect; |
| | | xstring m_ConnectID; |
| | | |
| | | xcontrol m_Edit; |
| | | htmlctrl m_Html; |
| | | xshtml m_Html; |
| | | xcombobox m_cb; |
| | | |
| | | int Init() |
| | | { |
| | | if (m_EntityID == "") return -1; |
| | | if (m_EntityID == L"") return -1; |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("EntityID", m_EntityID); |
| | | arg.AddArg("EntityType", m_EntityType); |
| | | arg.AddArg("EntityConnect", m_EntityConnect); |
| | | if (url::get("/sale/data/Commentary/entity/notelist", arg.GetString(), x) == 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.GetXml()); |
| | | m_Html.SetContent(x.xml()); |
| | | m_Html.Redraw(); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int AppendItem(xml x, msxml::IXMLDOMElement r, string name, string value) |
| | | int AppendItem(xml x, KXMLDOMElement r, xstring name, xstring value) |
| | | { |
| | | msxml::IXMLDOMElement e = x.GetXmlDoc().createElement(name); |
| | | e.text = value; |
| | | KXMLDOMElement e = x.createElement(name); |
| | | e.settext(value); |
| | | r.appendChild(e); |
| | | return 1; |
| | | } |
| | | |
| | | int showAtt() |
| | | { |
| | | xnode anode = GetAgentNode("att"); |
| | | int s = xcombobox::GetCount(m_cb.GetId()); |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | x.LoadXml("<vbox/>"); |
| | | msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement; |
| | | xnode anode = GetAgentNode(L"att"); |
| | | int s = m_cb.GetCount(); |
| | | xml x ; |
| | | x.loadXML(L"<vbox/>"); |
| | | |
| | | KXMLDOMElement ele = x.documentElement(); |
| | | int i = 0; |
| | | for (i = 0; i < s; i++) |
| | | { |
| | | string tmp = xcombobox::GetLBText(m_cb.GetId(), i); |
| | | msxml::IXMLDOMElement e = x.GetXmlDoc().createElement("hbox"); |
| | | e.setAttribute("height", "20"); |
| | | msxml::IXMLDOMElement l = x.GetXmlDoc().createElement("xlabel"); |
| | | l.setAttribute("caption", "" + tmp); |
| | | msxml::IXMLDOMElement b = x.GetXmlDoc().createElement("xtoolbutton"); |
| | | b.setAttribute("width", "18"); |
| | | b.setAttribute("name", "att_" + i.toString()); |
| | | b.setAttribute("image", "1,5"); |
| | | xstring tmp = m_cb.GetLBText(i); |
| | | KXMLDOMElement e = x.createElement(L"hbox"); |
| | | e.setAttribute(L"height", L"20"); |
| | | KXMLDOMElement l = x.createElement(L"xlabel"); |
| | | l.setAttribute(L"caption", L"" + tmp); |
| | | KXMLDOMElement b = x.createElement(L"xtoolbutton"); |
| | | b.setAttribute(L"width", L"18"); |
| | | b.setAttribute(L"name", L"att_" + xstring(i)); |
| | | b.setAttribute(L"image", L"1,5"); |
| | | e.appendChild(l); |
| | | e.appendChild(b); |
| | | ele.appendChild(e); |
| | | msxml::IXMLDOMElement g = x.GetXmlDoc().createElement("xlabel"); |
| | | g.setAttribute("height", "2"); |
| | | g.setAttribute("style", "background-color:#000000"); |
| | | KXMLDOMElement g = x.createElement(L"xlabel"); |
| | | g.setAttribute(L"height", L"2"); |
| | | g.setAttribute(L"style", L"background-color:#000000"); |
| | | ele.appendChild(g); |
| | | } |
| | | SetAgentNodeContent(anode, ele.xml); |
| | | SetAgentNode(anode, ele.xml()); |
| | | anode.SetWidthHeight(-1, i * 20 + 1); |
| | | return 1; |
| | | } |
| | | |
| | | int addAtt() |
| | | { |
| | | string guid = publiccode::GetGuid(); |
| | | string str = guid.left(2); |
| | | string ret = xaserver::UploadFile("attachment" + str, guid + ".jpg", this.GetHWND(), "", false); |
| | | int nIndex = xcombobox::AddItem(m_cb.GetId(), ret, guid + ".jpg"); |
| | | xstring guid = publiccode::GetGuid(); |
| | | xstring str = guid.left(2); |
| | | xstring ret = xaserver::UploadFile(L"attachment" + str, guid + L".jpg", GetHWND(), L"", false); |
| | | int nIndex = m_cb.AddItem(ret.c_str(true), (guid + L".jpg").c_str(true)); |
| | | showAtt(); |
| | | return 1; |
| | | } |
| | | |
| | | int delAtt(string no) |
| | | int delAtt(xstring no) |
| | | { |
| | | int nIndex = no.toInt(); |
| | | xcombobox::DeleteItem(m_cb.GetId(), nIndex); |
| | | m_cb.DeleteItem(nIndex); |
| | | showAtt(); |
| | | return 1; |
| | | } |
| | | |
| | | msxml::IXMLDOMElement getAtt() |
| | | KXMLDOMElement getAtt() |
| | | { |
| | | int s = xcombobox::GetCount(m_cb.GetId()); |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | x.LoadXml("<Attachment/>"); |
| | | msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement; |
| | | int s = m_cb.GetCount(); |
| | | xml x; |
| | | x.loadXML(L"<Attachment/>"); |
| | | KXMLDOMElement ele = x.documentElement(); |
| | | int i = 0; |
| | | for (i = 0; i < s; i++) |
| | | { |
| | | string tmp = xcombobox::GetLBText(m_cb.GetId(), i); |
| | | string tmp2 = xcombobox::GetItemData(m_cb.GetId(), i); |
| | | msxml::IXMLDOMElement e = x.GetXmlDoc().createElement("item"); |
| | | e.setAttribute("name", "" + tmp); |
| | | e.setAttribute("file", "" + tmp2); |
| | | xstring tmp = m_cb.GetLBText(i); |
| | | xstring tmp2 = m_cb.GetItemData( i); |
| | | KXMLDOMElement e = x.createElement(L"item"); |
| | | e.setAttribute(L"name", L"" + tmp); |
| | | e.setAttribute(L"file", L"" + tmp2); |
| | | ele.appendChild(e); |
| | | } |
| | | return ele; |
| | | } |
| | | //命令发布函数 |
| | | int OnCmdDispatch(string comdid) |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == "xmOK") |
| | | if (comdid == L"xmOK") |
| | | { |
| | | if (m_EntityID == "") return 1; |
| | | if (m_EntityID == L"") return 1; |
| | | |
| | | xml x = new xml; |
| | | x.setNativePointer(xml::CreateInstance()); |
| | | xaserverarg arg = new xaserverarg; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | string value = m_Edit.GetText(); |
| | | if (value == "") |
| | | xml x ; |
| | | xaserverarg arg; |
| | | |
| | | xstring value = m_Edit.GetText(); |
| | | if (value == L"") |
| | | { |
| | | alert("请填写批注!"); |
| | | return 1; |
| | | int s = m_cb.GetCount(); |
| | | if (s < 1) |
| | | { |
| | | alert(L"请填写批注!"); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | x.LoadXml("<Commentary update.new='1' update.modify='1'/>"); |
| | | msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement; |
| | | AppendItem(x, ele, "CommentaryID", publiccode::GetGuid()); |
| | | AppendItem(x, ele, "EntityID", m_EntityID); |
| | | AppendItem(x, ele, "EntityType", m_EntityType); |
| | | AppendItem(x, ele, "Remark", value); |
| | | AppendItem(x, ele, "ParentConnect", m_EntityConnect); |
| | | AppendItem(x, ele, "ParentCommentaryID", m_ConnectID); |
| | | AppendItem(x, ele, "CreatorID", xaserver::GetUserId()); |
| | | 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()); |
| | | |
| | | arg.AddArg("content", "<root>" + ele.xml + "</root>"); |
| | | arg.AddArg(L"content", (xstring)L"<root>" + ele.xml() + L"</root>"); |
| | | |
| | | if (getUrl("/workflow/action/Commentary/bill.update", arg.GetString(), x) == 1) |
| | | if (getUrl(L"/workflow/action/Commentary/bill.update", arg.GetString(), x) == 1) |
| | | { |
| | | m_Edit.SetText(""); |
| | | xcombobox::ResetContent(m_cb.GetId()); |
| | | m_Edit.SetText(L""); |
| | | m_cb.ResetContent(); |
| | | Init(); |
| | | showAtt(); |
| | | return 1; |
| | | } |
| | | else |
| | | { |
| | | alert("添加失败!"); |
| | | alert(L"添加失败!"); |
| | | return -1; |
| | | } |
| | | } |
| | | else if (comdid == "xmAtt") |
| | | else if (comdid == L"xmAtt") |
| | | { |
| | | addAtt(); |
| | | } |
| | | else if (comdid.left(4) == "att_") |
| | | else if (comdid.left(4) == L"att_") |
| | | { |
| | | delAtt(comdid.right(comdid.length() - 4)); |
| | | } |
| | |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(ref TXCommandEvent evt, int param) |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt.pStrID); |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnHtmlClick(ref TNotifyEvent evt, int pr) |
| | | int OnHtmlClick(TEvent* evt, LPARAM pr) |
| | | { |
| | | ref HTMLNMHDR p = evt.pnmh; |
| | | const string d = m_Html.GetData(p.object); |
| | | if (d == "") return -1; |
| | | string file = d.mid(0, d.find("|##@@|", 0)); |
| | | string name = d.mid(d.find("|##@@|", 0) + 6, d.length()); |
| | | /* |
| | | 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("C:/Temp"); |
| | | string str = file.left(2); |
| | | string ext = ""; |
| | | if (name.find(".") >= 0) ext = name.mid(name.find("."), name.length()); |
| | | string sfile = file.left(file.length() - 4); |
| | | //trace("--"+ext +" " + "/business/attachment/"+str+"/"+ file); |
| | | //int openRet = xaserver::DownLoadFile(GetServerUrl(),"/business/attachment/"+str+"/"+ file,name,"C:/Temp/"+name); |
| | | int openRet = xaserver::DownLoadFile(GetServerUrl(), "/business/attachment/" + str + "/" + file, "", "C:/Temp/" + sfile + ext); |
| | | 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("文件打开失败1!"); |
| | | alert(L"文件打开失败1!"); |
| | | return -1; |
| | | } |
| | | //openRet = win32::ShellExecute(0,"open","C:/Temp/"+name,"","",5); |
| | | openRet = win32::ShellExecute(0, "open", "C:/Temp/" + sfile + ext, "", "", 5); |
| | | //openRet = win32::ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5); |
| | | openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5); |
| | | if (openRet < 32) |
| | | { |
| | | alert("文件打开失败2!"); |
| | | alert(L"文件打开失败2!"); |
| | | return -1; |
| | | } |
| | | |
| | | */ |
| | | return -1; |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent("WM_XCOMMAND", OnXCommand); |
| | | AttachEvent("note", "HTC_OBJECTCLICKED", OnHtmlClick); |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&CommentaryEx::OnXCommand); |
| | | AttachEvent(L"note", L"HTC_OBJECTCLICKED", (FEvent)&CommentaryEx::OnHtmlClick); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | SetArg(); |
| | | OnAttachEvent(); |
| | | |
| | | m_Edit = GetControl("Txt"); |
| | | m_Edit = GetControl(L"Txt"); |
| | | |
| | | m_Html = GetControl("note"); |
| | | m_Html = GetControl(L"note"); |
| | | |
| | | m_cb = GetControl("attlist"); |
| | | m_cb = GetControl(L"attlist"); |
| | | |
| | | m_EntityID = ""; |
| | | m_EntityType = ""; |
| | | m_EntityConnect = ""; |
| | | m_ConnectID = ""; |
| | | m_EntityID = L""; |
| | | m_EntityType = L""; |
| | | m_EntityConnect = L""; |
| | | m_ConnectID = L""; |
| | | |
| | | if (this.GetParam()) |
| | | if (GetWinParam()) |
| | | { |
| | | //xaserverarg arg = new xaserverarg; |
| | | //arg.setNativePointer(GetParam()); |
| | | xaserverarg arg = GetParam(); |
| | | m_EntityID = arg.GetArgString("EntityID"); |
| | | m_EntityType = arg.GetArgString("m_EntityType"); |
| | | m_EntityConnect = arg.GetArgString("m_EntityConnect"); |
| | | 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; |
| | | } |
| | | }; |
| | | ] |
| | | }; |