Example #1
0
        //删除BE中没有而RTX中存在的组织信息
        public void DeleteExistedRTXAndNotExistedBE(string deptName, string parentDeptNameFullPath, string childDeptInfo)
        {
            string  logSql          = @" insert into S_D_ModifyLog (ID,ConnName,TableName,ModifyMode,EntityKey,CurrentValue,OriginalValue
                               ,ModifyUserID,ModifyUserName,ModifyTime,ClientIP,UserHostAddress) 
                               Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')";
            var     orgInfo_BE_Temp = orgDt.Select(" Name='" + deptName + "' ");
            DataRow orgInfo_BE      = null;

            if (orgInfo_BE_Temp != null && orgInfo_BE_Temp.Count() > 0)
            {
                orgInfo_BE = orgInfo_BE_Temp[0];
            }
            if (orgInfo_BE == null)
            {
                try
                {
                    deptManager.DelDept(deptName, true);
                }
                catch (Exception exp)
                {
                    logSql = @" insert into S_D_ModifyLog (ID,ConnName,TableName,ModifyMode,EntityKey,CurrentValue,OriginalValue
                               ,ModifyUserID,ModifyUserName,ModifyTime,ClientIP,UserHostAddress) 
                               Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')";
                    logSql = string.Format(logSql, FormulaHelper.CreateGuid(), "Base", "", "Added", "删除" + deptName + "部门失败"
                                           , "失败时间:" + DateTime.Now, "失败详细信息:" + exp.Message, "", "", DateTime.Now, "", "");
                    SQLHelper.CreateSqlHelper(ConnEnum.Base).ExecuteNonQuery(logSql);

                    return;
                }
            }
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(BeforeLoadXML(childDeptInfo));
            XmlElement  xmlEle   = xmlDoc.DocumentElement;
            XmlNodeList nodelist = xmlEle.SelectNodes("//Department");

            if (nodelist == null && nodelist.Count == 0)
            {
                return;
            }
            if (nodelist != null && nodelist.Count > 0)
            {
                for (int i = 0; i < nodelist.Count; i++)
                {
                    var    node          = nodelist[i];
                    string childDeptName = ((XmlElement)node).GetAttribute("Name");
                    var    tempdeptNameDeptNameFullPath = parentDeptNameFullPath + "\\" + childDeptName;
                    var    grandsenDeptInfo             = deptManager.GetChildDepts(tempdeptNameDeptNameFullPath);
                    DeleteExistedRTXAndNotExistedBE(childDeptName, tempdeptNameDeptNameFullPath, grandsenDeptInfo);
                }
            }
        }
Example #2
0
        //同步组织架构的主方法
        public void StartSynchDeptInfo()
        {
            string logSql = @" insert into S_D_ModifyLog (ID,ConnName,TableName,ModifyMode,EntityKey,CurrentValue,OriginalValue
                               ,ModifyUserID,ModifyUserName,ModifyTime,ClientIP,UserHostAddress) 
                               Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')";

            //获取组织架构根节点
            var rootOrg_BE_Temp = orgDt.Select("ParentID is null or ParentID = ''");

            if (rootOrg_BE_Temp == null || rootOrg_BE_Temp.Count() == 0)
            {
                logSql = string.Format(logSql, FormulaHelper.CreateGuid(), "Base", "", "Added", "获取组织架构根节点信息失败。"
                                       , "失败时间:" + DateTime.Now, "获取组织架构根节点信息失败:", "", DateTime.Now, "", "");
                baseSqlHelper.ExecuteNonQuery(logSql);
            }
            deptManager = RootObj.DeptManager;
            if (deptManager == null)
            {
                //记录异常信息
                logSql = string.Format(logSql, FormulaHelper.CreateGuid(), "Base", "", "Added", "获取RTX组织管理对象失败。"
                                       , "失败时间:" + DateTime.Now, "获取RTX组织管理对象失败:", "", DateTime.Now, "", "");
                baseSqlHelper.ExecuteNonQuery(logSql);
            }

            DataRow rootOrg         = rootOrg_BE_Temp[0];
            DataRow parentNode_Root = null;
            var     rootOrgID       = rootOrg["ID"].ToString();

            DataRow[] children    = orgDt.Select(" ParentID='" + rootOrgID + "'");
            var       rootOrgName = rootOrg["Name"] == null ? "" : rootOrg["Name"].ToString();

            AddDeptToRTX(rootOrg, parentNode_Root, children);

            //删除RTX中存在,金慧BE平台不存在的部门
            string childOrgInfo = deptManager.GetChildDepts(rootOrgName);

            DeleteExistedRTXAndNotExistedBE(rootOrgName, rootOrgName, childOrgInfo);
        }