Example #1
0
        /// <summary>
        /// 把指定机构中的所有用户对象加入到新的用户组中
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="strGroupGuid"></param>
        private static void AddOrganizationToGroup(DataSet ds, string strGroupGuid)
        {
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (OGUCommonDefine.DBValueToString(row["OBJECTCLASS"]) == "USERS")
                {
                    string strSql = @"
						DECLARE @MAX_INNER_SORT NVARCHAR(6);

						SET @MAX_INNER_SORT = (SELECT MAX(INNER_SORT) FROM GROUP_USERS WHERE GROUP_GUID = {0});

						INSERT INTO GROUP_USERS (GROUP_GUID, USER_GUID, USER_PARENT_GUID, INNER_SORT, MODIFY_TIME, CREATE_TIME)
						VALUES
						({0}, {1}, {2}, REPLACE(STR(ISNULL(@MAX_INNER_SORT, -1) + 1, 6), ' ', '0'), GETDATE(), GETDATE())
					"                    ;

                    strSql = string.Format(strSql,
                                           TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true),
                                           TSqlBuilder.Instance.CheckQuotationMark(OGUCommonDefine.DBValueToString(row["GUID"]), true),
                                           TSqlBuilder.Instance.CheckQuotationMark(OGUCommonDefine.DBValueToString(row["PARENT_GUID"]), true));

                    try
                    {
                        InnerCommon.ExecuteNonQuery(strSql);
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        if (ex.Number != 2627)                        //数据重复
                        {
                            throw ex;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 把指定用户对象作为指定领导的秘书
        /// </summary>
        /// <param name="elem"></param>
        /// <param name="strLeaderGuid"></param>
        /// <param name="strStartTime"></param>
        /// <param name="strEndTime"></param>
        private static void SetUserSecretaries(XmlElement elem, string strLeaderGuid, string strStartTime, string strEndTime)
        {
            ExceptionHelper.TrueThrow(elem.GetAttribute("GUID") == strLeaderGuid, "对不起,自己不能给自己做秘书!");
            string strSql = @"
				INSERT INTO SECRETARIES (LEADER_GUID, SECRETARY_GUID, START_TIME, END_TIME)
				VALUES
				({0}, {1}, {2}, {3})
				"                ;

            strSql = string.Format(strSql,
                                   TSqlBuilder.Instance.CheckQuotationMark(strLeaderGuid, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("GUID"), true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strStartTime, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strEndTime, true));
            try
            {
                InnerCommon.ExecuteNonQuery(strSql);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                if (ex.Number != 2627)                //数据重复
                {
                    throw ex;
                }
            }
        }
Example #3
0
        /// <summary>
        /// 用户组中添加一个新的用户
        /// </summary>
        /// <param name="elem"></param>
        /// <param name="strGroupGuid"></param>
        private static void AddUserToGroup(XmlElement elem, string strGroupGuid)
        {
            string strSql = @"
				DECLARE @MAX_INNER_SORT NVARCHAR(6);

				SET @MAX_INNER_SORT = (SELECT MAX(INNER_SORT) FROM GROUP_USERS WHERE GROUP_GUID = {0});

				INSERT INTO GROUP_USERS (GROUP_GUID, USER_GUID, USER_PARENT_GUID, INNER_SORT, MODIFY_TIME, CREATE_TIME)
				VALUES
				({0}, {1}, {2}, REPLACE(STR(ISNULL(@MAX_INNER_SORT, -1) + 1, 6), ' ', '0'), GETDATE(), GETDATE())
				"                ;

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("GUID"), true),
                                   TSqlBuilder.Instance.CheckQuotationMark(elem.GetAttribute("PARENT_GUID"), true));
            try
            {
                InnerCommon.ExecuteNonQuery(strSql);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                //				ExceptionHelper.TrueThrow(ex.Number == 2601, "对不起,系统中已经存在了该名称的");
                //				ExceptionHelper.TrueThrow(ex.Number == 2627, "对不起,系统关键字冲突;");//数据重复(key重复)
                if (ex.Number != 2627)                 //数据重复(key重复)就把错吃掉
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// 把指定用户组(或机构)中的用户对象作为指定领导的秘书
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="strLeaderGuid"></param>
        /// <param name="strStartTime"></param>
        /// <param name="strEndTime"></param>
        private static void SetOrgOrGroupSecretary(DataSet ds, string strLeaderGuid, string strStartTime, string strEndTime)
        {
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (OGUCommonDefine.DBValueToString(row["OBJECTCLASS"]) == "USERS" && OGUCommonDefine.DBValueToString(row["USER_GUID"]) != strLeaderGuid)
                {
                    string strSql = @"
						INSERT INTO SECRETARIES (LEADER_GUID, SECRETARY_GUID, START_TIME, END_TIME)
						VALUES
						({0}, {1}, {2}, {3})
						"                        ;

                    strSql = string.Format(strSql,
                                           TSqlBuilder.Instance.CheckQuotationMark(strLeaderGuid, true),
                                           TSqlBuilder.Instance.CheckQuotationMark(OGUCommonDefine.DBValueToString(row["USER_GUID"]), true),
                                           TSqlBuilder.Instance.CheckQuotationMark(strStartTime, true),
                                           TSqlBuilder.Instance.CheckQuotationMark(strEndTime, true));

                    try
                    {
                        InnerCommon.ExecuteNonQuery(strSql);
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        if (ex.Number != 2627)                        //数据重复
                        {
                            throw ex;
                        }
                    }
                }
            }
        }
Example #5
0
        private static void PrepareUpdateOrgOrGroups(XmlDocument xmlDoc, XmlDocument xsdDoc, Dictionary <object, object> context)
        {
            XmlNode nodeSet = xmlDoc.DocumentElement.SelectSingleNode(".//SET");
            XmlNode aNode   = nodeSet.SelectSingleNode(".//ALL_PATH_NAME");

            if (aNode != null)
            {
                CheckAllPathNameInSystem(aNode.InnerText);
            }

            XmlNode mNode = XmlHelper.AppendNode(nodeSet, "MODIFY_TIME", "GETDATE()");

            XmlHelper.AppendAttr(mNode, "type", "other");

            DataExtraCheck(xmlDoc, nodeSet.ParentNode.LocalName);            //附加的数据检查

            string strSql = InnerCommon.GetUpdateSqlStr(xmlDoc, xsdDoc);

            if (xmlDoc.DocumentElement.FirstChild.LocalName == "ORGANIZATIONS")
            {
                strSql += " \n ; \n " + UpdataOrganizationsChildrens(xmlDoc);
            }

            context.Add("Sql", strSql);
        }
Example #6
0
        private XmlDocument eventContainer_GroupSortObjects(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            XmlDocument result;

            XmlElement root         = xmlDoc.DocumentElement;
            string     strGroupGuid = root.GetAttribute("GUID");

            ExceptionHelper.TrueThrow(strGroupGuid == string.Empty, "对不起,没有指定人员组的标识!");

            string strSql = @"
			UPDATE GROUPS
				SET MODIFY_TIME = GETDATE()
			WHERE GUID = {0};"            ;

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true));
            int iPageNo   = Convert.ToInt32(root.GetAttribute("PageNo"));
            int iPageSize = Convert.ToInt32(root.GetAttribute("PageSize"));

            StringBuilder builder = new StringBuilder(1024);

            for (int iSort = iPageNo * iPageSize; iSort < root.ChildNodes.Count; iSort++)
            {
                XmlNode elem = root.ChildNodes[iSort];

                string strUserGuid = elem.SelectSingleNode("USER_GUID").InnerText;
                string strOrgGuid  = elem.SelectSingleNode("USER_PARENT_GUID").InnerText;
                ExceptionHelper.TrueThrow(strUserGuid == string.Empty || strOrgGuid == string.Empty, "对不起,存在未指定的用户身份标志!");

                strSql = @"
					UPDATE GROUP_USERS
						SET INNER_SORT = {0}, MODIFY_TIME = GETDATE()
					WHERE GROUP_GUID = {1}
						AND USER_GUID = {2}
						AND USER_PARENT_GUID = {3}
				"                ;

                strSql = string.Format(strSql,
                                       TSqlBuilder.Instance.CheckQuotationMark(iSort.ToString(CommonResource.OriginalSortDefault), true),
                                       TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true),
                                       TSqlBuilder.Instance.CheckQuotationMark(strUserGuid, true),
                                       TSqlBuilder.Instance.CheckQuotationMark(strOrgGuid, true));

                builder.Append(strSql + Environment.NewLine);
            }
            InnerCommon.ExecuteNonQuery(strSql);

            DataSet ds = OGUReader.GetUsersInGroups(strGroupGuid,
                                                    SearchObjectColumn.SEARCH_GUID,
                                                    OGUCommonDefine.CombinateAttr(root.GetAttribute("extAttr")),
                                                    string.Empty,
                                                    SearchObjectColumn.SEARCH_NULL,
                                                    string.Empty,
                                                    (int)ListObjectDelete.COMMON);


            result = this.GetXmlDocAttr(ds.Tables[0], "OBJECTCLASS");

            return(result);
        }
