コード例 #1
0
        public async Task <IActionResult> Delete([FromBody] ServerNodeVM model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var node = await _serverNodeService.GetAsync(model.Address);

            if (node == null)
            {
                return(Json(new
                {
                    success = false,
                    message = "未找到对应的节点。"
                }));
            }

            var result = await _serverNodeService.DeleteAsync(node);

            if (result)
            {
                await _sysLogService.AddSysLogSync(new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"删除节点:{node.Address}"
                });
            }
            return(Json(new
            {
                success = result,
                message = !result ? "删除节点失败,请查看错误日志" : ""
            }));
        }
コード例 #2
0
        public async Task <IActionResult> Delete([FromBody] ServerNodeVM model)
        {
            if (Appsettings.IsPreviewMode)
            {
                return(Json(new
                {
                    success = false,
                    message = "演示模式请勿删除节点"
                }));
            }
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var node = await _serverNodeService.GetAsync(model.Address);

            if (node == null)
            {
                return(Json(new
                {
                    success = false,
                    message = "未找到对应的节点。"
                }));
            }

            var result = await _serverNodeService.DeleteAsync(node);

            if (result)
            {
                TinyEventBus.Instance.Fire(EventKeys.ADD_SYSLOG, new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"删除节点:{node.Address}"
                });
            }
            return(Json(new
            {
                success = result,
                message = !result ? "删除节点失败,请查看错误日志" : ""
            }));
        }
コード例 #3
0
        public async Task <IActionResult> Delete([FromBody] ServerNodeVM model)
        {
            if (Appsettings.IsPreviewMode)
            {
                return(Json(new
                {
                    success = false,
                    message = "演示模式请勿删除节点"
                }));
            }
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var node = await _serverNodeService.GetAsync(model.Address);

            if (node == null)
            {
                return(Json(new
                {
                    success = false,
                    message = "未找到对应的节点。"
                }));
            }

            var result = await _serverNodeService.DeleteAsync(node);

            if (result)
            {
                dynamic param = new ExpandoObject();
                param.node     = node;
                param.userName = this.GetCurrentUserName();
                TinyEventBus.Instance.Fire(EventKeys.DELETE_NODE_SUCCESS, param);
            }
            return(Json(new
            {
                success = result,
                message = !result ? "删除节点失败,请查看错误日志" : ""
            }));
        }