示例#1
0
 /// <summary>
 /// 查询用户权限
 /// </summary>
 /// <param name="personId"></param>
 public void QueryPersonPurview(int personId, ActionExecutingContext e)
 {
     try
     {
         //根据人员id查询人员所有用的园区权限
         List <ServRolePurviewModel> rolePruList = servPersonInfoBLL.GetRegionPurByPersonId(personId);
         if (rolePruList.Count == 0)//没有园区权限则直接跳转到没有权限页面
         {
             Response.Redirect("/NotPurview.html");
             e.Result = new EmptyResult();
         }
         else
         {
             int regionId = 0; //园区id
                               //根据人员id获取人员信息
             ServPersonInfoModel personModel = servPersonInfoBLL.GetPersonInfoByPersonId(personId);
             //判断人员是否有默认主控园区
             if (personModel.ext1 != "" && personModel.ext1 != null)
             {//没有设置主控园区则使用有权限的第一条数据
                 ServRolePurviewModel purModel = rolePruList.FirstOrDefault(n => n.region_id == Convert.ToInt32(personModel.ext1));
                 //判断用户设置的主控园区是否存在
                 if (purModel != null)
                 {
                     regionId = Convert.ToInt32(personModel.ext1);
                 }
             }
             else
             {
                 regionId = rolePruList[0].region_id;
             }
             //用园区id和人员角色id查询权限
             List <ServPurviewInfoModel> purviewList = servPersonInfoBLL.GetPurviewInfoByRoleIdAndRegionId(personModel.role_id, regionId);
             if (regionId == 0)//超级管理员拥有所有的园区切换权限
             {
                 //获取当前配置的园区
                 ViewData["MasterRegion"] = baseRegionConfigBll.GetAllRegionConfig();
             }
             else
             {
                 //根据园区id集合获取园区
                 ViewData["MasterRegion"] = baseRegionConfigBll.GetRegionConfig(rolePruList);
             }
             //当前用户的权限
             ViewData["personPurviewList"]     = purviewList;
             ViewData["personPurviewListJson"] = json.Serialize(purviewList);
             //用户信息
             ViewData["UserInfoModel"] = personModel;
             ViewData["UserInfoJson"]  = json.Serialize(personModel);
             ReadingConfig();           //读取配置
             SetRegionCookie(regionId); //设置主控园区cookie
             //读取视频平台配置
             ReadVideoConfig();
             //ViewData["AllRegion"] = json.Serialize(baseRegionConfigBll.GetAllRegionConfig());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
 /// <summary>
 /// 添加超级管理员信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddSuperAdmin(ApiPersonInfoModel model)
 {
     try
     {
         bool   result   = false;
         string parStr   = JsonHelper.ObjectToString <ApiPersonInfoModel>(model);
         string str      = HttpHelper.PostWebRequestBandError("http://" + personIp + "/ApiPersonInfo/AddPersonInfoAndAccount", parStr, "application/json;charset=utf-8", Encoding.UTF8);
         int    personId = JsonHelper.StringToObject <int>(str);
         if (personId == 0)
         {
             return(false);
         }
         //创建角色
         ServRoleInfoModel roleModel = new ServRoleInfoModel();
         roleModel.role_name     = "超级管理员";
         roleModel.role_code     = "SCJGLY";
         roleModel.role_describe = "";
         roleModel.ext1          = "-1";
         int roleId = servRoleInfoDAL.AddEntity(roleModel);
         if (roleId == 0)
         {
             return(false);
         }
         //创建角色权限关联(拥有所有权限)
         List <EnumModel>     purviewList = EnumClass.GetEnumModelList <EnumClass.PurviewEnum>();
         ServRolePurviewModel purviewModel;
         for (int i = 0; i < purviewList.Count; i++)
         {
             purviewModel            = new ServRolePurviewModel();
             purviewModel.purview_id = Convert.ToInt32(purviewList[i].key);
             purviewModel.role_id    = roleId;
             purviewModel.region_id  = 0;
             int purviewId = servRolePurviewDAL.AddEntity(purviewModel);
             if (purviewId == 0)
             {
                 return(false);
             }
         }
         //创建用户
         ServPersonInfoModel personModel = new ServPersonInfoModel();
         personModel.status  = 1;
         personModel.ssoid   = personId;
         personModel.alias   = "超级管理员";
         personModel.role_id = roleId;
         int personinfoId = AddPersonInfo(personModel);
         if (personinfoId == 0)
         {
             return(false);
         }
         result = true;
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
 /// <summary>
 /// 获取角色树
 /// </summary>
 /// <param name="personId"></param>
 /// <returns></returns>
 public List <ServRoleInfoCustom> GetRoleAndPurviewByPersonId(int personId)
 {
     try
     {
         ServPersonInfoModel       person         = servPersonInfoDAL.GetPersonInfoBySSOId(personId);
         List <ServRoleInfoModel>  roleList       = servRoleInfoDAL.GetRoleInfo();
         List <ServRoleInfoCustom> roleCustomList = new List <ServRoleInfoCustom>();
         ServRoleInfoCustom        roleCustom;
         for (int i = 0; i < roleList.Count; i++)
         {
             roleCustom               = new ServRoleInfoCustom();
             roleCustom.id            = roleList[i].id;
             roleCustom.pid           = -1;
             roleCustom.role_code     = roleList[i].role_code;
             roleCustom.role_name     = roleList[i].role_name;
             roleCustom.role_describe = roleList[i].role_describe;
             if (person != null)
             {
                 if (roleList[i].id == person.role_id)
                 {
                     roleCustom.@checked = true;
                 }
                 else
                 {
                     roleCustom.@checked = false;
                 }
             }
             roleCustomList.Add(roleCustom);
         }
         roleCustom           = new ServRoleInfoCustom();
         roleCustom.id        = 0;
         roleCustom.pid       = -1;
         roleCustom.role_name = "无";
         if (person != null)
         {
             if (person.role_id == 0)
             {
                 roleCustom.@checked = true;
             }
             else
             {
                 roleCustom.@checked = false;
             }
         }
         else
         {
             roleCustom.@checked = false;
         }
         roleCustomList.Add(roleCustom);
         return(roleCustomList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#4
0
 /// <summary>
 /// 根据人员编号修改人员角色
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int UpdatePersonRoleByPersonId(ServPersonInfoModel model)
 {
     try
     {
         return(mapContext.Update("UpdatePersonRoleByPersonId", model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
 /// <summary>
 /// 根据人员id获取本系统中的人员信息
 /// </summary>
 /// <param name="personId"></param>
 /// <returns></returns>
 public ServPersonInfoModel GetPersonInfoByPersonId(int personId)
 {
     try
     {
         ServPersonInfoModel model = servPersonInfoDAL.GetPersonInfoBySSOId(personId);
         return(model);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
 /// <summary>
 /// 添加人员
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddPersonInfo(ServPersonInfoModel model)
 {
     try
     {
         int id = servPersonInfoDAL.AddEntity(model);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model"></param>
 public int UpdatePersonInfoById(ServPersonInfoModel model)
 {
     try
     {
         int result = mapContext.Update("UpdatePersonInfo", model);
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="entity"></param>
 public int AddEntity(ServPersonInfoModel entity)
 {
     try
     {
         int id = (int)mapContext.Insert("InsertPersonInfo", entity);
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#9
0
 /// <summary>
 /// 同步sso人员
 /// </summary>
 /// <returns></returns>
 public bool SynchronizationSSO()
 {
     try
     {
         bool result = true;
         //从sso获取所有人员信息
         string str = HttpHelper.HttpGet("http://" + personIp + "/ApiPersonInfo/GetPersonList", "", "application/json;charset=utf-8");
         List <ApiPersonInfoModel> personList = JsonHelper.StringToObject <List <ApiPersonInfoModel> >(str);
         for (int i = 0; i < personList.Count; i++)
         {
             ServPersonInfoModel model = servPersonInfoDAL.GetPersonInfoBySSOId(personList[i].PersonID);
             if (model == null)//数据库中没有需要同步
             {
                 ServPersonInfoModel entity = new ServPersonInfoModel();
                 entity.ssoid   = personList[i].PersonID;
                 entity.status  = (int)PersonState.在职;
                 entity.role_id = 0;                  //初始没角色权限
                 entity.alias   = personList[i].Name; //别名
                 int id = servPersonInfoDAL.AddEntity(entity);
                 if (id != 0)
                 {
                     result = true;
                 }
             }
             else//数据库中已有
             {
                 if (personList[i].Name != model.alias)//名称发生变化
                 {
                     ServPersonInfoModel Upmodel = new ServPersonInfoModel();
                     Upmodel.id      = model.id;
                     Upmodel.role_id = model.role_id;
                     Upmodel.ssoid   = model.ssoid;
                     Upmodel.status  = model.status;
                     Upmodel.alias   = personList[i].Name;
                     int num = servPersonInfoDAL.UpdatePersonInfoById(Upmodel);
                     if (num != 0)
                     {
                         result = true;
                     }
                 }
             }
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#10
0
 /// <summary>
 /// 根据名称获取人员id
 /// </summary>
 /// <param name="personName"></param>
 /// <returns></returns>
 public int GetPersonInfoId(string personName)
 {
     try
     {
         int person_id           = 0;
         ServPersonInfoModel num = servPersonInfoDAL.GetPersonInfoId(personName);
         if (num != null)
         {
             person_id = num.ssoid;
         }
         return(person_id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#11
0
 /// <summary>
 /// 给人员绑定角色
 /// </summary>
 /// <param name="roleId"></param>
 /// <param name="personId"></param>
 /// <returns></returns>
 public bool PersonBindRole(int roleId, int personId)
 {
     try
     {
         bool result = false;
         ServPersonInfoModel model = new ServPersonInfoModel();
         model.ssoid   = personId;
         model.role_id = roleId;
         int num = servPersonInfoDAL.UpdatePersonRoleByPersonId(model);
         if (num != 0)
         {
             result = true;
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#12
0
 /// <summary>
 /// 根据人员id查询人员所拥有的园区权限
 /// </summary>
 /// <param name="personId"></param>
 /// <returns></returns>
 public List <ServRolePurviewModel> GetRegionPurByPersonId(int personId)
 {
     try
     {
         //查询人员
         ServPersonInfoModel         person      = servPersonInfoDAL.GetPersonInfoBySSOId(personId);
         List <ServRolePurviewModel> rolePruList = new List <ServRolePurviewModel>();
         if (person != null)
         {
             if (person.role_id != 0)
             {
                 //根据角色id获取角色所包含的园区权限
                 rolePruList = servPurviewInfoDAL.GetRoleRegionIdByRoleId(person.role_id);
             }
         }
         return(rolePruList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#13
0
 /// <summary>
 /// 根据人员id获取权限
 /// </summary>
 /// <param name="personId"></param>
 /// <returns></returns>
 public List <ServPurviewInfoCustom> GetPurviewByPersonId(int personId)
 {
     try
     {
         ServPersonInfoModel          person      = servPersonInfoDAL.GetPersonInfoBySSOId(personId);
         List <ServPurviewInfoCustom> purviewList = new List <ServPurviewInfoCustom>();
         if (person != null)
         {
             if (person.role_id != 0)
             {
                 //根据角色id获取角色所包含的园区权限
                 List <ServRolePurviewModel> rolePurList = servPurviewInfoDAL.GetRoleRegionIdByRoleId(person.role_id);
                 for (int i = 0; i < rolePurList.Count; i++)
                 {
                     ServRolePurviewQuery query = new ServRolePurviewQuery();
                     query.role_id   = person.role_id;
                     query.region_id = rolePurList[i].region_id;
                     List <ServPurviewInfoModel> purviewList1 = servPurviewInfoDAL.GetPurviewInfoByRoleId(query);
                     for (int j = 0; j < purviewList1.Count; j++)
                     {
                         ServPurviewInfoCustom purCus = new ServPurviewInfoCustom();
                         purCus.id           = purviewList1[j].id;
                         purCus.purview_code = purviewList1[j].purview_code;
                         purCus.purview_name = purviewList1[j].purview_name;
                         purCus.sid          = Convert.ToInt32(purviewList1[j].purview_code + "" + rolePurList[i].region_id);
                         if (purviewList1[j].pid == -1)
                         {
                             purCus.pid = rolePurList[i].region_id;
                         }
                         else
                         {
                             purCus.pid = Convert.ToInt32(purviewList1[j].pid + "" + rolePurList[i].region_id);
                         }
                         purCus.region_id = rolePurList[i].region_id;
                         purviewList.Add(purCus);
                     }
                     //根据园区id获取园区信息
                     BaseRegionConfigModel regionModel = baseRegionConfigDAL.GetEntity(rolePurList[i].region_id);
                     ServPurviewInfoCustom purCus1     = new ServPurviewInfoCustom();
                     if (regionModel != null)
                     {
                         purCus1.id           = regionModel.id;
                         purCus1.purview_name = regionModel.region_name;
                         purCus1.purview_code = regionModel.id;
                         purCus1.pid          = -1;
                         purCus1.sid          = regionModel.id;
                     }
                     else
                     {
                         purCus1.purview_name = "超级管理员";
                     }
                     purCus1.region_id = rolePurList[i].region_id;
                     purviewList.Add(purCus1);
                 }
             }
         }
         return(purviewList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#14
0
 /// <summary>
 /// 添加人员信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddPersonInfo(PersonInfoCustom model)
 {
     try
     {
         bool result = false;
         //往sso中添加人员基础信息
         ApiPersonInfoModel personModel = new ApiPersonInfoModel();
         personModel.Name            = model.name;
         personModel.EnName          = model.EnName;
         personModel.Gender          = model.Gender;
         personModel.Nation          = model.Nation;
         personModel.Birthday        = model.birthday;
         personModel.BloodType       = model.BloodType;
         personModel.Religion        = model.Religion;
         personModel.NativePlace     = model.nativePlace;
         personModel.Nationality     = model.Nationality;
         personModel.PoliticalStatus = model.PoliticalStatus;
         personModel.MarriageStatus  = model.MarriageStatus;
         personModel.IDCard          = model.IDCard;
         personModel.Phone           = model.phone;
         personModel.Admin           = model.loginAdmin;
         personModel.PassWord        = model.loginPassWord;
         string parStr   = JsonHelper.ObjectToString <ApiPersonInfoModel>(personModel);
         string str      = HttpHelper.PostWebRequestBandError("http://" + personIp + "/ApiPersonInfo/AddPersonInfoAndAccount", parStr, "application/json;charset=utf-8", Encoding.UTF8);
         int    personId = JsonHelper.StringToObject <int>(str);
         if (personId < 1)
         {
             return(false);
         }
         else
         {
             result = true;
         }
         //添加人员信息表serv_person_info
         ServPersonInfoModel personInfoModel = new ServPersonInfoModel();
         personInfoModel.ssoid   = personId;
         personInfoModel.role_id = 0;
         personInfoModel.alias   = model.name;
         personInfoModel.status  = 1;
         int personInfoId = servPersonInfoDAL.AddEntity(personInfoModel);
         if (personInfoId < 1)
         {
             return(false);
         }
         //职工信息
         ServStaffInfoModel staffmodel = new ServStaffInfoModel();
         staffmodel.person_id = personId;
         staffmodel.org_id    = model.org_id;
         staffmodel.job_grade = model.job_grade;
         if (model.start_time != "")
         {
             staffmodel.start_time = Convert.ToDateTime(model.start_time);
         }
         staffmodel.work_num     = model.work_num;
         staffmodel.staff_type   = model.staff_type_id;
         staffmodel.staff_status = model.staff_status_id;
         if (model.staffFlag == 1)//有职工扩展
         {
             //新增人员职工关联
             BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
             staffRelation1.type_id   = (int)PersonType.职工;
             staffRelation1.person_id = personId;
             int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
             if (id1 < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
             //新增职工信息
             int id = servStaffInfoDAL.AddEntity(staffmodel);
             if (id < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
         }
         //教师信息
         ServTeacherInfoModel teacherModel = new ServTeacherInfoModel();
         teacherModel.person_id = personId;
         teacherModel.class_id  = model.faculty;
         teacherModel.level     = model.level_id;
         teacherModel.status    = model.teach_status_id;
         if (model.teacherFlag == 1)//有教师扩展
         {
             //新增人员教师关联
             BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
             staffRelation1.type_id   = (int)PersonType.教师;
             staffRelation1.person_id = personId;
             int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
             if (id1 < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
             //新增教师信息
             int id = servTeacherInfoDAL.AddEntity(teacherModel);
             if (id < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
         }
         //学生信息
         ServStudentInfoModel studentModel = new ServStudentInfoModel();
         studentModel.person_id     = personId;
         studentModel.student_num   = model.student_num;
         studentModel.student_grade = model.student_grade;
         studentModel.class_id      = model.class_Name;
         if (model.in_time != "")
         {
             studentModel.in_time = Convert.ToDateTime(model.in_time);
         }
         studentModel.edu_year     = model.edu_year;
         studentModel.teacher_id   = model.teacher_Name;
         studentModel.staff_id     = model.staff_Name;
         studentModel.student_type = model.student_type_id;
         studentModel.status       = model.studentStatus_id;
         if (model.studentFlag == 1)//有学生扩展
         {
             //新增人员学生关联
             BasePersonRelationshipModel staffRelation1 = new BasePersonRelationshipModel();
             staffRelation1.type_id   = (int)PersonType.学生;
             staffRelation1.person_id = personId;
             int id1 = basePersonRelationshipDAL.AddEntity(staffRelation1);
             if (id1 < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
             //新增学生信息
             int id = servStudentInfoDAL.AddEntity(studentModel);
             if (id < 1)
             {
                 return(false);
             }
             else
             {
                 result = true;
             }
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#15
0
 public bool UpdateEntity(int id, ServPersonInfoModel newentity)
 {
     throw new NotImplementedException();
 }