public ActionResult AddNewBeeFloor(Guid NewBeeID, string mdTxt, string mdValue) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(mdTxt) || string.IsNullOrEmpty(mdValue)) { return(Json(new { msg = "参数错误" })); } if (mdTxt.GetByteCount() > 2500 || mdValue.GetByteCount() > 5000) { return(Json(new { msg = "参数太长" })); } NewBee newBee = NewBeeDataSvc.GetByID(NewBeeID); newBee.FloorCount += 1; newBee.LastFloorDate = DateTime.Now; NewBeeFloor floor = new NewBeeFloor(); floor.NewBeeID = NewBeeID; floor.MDText = mdTxt; floor.MDValue = HtmlST.Sanitize(mdValue); floor.OwnerID = CurrentUser.ID; floor.Order = newBee.FloorCount; NewBeeFloorDataSvc.Add(floor); NewBeeDataSvc.Update(newBee); if (newBee.OwnerID != CurrentUser.ID) { string key = MyRedisKeys.Pre_CMsg + newBee.OwnerID; CMsg bcmsg = MyRedisDB.GetSet <CMsg>(key).Where(m => m.ObjID == NewBeeID).FirstOrDefault(); if (bcmsg != null) { MyRedisDB.SetRemove(key, bcmsg); bcmsg.Count += 1; MyRedisDB.SetAdd(key, bcmsg); } else { bcmsg = new CMsg(); bcmsg.ObjType = (int)EnumObjectType.NewBee; bcmsg.ObjID = NewBeeID; bcmsg.Count = 1; bcmsg.Date = DateTime.Now; bcmsg.Order = floor.Order; bcmsg.Title = newBee.Title.MaxByteLength(32); MyRedisDB.SetAdd(key, bcmsg); } } return(Json(new { msg = "done", count = newBee.FloorCount })); }
public ActionResult AddBlogComment(Guid blogID, string mdTxt, string mdValue) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(mdTxt) || string.IsNullOrEmpty(mdValue)) { return(Json(new { msg = "参数错误" })); } if (mdTxt.GetByteCount() > 5000 || mdValue.GetByteCount() > 10000) { return(Json(new { msg = "参数太长" })); } Blog blog = BlogDataSvc.GetByID(blogID); blog.CommentCount += 1; BlogComment comment = new BlogComment(); comment.BlogID = blogID; comment.MDText = mdTxt; comment.MDValue = HtmlST.Sanitize(mdValue); comment.OwnerID = CurrentUser.ID; comment.Order = blog.CommentCount; BlogCommentDataSvc.Add(comment); BlogDataSvc.Update(blog); if (blog.OwnerID != CurrentUser.ID) { string key = MyRedisKeys.Pre_CMsg + blog.OwnerID; CMsg bcmsg = MyRedisDB.GetSet <CMsg>(key).Where(m => m.ObjID == blogID).FirstOrDefault(); if (bcmsg != null) { MyRedisDB.SetRemove(key, bcmsg); bcmsg.Count += 1; MyRedisDB.SetAdd(key, bcmsg); } else { bcmsg = new CMsg(); bcmsg.ObjType = (int)EnumObjectType.姿势; bcmsg.ObjID = blogID; bcmsg.Count = 1; bcmsg.Date = DateTime.Now; bcmsg.Order = comment.Order; bcmsg.Title = blog.Title.MaxByteLength(32); MyRedisDB.SetAdd(key, bcmsg); } } return(Json(new { msg = "done", count = blog.CommentCount })); }
public void GetDisabledUsers() { String Arq = "Inativos_" + DateTime.Now.ToString("dd.MM.yyyy") + ".csv"; StreamWriter writer = new StreamWriter(@Arq, true); writer.WriteLine("Nome" + ";" + "Login" + ";" + "CPF"); ds.Filter = "(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))"; ds.SearchScope = SearchScope.Subtree; SearchResultCollection DisabledUsers = ds.FindAll(); FrmProgressBar FrmProgressBar = new FrmProgressBar(); FrmProgressBar.Show(); int i = 0; int progress; int total = DisabledUsers.Count; try { foreach (SearchResult DisabledUser in DisabledUsers) { LimparAtributos(); if (DisabledUser.GetDirectoryEntry().Properties["DisplayName"].Value != null) { User.Nome = DisabledUser.GetDirectoryEntry().Properties["Name"].Value.ToString(); } if (DisabledUser.GetDirectoryEntry().Properties["SamAccountName"].Value != null) { User.Login = DisabledUser.GetDirectoryEntry().Properties["SamAccountName"].Value.ToString(); } if (DisabledUser.GetDirectoryEntry().Properties["EmployeeNumber"].Value != null) { User.Cpf = DisabledUser.GetDirectoryEntry().Properties["EmployeeNumber"].Value.ToString(); } writer.WriteLine(User.Nome + ";" + User.Login + ";" + User.Cpf); i++; progress = (i / total * 100); FrmProgressBar.progressBar1.Value = progress; } } catch (Exception e) { MessageBox.Show(e.Message.ToString(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } finally { writer.Close(); } }
//TreeNewBee public ActionResult NewBeeList() { ViewBag.Login = CurrentUser != null; if (ViewBag.Login) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { ViewBag.DisableMsg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss"); } } return(View()); }
public async Task Add(DisabledUser disabledUser) { var disabledUserDto = _mapper.Map <DisabledUserDto>(disabledUser); disabledUserDto.Uuid = Guid.NewGuid(); if (!DisabledUserModelValid(disabledUserDto)) { throw new UnprocessableException(); } disabledUserDto.Uuid = Guid.NewGuid(); await _disabledUserDal.Add(disabledUserDto); }
public async Task <ActionResult> Add(DisabledUser disabledUser) { try { await _disabledUserLogic.Add(disabledUser); return(Ok()); } catch (Exception e) { _logLogic.Log(e); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public ActionResult AddBlogCommentReply(Guid commentID, Guid toUserID, string txt) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(txt)) { return(Json(new { msg = "参数错误" })); } if (txt.GetByteCount() > 400) { return(Json(new { msg = "参数太长" })); } BlogComment comment = BlogCommentDataSvc.GetByID(commentID); comment.ReplyCount += 1; BlogCommentReply reply = new BlogCommentReply(); reply.BlogCommentID = commentID; reply.Content = HttpUtility.HtmlEncode(txt); reply.ToUserID = toUserID; reply.OwnerID = CurrentUser.ID; reply.Order = comment.ReplyCount; BlogCommentReplyDataSvc.Add(reply); BlogCommentDataSvc.Update(comment); if (toUserID != CurrentUser.ID) { string key = MyRedisKeys.Pre_RMsg + toUserID; RMsg bcrmsg = new RMsg(); bcrmsg.ObjType = (int)EnumObjectType.姿势; bcrmsg.ObjID = comment.BlogID; bcrmsg.Date = DateTime.Now; bcrmsg.From = CurrentUser.UserName; bcrmsg.COrder = comment.Order; bcrmsg.ROrder = reply.Order; bcrmsg.Title = txt.MaxByteLength(32); MyRedisDB.SetAdd(key, bcrmsg); } return(Json(new { msg = "done" })); }
//新姿势 public ActionResult BlogNew() { string key = MyRedisKeys.Pre_BlogDraft + CurrentUser.ID; string draftval = MyRedisDB.StringGet(key); if (!string.IsNullOrEmpty(draftval)) { Blog draft = JsonConvert.DeserializeObject <Blog>(draftval); ViewBag.DraftBlog = draft; } DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { ViewBag.DisableMsg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss"); } return(View()); }
public ActionResult BlogCommentPage(Guid blogID, int pageSize, int pageNum = 1) { int totalCount; ViewBag.Login = CurrentUser != null; ViewBag.BlogCommentList = BlogCommentDataSvc.GetPagedEntitys(ref pageNum, pageSize, it => it.BlogID == blogID, it => it.InsertDate, false, out totalCount).ToList(); ViewBag.TotalCount = totalCount; ViewBag.CurrentPage = pageNum; if (ViewBag.Login) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { ViewBag.DisableMsg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss"); } ViewBag.CUID = CurrentUser.ID; } return(View()); }
public ActionResult UserOperate(string type, Guid uid, int objectType, int days = 0) { if (type == "启") { DisabledUser du = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == uid && d.ObjectType == objectType).FirstOrDefault(); MyRedisDB.SetRemove(MyRedisKeys.DisabledUsers, du); SysMsg msg = new SysMsg(); msg.Date = DateTime.Now; msg.Title = "你的账号已解封"; msg.Msg = "你的账号在" + Enum.GetName(typeof(EnumObjectType), objectType) + "版块中已解封"; string key = MyRedisKeys.Pre_SysMsg + uid; MyRedisDB.SetAdd(key, msg); } else { DisabledUser du = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == uid && d.ObjectType == objectType).FirstOrDefault(); if (du == null) { du = new DisabledUser(); du.UserID = uid; du.ObjectType = objectType; du.AbleDate = DateTime.Now.AddDays(days); MyRedisDB.SetAdd(MyRedisKeys.DisabledUsers, du); } else { MyRedisDB.SetRemove(MyRedisKeys.DisabledUsers, du); du.AbleDate = DateTime.Now.AddDays(days); MyRedisDB.SetAdd(MyRedisKeys.DisabledUsers, du); } SysMsg msg = new SysMsg(); msg.Date = DateTime.Now; msg.Title = "你的账号被封禁"; msg.Msg = "你在" + Enum.GetName(typeof(EnumObjectType), objectType) + "版块被封禁至" + du.AbleDate.ToString("yyyy-MM-dd HH:mm"); string key = MyRedisKeys.Pre_SysMsg + uid; MyRedisDB.SetAdd(key, msg); } return(Json(new { msg = "done" })); }
public ActionResult NewNewBee(string title, string mdTxt, string mdValue) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(mdTxt) || string.IsNullOrEmpty(mdValue)) { return(Json(new { msg = "参数错误" })); } if (title.GetByteCount() > 100 || mdTxt.GetByteCount() > 2500 || mdValue.GetByteCount() > 5000) { return(Json(new { msg = "参数太长" })); } NewBee nb = new NewBee(); nb.OwnerID = CurrentUser.ID; nb.Title = title; nb.FloorCount = 1; nb.LastFloorDate = DateTime.Now; nb.Top = false; NewBeeDataSvc.Add(nb); NewBeeFloor nbf = new NewBeeFloor(); nbf.MDText = mdTxt; nbf.MDValue = HtmlST.Sanitize(mdValue); nbf.NewBeeID = nb.ID; nbf.Order = 1; nbf.OwnerID = CurrentUser.ID; NewBeeFloorDataSvc.Add(nbf); return(Json(new { msg = "done" })); }
public ActionResult BlogNew(int type, string title, string mdTxt, string mdValue) { DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.姿势 && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { return(Json(new { msg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss") })); } if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(mdTxt) || string.IsNullOrEmpty(mdValue)) { return(Json(new { msg = "参数错误" })); } if (title.GetByteCount() > 90 || mdTxt.GetByteCount() > 50000 || mdValue.GetByteCount() > 100000) { return(Json(new { msg = "参数太长" })); } if (type < 0 || type > 4) { type = 0; } //内容无害化 mdValue = HtmlST.Sanitize(mdValue); Blog nblog = new Blog(); nblog.Type = type; nblog.Title = title; nblog.MDText = mdTxt; nblog.MDValue = mdValue; nblog.OwnerID = CurrentUser.ID; BlogDataSvc.Add(nblog); //发布成功删除草稿 string key = MyRedisKeys.Pre_BlogDraft + CurrentUser.ID; MyRedisDB.DelKey(key); return(Json(new { msg = "done", url = Url.Action("BlogList") })); }
void When(DisabledUser @event) { _disabled = true; _roles.Clear(); }
public void GetUsersByGroup(String[] grupos) { foreach (string grupo in grupos) { String Arq = grupo + "_" + DateTime.Now.ToString("dd.MM.yyyy") + ".csv"; StreamWriter writer = new StreamWriter(@Arq, true); writer.WriteLine("Nome" + ";" + "Login" + ";" + "CPF" + ";" + "Status"); ds.Filter = "(&(objectCategory=group)(cn=" + grupo + "))"; ds.SearchScope = SearchScope.Subtree; SearchResult grp = ds.FindOne(); string dnGrupo = grp.GetDirectoryEntry().Properties["distinguishedname"].Value.ToString(); try { ds.Filter = "(&(memberOf=" + dnGrupo + ")(!userAccountControl:1.2.840.113556.1.4.803:=2))"; SearchResultCollection EnabledUsers = ds.FindAll(); foreach (SearchResult Enabled in EnabledUsers) { LimparAtributos(); if (Enabled.GetDirectoryEntry().Properties["DisplayName"].Value != null) { User.Nome = Enabled.GetDirectoryEntry().Properties["Name"].Value.ToString(); } if (Enabled.GetDirectoryEntry().Properties["SamAccountName"].Value != null) { User.Login = Enabled.GetDirectoryEntry().Properties["SamAccountName"].Value.ToString(); } if (Enabled.GetDirectoryEntry().Properties["EmployeeNumber"].Value != null) { User.Cpf = Enabled.GetDirectoryEntry().Properties["EmployeeNumber"].Value.ToString(); } writer.WriteLine(User.Nome + ";" + User.Login + ";" + User.Cpf + ";" + "Ativo"); } ds.Filter = "(&(memberOf=" + dnGrupo + ")(userAccountControl:1.2.840.113556.1.4.803:=2))"; SearchResultCollection DisabledUsers = ds.FindAll(); foreach (SearchResult DisabledUser in DisabledUsers) { LimparAtributos(); if (DisabledUser.GetDirectoryEntry().Properties["DisplayName"].Value != null) { User.Nome = DisabledUser.GetDirectoryEntry().Properties["Name"].Value.ToString(); } if (DisabledUser.GetDirectoryEntry().Properties["SamAccountName"].Value != null) { User.Login = DisabledUser.GetDirectoryEntry().Properties["SamAccountName"].Value.ToString(); } if (DisabledUser.GetDirectoryEntry().Properties["EmployeeNumber"].Value != null) { User.Cpf = DisabledUser.GetDirectoryEntry().Properties["EmployeeNumber"].Value.ToString(); } writer.WriteLine(User.Nome + ";" + User.Login + ";" + User.Cpf + ";" + "Inativo"); } } catch (Exception e) { MessageBox.Show(e.Message.ToString(), "Erro Grupos", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } finally { writer.Close(); } } }
//NewBee详情 public ActionResult NewBeeView(Guid id, int co = 0, int ro = 0) { NewBee newBee = NewBeeDataSvc.GetByID(id); ViewBag.NewBee = newBee; ViewBag.Login = CurrentUser != null; ViewBag.Owner = CurrentUser != null ? CurrentUser.ID == newBee.OwnerID : false; ViewBag.COrder = co; ViewBag.ROrder = ro; newBee.ViewCount += 1; NewBeeDataSvc.Update(newBee); if (CurrentUser != null) { //查看次数 暂时不用户统计 //string key = MyRedisKeys.Pre_UserRecord + CurrentUser.ID; //IEnumerable<UserRecord> userRecords = MyRedisDB.GetSet<UserRecord>(key); //if (userRecords.Count() == 0) //{ // MyRedisDB.SetAdd(key, new UserRecord() { ObjID = newBee.ID, type = (int)EnumRecordType.查看 }); // MyRedisDB.RedisDB.KeyExpire(key, DateTime.Now.AddDays(1)); // newBee.ViewCount += 1; // NewBeeDataSvc.Update(newBee); //} //else if (userRecords.Where(r => r.ObjID == newBee.ID && r.type == (int)EnumRecordType.查看).Count() == 0) //{ // MyRedisDB.SetAdd(key, new UserRecord() { ObjID = newBee.ID, type = (int)EnumRecordType.查看 }); // newBee.ViewCount += 1; // NewBeeDataSvc.Update(newBee); //} //收藏 ViewBag.ShowStar = true; string starKey = MyRedisKeys.Pre_UserStarCache + CurrentUser.ID; IEnumerable <UserStarCache> userStarCaches = MyRedisDB.GetSet <UserStarCache>(starKey); if (userStarCaches.Count() == 0) { IEnumerable <UserStar> userStars = UserStarDataSvc.GetByCondition(s => s.OwnerID == CurrentUser.ID); if (userStars.Count() > 0) { if (userStars.Where(s => s.ObjID == newBee.ID).Count() > 0) { ViewBag.ShowStar = false; } //添加收藏缓存 foreach (UserStar star in userStars) { MyRedisDB.SetAdd(starKey, new UserStarCache() { ObjID = newBee.ID, ObjType = star.ObjType }); } MyRedisDB.RedisDB.KeyExpire(starKey, DateTime.Now.AddHours(3)); } } else if (userStarCaches.Where(s => s.ObjID == newBee.ID).Count() > 0) { ViewBag.ShowStar = false; } DisabledUser user = MyRedisDB.GetSet <DisabledUser>(MyRedisKeys.DisabledUsers).Where(d => d.UserID == CurrentUser.ID && d.ObjectType == (int)EnumObjectType.NewBee && d.AbleDate > DateTime.Now).FirstOrDefault(); if (user != null) { ViewBag.DisableMsg = "你被封禁至" + user.AbleDate.ToString("yyyy-MM-dd HH:ss"); } } return(View()); }