示例#1
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);
        }
示例#2
0
        private void eventContainer_BeforeResetPassword(XmlDocument xmlDoc, Dictionary <object, object> context)
        {
            XmlElement root          = xmlDoc.DocumentElement;
            string     strUserGuid   = root.SelectSingleNode("GUID").InnerText;
            string     strOrigOldPwd = root.SelectSingleNode("OldPwd").InnerText;
            string     strOldPwdType = root.SelectSingleNode("OldPwdType").InnerText;
            string     strOrigNewPwd = root.SelectSingleNode("NewPwd").InnerText;
            string     strNewPwdType = root.SelectSingleNode("NewPwdType").InnerText;

            string strOldPwd = SecurityCalculate.PwdCalculate(strOldPwdType, strOrigOldPwd);
            string strNewPwd = SecurityCalculate.PwdCalculate(strNewPwdType, strOrigNewPwd);

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

            strSql = string.Format(strSql, TSqlBuilder.Instance.CheckQuotationMark(strNewPwdType, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strNewPwd, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strUserGuid, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strOldPwd, true),
                                   TSqlBuilder.Instance.CheckQuotationMark(strOldPwdType, 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);
        }