Example #7
0
        private void eventContainer_SortObjects(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            XmlElement root          = xmlDoc.DocumentElement;
            string     strParentGuid = root.GetAttribute("OrgGuid");

            string strSql = @"
				UPDATE ORGANIZATIONS SET MODIFY_TIME = GETDATE() WHERE GUID = {0};
				SELECT GLOBAL_SORT FROM ORGANIZATIONS WHERE GUID = {0};
				"                ;

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strParentGuid, true));
            object obj = InnerCommon.ExecuteScalar(strSql);

            ExceptionHelper.TrueThrow(obj is DBNull, "对不起,你要排序的父部门不存在!");
            string strParentGlobalSort = obj.ToString();
            int    iSort;

            for (iSort = 0; iSort < root.ChildNodes.Count; iSort++)
            {
                XmlNode elem = root.ChildNodes[iSort];
                strSql = SetSortDataSql(elem.LocalName, elem.InnerText, strParentGlobalSort, strParentGuid, iSort);
                InnerCommon.ExecuteNonQuery(strSql);
            }

            strSql = @"
				SELECT * 
				FROM( 
						(SELECT 'USERS' AS OBJECTCLASS, USER_GUID AS GUID, PARENT_GUID, GLOBAL_SORT FROM OU_USERS WHERE STATUS > 1 AND GLOBAL_SORT LIKE {0} + '______') 
							UNION
						(SELECT 'GROUPS' AS OBJECTCLASS, GUID, PARENT_GUID, GLOBAL_SORT FROM GROUPS WHERE STATUS > 1 AND GLOBAL_SORT LIKE {0} + '______')
							UNION
						(SELECT 'ORGANIZATIONS' AS OBJECTCLASS, GUID, PARENT_GUID, GLOBAL_SORT FROM ORGANIZATIONS WHERE STATUS > 1 AND GLOBAL_SORT LIKE {0} + '______')
					)TEMPDB
				ORDER BY GLOBAL_SORT				
				"                ;
            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strParentGlobalSort, true));
            DataSet ds = InnerCommon.ExecuteDataset(strSql);

            StringBuilder builder = new StringBuilder(1024);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                strSql = SetSortDataSql(OGUCommonDefine.DBValueToString(row["OBJECTCLASS"]),
                                        OGUCommonDefine.DBValueToString(row["GUID"]),
                                        strParentGlobalSort,
                                        strParentGuid,
                                        iSort++,
                                        builder.Length == 0);

                builder.Append(strSql + Environment.NewLine);
            }
            if (builder.Length > 0)
            {
                InnerCommon.ExecuteNonQuery(builder.ToString());
            }
        }
