Beispiel #1
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);
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string code = context.Request.QueryString["code"];

            if (code.IsNullOrEmpty())
            {
                context.Response.Write("身份验证失败");
                context.Response.End();
                return;
            }
            string account = new RoadFlow.Platform.WeiXin.Organize().GetUserAccountByCode(code);

            if (account.IsNullOrEmpty())
            {
                context.Response.Write("身份验证失败-");
                context.Response.End();
                return;
            }
            var user = new RoadFlow.Platform.Users().GetByAccount(account);

            if (user == null)
            {
                context.Response.Write("未找到帐号对应的人员");
                context.Response.End();
                return;
            }
            context.Response.Cookies.Add(new HttpCookie("weixin_userid", user.ID.ToString()));
            context.Session.Add(RoadFlow.Utility.Keys.SessionKeys.UserID.ToString(), user.ID.ToString());
            var lastURLCookie = context.Request.Cookies.Get("LastURL");
            var lastURL       = lastURLCookie == null ? "" : lastURLCookie.Value;

            if (!lastURL.IsNullOrEmpty())
            {
                context.Response.Redirect(lastURL);
            }
        }