public TreeNode GenerateManageWebTreeNodeByParentDepartment(string rootImageUrl, string itemImageUrl, int rootDepartmentID) { SuperWebTreeNode baseTreeNode = new SuperWebTreeNode(SYSTEMDEPARTMENT_MIN_DEPTH, SYSTEMDEPARTMENT_MAX_DEPTH, 0); baseTreeNode.Checked = false; baseTreeNode.SelectAction = TreeNodeSelectAction.Select; baseTreeNode.Text = "²¿ÃŹÜÀí"; baseTreeNode.Value = "0"; baseTreeNode.ImageUrl = rootImageUrl; SystemDepartment rootDepartment = null; if (rootDepartmentID > 0) { rootDepartment = this.SelfDao.Load(rootDepartmentID); } List <SystemDepartment> topLevelSystemDepartment = this.SelfDao.GetSubDepartmentByParentDepartment(rootDepartment); foreach (SystemDepartment topDepartment in topLevelSystemDepartment) { GenerateSubManageWebTreeNodeByParentDepartment(itemImageUrl, topDepartment, baseTreeNode); } return(baseTreeNode); }
/// <summary> /// 默认构造函数 /// </summary> public SystemDepartmentBase() { _department_id = 0; _parent_department_id = null; _department_namecn = String.Empty; _department_nameen = String.Empty; _department_decription = String.Empty; }
/// <summary> /// 查找指定部门下面的子部门 /// </summary> /// <param name="parentDepartment">负部门类:null代表最上层</param> /// <returns>父部门下的所有子部门</returns> public List<SystemDepartment> GetSubDepartmentByParentDepartment(SystemDepartment parentDepartment) { DetachedCriteria departmentCriteria = DetachedCriteria.For(typeof(SystemDepartment)); if (parentDepartment == null) departmentCriteria.Add(SystemDepartmentDao.PROPERTY_PARENTDEPARTMENTID.IsNull()); else departmentCriteria.Add(SystemDepartmentDao.PROPERTY_PARENTDEPARTMENTID.Eq(parentDepartment)); return this.FindListByDetachedCriteriaQuery(departmentCriteria); }
public SystemDepartmentModel(SystemDepartment entity) { Id = entity.Id; ParentId = entity.ParentId; CanonicalName = entity.CanonicalName; Abbreviation = entity.Abbreviation; SubDepartments = Construct(entity.SubDepartments); IsDeleted = entity.IsDeleted; }
public async Task <SystemDepartmentModel> UpdateItem(SystemDepartmentModel model) { var department = new SystemDepartment(model); department = await _systemDepartmentsManager.UpdateItemAsync(department); var departmentModel = new SystemDepartmentModel(department); return(departmentModel); }
/// <summary> /// 默认构造函数 /// </summary> public SystemUserBase() { _user_id = 0; _user_loginid = String.Empty; _user_name = String.Empty; _user_email = String.Empty; _user_password = String.Empty; _user_status = String.Empty; _user_create_date = null; _user_type = String.Empty; _department_id = null; }
public async Task <SystemDepartment> GetSubItemAsync(string id) { IEnumerable <SystemDepartment> departments = await GetItemsAsync(); if (departments == null || !departments.Any()) { throw new DepartmentsNotFoundException(); } SystemDepartment systemDepartment = departments.SingleOrDefault(x => string.Compare(x.Id, id, true) == 0); return(systemDepartment); }
public List <SystemDepartment> GetSubDepartmentByParentDepartment(SystemDepartment parentDepartment) { DetachedCriteria departmentCriteria = DetachedCriteria.For(typeof(SystemDepartment)); if (parentDepartment == null) { departmentCriteria.Add(SystemDepartmentDao.PROPERTY_PARENTDEPARTMENTID.IsNull()); } else { departmentCriteria.Add(SystemDepartmentDao.PROPERTY_PARENTDEPARTMENTID.Eq(parentDepartment)); } return(this.FindListByDetachedCriteriaQuery(departmentCriteria)); }
private void GenerateSubManageWebTreeNodeByParentDepartment(string itemImageUrl, SystemDepartment upDepartment, TreeNode upTreeNode) { SuperWebTreeNode groupTreeNode = new SuperWebTreeNode(SYSTEMDEPARTMENT_MIN_DEPTH, SYSTEMDEPARTMENT_MAX_DEPTH, 0); groupTreeNode.Checked = false; groupTreeNode.SelectAction = TreeNodeSelectAction.Select; groupTreeNode.Text = upDepartment.DepartmentNameCn; groupTreeNode.ImageUrl = itemImageUrl; groupTreeNode.Value = upDepartment.DepartmentID.ToString(); upTreeNode.ChildNodes.Add(groupTreeNode); List<SystemDepartment> topLevelSystemDepartment = this.SelfDao.GetSubDepartmentByParentDepartment(upDepartment); foreach (SystemDepartment department in topLevelSystemDepartment) { GenerateSubManageWebTreeNodeByParentDepartment(itemImageUrl, department, groupTreeNode); } }
public OperationResult Insert(SystemDepartmentsModel model) { var entity = new SystemDepartment { Name = model.Name, ParentID = model.ParentId, CreateId = model.CreateId, CreateBy = model.CreateBy, CreateTime = DateTime.Now, ModifyId = model.ModifyId, ModifyBy = model.ModifyBy, ModifyTime = DateTime.Now, OrderSort = model.OrderSort, SystemOragnizationID = model.SystemOragnizationID, Enabled = model.Enabled }; SystemDepartmentRepository.Insert(entity); return(new OperationResult(OperationResultType.Success, "添加成功")); }
public ActionResult Save(SystemDepartment entity) { var hasResult = service.Exists(entity); if (hasResult.Failure) { return Json(hasResult); } var result = entity.Id == 0 ? service.Insert(entity) : service.Update(entity); return Json(result); }
public async Task <SystemDepartment> CreateItemAsync(SystemDepartment department) { var results = await _container.CreateItemAsync <SystemDepartment>(department, new PartitionKey(department.CanonicalName)); return(results); }
/// <summary> /// 默认构造函数 /// </summary> public SystemUserBase() { _user_id = 0; _user_loginid = String.Empty; _user_name = String.Empty; _user_email = String.Empty; _user_password = String.Empty; _user_status = String.Empty; _user_create_date = null; _user_type = String.Empty; _department_id = null; _mobilepin = String.Empty; _passwordformat = 0; _passwordsalt = String.Empty; _loweredemail = String.Empty; _passwordquestion = String.Empty; _passwordanswer = String.Empty; _comments = String.Empty; _isapproved = false; _islockedout = false; _lastactivitydate = null; _lastlogindate = null; _lastlockedoutdate = null; _lastpasswordchangedate = null; _failedpwdattemptcnt = 0; _failedpwdattemptwndstart = null; _failedpwdansattemptcnt = 0; _failedpwdansattemptwndstart = null; }
public IActionResult Getalluseranddep() { //1、获取access_token string access_token = Haikan3.Utils.DingDingHelper.GetAccessToken0().access_token; var response = ResponseModelFactory.CreateResultInstance; using (_dbContext) { try { UserEditViewModel model = new UserEditViewModel(); string pas = "******"; var code = access_token; string suiteKey = "dinga7xg5vjb2lwwvicu"; string suiteSecret = "pUiI0xvN0ZEbsFavSbuaLqctwHL2p9cIRlQ4HU5GS7y-TmYngcTjJGuI309ZLR_h"; string timestamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000).ToString(); string suiteTicket = "TestSuiteTicket"; string signature1 = timestamp + "\n" + suiteTicket; string signature2 = HmacSHA256(signature1, suiteSecret); string signature = System.Web.HttpUtility.UrlEncode(signature2, System.Text.Encoding.UTF8); string auth_corpid = access_token; //string url = "https://oapi.dingtalk.com/service/get_corp_token?signature=" + signature + "×tamp=" + timestamp + "&suiteTicket=" + suiteTicket + "&accessKey=" + suiteKey; string url = "https://oapi.dingtalk.com/gettoken?appkey=" + suiteKey + "&appsecret=" + suiteSecret; //string param = "{ \"auth_corpid\": \"ding5998aa137739c847bc961a6cb783455b\"}"; //var response11 = Haikan3.Utils.DingDingHelper.HttpPost(url, param); var response11 = Haikan3.Utils.DingDingHelper.HttpGet(url); var result = Newtonsoft.Json.JsonConvert.DeserializeObject <HaikanCRM.Api.ViewModels.DIngDing.PersistentCodeResult>(response11); if (result != null && result.errcode == "0") { //获取部门列表 string urldep = "https://oapi.dingtalk.com/department/list?access_token=" + result.access_token; var responseldep = Haikan3.Utils.DingDingHelper.HttpGet(urldep); var resultdep = Newtonsoft.Json.JsonConvert.DeserializeObject <HaikanCRM.Api.ViewModels.DIngDing.departmentAlldata>(responseldep); //将获取的部门信息保存到数据库 //if (resultdep.department == null) //{ // response.SetFailed(resultdep.errmsg); // return Ok(response); //} for (int i = 0; i < resultdep.department.Count; i++) { var depid = _dbContext.SystemDepartment.Count(x => x.Dingid == resultdep.department[i].id); //数据库中没有查到此部门--将数据添加到数据库中 if (depid == 0) { var entity = new SystemDepartment(); entity.Name = resultdep.department[i].name; //部门名称 entity.Dingid = resultdep.department[i].id; //部门钉钉id entity.IsDeleted = 0; //未删除 entity.EstablishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //添加时间 entity.EstablishName = "钉钉同步"; //添加人 entity.Remark = ""; //备注 entity.DepartmentUuid = Guid.NewGuid(); //部门guid _dbContext.SystemDepartment.Add(entity); //添加 _dbContext.SaveChanges(); } else//此部门已存在---更新部门数据 { var entity = _dbContext.SystemDepartment.FirstOrDefault(x => x.Dingid == resultdep.department[i].id); entity.Name = resultdep.department[i].name;//更新部门名称 _dbContext.SaveChanges(); } //获取该部门的所有用户 string urldepuser = "******" + result.access_token + "&department_id=" + resultdep.department[i].id; //获取部门uuid var depuuid = _dbContext.SystemDepartment.FirstOrDefault(x => x.Dingid == resultdep.department[i].id).DepartmentUuid; var responsedepuser = Haikan3.Utils.DingDingHelper.HttpGet(urldepuser); var resdepuser = Newtonsoft.Json.JsonConvert.DeserializeObject <HaikanCRM.Api.ViewModels.DIngDing.depauser>(responsedepuser); //将获取到的人员信息保存到数据库中 for (int j = 0; j < resdepuser.userlist.Count; j++) { var userid = _dbContext.SystemUser.Count(x => x.Streets == resdepuser.userlist[j].userid); //获取人员信息 var results = Haikan3.Utils.DingDingHelper.HttpGet("https://oapi.dingtalk.com/user/get?access_token=" + result.access_token + "&userid=" + resdepuser.userlist[j].userid); var usersxinxi = Newtonsoft.Json.JsonConvert.DeserializeObject <HaikanCRM.Api.ViewModels.DIngDing.usersdata>(results); var roiduuid = _dbContext.SystemRole.FirstOrDefault(x => x.RoleName == "客户经理"); //数据库中没有该人员信息--添加到数据库中 if (userid == 0) { var entity = new SystemUser(); entity.SystemUserUuid = Guid.NewGuid(); entity.LoginName = resdepuser.userlist[j].name; entity.RealName = resdepuser.userlist[j].name; entity.Streets = resdepuser.userlist[j].userid; entity.DepartmentUuid = depuuid;//部门uuid entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //entity.PassWord = Haikan3.Utils.DesEncrypt.Encrypt(pas.Trim(), MdDesEncrypt.SecretKey); entity.PassWord = Security.GenerateMD5(pas.Trim());; entity.SystemRoleUuid = roiduuid.SystemRoleUuid.ToString(); entity.IsDeleted = 0; entity.ZaiGang = "在岗"; entity.UserType = 2; _dbContext.SystemUser.Add(entity); _dbContext.SaveChanges(); _dbContext.Database.ExecuteSqlRaw("DELETE FROM SystemUserRoleMapping WHERE SystemUserUUID={0}", entity.SystemUserUuid); var success = true; ////循环加权限 //for (int i = 0; i < model.SystemRoleUuid.Count; i++) //{ if (entity.SystemRoleUuid != null) { var roles = new SystemUserRoleMapping(); roles.SystemUserUuid = entity.SystemUserUuid; roles.SystemRoleUuid = Guid.Parse(entity.SystemRoleUuid); roles.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); roles.AddPeople = AuthContextService.CurrentUser.DisplayName; _dbContext.SystemUserRoleMapping.Add(roles); } //} success = _dbContext.SaveChanges() > 0; if (success) { response.SetSuccess(); } else { _dbContext.Database.ExecuteSqlRaw("DELETE FROM SystemUser WHERE SystemUserUUID={0}", entity.SystemUserUuid); response.SetFailed("保存用户角色数据失败"); } } else { //数据库中存在该人员--修改信息 var entity = _dbContext.SystemUser.FirstOrDefault(x => x.Streets == resdepuser.userlist[j].userid); entity.RealName = resdepuser.userlist[j].name; entity.LoginName = resdepuser.userlist[j].name; entity.DepartmentUuid = depuuid;//部门uuid _dbContext.SaveChanges(); } } ////获取子部门id列表 //string urlzidep = "https://oapi.dingtalk.com/department/list_ids?access_token=" + result.access_token + "&id=" + resultdep.department[i].id; // var responselzidep = Haikan3.Utils.DingDingHelper.HttpGet(urlzidep); } } //var response = ResponseModelFactory.CreateInstance; return(Ok(response)); } catch (Exception ex) { response.SetFailed(ex.Message); return(Ok(response)); } } }
public async Task <SystemDepartment> UpdateItemAsync(SystemDepartment department) { var results = await _container.UpsertItemAsync <SystemDepartment>(department); return(results); }
/// <summary> /// 更新系统部门 /// </summary> /// <param name="entity">系统部门实体</param> public BoolMessage Update(SystemDepartment entity) { try { repos.Update(entity); return BoolMessage.True; } catch (Exception e) { return new BoolMessage(false, e.Message); } }
/// <summary> /// 检测是否存在指定系统部门 /// </summary> /// <param name="entity">系统部门实体</param> /// <returns>存在返回true</returns> public BoolMessage Exists(SystemDepartment entity) { var has = repos.Exists(p => p.Name == entity.Name && p.ParentId == entity.ParentId && p.Id != entity.Id); return has ? new BoolMessage(false, "指定的部门名称已经存在") : BoolMessage.True; }
private void GenerateSubManageWebTreeNodeByParentDepartment(string itemImageUrl, SystemDepartment upDepartment, TreeNode upTreeNode) { SuperWebTreeNode groupTreeNode = new SuperWebTreeNode(SYSTEMDEPARTMENT_MIN_DEPTH, SYSTEMDEPARTMENT_MAX_DEPTH, 0); groupTreeNode.Checked = false; groupTreeNode.SelectAction = TreeNodeSelectAction.Select; groupTreeNode.Text = upDepartment.DepartmentNameCn; groupTreeNode.ImageUrl = itemImageUrl; groupTreeNode.Value = upDepartment.DepartmentID.ToString(); upTreeNode.ChildNodes.Add(groupTreeNode); List <SystemDepartment> topLevelSystemDepartment = this.SelfDao.GetSubDepartmentByParentDepartment(upDepartment); foreach (SystemDepartment department in topLevelSystemDepartment) { GenerateSubManageWebTreeNodeByParentDepartment(itemImageUrl, department, groupTreeNode); } }
public async Task CreateItem(SystemDepartmentModel model) { SystemDepartment entity = new SystemDepartment(model); await _systemDepartmentsManager.CreateItemAsync(entity); }
private ActionResult EditCore(SystemDepartment entity) { SetParentEntity(entity.ParentId); return View("Edit", entity); }