Пример #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;
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <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;
                }
            }
        }
Пример #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;
                }
            }
        }
Пример #4
0
        /// <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;
                        }
                    }
                }
            }
        }
Пример #5
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);
        }
Пример #6
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());
            }
        }
Пример #7
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);
            }
        }
Пример #8
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());
        }
Пример #9
0
 private static int UpdateUserInOrganization(Dictionary <object, object> context)
 {
     return(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()));
 }
Пример #10
0
 /// <summary>
 /// 系统添加一个新的"机构"或者"人员组"
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 private static int InsertOrgORGroups(Dictionary <object, object> context)
 {
     return(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()));
 }
Пример #11
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);
        }
Пример #12
0
 /// <summary>
 /// 为用户设置兼职的部门
 /// </summary>
 /// <param name="context"></param>
 private static int SetUserSideline(Dictionary <object, object> context)
 {
     return(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()));
 }
Пример #13
0
 private void eventContainer_SetUserMainDuty(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }
Пример #14
0
 private void eventContainer_ResetPassword(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     ExceptionHelper.TrueThrow(InnerCommon.ExecuteNonQuery(context["Sql"].ToString()) == 0,
                               "对不起,你输入的旧口令或者口令加密类型不正确!请重来一次!");
     //本操作不记录日志
 }
Пример #15
0
 private void eventContainer_InitPassword(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }
Пример #16
0
 private void eventContainer_DelUsersFromGroups(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }
Пример #17
0
 private void eventContainer_DelSecsOfLeader(XmlDocument xmlDoc, Dictionary <object, object> context)
 {
     InnerCommon.ExecuteNonQuery(context["Sql"].ToString());
 }