Example #1
0
        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);
            }
        }