|  |  | 
 |  |  | use "xcontrol.vframe.vbusiness.vd" | 
 |  |  | use "xbase.vframe.vbusiness.vd" | 
 |  |  | #include <wobject/xstring.hpp> | 
 |  |  | #include <xcontrol/xtreeview.hpp> | 
 |  |  | #include <xcontrol/xdwgrid.hpp> | 
 |  |  | #include <wobject/xdouble.hpp> | 
 |  |  | #include <xcontrol/xlayersheet.hpp> | 
 |  |  | #include <xcontrol/xdatetimepick.hpp> | 
 |  |  |  | 
 |  |  | unit trade  | 
 |  |  | [ | 
 |  |  |    class DeveloperSynch :  public xframe | 
 |  |  |  | 
 |  |  | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" | 
 |  |  | #include "viewobject/view.base.hpp" | 
 |  |  |  | 
 |  |  | using xml = KXMLDOMDocument; | 
 |  |  |    class  __declspec(dllexport) DeveloperSynch :  public xframe | 
 |  |  |    { | 
 |  |  |    public: | 
 |  |  |       xtreeview   tv_gs; | 
 |  |  |       xsedit dw_log; | 
 |  |  |     | 
 |  |  |       int[100] nItems; | 
 |  |  |       int nItems; | 
 |  |  |       int nCount; | 
 |  |  |     | 
 |  |  |       string sContent; | 
 |  |  | 	 | 
 |  |  |       string ProcessDevCmd(string cmd,string ext, string aurl="", bool needlogin=false) | 
 |  |  |       xstring sContent; | 
 |  |  |    public: | 
 |  |  |       DeveloperSynch(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} | 
 |  |  |    public: | 
 |  |  |       static DeveloperSynch* CreateInstance(void* implPtr, void* hWnd) | 
 |  |  |       { | 
 |  |  |          if(aurl == "") aurl = GetServerUrl(); | 
 |  |  |          DeveloperSynch* pWin = new DeveloperSynch(implPtr, (HWND)hWnd); | 
 |  |  |          return pWin; | 
 |  |  |       } | 
 |  |  |       xstring ProcessDevCmd(xstring cmd,xstring ext, xstring aurl=L"", bool needlogin=false) | 
 |  |  |       { | 
 |  |  |          if(aurl == L"") aurl = GetServerUrl(); | 
 |  |  |          //alert(aurl); | 
 |  |  |          string d = xaserver::ProcessCmd(aurl,"uri.hxsoft.com/xaserver/developer "+cmd,ext,needlogin); | 
 |  |  |          xstring d = xaserver::ProcessCmd(aurl,L"uri.hxsoft.com/xaserver/developer "+cmd,ext,needlogin); | 
 |  |  |          return d; | 
 |  |  |       } | 
 |  |  |     | 
 |  |  |       string ProcessDevCmd2(string cmd,string ext, string aurl="", bool needlogin=false) | 
 |  |  |       xstring ProcessDevCmd2(xstring cmd,xstring ext, xstring aurl=L"", bool needlogin=false) | 
 |  |  |       { | 
 |  |  |          if(aurl == "") aurl = GetServerUrl(); | 
 |  |  |          if(aurl == L"") aurl = GetServerUrl(); | 
 |  |  |          //alert(aurl); | 
 |  |  |          string d = xaserver::ProcessCmd(aurl,"uri.hxsoft.com/xaserver/dev:"+cmd,ext,needlogin); | 
 |  |  |          xstring d = xaserver::ProcessCmd(aurl,L"uri.hxsoft.com/xaserver/dev:"+cmd,ext,needlogin); | 
 |  |  |          return d; | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       int GetProjectItem(int hItem) | 
 |  |  |       { | 
 |  |  |          int pitem = hItem; | 
 |  |  |          string typ; | 
 |  |  |          xstring typ; | 
 |  |  |          while(true) | 
 |  |  |          { | 
 |  |  |             int h = xtreeview::GetItemData(tv_gs.GetId(), pitem); | 
 |  |  |             msxml::IXMLDOMElement e = trust(h as msxml::IXMLDOMElement); | 
 |  |  |             typ = GetEleString(e, "@tagname"); | 
 |  |  |             if(typ=="project")break; | 
 |  |  |             pitem = xtreeview::GetParentItem(tv_gs.GetId(), pitem); | 
 |  |  |             int h =tv_gs.GetItemData(tv_gs.GetId(), pitem); | 
 |  |  |             KXMLDOMElement e = trust(h as KXMLDOMElement); | 
 |  |  |             typ = GetEleString(e, L"@tagname"); | 
 |  |  |             if(typ==L"project")break; | 
 |  |  |             pitem =tv_gs.GetParentItem(tv_gs.GetId(), pitem); | 
 |  |  |             if(pitem<=0)break; | 
 |  |  |          } | 
 |  |  |          return pitem; | 
 |  |  | 
 |  |  |          int hP2Item = hItem; | 
 |  |  |          while(true) | 
 |  |  |          { | 
 |  |  |             hDomainItem = xtreeview::GetParentItem(tv_gs.GetId(), hP2Item); | 
 |  |  |             hDomainItem =tv_gs.GetParentItem(tv_gs.GetId(), hP2Item); | 
 |  |  |             if(xtreeview::GetParentItem(tv_gs.GetId(), hDomainItem)<=0)break; | 
 |  |  |             hP2Item = hDomainItem; | 
 |  |  |          } | 
 |  |  |          return hP2Item; | 
 |  |  |       } | 
 |  |  |           | 
 |  |  |       string GetItemGuid(int hItem) | 
 |  |  |       xstring GetItemGuid(int hItem) | 
 |  |  |       { | 
 |  |  |          int h = xtreeview::GetItemData(tv_gs.GetId(), hItem); | 
 |  |  |          msxml::IXMLDOMElement e = trust(h as msxml::IXMLDOMElement); | 
 |  |  |          string guid = e.GetAttribute("guid"); | 
 |  |  |          int h =tv_gs.GetItemData(tv_gs.GetId(), hItem); | 
 |  |  |          KXMLDOMElement e = trust(h as KXMLDOMElement); | 
 |  |  |          xstring guid = e.GetAttribute(L"guid"); | 
 |  |  |          return guid; | 
 |  |  |       } | 
 |  |  |           | 
 |  |  |       xaserverarg GetDataArg(int hItem, xaserverarg arg) | 
 |  |  |       { | 
 |  |  |          int h = xtreeview::GetItemData(tv_gs.GetId(), hItem); | 
 |  |  |          msxml::IXMLDOMElement e = trust(h as msxml::IXMLDOMElement); | 
 |  |  |          string node = GetEleString(e, "@tagname"); | 
 |  |  |          int h =tv_gs.GetItemData(tv_gs.GetId(), hItem); | 
 |  |  |          KXMLDOMElement e = trust(h as KXMLDOMElement); | 
 |  |  |          xstring node = GetEleString(e, L"@tagname"); | 
 |  |  |          //WriteLog(e.xml); | 
 |  |  |          if(node=="File" || node=="file") | 
 |  |  |          if(node==L"File" || node==L"file") | 
 |  |  |          { | 
 |  |  |             string caption = e.getAttribute("caption"); | 
 |  |  |             xstring caption = e.getAttribute(L"caption"); | 
 |  |  |              | 
 |  |  |             int hP2Item = 0; | 
 |  |  |             int hDomainItem = 0; | 
 |  |  |             if(xtreeview::GetParentItem(tv_gs.GetId(), hItem)<=0) | 
 |  |  |             if(tv_gs.GetParentItem(hItem)<=0) | 
 |  |  |             { | 
 |  |  |                hDomainItem = hItem; | 
 |  |  |             }else | 
 |  |  |             { | 
 |  |  |                hP2Item = GetP2Item(hItem); | 
 |  |  |                hDomainItem = xtreeview::GetParentItem(tv_gs.GetId(), hP2Item); | 
 |  |  |                hDomainItem =tv_gs.GetParentItem(hP2Item); | 
 |  |  |             }    | 
 |  |  |  | 
 |  |  |             //find project folder | 
 |  |  |             string prjguid=""; | 
 |  |  |             int pitem = this.GetProjectItem(hItem); | 
 |  |  |             xstring prjguid=L""; | 
 |  |  |             int pitem = GetProjectItem(hItem); | 
 |  |  |             if(pitem > 0) | 
 |  |  |                prjguid = GetItemGuid(pitem); | 
 |  |  |  | 
 |  |  |             //xaserverarg arg = new xaserverarg; | 
 |  |  |             //arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |             arg.AddArg("project.guid",prjguid); | 
 |  |  |             //xaserverarg arg ; | 
 |  |  |             //; | 
 |  |  |             arg.AddArg(L"project.guid",prjguid); | 
 |  |  |             if(hP2Item) | 
 |  |  |             { | 
 |  |  |                if(hP2Item != hItem) | 
 |  |  |                { | 
 |  |  |                   string guid = e.getAttribute("guid"); | 
 |  |  |                   arg.AddArg("guid",guid); | 
 |  |  |                   xstring guid = e.getAttribute(L"guid"); | 
 |  |  |                   arg.AddArg(L"guid",guid); | 
 |  |  |                } | 
 |  |  |                string guid2 = GetItemGuid(hP2Item); | 
 |  |  |                arg.AddArg("root.guid",guid2); | 
 |  |  |                xstring guid2 = GetItemGuid(hP2Item); | 
 |  |  |                arg.AddArg(L"root.guid",guid2); | 
 |  |  |             }else if(hDomainItem > 0) | 
 |  |  |             { | 
 |  |  |                string guid3 = GetItemGuid(hDomainItem); | 
 |  |  |                arg.AddArg("domain.guid",guid3); | 
 |  |  |                xstring guid3 = GetItemGuid(hDomainItem); | 
 |  |  |                arg.AddArg(L"domain.guid",guid3); | 
 |  |  |             } | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          else if(node=="folder" || node=="project") | 
 |  |  |          else if(node==L"folder" || node==L"project") | 
 |  |  |             return 2; | 
 |  |  |          else | 
 |  |  |             return 0;          | 
 |  |  | 
 |  |  |  | 
 |  |  |       int SaveData(int hItem) | 
 |  |  |       { | 
 |  |  |          xcontrol xc = GetControl("surl"); | 
 |  |  |          string surl = xc.GetText(); | 
 |  |  |          if(surl == "") | 
 |  |  |          xcontrol xc = GetControl(L"surl"); | 
 |  |  |          xstring surl = xc.GetText(); | 
 |  |  |          if(surl == L"") | 
 |  |  |          { | 
 |  |  |             alert("请输入同步服务器地址"); | 
 |  |  |             alert(L"请输入同步服务器地址"); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |           | 
 |  |  |          string name = xtreeview::GetItemLabel(tv_gs.GetId(), hItem); | 
 |  |  |          xaserverarg arg = new xaserverarg; | 
 |  |  |          arg.setNativePointer(arg.CreateInstance()); | 
 |  |  |          xstring name =tv_gs.GetItemLabel(hItem); | 
 |  |  |          xaserverarg arg ; | 
 |  |  |          ; | 
 |  |  |          int ret = GetDataArg(hItem, arg); | 
 |  |  |          //alert(arg.GetString()); | 
 |  |  |          if(ret == 0)  | 
 |  |  |          { | 
 |  |  |             WriteLog(name+" 失败, 原因:获取工程或文件夹失败!"); | 
 |  |  |             WriteLog(name+L" 失败, 原因:获取工程或文件夹失败!"); | 
 |  |  |             return -1; | 
 |  |  |          } | 
 |  |  |          else if(ret == 2)  | 
 |  |  |          { | 
 |  |  |             ret = SynchFolder(hItem); | 
 |  |  |             if(ret == -1) | 
 |  |  |                WriteLog(name+" 失败, 原因:获取文件数据失败!"); | 
 |  |  |                WriteLog(name+L" 失败, 原因:获取文件数据失败!"); | 
 |  |  |             else if(ret == 0) | 
 |  |  |                WriteLog(name+" 失败, 原因:复制文件失败!"); | 
 |  |  |                WriteLog(name+L" 失败, 原因:复制文件失败!"); | 
 |  |  |             else | 
 |  |  |                WriteLog(name); | 
 |  |  |             return -1; | 
 |  |  |          } | 
 |  |  |          SynchFolder(hItem); | 
 |  |  |          arg.AddArg("__name",name); | 
 |  |  |          arg.AddArg("__url",surl); | 
 |  |  |          arg.AddArg(L"__name",name); | 
 |  |  |          arg.AddArg(L"__url",surl); | 
 |  |  |          synchServer(arg); | 
 |  |  |          if(name.right(3) == ".vx" || name.right(5) == ".xpage") | 
 |  |  |          if(name.right(3) == L".vx" || name.right(5) == L".xpage") | 
 |  |  |          { | 
 |  |  |             arg.AddArg("__name",name + "[Code]"); | 
 |  |  |             arg.AddArg("iscode","yes"); | 
 |  |  |             arg.AddArg(L"__name",name + L"[Code]"); | 
 |  |  |             arg.AddArg(L"iscode",L"yes"); | 
 |  |  |             synchServer(arg); | 
 |  |  |          } | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |           | 
 |  |  |       string GetFolderPath(int hItem) | 
 |  |  |       xstring GetFolderPath(int hItem) | 
 |  |  |       { | 
 |  |  |          int k = hItem; | 
 |  |  |          if(k == 0) return ""; | 
 |  |  |          string src = ""; | 
 |  |  |          //string name = ""; | 
 |  |  |          if(k == 0) return L""; | 
 |  |  |          xstring src = L""; | 
 |  |  |          //xstring name = L""; | 
 |  |  |          while(k > 0) | 
 |  |  |          { | 
 |  |  |             int h = xtreeview::GetItemData(tv_gs.GetId(), k); | 
 |  |  |             k = xtreeview::GetParentItem(tv_gs.GetId(), k); | 
 |  |  |             msxml::IXMLDOMElement e = trust(h as msxml::IXMLDOMElement); | 
 |  |  |             string node = GetEleString(e, "@tagname"); | 
 |  |  |             if(node != "File" && node != "file") | 
 |  |  |             int h =tv_gs.GetItemData(tv_gs.GetId(), k); | 
 |  |  |             k =tv_gs.GetParentItem(tv_gs.GetId(), k); | 
 |  |  |             KXMLDOMElement e = trust(h as KXMLDOMElement); | 
 |  |  |             xstring node = GetEleString(e, L"@tagname"); | 
 |  |  |             if(node != L"File" && node != L"file") | 
 |  |  |             { | 
 |  |  |                string tmp = GetEleString(e, "@src"); | 
 |  |  |                //if(name == "") name = GetEleString(e, "@caption"); | 
 |  |  |                if(tmp != "") | 
 |  |  |                xstring tmp = GetEleString(e, L"@src"); | 
 |  |  |                //if(name == L"") name = GetEleString(e, L"@caption"); | 
 |  |  |                if(tmp != L"") | 
 |  |  |                { | 
 |  |  |                   SynchFolder(k); | 
 |  |  |                   if(src == "") src = tmp; | 
 |  |  |                   if(src == L"") src = tmp; | 
 |  |  |                   else | 
 |  |  |                   { | 
 |  |  |                      int j = 1; | 
 |  |  |                      int s =  tmp.length(); | 
 |  |  |                      string t = tmp.right(j).left(1); | 
 |  |  |                      while(t != "\\" && j < s) | 
 |  |  |                      int s =  tmp.length()(); | 
 |  |  |                      xstring t = tmp.right(j).left(1); | 
 |  |  |                      while(t != L"\\" && j < s) | 
 |  |  |                      { | 
 |  |  |                         //WriteLog(t); | 
 |  |  |                         j++; | 
 |  |  |                         t = tmp.right(j).left(1); | 
 |  |  |                      } | 
 |  |  |                      if(j >= s) | 
 |  |  |                         src = tmp+ "\\" + src;  | 
 |  |  |                         src = tmp+ L"\\" + src;  | 
 |  |  |                      else | 
 |  |  |                         src = tmp.left(s - j)+ "\\" + src; | 
 |  |  |                         src = tmp.left(s - j)+ L"\\" + src; | 
 |  |  |                   } | 
 |  |  |                } | 
 |  |  |             } | 
 |  |  |          } | 
 |  |  |          if(src == "") | 
 |  |  |          if(src == L"") | 
 |  |  |          { | 
 |  |  |             //WriteLog(name+" 同步失败, 原因:获取文件数据失败0!"); | 
 |  |  |             return ""; | 
 |  |  |             //WriteLog(name+L" 同步失败, 原因:获取文件数据失败0!"); | 
 |  |  |             return L""; | 
 |  |  |          } | 
 |  |  |          //if(src.left(9) =="Projects\\") src = src.mid(9, src.length()); | 
 |  |  |          src = "\\" + src;//.replace("Projects\\",""); | 
 |  |  |          //if(src.left(9) ==L"Projects\\") src = src.mid(9, src.length()()); | 
 |  |  |          src = L"\\" + src;//.replace(L"Projects\\",L""); | 
 |  |  |          //WriteLog(src); | 
 |  |  |          return src; | 
 |  |  |       } | 
 |  |  |           | 
 |  |  |       int SynchFolder(int hItem) | 
 |  |  |       { | 
 |  |  |          string src =  GetFolderPath(hItem); | 
 |  |  |          if(src== "") return -1; | 
 |  |  |          if(xaserver::FileCopy("devfolder8001", src, "devfolder5001", src) != 1) | 
 |  |  |          xstring src =  GetFolderPath(hItem); | 
 |  |  |          if(src== L"") return -1; | 
 |  |  |          if(xaserver::FileCopy(L"devfolder8001", src, L"devfolder5001", src) != 1) | 
 |  |  |             return 0; | 
 |  |  |          //WriteLog(src); | 
 |  |  |          return 1; | 
 |  |  | 
 |  |  |           | 
 |  |  |       int synchServer(xaserverarg arg) | 
 |  |  |       { | 
 |  |  |          string name = arg.GetArgString("__name"); | 
 |  |  |          string surl = arg.GetArgString("__url"); | 
 |  |  |          string d =  ProcessDevCmd("getobject",arg.GetString()); | 
 |  |  |          if(d == "")  | 
 |  |  |          xstring name = arg.GetArgString(L"__name"); | 
 |  |  |          xstring surl = arg.GetArgString(L"__url"); | 
 |  |  |          xstring d =  ProcessDevCmd(L"getobject",arg.GetString()); | 
 |  |  |          if(d == L"")  | 
 |  |  |          { | 
 |  |  |             WriteLog(name+" 失败, 原因:获取文件数据失败!"); | 
 |  |  |             WriteLog(name+L" 失败, 原因:获取文件数据失败!"); | 
 |  |  |             return -1; | 
 |  |  |          } | 
 |  |  |          //WriteLog(d); | 
 |  |  |          arg.AddArg("content",d); | 
 |  |  |          ProcessDevCmd("saveobject",arg.GetString(), surl,true); | 
 |  |  |          arg.AddArg(L"content",d); | 
 |  |  |          ProcessDevCmd(L"saveobject",arg.GetString(), surl,true); | 
 |  |  |          WriteLog(name); | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |           | 
 |  |  |       int WriteLog(string str) | 
 |  |  |       int WriteLog(xstring str) | 
 |  |  |       { | 
 |  |  |          if(sContent == "") | 
 |  |  |          if(sContent == L"") | 
 |  |  |             sContent = str; | 
 |  |  |          else | 
 |  |  |             sContent += "\r\n" + str; | 
 |  |  |             sContent += L"\r\n" + str; | 
 |  |  |          //alert(sContent); | 
 |  |  |          dw_log.SetContent(sContent, ""); | 
 |  |  |          dw_log.SetContent(sContent, L""); | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |     | 
 |  |  |       //焦点激活处理函数 | 
 |  |  |       int OnSetFocus(ref TEvent evt,int param) | 
 |  |  |       int OnSetFocus(TEvent* evt, LPARAM param) | 
 |  |  |       { | 
 |  |  |          //重置工具条 | 
 |  |  |          SetAgent(); | 
 |  |  | 
 |  |  |       {    | 
 |  |  |          if(nCount >99) | 
 |  |  |          { | 
 |  |  |             alert("同时同步的数量不能大于100个!"); | 
 |  |  |             alert(L"同时同步的数量不能大于100个!"); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          nItems[nCount] = hItem;  | 
 |  |  | 
 |  |  |       } | 
 |  |  |  | 
 |  |  |       //命令发布函数 | 
 |  |  |       int OnCmdDispatch(string comdid) | 
 |  |  |       int OnCmdDispatch(xstring comdid) | 
 |  |  |       { | 
 |  |  |          if(comdid != "synch") return 1; | 
 |  |  |          if(comdid != L"synch") return 1; | 
 |  |  |           | 
 |  |  |          int hCursor = xutil::SetCursorWait(); | 
 |  |  |          sContent = ""; | 
 |  |  |          HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |          sContent = L""; | 
 |  |  |          for(int i=0; i<nCount; i++) | 
 |  |  |          { | 
 |  |  |             int p = nItems[i]; | 
 |  |  |             //int h = xtreeview::GetItemData(tv_gs.GetId(), p); | 
 |  |  |             //msxml::IXMLDOMElement e = trust(h as msxml::IXMLDOMElement); | 
 |  |  |             //int h =tv_gs.GetItemData(tv_gs.GetId(), p); | 
 |  |  |             //KXMLDOMElement e = trust(h as KXMLDOMElement); | 
 |  |  |             //alert(e.xml); | 
 |  |  |             SaveData(p); | 
 |  |  |             xtreeview::SetChecked(tv_gs.GetId(), p,0); | 
 |  |  | 
 |  |  |          return 0; | 
 |  |  |       } | 
 |  |  |     | 
 |  |  |       int OnTreeCheckBoxSel(ref TNotifyEvent evt,int p) | 
 |  |  |       int OnTreeCheckBoxSel(TEvent* evt, LPARAM p) | 
 |  |  |       { | 
 |  |  |          ref TVNNMHDR nmtv = trust(evt.pnmh as ref TVNNMHDR); | 
 |  |  |          TVNNMHDR* nmtv = (TVNNMHDR*)evt->notify.pnmh; | 
 |  |  |  | 
 |  |  |          int hItem = nmtv.FromItem; | 
 |  |  |          int hCursor = xutil::SetCursorWait(); | 
 |  |  |  | 
 |  |  |          HCURSOR hCursor = xutil::SetCursorWait(); | 
 |  |  |          int hwnd = nmtv.hwndFrom; | 
 |  |  |          int c = 1 - xtreeview::GetChecked(hwnd, hItem); | 
 |  |  |  | 
 |  |  |          int c = 1 -tv_gs.GetChecked(hwnd, hItem); | 
 |  |  |          if(c == 1) | 
 |  |  |             Add(hItem); | 
 |  |  |          else | 
 |  |  | 
 |  |  |       }    | 
 |  |  |        | 
 |  |  |       //命令处理事件 | 
 |  |  |       int OnXCommand(ref TXCommandEvent evt,int param) | 
 |  |  |       int OnXCommand(TEvent* evt, LPARAM param) | 
 |  |  |       { | 
 |  |  |          return OnCmdDispatch(evt.pStrID); | 
 |  |  |          return OnCmdDispatch(evt->xcommand.pStrID); | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       int OnAttachEvent() | 
 |  |  |       { | 
 |  |  |          //绑定工具条点击事件 | 
 |  |  |          AttachEvent("WM_XCOMMAND",OnXCommand); | 
 |  |  |          AttachEvent(L"WM_XCOMMAND", (FEvent)&DeveloperSynch::OnXCommand); | 
 |  |  |          //获取焦点事件,用于重置工具条 | 
 |  |  |          //AttachEvent("WM_SETFOCUS",OnSetFocus); | 
 |  |  |          AttachEvent("DevExplorer","TVN_CHECKBOXSEL",OnTreeCheckBoxSel);	 | 
 |  |  |          AttachEvent("DevExplorer", "TVN_ITEMEXPANDING",OnTreeExpanding); | 
 |  |  |          //AttachEvent(L"WM_SETFOCUS",OnSetFocus); | 
 |  |  |          AttachEvent(L"DevExplorer",L"TVN_CHECKBOXSEL", (FEvent)&DeveloperSynch::OnTreeCheckBoxSel); | 
 |  |  |          AttachEvent(L"DevExplorer", L"TVN_ITEMEXPANDING", (FEvent)&DeveloperSynch::OnTreeExpanding); | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |        | 
 |  |  |       int OnTreeExpanding(ref TNotifyEvent evt,int lparam)	 | 
 |  |  |       int OnTreeExpanding(TEvent* evt, LPARAM lparam) | 
 |  |  |       { | 
 |  |  |          ref NMTREEVIEW nmtv = trust(evt.pnmh as ref NMTREEVIEW); | 
 |  |  |          TVNNMHDR* nmtv = (TVNNMHDR*)evt->notify.pnmh; | 
 |  |  |          int hItem = nmtv.itemNew.hItem; | 
 |  |  |          int cItem=xtreeview::GetChildItem(tv_gs.GetId(), hItem); | 
 |  |  |          if(cItem > 0) return 1; | 
 |  |  |          int p = xtreeview::GetItemData(tv_gs.GetId(), hItem); | 
 |  |  |          msxml::IXMLDOMElement ele = trust(p as msxml::IXMLDOMElement); | 
 |  |  |          string src =GetEleString(ele, "@src"); | 
 |  |  |          string tagname =GetEleString(ele, "@tagname"); | 
 |  |  |          if (src == "" || tagname == "file" || tagname == "File") return 1; | 
 |  |  |          int p =tv_gs.GetItemData(tv_gs.GetId(), hItem); | 
 |  |  |          KXMLDOMElement ele = trust(p as KXMLDOMElement); | 
 |  |  |          xstring src =GetEleString(ele, L"@src"); | 
 |  |  |          xstring tagname =GetEleString(ele, L"@tagname"); | 
 |  |  |          if (src == L"" || tagname == L"file" || tagname == L"File") return 1; | 
 |  |  |          OnSetTree(hItem, GetFolderPath(hItem)); | 
 |  |  |           | 
 |  |  |          return 1; | 
 |  |  |       }       | 
 |  |  |           | 
 |  |  |       int OnSetTree(int pItem, msxml::IXMLDOMElement e) | 
 |  |  |       int OnSetTree(int pItem, KXMLDOMElement e) | 
 |  |  |       { | 
 |  |  |          msxml::IXMLDOMNodeList li=e.selectNodes("*"); | 
 |  |  |          KXMLDOMNodeList li=e.selectNodes(L"*"); | 
 |  |  |          int i=0; | 
 |  |  |          int s=li.length; | 
 |  |  |          int s=li.length(); | 
 |  |  |          for (i=0;i<s;i++){ | 
 |  |  |             msxml::IXMLDOMElement  ele= li.item(s - i - 1); | 
 |  |  |             string caption = GetEleString(ele, "@caption"); | 
 |  |  |             string src =GetEleString(ele, "@src"); | 
 |  |  |             string image =GetEleString(ele, "@image"); | 
 |  |  |             KXMLDOMElement  ele= li.item(s - i - 1); | 
 |  |  |             xstring caption = GetEleString(ele, L"@caption"); | 
 |  |  |             xstring src =GetEleString(ele, L"@src"); | 
 |  |  |             xstring image =GetEleString(ele, L"@image"); | 
 |  |  |             int p = trust(ele as int); | 
 |  |  |             int hItem=xtreeview::InsertItem(tv_gs.GetId(), pItem,0,caption,p,image.toInt()); | 
 |  |  |             string tagname =GetEleString(ele, "@tagname"); | 
 |  |  |             if (src != "" && tagname != "file" && tagname != "File") | 
 |  |  |             xstring tagname =GetEleString(ele, L"@tagname"); | 
 |  |  |             if (src != L"" && tagname != L"file" && tagname != L"File") | 
 |  |  |                xtreeview::SetItemChild1(tv_gs.GetId(), hItem,1); | 
 |  |  |             OnSetTree(hItem, ele); | 
 |  |  |          } | 
 |  |  | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  |           | 
 |  |  |       int OnSetTree(int hItem, string src) | 
 |  |  |       int OnSetTree(int hItem, xstring src) | 
 |  |  |       { | 
 |  |  |          xml x=new xml; | 
 |  |  |          x.setNativePointer(xml::CreateInstance()); | 
 |  |  |          xaserverarg arg=new xaserverarg; | 
 |  |  |          arg.setNativePointer(arg.CreateInstance());	 | 
 |  |  |          arg.AddArg("src",src); | 
 |  |  |          if(xaserver::ExecXQuery(GetServerUrl(),"[Developer.Tree.xq]",arg.GetString(),x)!=1) | 
 |  |  |          xml x; | 
 |  |  | 			 | 
 |  |  |          xaserverarg arg; | 
 |  |  |          ;	 | 
 |  |  |          arg.AddArg(L"src",src); | 
 |  |  |          if(xaserver::ExecXQuery(GetServerUrl(),L"[Developer.Tree.xq]",arg.GetString(),x)!=1) | 
 |  |  |          { | 
 |  |  |             alert("读取节点失败!"); | 
 |  |  |             alert(L"读取节点失败!"); | 
 |  |  |             return 1; | 
 |  |  |          } | 
 |  |  |          msxml::IXMLDOMElement e = x.GetXmlDoc().documentElement; | 
 |  |  |          KXMLDOMElement e = x.documentElement(); | 
 |  |  |          OnSetTree(hItem, e); | 
 |  |  |          return 1; | 
 |  |  |       } | 
 |  |  | 
 |  |  |       int onload() | 
 |  |  |       { | 
 |  |  |          nCount = 0; | 
 |  |  |          tv_gs = GetControl("DevExplorer");			 | 
 |  |  |          dw_log = GetControl("xlog"); | 
 |  |  |          tv_gs = GetControl(L"DevExplorer");			 | 
 |  |  |          dw_log = GetControl(L"xlog"); | 
 |  |  |          OnAttachEvent();    | 
 |  |  |           | 
 |  |  |          return 1; | 
 |  |  | 
 |  |  |        | 
 |  |  |       int onloaded() | 
 |  |  |       { | 
 |  |  |          OnSetTree(0, "Projects/projects.xhw"); | 
 |  |  |          OnSetTree(0, L"Projects/projects.xhw"); | 
 |  |  |          return 1; | 
 |  |  |       }       | 
 |  |  |    }; | 
 |  |  | ] | 
 |  |  |    }; |