/// <summary> /// 通知管理有心任务来了 /// </summary> /// <param name="order"></param> /// <returns></returns> private async Task NotificationToAdmin(WOrder_Order order) { UserNotification userNotification = new UserNotification(); NotificationData notificationData = new NotificationData(); notificationData["category"] = order.Category; notificationData["title"] = order.ItemName; userNotification.Notification = new TenantNotification() { CreationTime = DateTime.Now, NotificationName = "新消息", Severity = NotificationSeverity.Info, Data = notificationData }; userNotification.TenantId = AbpSession.GetTenantId(); //通知管理员 userNotification.UserId = 1; userNotification.Id = Guid.NewGuid(); //实时通知 await _realTimeNotifier.SendNotificationsAsync(new UserNotification[] { userNotification }); //记录消息 await _messageService.Create(new CreateMessageInput() { Title = order.Category, Content = order.ItemName, UserId = 1, //派单 AppPage = "Assign", SrcId = order.Id }); }
public void Exit(string nodeId) { var message = new CreateMessageInput { ApplicationName = "NULL", Name = Core.Entities.Message.ExitMessageName, NodeId = nodeId, TaskId = 0 }; Logger.Information($"Exit node: {nodeId}."); _messageAppService.Create(message); }
private string PushTask(Core.Entities.Task task) { var nodes = _nodeAppService.GetAvailable(task.Os, task.NodeType, task.NodeCount); if (nodes.Count == 0) { // TODO LOG return(null); } var identity = Guid.NewGuid().ToString("N"); var messages = new List <CreateMessageInput>(); foreach (var node in nodes) { var arguments = string.Concat(task.Arguments, task.IsSingle ? " --tid:" : " ", task.Id, task.IsSingle ? " -i:" : " ", identity); var msg = new CreateMessageInput { TaskId = task.Id, ApplicationName = task.ApplicationName, Name = Core.Entities.Message.RunMessageName, NodeId = node.NodeId, Package = task.Package, Arguments = arguments }; messages.Add(msg); } _messageAppService.Create(messages); var taskHistory = new AddTaskHistoryInput { Identity = identity, NodeIds = string.Join("|", nodes.Select(a => a.NodeId)), TaskId = task.Id }; _taskHistoryAppService.Add(taskHistory); return(identity); }
public async Task <IActionResult> Create(CreateMessageDto input) { var token = GetToken(); var userId = LoginHelper.GetClaim(token, "UserId"); if (input.SenderId != Guid.Parse(userId)) { return(Unauthorized()); } var result = await _messageAppService.Create(input); return(Ok(result)); }
public async Task <ActionResult> SendMessage(int userId, string message) { var currentUserInfo = await _userService.Get(new EntityDto <long>(_AbpSession.GetUserId())); CreateMessageInput input = new CreateMessageInput { Content = message, RecieverId = userId, SenderId = currentUserInfo.Id }; await _messageService.Create(input); AppointmentHub.Static_Message(userId, currentUserInfo.FullName, message); return(Json(new AjaxResponse { Success = true })); }
/// <summary> /// 结束节点(作用??) /// </summary> /// <param name="nodeId"></param> public void Exit(string nodeId) { var node = DbContext.Node.FirstOrDefault(n => n.NodeId == nodeId); if (node != null) { var message = new CreateMessageInput { ApplicationName = "NULL", Name = Core.Entities.Message.ExitMessageName, NodeId = nodeId, TaskId = string.Empty }; Logger.Information($"Exit node: {nodeId}."); _messageAppService.Create(message); } else { throw new DotnetSpiderHubException("Node unfound."); } }
public static void ExitTask(INodeAppService nodeAppService, IMessageAppService messageAppService, Core.Entities.Task task, ILogger logger = null) { var runningNodes = nodeAppService.GetAllOnline(); var messages = new List<CreateMessageInput>(); foreach (var status in runningNodes) { var msg = new CreateMessageInput { ApplicationName = "NULL", TaskId = task.Id, Name = Core.Entities.Message.CanleMessageName, NodeId = status.NodeId }; logger?.Warning($"Add CANCLE message: {JsonConvert.SerializeObject(msg)}."); messages.Add(msg); } messageAppService.Create(messages); task.IsRunning = false; task.NodeRunningCount = 0; }