yzh
2022-06-30 ba73ec7987459b7bc5710798e8b4989cfe0e13a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Web;
using System.Web.SessionState;
 
public abstract class PageHandler<T> : IHttpHandler, IRequiresSessionState where T : ISessionObject
{
    public bool IsReusable
    {
        get
        {
            return true;
        }
    }
 
    public abstract JsonPageResult ProcessRequestInternal(PageContext<T> context);
 
    public void ProcessRequest(HttpContext context)
    {
        PageContext<T> context1 = new PageContext<T>(context);
        JsonPageResult jsonPageResult;
        try
        {
            string @string = context1.GetString("action");
            if (!context1.IsValid && @string != "login" && @string != "logout")
                throw new Exception("由于长时间未操作,请重新登陆平台!");
            jsonPageResult = this.ProcessRequestInternal(context1);
        }
        catch (Exception ex)
        {
            jsonPageResult = new JsonPageResult(false, (object)ex.Message);
        }
        IsoDateTimeConverter dateTimeConverter = new IsoDateTimeConverter();
        dateTimeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        context.Response.ContentType = "application/json";
        string s = JsonConvert.SerializeObject((object)jsonPageResult, Formatting.Indented, new JsonConverter[1]
        {
      (JsonConverter) dateTimeConverter
        });
        context.Response.Write(s);
        context.Response.End();
    }
}