Пример #1
0
        /// <summary>
        /// 针对机构中的人员的相关数据处理
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <param name="userXml"></param>
        /// <param name="userXsd"></param>
        /// <param name="orgUserXml"></param>
        /// <param name="orgUsersXsd"></param>
        private static void XmlDocToUsersAndOrgUsers(XmlDocument xmlDoc,
                                                     XmlDocument userXml,
                                                     XmlDocument userXsd,
                                                     XmlDocument orgUserXml,
                                                     XmlDocument orgUsersXsd)
        {
            XmlNode oNodeSet  = xmlDoc.DocumentElement.SelectSingleNode(".//SET");
            XmlNode uNodeSet  = userXml.DocumentElement.SelectSingleNode(".//SET");
            XmlNode ouNodeSet = orgUserXml.DocumentElement.SelectSingleNode(".//SET");

            foreach (XmlNode oElemNode in oNodeSet.ChildNodes)
            {
                if (InnerCommon.GetXSDColumnNode(userXsd, oElemNode.LocalName) != null)
                {
                    XmlHelper.AppendNode(uNodeSet, oElemNode.LocalName, oElemNode.InnerText);
                }

                if (InnerCommon.GetXSDColumnNode(orgUsersXsd, oElemNode.LocalName) != null)
                {
                    XmlHelper.AppendNode(ouNodeSet, oElemNode.LocalName, oElemNode.InnerText);
                }
            }

            XmlNode wNode = xmlDoc.DocumentElement.SelectSingleNode(".//WHERE");

            if (wNode != null)
            {
                XmlNode uWNode = XmlHelper.AppendNode(userXml.DocumentElement.FirstChild, "WHERE");
                XmlHelper.AppendNode(uWNode, "GUID", wNode.SelectSingleNode("USER_GUID").InnerText);

                XmlNode ouWNode = XmlHelper.AppendNode(orgUserXml.DocumentElement.FirstChild, "WHERE");
                foreach (XmlNode wcNode in wNode.ChildNodes)
                {
                    XmlHelper.AppendNode(ouWNode, wcNode.LocalName, wcNode.InnerText);
                }
            }

            if (uNodeSet.ChildNodes.Count > 0)
            {
                XmlNode mNode = XmlHelper.AppendNode(uNodeSet, "MODIFY_TIME", "GETDATE()");
                XmlHelper.AppendAttr(mNode, "type", "other");
            }

            if (ouNodeSet.ChildNodes.Count > 0)
            {
                XmlNode mNode = XmlHelper.AppendNode(ouNodeSet, "MODIFY_TIME", "GETDATE()");
                XmlHelper.AppendAttr(mNode, "type", "other");
            }
        }
Пример #2
0
        private static void PrepareSetUserSideline(XmlDocument xmlDoc, XmlDocument orgUserXsd, Dictionary <object, object> context)
        {
            XmlElement root    = xmlDoc.DocumentElement;
            XmlNode    nodeSet = xmlDoc.DocumentElement.SelectSingleNode(".//SET");

            CheckAllPathNameInSystem(nodeSet.SelectSingleNode(".//ALL_PATH_NAME").InnerText);
            InsertSqlClauseBuilder ic = new InsertSqlClauseBuilder();

            foreach (XmlElement elem in nodeSet.ChildNodes)
            {
                if (InnerCommon.GetXSDColumnNode(orgUserXsd, elem.LocalName) != null)
                {
                    ic.AppendItem(elem.LocalName, elem.InnerText);
                }
            }

            ic.AppendItem("INNER_SORT", "@U_INNER_SORT", "other", true);
            ic.AppendItem("ORIGINAL_SORT", "@O_ORIGINAL_SORT + @U_INNER_SORT", "other", true);
            ic.AppendItem("GLOBAL_SORT", "@O_GLOBAL_SORT + @U_INNER_SORT", "other", true);
            ic.AppendItem("MODIFY_TIME", "GETDATE()", "other", true);
            ic.AppendItem("STATUS", "1");

            string strSql = @"
				DECLARE @U_INNER_SORT NVARCHAR(6);
				DECLARE @O_ORIGINAL_SORT NVARCHAR(255);
				DECLARE @O_GLOBAL_SORT NVARCHAR(255);

				UPDATE ORGANIZATIONS
					SET CHILDREN_COUNTER = CHILDREN_COUNTER + 1, 
						MODIFY_TIME = GETDATE(), 
						@U_INNER_SORT = REPLACE(STR(CHILDREN_COUNTER + 1, 6), ' ', '0'),
						@O_ORIGINAL_SORT = ORIGINAL_SORT,
						@O_GLOBAL_SORT = GLOBAL_SORT
				WHERE GUID = {0};
				
				INSERT INTO OU_USERS "                 + ic.ToSqlString(TSqlBuilder.Instance);

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(nodeSet.SelectSingleNode("PARENT_GUID").InnerText, true));

            context.Add("Sql", strSql);
            // InnerCommon.ExecuteNonQuery(strSql);
        }