jrj/ext-jrj/ext-jrj.vcxproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jrj/ext-jrj/ext-jrj.vcxproj.filters | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jrj/xframe/devloper/XDevEditPage.hpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jrj/xframe/devloper/XDevEditXPage.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jrj/xframe/src/xfile.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jrj/xframe/win32/win.hpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
jrj/xframe/win32/xfile.hpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
jrj/ext-jrj/ext-jrj.vcxproj
@@ -1248,6 +1248,7 @@ <ClCompile Include="..\xframe\devloper\XDevItemDlg.cpp" /> <ClCompile Include="..\xframe\src\nmemory.cpp" /> <ClCompile Include="..\xframe\src\nstring.cpp" /> <ClCompile Include="..\xframe\src\xfile.cpp" /> <ClCompile Include="..\xframe\src\xstring.cpp" /> <ClCompile Include="dllmain.cpp" /> <ClCompile Include="JAllocImpl.cpp" /> jrj/ext-jrj/ext-jrj.vcxproj.filters
@@ -1589,6 +1589,9 @@ <ClCompile Include="..\project\business\Expense\ManageCostList.cpp"> <Filter>project\business\Expense</Filter> </ClCompile> <ClCompile Include="..\xframe\src\xfile.cpp"> <Filter>xframe\src</Filter> </ClCompile> </ItemGroup> <ItemGroup> <None Include="ext-jrj.def"> jrj/xframe/devloper/XDevEditPage.hpp
@@ -8,6 +8,8 @@ #include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp> #include <win32/xfile.hpp> #include <tchar.h> using xml = KXMLDOMDocument; class export XDevEditPage : public xwin { @@ -106,11 +108,10 @@ return GetData(0); } int SaveContentEx(xstring content, int bcode) int SaveContentEx(HTREEITEM hItem,xstring content, int bcode) { xwin w = GetFrameWindow(); xtreeview tv_folder = w.GetControl(L"DevExplorer"); HTREEITEM hItem = (HTREEITEM)GetWinParam(); KXMLDOMElement e = tv_folder.GetItemData(hItem); xstring node = e.tagName(); if (node == L"File" || node == L"file") @@ -129,7 +130,7 @@ //find project folder xstring prjguid = L""; HTREEITEM pitem = GetProjectItem(tv_folder, hItem); HTREEITEM pitem = GetProjectItem(tv_folder, hItem); if (pitem) prjguid = ((KXMLDOMElement)tv_folder.GetItemData(pitem)).getAttribute(L"guid"); @@ -158,9 +159,34 @@ } return 1; } int SaveContentEx(xstring content, int bcode) { HTREEITEM hItem = (HTREEITEM)GetWinParam(); return SaveContentEx(hItem,content,bcode); } int SaveContent(HTREEITEM hItem,xstring content) { return SaveContentEx(hItem,content, 0); } int SaveContent(xstring content) { return SaveContentEx(content, 0); } int SaveContentEx(xstring prjguid, xstring domainguid, xstring rootguid, xstring guid,xstring content, int bcode) { xaserverarg arg; arg.AddArg(L"project.guid", prjguid); arg.AddArg(L"root.guid", rootguid); arg.AddArg(L"domain.guid", domainguid); arg.AddArg(L"guid", guid); arg.AddArg(L"content", content); if (bcode)arg.AddArg(L"iscode", L"yes"); ProcessDevCmd(L"saveobject", arg.GetString()); return 1; } xstring GetGuid() @@ -168,18 +194,19 @@ return publiccode::GetGuid(); } int ImportItem(HTREEITEM hItem, KXMLDOMElement ele, xstring prjguid, xstring domainguid, xstring rootguid) int ImportItem(xstring baseFolder,HTREEITEM hItem, KXMLDOMElement ele, xstring prjguid, xstring domainguid, xstring rootguid) { xwin w = GetFrameWindow(); xtreeview tv_folder = w.GetControl(L"DevExplorer"); xstring caption = ele.getAttribute(L"src"); xstring uri = ele.getAttribute(L"uri"); xstring guid = ((KXMLDOMElement)tv_folder.GetItemData(hItem)).getAttribute(L"guid"); xstring typ = ele.tagName(); KXMLDOMElement e = tv_folder.GetItemData(hItem); xaserverarg arg; KXMLDOMNode node = e.selectSingleNode(typ + L"[@caption='" + caption + L"']"); KXMLDOMNode node = e.selectSingleNode(typ + L"[not(@delete) and @caption='" + caption + L"']"); if (!node) { //add file folder @@ -209,15 +236,69 @@ int lens; KXMLDOMNodeList nodes = ele.selectNodes(L"node()"); KXMLDOMNodeList nodes = ele.selectNodes(L"node()[not(@delete)]"); lens = nodes.length(); for (int i = 0; i < lens; i++) { KXMLDOMElement child = nodes.item(i); ImportItem(hNewItem, child, prjguid, domainguid, rootguid); ImportItem(baseFolder,hNewItem, child, prjguid, domainguid, rootguid); } } return 1; } else { //update content if (typ == L"file" && node.selectSingleNode(L"@guid") && node.selectSingleNode(L"@src")) { wchar_t path[MAX_PATH]=L""; xstring src = node.selectSingleNode(L"@src").text(); trace(L"\r\n" + src); wcscat_s(path, MAX_PATH, baseFolder); wcscat_s(path, MAX_PATH, L"/"); wcscat_s(path, MAX_PATH, src.c_str()); xstring xs = xfile::GetString(path); const wchar_t* val = xs.c_str(); xstring myguid = node.selectSingleNode(L"@guid").text(); xstring mytype = node.selectSingleNode(L"@type") ? node.selectSingleNode(L"@type").text() : L""; if (xs != L"") { this->SaveContentEx(prjguid, domainguid, rootguid, myguid, xs, false); if (mytype == L"xpage") { ::PathRemoveExtensionW(path); wcscat_s(path, MAX_PATH, L".xss"); xs = xfile::GetString(path); if (xs != L"")this->SaveContentEx(prjguid, domainguid, rootguid, myguid, xs, true); } } } HTREEITEM hNewItem = tv_folder.GetChildItem(hItem); KXMLDOMElement e2 = node; xstring url2 = e2.getAttribute(L"uri"); while (hNewItem) { KXMLDOMElement e1 = tv_folder.GetItemData(hNewItem); wchar_t* uri1 = e1.getAttribute(L"uri"); wchar_t* uri2 = e2.getAttribute(L"uri"); if (url2 == e1.getAttribute(L"uri"))break; hNewItem = tv_folder.GetNextItem(hNewItem); } if (hNewItem) { int lens; KXMLDOMNodeList nodes = ele.selectNodes(L"node()[not(@delete)]"); lens = nodes.length(); for (int i = 0; i < lens; i++) { KXMLDOMElement child = nodes.item(i); ImportItem(baseFolder, hNewItem, child, prjguid, domainguid, rootguid); } } } return 1; } @@ -231,7 +312,12 @@ xml src; src.load(srcfile); xstring path = L"//*[(name()='file' or name()='folder') and @src='" + id + L"']"; TCHAR szPath[MAX_PATH]=L""; wcscat_s(szPath, MAX_PATH,srcfile.c_str()); ::PathRemoveExtensionW(szPath); xstring path = L"//*[(name()='file' or name()='folder') and not(@delete) and @src='" + id + L"']"; const wchar_t* str = src.xml(); KXMLDOMElement srcele = src.selectSingleNode(path); if (!srcele) return 1; @@ -270,12 +356,12 @@ domainguid = d.getAttribute(L"guid"); } int lens; KXMLDOMNodeList nodes = srcele.selectNodes(L"node()"); KXMLDOMNodeList nodes = srcele.selectNodes(L"node()[not(@delete)]"); lens = nodes.length(); for (int i = 0; i < lens; i++) { KXMLDOMElement child = nodes.item(i); ImportItem(hItem, child, prjguid, domainguid, rootguid); ImportItem(szPath,hItem, child, prjguid, domainguid, rootguid); } return 1; jrj/xframe/devloper/XDevEditXPage.cpp
@@ -55,10 +55,19 @@ } else if (comdid == L"xmImport") { ImportItems(L"file://D:/jrjhome/developer-yh/projects/mherp.com.cn/å端çç¥/works/ä¾åºé¾.xml", L"Profit3.vface");// L"{94124797-1F4A-4BAC-8839-B5A119895C92}"); //ImportItems(L"file://D:/jrjhome/developer-yh/projects/mherp.com.cn/æ°æ®ä¸å¿/works/trade.xml", // L"Profit3.iface");// L"{94124797-1F4A-4BAC-8839-B5A119895C92}"); xwin w = GetFrameWindow(); xtreeview tv_folder = w.GetControl(L"DevExplorer"); HTREEITEM hItem = tv_folder.GetSelectedItem(); if (!hItem) return 1; KXMLDOMElement e = tv_folder.GetItemData(hItem); xstring src = e.getAttribute(L"src"); if(src==L"Profit3.vface") ImportItems(L"file://D:/jrjhome/developer-yh/projects/mherp.com.cn/å端çç¥/works/ä¾åºé¾.xml", L"Profit3.vface"); else if (src == L"Profit3.iface") ImportItems(L"file://D:/jrjhome/developer-yh/projects/mherp.com.cn/æ°æ®ä¸å¿/works/trade.xml", L"Profit3.iface"); return 1; } jrj/xframe/src/xfile.cpp
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,70 @@ #include "wobject/xbase.hpp" #include "wobject/xstring.hpp" #include "win32/xfile.hpp" #include <vector> xstring xfile::GetString(xstring path) { int nLen = 0; const wchar_t* file = path.c_str(false); if (file[0] == 'f' && file[1] == 'i' && file[2] == 'l' && file[3] == 'e' && file[4] == ':' && file[5] == '/' && file[6] == '/') file += 7; BYTE* lpBuffer = xfile::GetBuffer(file, nLen); if (!lpBuffer)return L""; void* p = lpBuffer; if (nLen > 2) { if ((lpBuffer[0] == 0xff && lpBuffer[1] == 0xfe) || (lpBuffer[0] == 0xfe && lpBuffer[1] == 0xff))lpBuffer = lpBuffer + 2; } xstring str = (wchar_t*)lpBuffer; if (p)delete p; return str; } BYTE* xfile::GetBuffer(xstring path, int& Length) { TCHAR buf[255]; TCHAR* pToken = NULL; int len = 0; DWORD dwFileSize = 0; DWORD dwReadSize = 0; DWORD GENERIC_READ = (0x80000000L); DWORD GENERIC_WRITE = (0x40000000L); DWORD GENERIC_EXECUTE = (0x20000000L); DWORD GENERIC_ALL = (0x10000000L); DWORD FILE_SHARE_READ = 0x00000001; DWORD FILE_SHARE_WRITE = 0x00000002; DWORD FILE_SHARE_DELETE = 0x00000004; DWORD FILE_ATTRIBUTE_NORMAL =0x00000080; DWORD OPEN_ALWAYS = 4; DWORD OPEN_EXISTING = 3; HANDLE INVALID_HANDLE_VALUE = ((HANDLE)(LONG_PTR)-1); try { HANDLE hFile = xfile::CreateFile(path.c_str(false), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { dwFileSize = ::GetFileSize(hFile, NULL); BYTE* lpBuffer = new BYTE[dwFileSize+2]; lpBuffer[dwFileSize] = 0; lpBuffer[dwFileSize+1] = 0; ReadFile(hFile, lpBuffer, dwFileSize, &dwReadSize, NULL); Length = dwReadSize; if (hFile != INVALID_HANDLE_VALUE)CloseHandle(hFile); return lpBuffer; } } catch (...) { } return nullptr; } jrj/xframe/win32/win.hpp
@@ -109,7 +109,8 @@ int WINAPI GetModuleFileNameW(HMODULE hModule ,string lpFileName, int nSize);//native from "kernel32.dll" alias "GetModuleFileNameW"; void WINAPI GetLocalTime(SYSTEMTIME& lpSystemTime) ;//native from "kernel32.dll" alias "GetLocalTime"; int WINAPI PathRemoveFileSpecW(string lpFileName);// native from "shlwapi.dll" alias "PathRemoveFileSpecW"; int WINAPI PathRemoveExtensionW(string lpFileName);// native from "shlwapi.dll" alias "PathRemoveExtensionW"; } #define SendMessage SendMessageW #define PostMessage PostMessageW jrj/xframe/win32/xfile.hpp
@@ -2,6 +2,7 @@ #include "system/base.hpp" #include "win.hpp" #include "wobject/xstring.hpp" #if _XWIN #define CALLBACK __stdcall @@ -151,5 +152,8 @@ { return ::GetFileSize(hFile, &lpFileSizeHigh); } static xstring GetString(xstring path); static BYTE* GetBuffer(xstring path,int& Length); };