/// <summary> /// 添加站内信阅读日志 /// </summary> /// <param name="logModel">The log model.</param> /// <returns>true if XXXX, false otherwise.</returns> public static bool AddMailReadLog(ReadLogModel logModel) { using (var dal = FactoryDispatcher.LogFactory()) { return(dal.AddMailReadLog(logModel)); } }
/// <summary> /// 添加资讯阅读日志 /// </summary> /// <param name="logModel">The log model.</param> /// <returns>true if XXXX, false otherwise.</returns> /// <exception cref="NotImplementedException"></exception> public bool AddReadLog(ReadLogModel logModel) { string strSql = "insert into BM_ReadLog(UserId,ArticleId,IsRead,ClientIp,cookie,ReadTime) values(@UserId,@ArticleId,@IsRead,@ClientIp,@cookie,@ReadTime)"; var param = new[] { new SqlParameter("@UserId", logModel.UserId), new SqlParameter("@ArticleId", logModel.ArticleId), new SqlParameter("@IsRead", logModel.IsRead), new SqlParameter("@ClientIp", logModel.ClientIp), new SqlParameter("@cookie", logModel.cookie), new SqlParameter("@ReadTime", logModel.ReadTime) }; return(DbHelperSQLP.ExecuteNonQuery(WebConfig.getConnectionString(), CommandType.Text, strSql, param) > 0); }
public new void ProcessRequest(HttpContext context) { int articleId = GetFormValue("articleId", 0); string auth = GetFormValue("auth", ""); string json = string.Empty; int userId = 0; if (!string.IsNullOrEmpty(auth)) { userId = UserLogic.GetUserIdByAuthToken(auth); } else { json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效)); context.Response.ContentType = "application/json"; context.Response.Write(json); } ArticleModel data = ArticleLogic.GetModel(articleId); json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK, data)); //相同的资讯是否被一个人浏览(cookie + Ip) string clientip = GetClientIP; string cookie = CookieHelper.GetCookieVal("HOTBMUSER"); if (cookie == "") { cookie = Guid.NewGuid().ToString("n"); CookieHelper.SetCookieValByCurrentDomain("HOTBMUSER", 1, cookie); } if (cookie.Length != 32) { goto Finish; } ReadLogModel logModel = new ReadLogModel() { UserId = userId, cookie = cookie, ClientIp = clientip, ArticleId = articleId, IsRead = 1, ReadTime = DateTime.Now }; int type = data.AuthorIdentity; //判断是否已经阅读 if (!LogLogic.IsRead(articleId, type, userId, cookie, clientip)) { //添加阅读日志 if (type == 3 || type == 4) { LogLogic.UpdateReadStatus(userId, articleId); } else { LogLogic.AddReadLog(logModel); } ArticleLogic.UpdateArticleAmount(articleId); } goto Finish; Finish: context.Response.ContentType = "application/json"; context.Response.Write(json); }
public new void ProcessRequest(HttpContext context) { try { int articleId = GetFormValue("articleId", 0); string auth = GetFormValue("auth", ""); string json = string.Empty; int userId = 0; if (!string.IsNullOrEmpty(auth)) { userId = UserLogic.GetUserIdByAuthToken(auth); if (userId == 0) { json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效)); context.Response.ContentType = "application/json"; context.Response.Write(json); context.Response.End(); } } //else //{ // json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效)); // context.Response.ContentType = "application/json"; // context.Response.Write(json); // context.Response.End(); //} MailModel data = ArticleLogic.GetMailModel(articleId); json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK, data)); ReadLogModel logModel = new ReadLogModel() { UserId = userId, cookie = "", ClientIp = "", ArticleId = articleId, IsRead = 1, ReadTime = DateTime.Now }; if (data != null && userId > 0) { //判断是否已经阅读 if (!LogLogic.IsMailRead(articleId, userId)) { LogLogic.UpdateMailReadStatus(userId, articleId); } //else //LogLogic.AddMailReadLog(logModel); } goto Finish; Finish: context.Response.ContentType = "application/json"; context.Response.Write(json); } catch (Exception ex) { LogHelper.Log(string.Format("message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR); } }
public ActionResult create(string title, string content, string ids) { try { var user = GetUserData(); //ArticleModel model = new ArticleModel(); //model.ArticleBody = content; //model.ArticleIntro = title; //model.ArticleTitle = title; //model.ArticleCover = ""; //model.ArticleStatus = 1; //model.AuthorId = user.UserId; //model.AuthorIdentity = user.UserIdentity == 0 ? 4 : 3; //model.AuthorName = user.RealName; //model.EnablePublish = 1; //model.EnableTop = 0; //model.PublishTime = DateTime.Now; //model.TopTime = DateTime.Now; //model.UpdateTime = DateTime.Now; ////如果当前创建资讯的用户身份为盟友,则发送目标为盟主的ID ////如果当前创建资讯的用户身份为盟主时,则发送目标为 2(盟友) //model.SendTargetId = user.UserIdentity == 1 ? 2 : user.BelongOne; string[] TargetIds = null; //如果是盟主身份,则需要判断发送目标 if (user.UserIdentity == 1) { if (string.IsNullOrEmpty(ids)) { return(Json(new ResultModel(ApiStatusCode.缺少发送目标))); } TargetIds = ids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (TargetIds.Length <= 0) { return(Json(new ResultModel(ApiStatusCode.缺少发送目标))); } } MailModel model = new MailModel(); model.AuthorId = user.UserId; model.AuthorName = user.NickName; model.Title = title; model.BodyContent = content; model.CoverUrl = user.UserHeadImg; model.SendType = ids == "-1" ? 2 : user.UserIdentity == 1 ? 0 : 1; model.ReplyPid = 0; model.ReplyUserId = 0; int articleId = ArticleLogic.AddMailInfo(model); ApiStatusCode apiCode = ApiStatusCode.OK; if (articleId > 0) { ReadLogModel logModel = new ReadLogModel() { ArticleId = articleId, ClientIp = "", cookie = "", IsRead = 0, ReadTime = DateTime.Now }; if (user.UserIdentity == 1) { foreach (var TargetId in TargetIds) { logModel.UserId = Convert.ToInt32(TargetId); //LogLogic.AddReadLog(logModel); LogLogic.AddMailReadLog(logModel); } } else { logModel.UserId = user.BelongOne; LogLogic.AddMailReadLog(logModel); } //将自己也添加进去,这样自己就可以看到自己发布的信息 logModel.UserId = user.UserId; logModel.IsRead = 1; LogLogic.AddMailReadLog(logModel); } else { apiCode = ApiStatusCode.发送失败; } return(Json(new ResultModel(apiCode))); } catch (Exception ex) { LogHelper.Log(string.Format("create:message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR); return(Json(new ResultModel(ApiStatusCode.SERVICEERROR))); } }
public ActionResult create(string title, string content, string ids) { var user = GetUserData(); ArticleModel model = new ArticleModel(); model.ArticleBody = content; model.ArticleIntro = content; model.ArticleTitle = title; model.ArticleCover = ""; model.ArticleStatus = 1; model.AuthorId = user.UserId; model.AuthorIdentity = user.UserIdentity == 0 ? 4 : 3; model.AuthorName = user.RealName; model.EnablePublish = 1; model.EnableTop = 0; model.PublishTime = DateTime.Now; model.TopTime = DateTime.Now; model.UpdateTime = DateTime.Now; //如果当前创建资讯的用户身份为盟友,则发送目标为盟主的ID //如果当前创建资讯的用户身份为盟主时,则发送目标为 2(盟友) model.SendTargetId = user.UserIdentity == 1 ? 2 : user.BelongOne; string[] TargetIds = null; //如果是盟主身份,则需要判断发送目标 if (user.UserIdentity == 1) { if (string.IsNullOrEmpty(ids)) { return(Json(new ResultModel(ApiStatusCode.缺少发送目标))); } TargetIds = ids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (TargetIds.Length <= 0) { return(Json(new ResultModel(ApiStatusCode.缺少发送目标))); } } int articleId = ArticleLogic.AddArticle(model); ApiStatusCode apiCode = ApiStatusCode.OK; if (articleId > 0) { ReadLogModel logModel = new ReadLogModel() { ArticleId = articleId, ClientIp = "", cookie = "", IsRead = 0, ReadTime = DateTime.Now }; if (user.UserIdentity == 1) { foreach (var TargetId in TargetIds) { logModel.UserId = Convert.ToInt32(TargetId); LogLogic.AddReadLog(logModel); } } else { logModel.UserId = user.BelongOne; LogLogic.AddReadLog(logModel); } } else { apiCode = ApiStatusCode.发送失败; } return(Json(new ResultModel(apiCode))); }
public new void ProcessRequest(HttpContext context) { try { int articleId = GetFormValue("articleId", 0); string auth = GetFormValue("auth", ""); string json = string.Empty; int userId = 0; if (!string.IsNullOrEmpty(auth)) { userId = UserLogic.GetUserIdByAuthToken(auth); if (userId == 0) { json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.令牌失效)); context.Response.ContentType = "application/json"; context.Response.Write(json); context.Response.End(); } } ArticleModel data = ArticleLogic.GetModel(articleId); if (data != null) { if (!string.IsNullOrEmpty(data.ArticleCover)) { data.ArticleCover = WebConfig.articleDetailsDomain() + data.ArticleCover; } else { data.ArticleCover = "http://" + context.Request.Url.Host + "/app/images/appShareLogo.png"; } } json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK, data)); //相同的资讯是否被一个人浏览(cookie + Ip) string clientip = GetClientIP; string cookieKey = "HOTBMUSER" + articleId.ToString(); string cookie = CookieHelper.GetCookieVal(cookieKey); if (string.IsNullOrEmpty(cookie) && userId == 0) { cookie = Guid.NewGuid().ToString("n"); CookieHelper.SetCookieValByCurrentDomain(cookieKey, 1, cookie); } else { cookie = string.Empty; } if (cookie.Length != 32 && userId == 0) { goto Finish; } ReadLogModel logModel = new ReadLogModel() { UserId = userId, cookie = cookie, ClientIp = clientip, ArticleId = articleId, IsRead = 1, ReadTime = DateTime.Now }; if (data != null) { int type = data.AuthorIdentity; //判断是否已经阅读 if (!LogLogic.IsRead(articleId, type, userId, cookie, clientip)) { //添加阅读日志 if (type == 3 || type == 4) { if (LogLogic.IsRead(userId, articleId)) { LogLogic.UpdateReadStatus(userId, articleId); } else { LogLogic.AddReadLog(logModel); } } else { LogLogic.AddReadLog(logModel); } ArticleLogic.UpdateArticleAmount(articleId); } } goto Finish; Finish: context.Response.ContentType = "application/json"; context.Response.Write(json); } catch (Exception ex) { LogHelper.Log(string.Format("message:{0},StackTrace:{1}", ex.Message, ex.StackTrace), LogHelperTag.ERROR); } }