Example #8
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");
            }
        }
Example #9
0
        private void MoveUsersToNewOrg(XmlElement elem, string strOrgGuid, Dictionary <object, object> context)
        {
            string strGuid          = elem.GetAttribute("GUID");
            string strOldParentGuid = elem.GetAttribute("PARENT_GUID");

            string strSql = @"
				DECLARE @ORG_ORIGINAL_SORT NVARCHAR(255);
				DECLARE @ORG_GLOBAL_SORT NVARCHAR(255);
				DECLARE @ORG_ALL_PATH_NAME NVARCHAR(255);

				DECLARE @NEW_INNER_SORT NVARCHAR(6);
				DECLARE @NEW_ALL_PATH_NAME NVARCHAR(255);

				/*获取被放入机构的相关数据*/
				UPDATE ORGANIZATIONS
					SET @ORG_ORIGINAL_SORT = ORIGINAL_SORT, 
						@ORG_GLOBAL_SORT = GLOBAL_SORT, 
						@NEW_INNER_SORT = REPLACE(STR(CHILDREN_COUNTER + 1, 6), ' ', '0'),
						@ORG_ALL_PATH_NAME = ALL_PATH_NAME, 
						CHILDREN_COUNTER = CHILDREN_COUNTER + 1
				WHERE GUID = {0};

				/*修改自身数据字段*/
				UPDATE OU_USERS
					SET PARENT_GUID = {0},
						INNER_SORT = @NEW_INNER_SORT, 
						ORIGINAL_SORT = @ORG_ORIGINAL_SORT + @NEW_INNER_SORT,
						GLOBAL_SORT = @ORG_GLOBAL_SORT + @NEW_INNER_SORT,
						ALL_PATH_NAME = @ORG_ALL_PATH_NAME + '\' + OBJ_NAME,
						@NEW_ALL_PATH_NAME = @ORG_ALL_PATH_NAME + '\' + OBJ_NAME
				WHERE USER_GUID = {1}
					AND PARENT_GUID = {2};

				/*获取新的数据值*/
				SELECT @ORG_ORIGINAL_SORT + @NEW_INNER_SORT AS ORIGINAL_SORT, 
					@ORG_GLOBAL_SORT + @NEW_INNER_SORT AS GLOBAL_SORT, 
					@NEW_INNER_SORT AS INNER_SORT, 
					@NEW_ALL_PATH_NAME AS ALL_PATH_NAME
				"                ;

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strOrgGuid, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strGuid, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strOldParentGuid, true));

            DataSet ds = InnerCommon.ExecuteDataset(strSql);

            SetMoveDataToXml(ds, elem, strOrgGuid);
        }
Example #10
0
        /// <summary>
        /// 检测系统中是否存在相同All_PATH_NAME属性的对象,如果存在就得要抛出异常提醒。
        /// </summary>
        /// <param name="strAllPathName"></param>
        private static void CheckAllPathNameInSystem(string strAllPathName)
        {
            string strSql = @"
				SELECT * FROM ORGANIZATIONS WHERE ALL_PATH_NAME = {0};
				SELECT * FROM GROUPS WHERE ALL_PATH_NAME = {0};
				SELECT * FROM OU_USERS WHERE ALL_PATH_NAME = {0};"                ;

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strAllPathName, true));

            DataSet ds = InnerCommon.ExecuteDataset(strSql);

            foreach (DataTable table in ds.Tables)
            {
                ExceptionHelper.TrueThrow(table.Rows.Count > 0,
                                          "对不起,系统中已经存在您命名的对象"" + strAllPathName + ""!\n\n请修改"对象名称"后再保存!");
            }
        }
Example #11
0
        private void eventContainer_BeforeInitPassword(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            string strUserGuid = xmlDoc.DocumentElement.SelectSingleNode("GUID").InnerText;

            string strSql   = "SELECT TOP 1 GUID FROM PWD_ARITHMETIC WHERE VISIBLE = 1 ORDER BY SORT_ID";
            object oPwdGuid = InnerCommon.ExecuteScalar(strSql);

            ExceptionHelper.TrueThrow(oPwdGuid == null, "对不起,系统中没有设置数据加密算法类型!");

            strSql = "UPDATE USERS SET MODIFY_TIME=GETDATE(), PWD_TYPE_GUID = {0}, USER_PWD = {1} WHERE GUID = {2}";

            string strPwd = SecurityCalculate.PwdCalculate(oPwdGuid.ToString(), CommonResource.OriginalSortDefault);

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(oPwdGuid.ToString(), true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strPwd, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strUserGuid, true));

            context.Add("Sql", strSql);
        }
Example #12
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);
        }
Example #13
0
        private void DeleteObjects(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            string strGroupSql = context["GroupSql"].ToString();
            string strUserSql  = context["UserSql"].ToString();
            string strOrgSql   = context["OrgSql"].ToString();

            if (!string.IsNullOrEmpty(strGroupSql))
            {
                InnerCommon.ExecuteNonQuery(strGroupSql);
            }

            if (!string.IsNullOrEmpty(strUserSql))
            {
                InnerCommon.ExecuteNonQuery(strUserSql);
            }

            if (!string.IsNullOrEmpty(strOrgSql))
            {
                InnerCommon.ExecuteNonQuery(strOrgSql);
            }
        }
Example #14
0
        private static void PrepareUpdateUserInOrganization(XmlDocument xmlDoc, XmlDocument userXsd, XmlDocument orgUserXsd, Dictionary <object, object> context)
        {
            XmlNode nodeSet = xmlDoc.DocumentElement.SelectSingleNode(".//SET");

            XmlNode aNode = nodeSet.SelectSingleNode(".//ALL_PATH_NAME");

            if (aNode != null)
            {
                CheckAllPathNameInSystem(aNode.InnerText);
            }

            DataExtraCheck(xmlDoc, "USERS", "OU_USERS");

            XmlDocument userXml = new XmlDocument();

            userXml.LoadXml("<Update><USERS><SET/></USERS></Update>");
            XmlDocument orgUserXml = new XmlDocument();

            orgUserXml.LoadXml("<Update><OU_USERS><SET/></OU_USERS></Update>");

            XmlDocToUsersAndOrgUsers(xmlDoc, userXml, userXsd, orgUserXml, orgUserXsd);

            string strSql = string.Empty;

            if (userXml.DocumentElement.SelectSingleNode(".//SET").ChildNodes.Count > 0)
            {
                strSql = InnerCommon.GetUpdateSqlStr(userXml, userXsd);
            }

            Debug.WriteLine(strSql, "USERS");

            if (orgUserXml.DocumentElement.SelectSingleNode(".//SET").ChildNodes.Count > 0)
            {
                strSql += " \n \n " + InnerCommon.GetUpdateSqlStr(orgUserXml, orgUserXsd);
            }
            Debug.WriteLine(strSql, "OU_USERS");

            context.Add("Sql", strSql);
        }
Example #15
0
        /// <summary>
        /// 因为更新了机构的对象名称,要求同步修改其子孙的ALL_PATH_NAME
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        private static string UpdataOrganizationsChildrens(XmlDocument xmlDoc)
        {
            string strResult = string.Empty;

            XmlNode root = xmlDoc.DocumentElement.FirstChild;

            if (root.SelectSingleNode("SET/OBJ_NAME") != null)
            {
                string strNewOrgAPN = root.SelectSingleNode("SET/ALL_PATH_NAME").InnerText;
                string strGuid      = root.SelectSingleNode("WHERE/GUID").InnerText;
                ExceptionHelper.TrueThrow(strGuid.Length == 0, "对不起,没有找到确定修改的目标!");

                string  strSql = "SELECT * FROM ORGANIZATIONS WHERE GUID = " + TSqlBuilder.Instance.CheckQuotationMark(strGuid, true);
                DataSet ds     = InnerCommon.ExecuteDataset(strSql);
                ExceptionHelper.TrueThrow(ds.Tables[0].Rows.Count == 0, "对不起,没有找到确定修改的目标!");

                string strOldOrgAPN = OGUCommonDefine.DBValueToString(ds.Tables[0].Rows[0]["ALL_PATH_NAME"]);
                string strOrgOS     = OGUCommonDefine.DBValueToString(ds.Tables[0].Rows[0]["ORIGINAL_SORT"]);

                strResult = @"
				UPDATE ORGANIZATIONS 
					SET ALL_PATH_NAME = {0} + SUBSTRING(ALL_PATH_NAME, LEN({2}) + 1, LEN(ALL_PATH_NAME) - LEN({2})) 
				WHERE ORIGINAL_SORT LIKE {1} + '_%';  

				UPDATE GROUPS 
					SET ALL_PATH_NAME = {0} +  SUBSTRING(ALL_PATH_NAME, LEN({2}) + 1, LEN(ALL_PATH_NAME) - LEN({2})) 
				WHERE ORIGINAL_SORT LIKE {1} + '_%'; 

				UPDATE OU_USERS 
					SET ALL_PATH_NAME = {0} +  SUBSTRING(ALL_PATH_NAME, LEN({2}) + 1, LEN(ALL_PATH_NAME) - LEN({2})) 
				WHERE ORIGINAL_SORT LIKE {1} + '_%';"                ;

                strResult = string.Format(strResult, TSqlBuilder.Instance.CheckQuotationMark(strNewOrgAPN, true),
                                          TSqlBuilder.Instance.CheckQuotationMark(strOrgOS, true),
                                          TSqlBuilder.Instance.CheckQuotationMark(strOldOrgAPN, true));
            }

            return(strResult);
        }
