static void Test4() { foreach (var item in PushPositionQueue.QUEUE_SYMBOLS) { Console.WriteLine($"{item.Value} receive start..."); MQConsumer.ReceiveMessage(item.Value, m => { string msg = Encoding.UTF8.GetString(m); Console.WriteLine($"{item.Value}:{msg}"); try { PushModel model = JsonConvert.DeserializeObject <PushModel>(msg); IConsumeHandler consumeHandler = ConsumeFactory.Create(model.PositionType); consumeHandler.Process(model); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Process failure:{CommonCs.GetExceptionMessages(ex)}"); Console.ResetColor(); } }); } }
//public static string GetShowName(string nameRemark, string name, string symbol) //{ // if (!string.IsNullOrEmpty(nameRemark)) // { // return nameRemark; // } // return GetShowName(nameRemark, name); //} public static string BuildToken(int userId) { byte[] guid = Guid.NewGuid().ToByteArray(); string key = Convert.ToString(userId, 2); string token = key + "-" + String.Join("-", guid); return(CommonCs.GetMd5Str32(token)); }
// GET: User public ActionResult List(int page = 0) { int pageCount = 20; int recordCount = userService.GetUserCount(); ViewBag.UseList = userService.GetUserList(page, pageCount); ViewBag.PageHtml = CommonCs.GetPageHtmlStr(recordCount, pageCount, page, 8, "/User/List", ""); return(View()); }
/// <summary> /// 审核发布 /// </summary> /// <param name="id"></param> /// <param name="error"></param> /// <returns></returns> public int Publish(int id, int categoryId, out string error) { error = ""; if (id <= 0) { error = "参数错误"; return(0); } if (categoryId <= 0) { error = "发布类型错误"; return(0); } var model = dbContext.t_article_coll.Where(a => a.id == id).FirstOrDefault(); if (model == null) { error = "发布的数据不存在"; return(0); } if (model.status != ArticleAuditStatus.Auditing) { error = "发布数据的状态错误"; return(0); } int result = this.Action(new Article() { Id = 0, Author = model.author, CategoryId = categoryId, Contents = model.contents, Summary = CommonCs.GetChineseWord(model.contents), Keys = "", Title = model.title, Recommend = false, }, out error); if (result <= 0) { //error = "发布失败"; return(0); } try { model.status = ArticleAuditStatus.Complete; dbContext.SaveChanges(); return(1); } catch (Exception ex) { error = ex.Message; return(0); } }
public ActionResult Comments() { int page = CommonCs.GetObjToInt(Request.Params["page"]); int pageCount = 30; int recordCount = 0; ViewBag.Comments = service.Comments(page, pageCount, out recordCount); ViewBag.PageHtml = CommonCs.GetPageHtmlStr(recordCount, pageCount, page, 8, "/Article/Comments/", ""); ViewBag.CurrUrl = string.Format("/Article/Comments?page={0}", page); return(View()); }
public ActionResult FeedBack() { int page = CommonCs.GetObjToInt(Request.Params["page"]); int pageCount = 30; int recordCount = 0; ViewBag.FeedBacks = fdService.List(null, page, pageCount, out recordCount); ViewBag.PageHtml = CommonCs.GetPageHtmlStr(recordCount, pageCount, page, 8, "/User/FeedBack/", ""); TempData["ReferUrl"] = string.Format("/User/FeedBack?page={0}", page); return(View()); }
public ActionResult List() { //string Email = Request.Params["email"];//Email //int State = Convert.ToInt32(Request.Params["state"]);//状态 //DateTime? startDate = CommonCs.GetObjToDateTime2(Request.Params["startdate"]);//开始日期 //DateTime? endDate = CommonCs.GetObjToDateTime2(Request.Params["enddate"]);//结束日期 int page = CommonCs.GetObjToInt(Request.Params["page"]); int pageCount = 30; int recordCount = 0; ViewBag.ArticleList = service.List(page, pageCount, out recordCount); ViewBag.PageHtml = CommonCs.GetPageHtmlStr(recordCount, pageCount, page, 8, "/Article/List/", ""); TempData["ReferUrl"] = string.Format("/Article/List?page={0}", page); return(View()); }
/// <summary> /// 分断接收处理 /// </summary> /// <param name="token"></param> /// <returns></returns> public Response <ResxResult> Video(string token = null) { if (string.IsNullOrEmpty(token)) { token = "88888888"; } var ret = this.CheckToken(token); if (!ret.Item1) { return(GetResult(GMSF.ResponseResult.FAILED, "TOKEN 验证失败")); } //System.Threading.Thread.Sleep(1000); ResxModel resxModel = new ResxModel() { UserId = ret.Item2, ResxType = ResxType.ChatVideo, ResxSize = ResxConfigManager.VIDEO_MAX_SIZE, ResxTypes = ResxConfigManager.VIDEO_FILE_TYPES }; try { VideoHandler2 resx = new VideoHandler2( HttpContext.Current.Request.Files, resxModel, CommonCs.GetObjToInt(HttpContext.Current.Request.Form["chunkindex"]), CommonCs.GetObjToInt(HttpContext.Current.Request.Form["chunkcount"]), HttpContext.Current.Request.Form["tempfileurl"] ); //log.WriterLog("Video : chunkIndex="+ CommonCs.GetObjToInt(HttpContext.Current.Request.Form["chunkindex"]) + " chunkCount=" + CommonCs.GetObjToInt(HttpContext.Current.Request.Form["chunkcount"]) + " tempfileurl=" + HttpContext.Current.Request.Form["tempfileurl"]); var responseResult = resx.SaveStream(); var res = GetResult(GMSF.ResponseResult.SUCCESS, null, responseResult); return(res); } catch (Exception ex) { //log.WriterLog(ex.Message); return(GetResult(GMSF.ResponseResult.FAILED, ex.Message)); } }
public int Add(FeedBack model, out string error) { error = ""; if (model == null || string.IsNullOrEmpty(model.Title) || string.IsNullOrEmpty(model.Contents)) { error = "内容不能为空"; return(0); } if (model.Title.Length > 50 || model.Contents.Length > 300) { error = "反馈内容的字数超过范围"; return(0); } string ip = CommonCs.GetHostAddress(); t_feedback entity = new t_feedback() { contents = model.Contents, title = model.Title, from_ip = ip, from_area = BaiduIPAdressAPI.GetAddress(ip), create_time = DateTime.Now, status = FeedBackStatus.Unread, }; try { dbContext.t_feedback.Add(entity); dbContext.SaveChanges(); return(1); } catch (Exception ex) { error = ex.Message; return(0); } }
public string CreateTimeStr() { return(CommonCs.DateFormatToString(this.CreateTime)); }
/// <summary> /// 添加评论 /// </summary> /// <param name="model"></param> /// <param name="error"></param> /// <returns></returns> public ArticleComments AddComment(ArticleComment model, out string error) { error = ""; if (model == null) { error = "评论模型不能为空"; return(null); } if (model.ArticleId <= 0) { error = "参数错误"; return(null); } if (string.IsNullOrEmpty(model.Contents)) { error = "评论内容不能为空"; return(null); } if (model.Contents.Length > 200) { error = "评论字数只能在200字以内"; return(null); } string ip = CommonCs.GetIP(); t_article_comments entity = new t_article_comments() { article_id = model.ArticleId, contents = model.Contents, parent_id = model.ParentId, user_id = model.UserId, from_ip = ip, from_area = BaiduIPAdressAPI.GetAddress(ip), child_count = 0, status = CommentStatus.Show, create_time = DateTime.Now, }; try { dbContext.t_article_comments.Add(entity); dbContext.SaveChanges(); #region 更新文章评论数,更新评论回复数 if (entity.id > 0)//表示添加评论成功 { //更新文章评论数 if (entity.article_id > 0) { this.UpdateArticleCommentCount(entity.article_id); } //更新评论回复数 if (entity.parent_id > 0) { this.UpdateCommentCount(entity.parent_id); } } #endregion return(new ArticleComments() { ArticleId = entity.article_id, ChildCount = entity.child_count, CommentId = entity.id, Contents = entity.contents, CreateTime = entity.create_time, FromArea = entity.from_area, UserId = entity.user_id, UserImage = base.defaultUserImgUrl, UserName = "******", }); } catch (Exception ex) { error = ex.Message; return(null); } }
/// <summary> /// 更新,添加 /// </summary> /// <param name="model"></param> /// <param name="error"></param> /// <returns></returns> public int Action(Article model, out string error) { error = ""; if (model == null) { error = "数据不能为空"; return(0); } if (string.IsNullOrWhiteSpace(model.Title)) { error = "标题不能为空"; return(0); } if (string.IsNullOrWhiteSpace(model.Contents)) { error = "内容不能为空"; return(0); } //if (model.Contents.Length > 2000) //{ // error = "内容字数在2000个以内"; // return 0; //} if (string.IsNullOrEmpty(model.ImgUrl)) { model.ImgUrl = CommonCs.GetImageSrc(model.Contents); } if (model.Id > 0)//更新 { var artModel = dbContext.t_article.Where(a => a.id == model.Id).FirstOrDefault(); if (artModel == null) { error = "更新失败"; return(0); } artModel.category = model.CategoryId; artModel.title = model.Title; artModel.keys = model.Keys; if (string.IsNullOrEmpty(artModel.keys))//关键字处理 { artModel.keys = SCWSSegment.ParserStr(model.Title); } artModel.contents = model.Contents; if (string.IsNullOrEmpty(model.Summary))//摘要处理 { artModel.summary = CommonCs.GetChineseWord(model.Contents); } artModel.author = model.Author; artModel.read_count = model.ReadCount; artModel.update_time = DateTime.Now; artModel.recommend = model.Recommend ? 1 : 0; artModel.img_url = model.ImgUrl; } else //添加 { if (string.IsNullOrEmpty(model.Keys))//关键字处理 { model.Keys = SCWSSegment.ParserStr(model.Title); } model.ImgUrl = CommonCs.GetImageSrc(model.Contents); model.CreateTime = DateTime.Now; model.UpdateTime = DateTime.Now; dbContext.t_article.Add(model.ConvertTo()); } try { dbContext.SaveChanges(); return(1); } catch (Exception ex) { error = ex.Message; return(0); } }