LiFan
2025-04-17 3cc879bd09b69310d905b843aadc2d0abd67513b
jrj/project/business/SystemSettings/UserImport.cpp
@@ -6,7 +6,8 @@
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
//use "dev:code[SysUser.vx]"
#include "SysUser.hpp"
using xml = KXMLDOMDocument;
class __declspec(dllexport) UserImport : public xframe
@@ -14,7 +15,7 @@
public:
   SysUser lw_obj;
   SysUser* lw_obj;
   xdwgrid   dw_list;
   xtreeview   tv_org;
   xnode   m_agentNode;   //Agent Condition
@@ -22,7 +23,7 @@
   xstring   m_sTxt;
   xstring      is_orgid;
public:
   UserImport(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
   UserImport(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd), lw_obj(nullptr) {}
public:
   static UserImport* CreateInstance(void* implPtr, void* hWnd)
   {
@@ -81,9 +82,7 @@
   {
      if (GetWinParam())
      {
         lw_obj = new SysUser;
         lw_obj.setNativePointer(GetParam());
         lw_obj = GetParam();
         lw_obj = (SysUser*)GetWinParam();
      }
      else
         return 0;
@@ -99,9 +98,9 @@
      xstring sPositionID, sPositionName;
      xstring sOrgID, sOrgName;
      xstring sJobID, sJobName;
      int wid = lw_obj.tv_usergroup.GetId();
      int hitem = tv_org.GetSelectedItem(wid);
      KXMLDOMElement ele = tv_org.GetItemData(wid, hitem);
      //int wid = lw_obj.tv_usergroup.GetId();
      HTREEITEM hitem = tv_org.GetSelectedItem();
      //KXMLDOMElement ele = tv_org.GetItemData(hitem);
      while (row > 0)
@@ -109,10 +108,10 @@
         //trace(row);
         KXMLDOMElement e = dw_list.GetRowElement(row);
         trace(e.xml());
         xstring sEmployeeNo = e.selectSingleNode(L"EmployeeNo").text() + L"";
         xstring sOldEmpNo = e.selectSingleNode(L"OldEmpNo").text() + L"";
         xstring sPersonID = e.selectSingleNode(L"PersonID").text() + L"";
         xstring sPersonName = e.selectSingleNode(L"Name").text() + L"";
         xstring sEmployeeNo = e.selectSingleNode(L"EmployeeNo").text() + (xstring)L"";
         xstring sOldEmpNo = e.selectSingleNode(L"OldEmpNo").text() + (xstring)L"";
         xstring sPersonID = e.selectSingleNode(L"PersonID").text() + (xstring)L"";
         xstring sPersonName = e.selectSingleNode(L"Name").text() + (xstring)L"";
         xstring sPassWord = xutil::MD5(sOldEmpNo);
         /*
@@ -131,15 +130,15 @@
            }
         }*/
         int nRow = lw_obj.dw_user.InsertRow(0);
         lw_obj.dw_user.SetItemString(nRow, L"EmployeeNo", sEmployeeNo);
         lw_obj.dw_user.SetItemString(nRow, L"UserName", sOldEmpNo);
         lw_obj.dw_user.SetItemString(nRow, L"PassWord", sPassWord);
         lw_obj.dw_user.SetItemString(nRow, L"PersonID", sPersonID);
         lw_obj.dw_user.SetItemDisplayString(nRow, L"PersonID", sPersonName);
         lw_obj.dw_user.SetItemString(nRow, L"Status", L"Y");
         lw_obj.dw_user.SetItemDisplayString(nRow, L"Status", L"有效");
         lw_obj.dw_user.SetItemString(nRow, L"OldEmpNo", sOldEmpNo);
         int nRow = lw_obj->dw_user.InsertRow(0);
         lw_obj->dw_user.SetItemString(nRow, L"EmployeeNo", sEmployeeNo);
         lw_obj->dw_user.SetItemString(nRow, L"UserName", sOldEmpNo);
         lw_obj->dw_user.SetItemString(nRow, L"PassWord", sPassWord);
         lw_obj->dw_user.SetItemString(nRow, L"PersonID", sPersonID);
         lw_obj->dw_user.SetItemDisplayString(nRow, L"PersonID", sPersonName);
         lw_obj->dw_user.SetItemString(nRow, L"Status", L"Y");
         lw_obj->dw_user.SetItemDisplayString(nRow, L"Status", L"有效");
         lw_obj->dw_user.SetItemString(nRow, L"OldEmpNo", sOldEmpNo);
         /*
            lw_obj.dw_user.SetItemString(nRow,L"PositionID",sPositionID);
            lw_obj.dw_user.SetItemDisplayString(nRow,L"PositionID",sPositionName);
@@ -162,12 +161,12 @@
   }
   int OnSubTree(xstring id, HTREEITEM parentitem)
   {
      int wid = tv_org.GetId();
      if (tv_org.GetChildItem(wid, parentitem) > 0) return 1;
      //int wid = tv_org.GetId();
      if (tv_org.GetChildItem( parentitem)) return 1;
      xml x;
      xaserverarg arg;
      arg.setNativePointer(arg.CreateInstance());
      arg.AddArg(L"sguid", id);
      if (xurl::post(L"/sale/data/OrganizationStruct/tree.child.OrgChart", arg.GetString(), x) != 1)
      {
@@ -175,8 +174,8 @@
         return -1;
      }
      //trace(x.xml());
      var list = x.selectNodes(L"//item");
      int i = 0, s = list.length;
      auto list = x.selectNodes(L"//item");
      int i = 0, s = list.length();
      KXMLDOMElement xitem;
      xstring sName;
      xstring sguid;
@@ -190,15 +189,15 @@
            sguid = xitem.selectSingleNode(L"id").text();
            stype = xitem.selectSingleNode(L"typ").text();
            //int curItem = tv_org.InsertChildItemEx(wid,parentitem,sName,xitem,15,4);
            int curItem = 0;
            HTREEITEM curItem = 0;
            if (stype == L"Org")
            {
               curItem = tv_org.InsertChildItemEx(wid, parentitem, sName, xitem, 15, 4);
               tv_org.SetItemChild1(wid, curItem, 1);
               curItem = tv_org.InsertChildItemEx( parentitem, sName, xitem, 15, 4);
               tv_org.SetItemChild1(curItem, 1);
            }
            else
            {
               curItem = tv_org.InsertChildItemEx(wid, parentitem, sName, xitem, 21, 21);
               curItem = tv_org.InsertChildItemEx(parentitem, sName, xitem, 21, 21);
            }
            //OnSubTree(sguid,curItem);
         }
@@ -206,20 +205,20 @@
      return 1;
   }
   int OnCreateTree(xstring id, int parentitem)
   int OnCreateTree(xstring id, HTREEITEM parentitem)
   {
      //while (tv_1.GetRootItem()>0)
      //   tv_1.DeleteItem(tv_1.GetRootItem());            
      int wid = tv_org.GetId();
      //int wid = tv_org.GetId();
      xml x;
      x.loadXML(L"<item><id>" + id + L"</id><no/><name>凤凰集团</name><typ>Org</typ></item>");
      x.loadXML(L"<item><id>" + id + L"</id><no/><name>组织结构</name><typ>Org</typ></item>");
      //KXMLDOMDocument root = x;
      //KXMLDOMElement RDoc = x.documentElement();
      //KXMLDOMElement ele = RDoc.SelectSingleNode(L"//Org");
      KXMLDOMElement ele = x.selectSingleNode(L"//item");
      int hItem = tv_org.InsertChildItemEx(wid, 0, L"凤凰集团", ele, 15, 4);
      tv_org.SetItemChild1(wid, hItem, 1);
      HTREEITEM hItem = tv_org.InsertChildItemEx( (HTREEITEM)0, L"组织结构", ele, 15, 4);
      tv_org.SetItemChild1(hItem, 1);
      return 1;
      /*xaserverarg arg;
@@ -259,7 +258,7 @@
      HCURSOR hCursor = xutil::SetCursorWait();
      //xstring id = tv_org.GetItemData(tv_org.GetId(), sitem);
      KXMLDOMElement ele = tv_org.GetItemData(tv_org.GetId(), sitem);
      KXMLDOMElement ele = tv_org.GetItemData(sitem);
      xstring id = ele.selectSingleNode(L"id").text();
      OnSubTree(id, sitem);
      xutil::RestoreCursor(hCursor);
@@ -269,7 +268,7 @@
   int OnTreeSelChanged(TEvent* evt, LPARAM p)
   {
      //int wid = tv_org.GetId();
      int hitem = tv_org.GetSelectedItem();
      HTREEITEM hitem = tv_org.GetSelectedItem();
      KXMLDOMElement ele = tv_org.GetItemData(hitem);
      if (ele)
      {
@@ -283,9 +282,15 @@
   int OnCmdDispatch(xstring comdid)
   {
      if (comdid == L"cb_import")
      {
         OnOK();
         return 1;
      }
      else if (comdid == L"cb_close")
      {
         CloseWindow();
         return 1;
      }
      return 0;
   }
@@ -310,14 +315,13 @@
   int OnInitial()
   {
      SetAgent();
      OnAttachEvent();
      OnAttachEvent();
      return 1;
   }
   int onload()
   {
      tv_org = new treeview;
      tv_org.setNativePointer(GetControl(L"tv_org"));
      tv_org = GetControl(L"tv_org");
      dw_list = new xdwgrid;
      dw_list.setNativePointer(GetControl(L"dw_list"));
      dw_list.openUrl(L"系统用户.vface/template/SysUser/EmpSelect");
@@ -327,7 +331,7 @@
      OnInitial();
      OnCreateTree(L"00000000-0000-0000-0000-000000000000", 0);
      //int wid = tv_org.GetId();
      int root = tv_org.GetRootItem();
      HTREEITEM root = tv_org.GetRootItem();
      tv_org.ExpandItem(root);
      OnRetrieve(L"00000000-0000-0000-0000-000000000000");
      return 1;