コード例 #1
0
        /// <summary>
        /// 删除一个机构及其所有下级(包括下级人员)
        /// </summary>
        /// <param name="orgID"></param>
        /// <returns></returns>
        public int DeleteAndAllChilds(Guid orgID)
        {
            int i = 0;

            using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
            {
                UsersRelation bur      = new UsersRelation();
                Users         user     = new Users();
                UsersInfo     userInfo = new UsersInfo();
                var           childs   = GetAllChilds(orgID);
                foreach (var child in childs)
                {
                    //删除人员及关系
                    var urs = bur.GetAllByOrganizeID(child.ID);
                    foreach (var ur in urs)
                    {
                        bur.Delete(ur.UserID, ur.OrganizeID);
                        user.Delete(ur.UserID);
                        i += userInfo.Delete(ur.UserID);
                    }
                    i += Delete(child.ID);
                }
                //删除人员及关系
                var urs1 = bur.GetAllByOrganizeID(orgID);
                foreach (var ur in urs1)
                {
                    bur.Delete(ur.UserID, ur.OrganizeID);
                    user.Delete(ur.UserID);
                    i += userInfo.Delete(ur.UserID);
                }
                i += Delete(orgID);
                scope.Complete();
            }
            return(i);
        }
コード例 #2
0
        /// <summary>
        /// 添加一个用户到在线用户表
        /// </summary>
        public bool Add(MyCreek.Data.Model.Users user, Guid uniqueID)
        {
            if (user == null)
            {
                return(false);
            }
            var  onList = GetAll();
            bool isadd  = false;
            var  onUser = onList.Find(p => p.ID == user.ID);

            if (onUser == null)
            {
                isadd  = true;
                onUser = new MyCreek.Data.Model.OnlineUsers();
                var station = new UsersRelation().GetMainByUserID(user.ID);
                if (station != null)
                {
                    onUser.OrgName = new Organize().GetAllParentNames(station.OrganizeID);
                }
            }
            onUser.ID         = user.ID;
            onUser.ClientInfo = string.Concat("操作系统:", MyCreek.Utility.Tools.GetOSName(), "  浏览器:", MyCreek.Utility.Tools.GetBrowse());
            onUser.IP         = MyCreek.Utility.Tools.GetIPAddress();
            onUser.LastPage   = "";
            onUser.LoginTime  = MyCreek.Utility.DateTimeNew.Now;
            onUser.UniqueID   = uniqueID;
            onUser.UserName   = user.Name;
            if (isadd)
            {
                onList.Add(onUser);
            }
            set(onList);
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// 得到一个用户的所有岗位
        /// </summary>
        /// <param name="userID"></param>
        /// <returns>Dictionary<Guid, bool> Guid 岗位ID bool 是否主要岗位</returns>
        public Dictionary <Guid, bool> GetAllStation(Guid userID)
        {
            UsersRelation           ur   = new UsersRelation();
            var                     urs  = ur.GetAllByUserID(userID);
            Dictionary <Guid, bool> dict = new Dictionary <Guid, bool>();

            foreach (var u in urs)
            {
                if (!dict.ContainsKey(u.OrganizeID))
                {
                    dict.Add(u.OrganizeID, u.IsMain == 1);
                }
            }
            return(dict);
        }
コード例 #4
0
        /// <summary>
        /// 得到一个用户的主要岗位
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public Guid GetMainStation(Guid userID)
        {
            var ur = new UsersRelation().GetMainByUserID(userID);

            return(ur == null ? Guid.Empty : ur.OrganizeID);
        }