Example #1
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));
            }
        }
Example #2
0
        public virtual OUProviderInfo GetProviderInfo(HttpContext context)
        {
            YZRequest request   = new YZRequest(context);
            string    nameSpace = request.GetString("nameSpace");

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();
                return(OrgSvr.GetProviderInfo(cn, nameSpace));
            }
        }
Example #3
0
        public virtual OU SaveOU(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            JObject   post    = request.GetPostData <JObject>();
            OU        ou      = post["data"].ToObject <OU>();
            ACL       acl     = post["acl"].ToObject <ACL>();
            string    mode    = request.GetString("mode");
            OU        newou   = 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)
                    {
                        newou = OU.UpdateOU(cn, fullname, ou);
                    }
                    else
                    {
                        newou = OU.FromFullName(cn, fullname);
                    }
                }
                else
                {
                    string parentou = request.GetString("parentou", "");
                    if (String.IsNullOrEmpty(parentou))
                    {
                        newou = cn.CreateOrg("BPMOU://", ou);
                    }
                    else
                    {
                        newou = OU.AddChildOU(cn, parentou, ou);
                    }
                }

                SecurityManager.SaveACL(cn, SecurityResType.OU, newou.FullName, null, acl);

                return(newou);
            }
        }