Exemplo n.º 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加一个用户到在线用户表
        /// </summary>
        public bool Add(RoadFlow.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 RoadFlow.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("操作系统:", RoadFlow.Utility.Tools.GetOSName(), "  浏览器:", RoadFlow.Utility.Tools.GetBrowse());
            onUser.IP         = RoadFlow.Utility.Tools.GetIPAddress();
            onUser.LastPage   = "";
            onUser.LoginTime  = RoadFlow.Utility.DateTimeNew.Now;
            onUser.UniqueID   = uniqueID;
            onUser.UserName   = user.Name;
            if (isadd)
            {
                onList.Add(onUser);
            }
            set(onList);
            return(true);
        }
Exemplo n.º 3
0
        public bool Add(RoadFlow.Data.Model.Users user, Guid uniqueID)
        {
            if (user == null)
            {
                return(false);
            }
            List <RoadFlow.Data.Model.OnlineUsers> all = this.GetAll();
            bool flag = false;

            RoadFlow.Data.Model.OnlineUsers onlineUsers = all.Find((Predicate <RoadFlow.Data.Model.OnlineUsers>)(p => p.ID == user.ID));
            if (onlineUsers == null)
            {
                flag        = true;
                onlineUsers = new RoadFlow.Data.Model.OnlineUsers();
                RoadFlow.Data.Model.UsersRelation mainByUserId = new UsersRelation().GetMainByUserID(user.ID);
                if (mainByUserId != null)
                {
                    onlineUsers.OrgName = new Organize().GetAllParentNames(mainByUserId.OrganizeID, false, " / ");
                }
            }
            onlineUsers.ID         = user.ID;
            onlineUsers.ClientInfo = "操作系统:" + Tools.GetOSName() + "  浏览器:" + Tools.GetBrowse();
            onlineUsers.IP         = Tools.GetIPAddress();
            onlineUsers.LastPage   = "";
            onlineUsers.LoginTime  = DateTimeNew.Now;
            onlineUsers.UniqueID   = uniqueID;
            onlineUsers.UserName   = user.Name;
            if (flag)
            {
                all.Add(onlineUsers);
            }
            this.set(all);
            return(true);
        }
Exemplo n.º 4
0
        public int DeleteAndAllChilds(Guid orgID)
        {
            int num = 0;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                UsersRelation usersRelation = new UsersRelation();
                Users         users         = new Users();
                List <RoadFlow.Data.Model.Organize> allChilds = GetAllChilds(orgID);
                List <string> list = new List <string>();
                List <RoadFlow.Data.Model.Organize> list2 = new List <RoadFlow.Data.Model.Organize>();
                foreach (RoadFlow.Data.Model.Organize item in allChilds)
                {
                    foreach (RoadFlow.Data.Model.UsersRelation item2 in usersRelation.GetAllByOrganizeID(item.ID).FindAll((RoadFlow.Data.Model.UsersRelation p) => p.IsMain == 1))
                    {
                        RoadFlow.Data.Model.Users users2 = users.Get(item2.UserID);
                        usersRelation.Delete(item2.UserID, item2.OrganizeID);
                        num += users.Delete(item2.UserID);
                        if (users2 != null)
                        {
                            list.Add(users2.Account);
                        }
                    }
                    num += Delete(item.ID);
                    list2.Add(item);
                }
                foreach (RoadFlow.Data.Model.UsersRelation item3 in usersRelation.GetAllByOrganizeID(orgID).FindAll((RoadFlow.Data.Model.UsersRelation p) => p.IsMain == 1))
                {
                    usersRelation.Delete(item3.UserID, item3.OrganizeID);
                    num += users.Delete(item3.UserID);
                    RoadFlow.Data.Model.Users users3 = users.Get(item3.UserID);
                    if (users3 != null)
                    {
                        list.Add(users3.Account);
                    }
                }
                num += Delete(orgID);
                RoadFlow.Data.Model.Organize organize = Get(orgID);
                if (organize != null)
                {
                    list2.Add(organize);
                }
                if (RoadFlow.Platform.WeiXin.Config.IsUse)
                {
                    RoadFlow.Platform.WeiXin.Organize organize2 = new RoadFlow.Platform.WeiXin.Organize();
                    if (list.Count > 0)
                    {
                        organize2.DeleteUserAsync(list.ToArray());
                    }
                    foreach (RoadFlow.Data.Model.Organize item4 in list2)
                    {
                        organize2.DeleteDeptAsync(item4.IntID);
                    }
                }
                transactionScope.Complete();
                return(num);
            }
        }
