Ejemplo n.º 1
0
 public string Save(Model.Organize organizeModel)
 {
     if (!ModelState.IsValid)
     {
         return(Tools.GetValidateErrorMessag(ModelState));
     }
     Business.Organize organize = new Business.Organize();
     if (!"1".Equals(Request.Querys("isadddept")) && Request.Querys("orgid").IsGuid(out Guid guid))
     {
         var    oldModel = organize.Get(guid);
         string oldJSON  = null == oldModel ? "" : oldModel.ToString();
         organize.Update(organizeModel);
         if (organizeModel.Status == 1)
         {
             //如果是冻结了机构,则要向企业微信冻结下面的所有人员
             if (Config.Enterprise_WeiXin_IsUse)
             {
                 var allUsers = new Business.Organize().GetAllUsers(organizeModel.Id, false);
                 Business.EnterpriseWeiXin.Organize wxOrganize = new Business.EnterpriseWeiXin.Organize();
                 foreach (var user in allUsers)
                 {
                     user.Status = 1;
                     wxOrganize.UpdateUser(user);
                 }
             }
         }
         Business.Log.Add("修改了组织机构-" + organizeModel.Name, type: Business.Log.Type.系统管理, oldContents: oldJSON, newContents: organizeModel.ToString());
     }
     else
     {
         organize.Add(organizeModel);
         Business.Log.Add("添加了组织机构-" + organizeModel.Name, organizeModel.ToString(), Business.Log.Type.系统管理);
     }
     return("保存成功!");
 }
Ejemplo n.º 2
0
        public string DeptMove()
        {
            string toOrgId = Request.Forms("toOrgId");
            string orgid   = Request.Querys("orgid");

            if (!toOrgId.IsGuid(out Guid toGuid))
            {
                return("请选择要移动到的组织架构");
            }
            if (!orgid.IsGuid(out Guid orgId))
            {
                return("没有找到当前组织架构");
            }
            if (toGuid == orgId)
            {
                return("不能将自己移动到自己");
            }
            Business.Organize organize = new Business.Organize();
            if (orgId == organize.GetRootId())
            {
                return("不能移动根");
            }
            var org = organize.Get(orgId);

            if (null == org)
            {
                return("没有找到当前组织架构");
            }
            var toOrg = organize.Get(toGuid);

            if (null == toOrg)
            {
                return("没有找到要移动到的组织架构");
            }
            org.ParentId = toGuid;
            org.Sort     = organize.GetMaxSort(toGuid);
            organize.Update(org);
            //同步企业微信人员(更新机构下所有人员的职务)
            if (Config.Enterprise_WeiXin_IsUse)
            {
                var allUsers = new Business.Organize().GetAllUsers(org.Id, false);
                Business.EnterpriseWeiXin.Organize wxOrganize = new Business.EnterpriseWeiXin.Organize();
                foreach (var user in allUsers)
                {
                    wxOrganize.UpdateUser(user);
                }
            }
            Business.Log.Add("移动了组织架构-" + org.Name + "到" + toOrg.Name, org.Id + "&" + toOrg.Id, Business.Log.Type.系统管理);
            return("移动成功!");
        }
Ejemplo n.º 3
0
        public string SaveSort()
        {
            string sorts = Request.Forms("sort");

            Business.Organize     organize  = new Business.Organize();
            List <Model.Organize> organizes = new List <Model.Organize>();
            int i = 0;

            foreach (string sort in sorts.Split(','))
            {
                if (sort.IsGuid(out Guid orgId))
                {
                    var org = organize.Get(orgId);
                    if (null != org)
                    {
                        org.Sort = i += 5;
                        organizes.Add(org);
                    }
                }
            }
            organize.Update(organizes.ToArray());
            return("排序成功!");
        }