Exemplo n.º 1
0
 public WebSocketClient(HttpContext context, WebSocket webSocket)
 {
     this.ID        = Guid.NewGuid();
     this.WebSocket = webSocket;
     this.Host      = context.Request.Host.Value;
     this.Query     = context.Request.Query.ToDictionary(t => t.Key, t => t.Value.ToString());
     this.Headers   = context.Request.Headers.ToDictionary(t => t.Key, t => t.Value.ToString());
     this.IpAddress = IPAgent.GetIP(context);
     this.Join      = WebAgent.GetTimestamps();
 }
Exemplo n.º 2
0
        public Result Info()
        {
            SystemAdmin admin = AdminAgent.Instance().GetAdminInfo(this.AdminInfo);

            return(this.GetResultContent(new
            {
                admin.ID,
                admin.Name,
                admin.LoginAt,
                admin.LoginIP,
                IPAddress = IPAgent.GetAddress(admin.LoginIP),
                admin.Face
            }));
        }
Exemplo n.º 3
0
        public Result GetList()
        {
            var list = BDC.SystemAdmin.Where(t => t.Status != SystemAdmin.AdminStatus.Delete).OrderByDescending(t => t.ID).AsEnumerable();

            return(this.GetResultContent(this.GetResultList(list, t => new
            {
                t.ID,
                t.Name,
                t.Face,
                t.Status,
                t.LoginAt,
                t.LoginIP,
                IPAddress = IPAgent.GetAddress(t.LoginIP).ToString(),
                IsSecretKey = t.SecretKey != Guid.Empty
            })));
        }
Exemplo n.º 4
0
        public Task GetAdminList([FromForm] int siteId)
        {
            IEnumerable <SiteAdmin> list = SiteAdminAgent.Instance().GetAdminList(siteId);

            return(this.GetResult(this.ShowResult(list, t => new
            {
                t.ID,
                t.SiteID,
                t.AdminName,
                t.IsDefault,
                t.Status,
                t.LoginAt,
                t.LoginIP,
                IsSecretKey = t.SecretKey != Guid.Empty,
                IPAddress = IPAgent.GetAddress(t.LoginIP),
                t.CreateAt
            })));
        }
Exemplo n.º 5
0
 public async Task Invoke(HttpContext context)
 {
     if (context.WebSockets.IsWebSocketRequest)
     {
         ws = ToolsFactory.GetWebSocket(context);
         if (ws == null)
         {
             throw new ResultException("不支持WebSocket连接");
         }
         //后台成功接收到连接请求并建立连接后,前台的webSocket.onopen = function (event){}才执行
         WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(true);;
         Dictionary <string, string> data = context.Request.Query.ToDictionary(t => t.Key, t => t.Value.ToString());
         if (!data.ContainsKey("IP"))
         {
             data.Add("IP", IPAgent.GetIP(context));
         }
         if (!data.ContainsKey("IPAddress"))
         {
             data.Add("IPAddress", IPAgent.GetAddress(IPAgent.GetIP(context)));
         }
         wsClient = ws.Register(new WebSocketClient
         {
             ID        = Guid.NewGuid(),
             WebSocket = webSocket,
             Query     = data
         });
         try
         {
             await Handler(wsClient);
         }
         catch (Exception ex)
         {
             await context.Response.WriteAsync(ex.Message).ConfigureAwait(true);;
         }
         finally
         {
             ws.Remove(wsClient);
         }
     }
     else
     {
         await _next(context).ConfigureAwait(true);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 保存错误日志
        /// </summary>
        /// <param name="model"></param>
        public void SaveLog(ErrorLogModel model)
        {
            ErrorLog log = new ErrorLog()
            {
                SiteID    = model.SiteID,
                UserID    = model.UserID,
                CreateAt  = DateTime.Now,
                Title     = model.Title.Left(100),
                Content   = model.Content,
                IP        = model.IP,
                IPAddress = IPAgent.GetAddress(model.IP),
                ErrorID   = model.RequestID
            };

            using (DbExecutor db = NewExecutor())
            {
                log.Add(db);
            }
        }