Exemplo n.º 5
0
        public int DeleteAndAllChilds(Guid orgID)
        {
            int num = 0;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                UsersRelation usersRelation1 = new UsersRelation();
                Users         users1         = new Users();
                List <RoadFlow.Data.Model.Organize> allChilds = this.GetAllChilds(orgID);
                List <string> stringList = new List <string>();
                List <RoadFlow.Data.Model.Organize> organizeList = new List <RoadFlow.Data.Model.Organize>();
                foreach (RoadFlow.Data.Model.Organize organize in allChilds)
                {
                    foreach (RoadFlow.Data.Model.UsersRelation usersRelation2 in usersRelation1.GetAllByOrganizeID(organize.ID).FindAll((Predicate <RoadFlow.Data.Model.UsersRelation>)(p => p.IsMain == 1)))
                    {
                        RoadFlow.Data.Model.Users users2 = users1.Get(usersRelation2.UserID);
                        usersRelation1.Delete(usersRelation2.UserID, usersRelation2.OrganizeID);
                        num += users1.Delete(usersRelation2.UserID);
                        if (users2 != null)
                        {
                            stringList.Add(users2.Account);
                        }
                    }
                    num += this.Delete(organize.ID);
                    organizeList.Add(organize);
                }
                foreach (RoadFlow.Data.Model.UsersRelation usersRelation2 in usersRelation1.GetAllByOrganizeID(orgID).FindAll((Predicate <RoadFlow.Data.Model.UsersRelation>)(p => p.IsMain == 1)))
                {
                    usersRelation1.Delete(usersRelation2.UserID, usersRelation2.OrganizeID);
                    num += users1.Delete(usersRelation2.UserID);
                    RoadFlow.Data.Model.Users users2 = users1.Get(usersRelation2.UserID);
                    if (users2 != null)
                    {
                        stringList.Add(users2.Account);
                    }
                }
                num += this.Delete(orgID);
                RoadFlow.Data.Model.Organize organize1 = this.Get(orgID);
                if (organize1 != null)
                {
                    organizeList.Add(organize1);
                }
                if (RoadFlow.Platform.WeiXin.Config.IsUse)
                {
                    RoadFlow.Platform.WeiXin.Organize organize2 = new RoadFlow.Platform.WeiXin.Organize();
                    if (stringList.Count > 0)
                    {
                        organize2.DeleteUserAsync(stringList.ToArray());
                    }
                    foreach (RoadFlow.Data.Model.Organize organize3 in organizeList)
                    {
                        organize2.DeleteDeptAsync(organize3.IntID);
                    }
                }
                transactionScope.Complete();
            }
            return(num);
        }
Exemplo n.º 6
0
 public Guid GetMainStation(Guid userID)
 {
     RoadFlow.Data.Model.UsersRelation mainByUserId = new UsersRelation().GetMainByUserID(userID);
     if (mainByUserId != null)
     {
         return(mainByUserId.OrganizeID);
     }
     return(Guid.Empty);
 }
Exemplo n.º 7
0
        public System.Collections.Generic.Dictionary <Guid, bool> GetAllStation(Guid userID)
        {
            List <RoadFlow.Data.Model.UsersRelation> allByUserId = new UsersRelation().GetAllByUserID(userID);

            System.Collections.Generic.Dictionary <Guid, bool> dictionary = new System.Collections.Generic.Dictionary <Guid, bool>();
            foreach (RoadFlow.Data.Model.UsersRelation usersRelation in allByUserId)
            {
                if (!dictionary.ContainsKey(usersRelation.OrganizeID))
                {
                    dictionary.Add(usersRelation.OrganizeID, usersRelation.IsMain == 1);
                }
            }
            return(dictionary);
        }
Exemplo n.º 8
0
        public Dictionary <Guid, bool> GetAllStation(Guid userID)
        {
            List <RoadFlow.Data.Model.UsersRelation> allByUserID = new UsersRelation().GetAllByUserID(userID);
            Dictionary <Guid, bool> dictionary = new Dictionary <Guid, bool>();

            foreach (RoadFlow.Data.Model.UsersRelation item in allByUserID)
            {
                if (!dictionary.ContainsKey(item.OrganizeID))
                {
                    dictionary.Add(item.OrganizeID, item.IsMain == 1);
                }
            }
            return(dictionary);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }