Пример #1
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());
            }
        }
Пример #2
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);
        }
Пример #3
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);
        }