//组织 static void GenerateOrganizeInfo(int num) { OrganizeInfoDal dal = new OrganizeInfoDal(); DbSession dbSession = new DbSession(); for (int i = 0; i < num; i++) { OrganizeInfo organize = new OrganizeInfo(); organize.OrganizeInfoLoginId = Guid.NewGuid().ToString().Substring(0, 10); organize.OrganizeInfoShowName = (Faker.Name.First() + Faker.Name.First()).Substring(3); organize.OrganizeInfoPwd = MD5Helper.Get_MD5(Faker.Name.First()).Substring(3); organize.OrganizeInfoPeople = (Faker.Name.Last() + Faker.Name.First()).Substring(3); organize.OrganizeInfoEmail = Faker.Internet.FreeEmail().Substring(0, 10); organize.OrganizeInfoManageId = 2; organize.OrganizeInfoLastTime = Convert.ToDateTime(Faker.Business.CreditCardExpiryDate()); organize.CreateTime = organize.OrganizeInfoLastTime.AddMonths(-10); organize.ModfiedOn = organize.OrganizeInfoLastTime.AddMonths(-4); organize.OrganizeInfoIcon = "/Content/Upload/images/1.jpg"; organize.ActivityCount = 0; organize.Status = (short)((new Random().Next(9)) % 3); dal.Add(organize); } dbSession.SaveChanges(); }
//查找所有子节点的任务 private void GetOrganizeInfosChildrens(OrganizeInfo p_organ) { IEnumerable <OrganizeInfo> childs = null; var p_id = p_organ.id.ToString(); string sql = "SELECT [id],[Name] as Label,[parentguid],[Blevel],[OrderNumber] FROM [WebBus].[dbo].[T_OrganizeInfo] Where parentguid='" + p_id + "' order by [OrderNumber]"; using (IDbConnection connection = new SqlConnection(connectionString)) { childs = connection.Query <OrganizeInfo>(sql); p_organ.children = childs; } if (childs == null || childs.Count() == 0) { return; } foreach (var item in childs) { if (item != null) { GetOrganizeInfosChildrens(item); } else { break; } } return; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (BoolCheckLogin) { if (filterContext.HttpContext.Request.Cookies["userLoginId"] == null) { filterContext.Result = new RedirectResult("~/Login/Index"); base.OnActionExecuting(filterContext); return; } String userLoginId = filterContext.HttpContext.Request.Cookies["userLoginId"].Value; if (Common.Cache.CacheHelper.GetCache(userLoginId) is UserInfo) { LoginUser = Common.Cache.CacheHelper.GetCache(userLoginId) as UserInfo; } else if (Common.Cache.CacheHelper.GetCache(userLoginId) is OrganizeInfo) { LoginOrganize = Common.Cache.CacheHelper.GetCache(userLoginId) as OrganizeInfo; } //缓存过期 if (LoginUser == null && LoginOrganize == null) { filterContext.Result = new RedirectResult("~/Login/Index"); base.OnActionExecuting(filterContext); return; } } base.OnActionExecuting(filterContext); }
/// <summary> /// 头像上传 /// </summary> /// <returns></returns> public ActionResult UploadIcon() { var file = Request.Files["file"]; String filePath = System.Configuration.ConfigurationManager.AppSettings["DefaultIconSavePath"]; string dirPath = Request.MapPath(filePath); if (Common.FileUpload.FileHelper.ImageUpload(file, dirPath, filePath, out string fileName)) { OrganizeInfo organizeInfo = OrganizeInfoService.GetEntities(u => u.OrganizeInfoID == LoginOrganize.OrganizeInfoID).FirstOrDefault(); organizeInfo.OrganizeInfoIcon = fileName; organizeInfo.ModfiedOn = DateTime.Now; if (OrganizeInfoService.Update(organizeInfo)) { LoginOrganize.OrganizeInfoIcon = fileName; return(Json(new { src = fileName, msg = "success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create() { OrganizeInfo organizeInfo = new OrganizeInfo(); organizeInfo.OrganizeInfoIcon = System.Configuration.ConfigurationManager.AppSettings["DefaultIconPath"]; ViewData.Model = organizeInfo; return(View()); }
public ActionResult ResetPwd(int id) { OrganizeInfo organize = OrganizeInfoService.GetEntities(u => u.OrganizeInfoID == id).FirstOrDefault(); organize.OrganizeInfoPwd = Common.Encryption.MD5Helper.Get_MD5("000000"); if (OrganizeInfoService.Update(organize)) { return(Content("success")); } else { return(Content("fail")); } }
//返回页面 public ActionResult ValName() { string loginId = Request["name"]; UserInfo userInfo = UserInfoService.GetEntities(u => u.UserInfoLoginId == loginId).FirstOrDefault(); if (userInfo == null) { OrganizeInfo organizeInfo = OrganizeInfoService.GetEntities(u => u.OrganizeInfoLoginId == loginId).FirstOrDefault(); if (organizeInfo == null) { return(Content("success")); } } return(Content("fail")); }
//注册时进行判断 public Boolean ValidateName(string loginId) { bool flag = false; UserInfo userInfo = UserInfoService.GetEntities(u => u.UserInfoLoginId == loginId).FirstOrDefault(); if (userInfo == null) { OrganizeInfo organizeInfo = OrganizeInfoService.GetEntities(u => u.OrganizeInfoLoginId == loginId).FirstOrDefault(); if (organizeInfo == null) { flag = true; } } return(flag); }
public ActionResult Edit(int id) { //非最高等级团队用户欲编辑其他用户信息 if (LoginOrganize.OrganizeInfoManageId != null && LoginOrganize.OrganizeInfoID != id) { return(Redirect("/OrganizeInfo/Index")); } OrganizeInfo organizeInfo = OrganizeInfoService.GetEntities(p => p.OrganizeInfoID == id && p.Status == delNormal).FirstOrDefault(); if (organizeInfo == null) { return(Redirect("/OrganizeInfo/Index")); } return(View(organizeInfo)); }
public ActionResult Edit(OrganizeInfo organizeInfo) { if (ModelState.IsValid) { organizeInfo.ModfiedOn = DateTime.Now; if (OrganizeInfoService.Update(organizeInfo)) { return(Content("success")); } else { return(Content("fail")); } } return(Content("fail")); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (AbleUser && AbleOrganize) { }//用户可以执行 团队可以执行 else if (AbleUser && !AbleOrganize) { String userLoginId = filterContext.HttpContext.Request.Cookies["userLoginId"].Value; if (Common.Cache.CacheHelper.GetCache(userLoginId) is OrganizeInfo) { filterContext.Result = new RedirectResult("~/OrganizeInfo/Index"); } }//用户可以执行 团队不可以执行 else if (!AbleUser && AbleOrganize) { String userLoginId = filterContext.HttpContext.Request.Cookies["userLoginId"].Value; if (Common.Cache.CacheHelper.GetCache(userLoginId) is UserInfo) { filterContext.Result = new RedirectResult("~/UserInfo/Index"); } if (Super) { OrganizeInfo organizeInfo = Common.Cache.CacheHelper.GetCache(userLoginId) as OrganizeInfo; if (organizeInfo.OrganizeInfoManageId != null) { filterContext.Result = new RedirectResult("~/OrganizeInfo/Index"); } } }//用户不可以执行 团队可以执行 else if (!AbleUser && !AbleOrganize) { String userLoginId = filterContext.HttpContext.Request.Cookies["userLoginId"].Value; if (Common.Cache.CacheHelper.GetCache(userLoginId) is UserInfo) { filterContext.Result = new RedirectResult("~/UserInfo/Index"); } else { filterContext.Result = new RedirectResult("~/OrganizeInfo/Index"); } }//用户不可以执行 团队不可以执行 base.OnActionExecuting(filterContext); }
public JsonResult Create(OrganizeInfo organizeInfo) { string msg = "fail"; Regex regex1 = new Regex(@"^[0-9]{6,12}$"); if (!ValidateName(organizeInfo.OrganizeInfoLoginId)) { return(Json(new { msg = "exist" }, JsonRequestBehavior.AllowGet)); } if (regex1.IsMatch(organizeInfo.OrganizeInfoLoginId)) { return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet)); } if (ModelState.IsValid) { organizeInfo.OrganizeInfoManageId = LoginOrganize.OrganizeInfoID; if (OrganizeInfoService.AddOrg(organizeInfo)) { msg = "success"; } } return(Json(new { msg }, JsonRequestBehavior.AllowGet)); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.HttpContext.Request.Cookies["userLoginId"] == null) { base.OnActionExecuting(filterContext); return; } else { String userLoginId = filterContext.HttpContext.Request.Cookies["userLoginId"].Value; if (Common.Cache.CacheHelper.GetCache(userLoginId) is UserInfo) { LoginUser = Common.Cache.CacheHelper.GetCache(userLoginId) as UserInfo; } else if (Common.Cache.CacheHelper.GetCache(userLoginId) is OrganizeInfo) { LoginOrganize = Common.Cache.CacheHelper.GetCache(userLoginId) as OrganizeInfo; } //缓存过期 if (LoginUser == null && LoginOrganize == null) { filterContext.Result = new RedirectResult("~/Login/Index"); base.OnActionExecuting(filterContext); return; } if (LoginUser != null) { Common.Cache.CacheHelper.SetCache(userLoginId, LoginUser, DateTime.Now.AddMinutes(40)); } else { Common.Cache.CacheHelper.SetCache(userLoginId, LoginOrganize, DateTime.Now.AddMinutes(40)); } } base.OnActionExecuting(filterContext); }
public ActionResult OrganizeRegister(string loginname, string pwd, string nickname, string people, string phone) { if (!ValidateName(loginname)) { return(Content("exist")); } //验证 //登录名 Regex regex = new Regex(@"^[A-Za-z0-9]{6,12}$"); Regex regex1 = new Regex(@"^[0-9]{6,12}$"); if (!regex.IsMatch(loginname) || regex1.IsMatch(loginname)) { return(Content("fail")); } //密码 regex = new Regex(@"^[A-Za-z0-9]{6,12}$"); if (!regex.IsMatch(pwd)) { return(Content("fail")); } //昵称 regex = new Regex(@"^[\u4e00-\u9fa5]{2,15}$"); if (!regex.IsMatch(nickname)) { return(Content("fail")); } regex = new Regex(@"^[\u4e00-\u9fa5]{2,10}$"); if (!regex.IsMatch(people)) { return(Content("fail")); } //电话号码 regex = new Regex(@"^\d{11}$"); if (!regex.IsMatch(phone)) { return(Content("fail")); } OrganizeInfo organize = new OrganizeInfo { OrganizeInfoLoginId = loginname, OrganizeInfoPwd = Common.Encryption.MD5Helper.Get_MD5(pwd), OrganizeInfoShowName = nickname, OrganizeInfoPeople = people, OrganizeInfoPhone = phone, Status = (short)Model.Enum.DelFlagEnum.Auditing, ModfiedOn = DateTime.Now, CreateTime = DateTime.Now, OrganizeInfoLastTime = DateTime.Now, OrganizeInfoManageId = OrganizeInfoService.GetEntities(u => u.OrganizeInfoManageId == null).FirstOrDefault().OrganizeInfoID, OrganizeInfoIcon = System.Configuration.ConfigurationManager.AppSettings["DefaultIconPath"], ActivityCount = 0 }; if (OrganizeInfoService.Add(organize) != null) { return(Content("organize")); } else { return(Content("fail")); } }