Example #16
0
        private static void PrepareInsertOrgORGroups(XmlDocument xmlDoc, XmlDocument xsdDoc, Dictionary <object, object> context)
        {
            XmlNode nodeSet = xmlDoc.DocumentElement.SelectSingleNode(".//SET");

            CheckAllPathNameInSystem(nodeSet.SelectSingleNode(".//ALL_PATH_NAME").InnerText);

            string strSql = @"
				UPDATE ORGANIZATIONS 
					SET CHILDREN_COUNTER = CHILDREN_COUNTER + 1, MODIFY_TIME = GETDATE() 
				WHERE GUID = {0} ; 

				SELECT * 
				FROM ORGANIZATIONS 
				WHERE GUID = {0}"                ;

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

            DataSet ds = InnerCommon.ExecuteDataset(strSql);

            ExceptionHelper.TrueThrow((ds == null) || (ds.Tables.Count == 0) || (ds.Tables[0].Rows.Count == 0), "对不起,系统中没有找到父部门对象!");
            DataRow row = ds.Tables[0].Rows[0];

            string strChildCounter = OGUCommonDefine.DBValueToString(row["CHILDREN_COUNTER"]);
            string strInnerSort    = CommonResource.OriginalSortDefault.Substring(0,
                                                                                  CommonResource.OriginalSortDefault.Length - strChildCounter.Length) + strChildCounter;

            XmlHelper.AppendNode(nodeSet, "INNER_SORT", strInnerSort);
            XmlHelper.AppendNode(nodeSet, "GLOBAL_SORT", OGUCommonDefine.DBValueToString(row["GLOBAL_SORT"]) + strInnerSort);
            XmlHelper.AppendNode(nodeSet, "ORIGINAL_SORT", OGUCommonDefine.DBValueToString(row["ORIGINAL_SORT"]) + strInnerSort);

            XmlHelper.AppendNode(nodeSet, "GUID", Guid.NewGuid().ToString());
            XmlHelper.AppendNode(nodeSet, "STATUS", "1");

            DataExtraCheck(xmlDoc, nodeSet.ParentNode.LocalName);//附加的数据检查

            strSql = InnerCommon.GetInsertSqlStr(xmlDoc, xsdDoc);

            context.Add("Sql", strSql);
        }
Example #17
0
        private void eventContainer_BeforeDelUsersFromGroups(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            XmlElement root = xmlDoc.DocumentElement;

            string strGroupGuid = root.GetAttribute("GUID");

            ExceptionHelper.TrueThrow(strGroupGuid == string.Empty, "未指定用户组对象!");

            string strSql = "UPDATE GROUPS SET MODIFY_TIME = GETDATE() WHERE GUID = {0}";

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true));
            InnerCommon.ExecuteNonQuery(strSql);

            StringBuilder builder = new StringBuilder(1024);

            foreach (XmlElement elem in root.ChildNodes)
            {
                ExceptionHelper.TrueThrow(elem.LocalName != "USERS", "对不起,选项中存在非用户对象!");

                string strUserGuid = elem.GetAttribute("GUID");
                string strOrgGuid  = elem.GetAttribute("PARENT_GUID");

                ExceptionHelper.TrueThrow(strUserGuid == string.Empty || strOrgGuid == string.Empty, "存在未确定的用户对象!");

                strSql = @"
					DELETE FROM GROUP_USERS
					WHERE GROUP_GUID = {0}
						AND USER_GUID = {1}
						AND USER_PARENT_GUID = {2}
					"                    ;
                strSql = string.Format(strSql,
                                       TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true),
                                       TSqlBuilder.Instance.CheckQuotationMark(strUserGuid, true),
                                       TSqlBuilder.Instance.CheckQuotationMark(strOrgGuid, true));
                builder.Append(strSql + Environment.NewLine);
            }
            context.Add("Sql", builder.ToString());
        }
 private void eventContainer_DelSecsOfLeader(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }
