示例#1
0
        public virtual JObject AddExistUsers(HttpContext context)
        {
            YZRequest request  = new YZRequest(context);
            string    parentou = request.GetString("parentou");

            JArray post = request.GetPostData <JArray>();
            BPMObjectNameCollection accounts = post.ToObject <BPMObjectNameCollection>();

            JObject rv    = new JObject();
            JArray  added = new JArray();

            rv["added"] = added;

            try
            {
                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();

                    foreach (string account in accounts)
                    {
                        OU.AddMember(cn, parentou, account);
                        added.Add(account);
                    }
                }
            }
            catch (Exception e)
            {
                rv[YZJsonProperty.success]      = false;
                rv[YZJsonProperty.errorMessage] = e.Message;
            }

            return(rv);
        }
示例#2
0
        public virtual JObject SaveMember(HttpContext context)
        {
            YZRequest request  = new YZRequest(context);
            string    mode     = request.GetString("mode");
            string    parentou = request.GetString("parentou", "");

            JObject data   = request.GetPostData <JObject>();
            Member  member = data["Member"].ToObject <Member>();
            User    user   = data["User"].ToObject <User>(request.Serializer);
            BPMObjectNameCollection fgOUs = data["Member"]["FGOUs"].ToObject <BPMObjectNameCollection>();
            BPMObjectNameCollection fgYWs = data["Member"]["FGYWs"].ToObject <BPMObjectNameCollection>();
            SupervisorCollection    spvs  = data["Supervisors"].ToObject <SupervisorCollection>();

            string headshot = (string)data["User"]["headshot"];
            string sign     = (string)data["User"]["sign"];

            Member newMember = null;

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                if (mode == "edit")
                {
                    string         fullname     = request.GetString("fullname");
                    OUProviderInfo providerInfo = OrgSvr.GetProviderInfo(cn, fullname);
                    if (providerInfo.Editable)
                    {
                        newMember = Member.UpdateMember(cn, parentou, fullname, member, user, fgOUs, fgYWs, spvs);
                    }
                    else
                    {
                        newMember = Member.FromFullName(cn, fullname);
                    }
                }
                else
                {
                    newMember = OU.AddMember(cn, request.GetString("parentou"), null, member, user, fgOUs, fgYWs, spvs);
                }

                //设置外出
                UserCommonInfo userCommonInfo = data["UserCommonInfo"].ToObject <UserCommonInfo>();
                User.SetOutOfOffice(cn, user.Account, userCommonInfo.OutOfOfficeState, userCommonInfo.OutOfOfficeFrom, userCommonInfo.OutOfOfficeTo);

                //设置主管
                TaskRuleCollection taskRules = data["TaskRules"].ToObject <TaskRuleCollection>();
                User.SaveTaskRules(cn, user.Account, taskRules);

                //头像与签名
                this.SaveHeadshot(context, headshot, sign, user.Account);

                return(this.SerializeOUObject(cn, newMember));
            }
        }
示例#3
0
        public Result AddUser(AuthInfo authInfo, UserInfo userInfo)
        {
            try
            {
                YZService.AuthSystem(authInfo);
                YZAuthHelper.SetAuthCookie(authInfo.RealLoginAccount);

                using (BPMConnection cn = new BPMConnection())
                {
                    cn.WebOpen();
                    OU.AddMember(cn, YZService.LDAPOU2BPMOUPath(userInfo.LDAPOU), null, userInfo.Member, userInfo.User, null, null, null);
                }

                return(Result.SuccessResult);
            }
            catch (Exception e)
            {
                return(Result.FromException(e));
            }
        }