Ejemplo n.º 1
0
        public string RegisterWatch([FromBody] RegisterRequest request, [FromServices] WatchDog watchDog)
        {
            var registerContext = WatchDagServerContext.RegisterContext.FirstOrDefault(temp => temp.Token == request.Token);

            if (registerContext == null)
            {
                // 恭喜你,是第一次注册,汪
                registerContext = new RegisterContext
                {
                    Token = request.Token,
                };
                WatchDagServerContext.RegisterContext.Add(registerContext);
            }
            // 更新一下数据
            registerContext.CurrentDelayCount = 0;
            registerContext.MaxDelayCount     = request.MaxDelayCount;
            registerContext.DelaySecond       = request.DelaySecond;
            registerContext.LastRegisterTime  = DateTimeOffset.Now;

            WatchDagServerContext.SaveChanges();

            watchDog.AddWatch(registerContext);

            return($"注册成功,汪");
        }
 public RegisterContextsController(WatchDagServerContext context)
 {
     _context = context;
 }
Ejemplo n.º 3
0
 public DogController(WatchDagServerContext watchDagServerContext, ILogger <DogController> logger)
 {
     WatchDagServerContext = watchDagServerContext;
     Logger = logger;
 }