Example #19
0
 private void eventContainer_DelUsersFromGroups(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }
Example #20
0
 /// <summary>
 /// 系统添加一个新的"机构"或者"人员组"
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 private static int InsertOrgORGroups(Dictionary <object, object> context)
 {
     return(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()));
 }
Example #21
0
        private static void PrepareInsertUserToOrganization(XmlDocument xmlDoc, XmlDocument userXsd, XmlDocument orgUserXsd, Dictionary <object, object> context)
        {
            XmlNode nodeSet = xmlDoc.DocumentElement.SelectSingleNode(".//SET");

            XmlNode tNode = nodeSet.SelectSingleNode(".//IC_CARD");

            if (tNode != null)
            {
                ExceptionHelper.FalseThrow(tNode.InnerText.Trim() == string.Empty || tNode.InnerText.Trim().Length == 16, "请注意,系统中要求“IC卡号”只能是16位!");
            }

            CheckAllPathNameInSystem(nodeSet.SelectSingleNode(".//ALL_PATH_NAME").InnerText);

            string strSql = @"
				UPDATE ORGANIZATIONS 
					SET CHILDREN_COUNTER = CHILDREN_COUNTER + 1, MODIFY_TIME = GETDATE() 
				WHERE GUID = {0} ; 

				SELECT * 
				FROM ORGANIZATIONS 
				WHERE GUID = {0}"                ;

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

            DataSet ds = InnerCommon.ExecuteDataset(strSql);

            ExceptionHelper.TrueThrow((ds == null) || (ds.Tables.Count == 0) || (ds.Tables[0].Rows.Count == 0), "对不起,系统中没有找到父部门对象!");
            DataRow row = ds.Tables[0].Rows[0];

            string strChildCounter = OGUCommonDefine.DBValueToString(row["CHILDREN_COUNTER"]);
            string strInnerSort    = CommonResource.OriginalSortDefault.Substring(0,
                                                                                  CommonResource.OriginalSortDefault.Length - strChildCounter.Length) + strChildCounter;

            XmlHelper.AppendNode(nodeSet, "INNER_SORT", strInnerSort);
            XmlHelper.AppendNode(nodeSet, "GLOBAL_SORT", OGUCommonDefine.DBValueToString(row["GLOBAL_SORT"]) + strInnerSort);
            XmlHelper.AppendNode(nodeSet, "ORIGINAL_SORT", OGUCommonDefine.DBValueToString(row["ORIGINAL_SORT"]) + strInnerSort);

            XmlHelper.AppendNode(nodeSet, "STATUS", "1");
            string strUserGuid = Guid.NewGuid().ToString();

            XmlHelper.AppendNode(nodeSet, "GUID", strUserGuid);
            XmlHelper.AppendNode(nodeSet, "USER_GUID", strUserGuid);
            // 默认初始化登录口令[cgac\yuan_yong--2004/07/20]
            object oPwdGuid = InnerCommon.ExecuteScalar("SELECT TOP 1 GUID FROM PWD_ARITHMETIC WHERE VISIBLE = 1 ORDER BY SORT_ID");

            XmlHelper.AppendNode(nodeSet, "PWD_TYPE_GUID", oPwdGuid.ToString());
            XmlHelper.AppendNode(nodeSet, "USER_PWD", SecurityCalculate.PwdCalculate(oPwdGuid.ToString(), CommonResource.OriginalSortDefault));

            DataExtraCheck(xmlDoc, "USERS", "OU_USERS");//附加数据检查

            XmlDocument userXml = new XmlDocument();

            userXml.LoadXml("<Insert><USERS><SET/></USERS></Insert>");
            XmlDocument orgUserXml = new XmlDocument();

            orgUserXml.LoadXml("<Insert><OU_USERS><SET/></OU_USERS></Insert>");
            XmlDocToUsersAndOrgUsers(xmlDoc, userXml, userXsd, orgUserXml, orgUserXsd);

            strSql = InnerCommon.GetInsertSqlStr(userXml, userXsd);
            Debug.WriteLine(strSql, "USERS");

            strSql += " \n ; \n " + InnerCommon.GetInsertSqlStr(orgUserXml, orgUserXsd);
            Debug.WriteLine(strSql, "OU_USERS");

            context.Add("Sql", strSql);
        }
