コード例 #1
0
ファイル: OguDBInsert.cs プロジェクト: ounata/AK47-2016Source
        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);
        }
コード例 #2
0
ファイル: OguDBInsert.cs プロジェクト: ounata/AK47-2016Source
        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);
        }