Example #22
0
        private XmlDocument eventContainer_AddObjectsToGroups(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            XmlDocument result;

            XmlElement root           = xmlDoc.DocumentElement;
            string     strGroupGuid   = root.GetAttribute("GUID");
            string     strAccessLevel = root.GetAttribute("USER_ACCESS_LEVEL");

            ExceptionHelper.TrueThrow(strGroupGuid == string.Empty, "未指定用户组对象!");

            string strSql = "UPDATE GROUPS SET MODIFY_TIME = GETDATE() WHERE GUID = {0}";

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strGroupGuid, true));
            InnerCommon.ExecuteNonQuery(strSql);

            foreach (XmlElement elem in root.ChildNodes)
            {
                switch (elem.GetAttribute("OBJECTCLASS"))
                {
                case "ORGANIZATIONS":
                    string  strOrgGuid = elem.GetAttribute("GUID");
                    DataSet ods        = OGUReader.GetOrganizationChildren(strOrgGuid,
                                                                           SearchObjectColumn.SEARCH_GUID,
                                                                           (int)ListObjectType.ALL_TYPE,
                                                                           (int)ListObjectDelete.COMMON,
                                                                           0,
                                                                           string.Empty,
                                                                           strAccessLevel,
                                                                           string.Empty,
                                                                           OGUCommonDefine.CombinateAttr(string.Empty));
                    AddOrganizationToGroup(ods, strGroupGuid);
                    break;

                case "GROUPS":
                    string strOldGroupGuid = elem.GetAttribute("GUID");
                    if (strOldGroupGuid != strGroupGuid)                            //组中用户不能循环倒入倒出
                    {
                        DataSet gds = OGUReader.GetUsersInGroups(strOldGroupGuid, SearchObjectColumn.SEARCH_GUID,
                                                                 OGUCommonDefine.CombinateAttr("PARENT_GUID,USER_GUID"),
                                                                 string.Empty, SearchObjectColumn.SEARCH_NULL, string.Empty,
                                                                 (int)ListObjectDelete.COMMON);
                        AddGroupToGroup(gds, strGroupGuid);
                    }
                    break;

                case "USERS":
                    AddUserToGroup(elem, strGroupGuid);
                    break;

                default:
                    ExceptionHelper.TrueThrow(true, "对不起,系统没有与“" + elem.GetAttribute("OBJECTCLASS") + "”对象相应的数据处理!");
                    break;
                }
            }

            DataSet ds = OGUReader.GetUsersInGroups(strGroupGuid, SearchObjectColumn.SEARCH_GUID,
                                                    OGUCommonDefine.CombinateAttr(root.GetAttribute("extAttr")),
                                                    string.Empty, SearchObjectColumn.SEARCH_NULL, string.Empty,
                                                    (int)ListObjectDelete.COMMON);

            result = this.GetXmlDocAttr(ds.Tables[0], "OBJECTCLASS");

            return(result);
        }
Example #23
0
 private void eventContainer_ResetPassword(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     ExceptionHelper.TrueThrow(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()) == 0,
                               "对不起,你输入的旧口令或者口令加密类型不正确!请重来一次!");
     //本操作不记录日志
 }
Example #24
0
 /// <summary>
 /// 为用户设置兼职的部门
 /// </summary>
 /// <param name="context"></param>
 private static int SetUserSideline(Dictionary <object, object> context)
 {
     return(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()));
 }
Example #25
0
 private static int UpdateUserInOrganization(Dictionary <object, object> context)
 {
     return(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()));
 }
Example #26
0
 private void eventContainer_InitPassword(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }
Example #27
0
 private void eventContainer_SetUserMainDuty(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }