public int CreateModule(CreateModuleDto input) { Logger.Info("Creating a module for input: " + input); var module = new Module { TenantId = _abpSession.TenantId, Name = input.Name, Description = input.Description, StartTime = input.StartTime, DeliverTime = input.DeliverTime, TechStack = input.TechStack, Level = input.Level, MemberId = input.MemberId, ProjectId = input.ProjectId }; if (input.MemberId.HasValue) { var user = _userRepository.Get(ObjectMapper.Map <long>(input.MemberId)); module.Member = user; string message = "A new module -- \"" + input.Name + "\" has being assigned to u."; _notificationPublisher.Publish("New Module", new MessageNotificationData(message), null, NotificationSeverity.Info, new[] { user.ToUserIdentifier() }); } if (input.ProjectId.HasValue) { var project = _projectRepository.Get(ObjectMapper.Map <int>(input.ProjectId)); module.Project = project; } return(_moduleRepository.InsertAndGetId(module)); }
public int CreateProject(CreateProjectDto input) { Logger.Info("Creating a project for input: " + input); var project = new Project { TenantId = _abpSession.TenantId, Name = input.Name, Description = input.Description, StartTime = input.StartTime, DeliverTime = input.DeliverTime, TeamLeaderId = input.TeamLeaderId }; if (input.TeamLeaderId.HasValue) { var user = _userRepository.Get(ObjectMapper.Map <long>(input.TeamLeaderId)); project.TeamLeader = user; string message = "A new project -- \"" + input.Name + "\" has being assigned to u."; _notificationPublisher.Publish("New Project", new MessageNotificationData(message), null, NotificationSeverity.Info, new[] { user.ToUserIdentifier() }); } return(_projectRepository.InsertAndGetId(project)); }
/// <summary> /// Создание нового перевода /// </summary> /// <param name="transactionInputDto"></param> /// <returns></returns> public TransactionInfoDto Create(TransactionInputDto transactionInputDto) { var recipientUserId = transactionInputDto.RecipientUserId; var amount = transactionInputDto.Amount; var currentBalance = GetBalance(); if (amount > currentBalance) { throw new UserFriendlyException("Суммы на счёте недостаточно для перевода"); } var recipientUser = _userRepository.Get(recipientUserId); if (AbpSession.UserId == null) { throw new UserFriendlyException("Текущий пользователь не найден"); } var creator = _userRepository.Get(AbpSession.UserId.Value); if (creator.Id == recipientUser.Id) { throw new UserFriendlyException("Невозможно выполнить перевод этому же пользователю"); } var transaction = new Transaction() { Amount = amount, CreatorUser = creator, RecipientUser = recipientUser, Type = -1 }; var id = _transactionRepository.InsertAndGetId(transaction); transaction = _transactionRepository.Get(id); _notificationPublisher.Publish("BalanceChanged", new BalanceChangedNotificationData(_transactionRepository.GetCurrentBalance(creator.Id)), userIds: new[] { new UserIdentifier(creator.TenantId, creator.Id) }); _notificationPublisher.Publish("BalanceChanged", new BalanceChangedNotificationData(_transactionRepository.GetCurrentBalance(recipientUser.Id)), userIds: new[] { new UserIdentifier(creator.TenantId, recipientUser.Id) }); return(Mapper.Map <TransactionInfoDto>(transaction)); }
//由于授权一般在服务层,所以ABP直接在ApplicationService基类注入并定义了一个PermissionChecker属性 这样 在服务层 就可以直接调PermissionChecker属性进行权限检查 //public IPermissionChecker PermissionChecker { protected get; set; } //创建任务 public int CreateTask(CreateTaskInput input) { //We can use Logger, it's defined in ApplicationService class. Logger.Info("Creating a task for input: " + input); //判断用户是否有权限 if (input.AssignedPersonId.HasValue && input.AssignedPersonId.Value != AbpSession.GetUserId()) { PermissionChecker.Authorize(PermissionNames.Pages_Tasks_AssignPerson); } var task = Mapper.Map <Task>(input); int result = _taskRepository.InsertAndGetId(task); if (result > 0)//只有创建成功才发送邮件和通知 { task.CreationTime = Clock.Now; if (input.AssignedPersonId.HasValue) { task.AssignedPerson = _userRepository.Load(input.AssignedPersonId.Value); var message = "You hava been assigned one task into your todo list."; //TODO:需要重新配置QQ邮箱密码 //SmtpEmailSender emailSender = new SmtpEmailSender(_smtpEmialSenderConfig); //emailSender.Send("*****@*****.**", task.AssignedPerson.EmailAddress, "New Todo item", message); _notificationPublisher.Publish("NewTask", new MessageNotificationData(message), null, NotificationSeverity.Info, new[] { task.AssignedPerson.ToUserIdentifier() }); } } return(result); }
public int CreateTask(CreateTaskInput input) { //We can use Logger, it's defined in ApplicationService class. Logger.Info("Creating a task for input: " + input); var task = Mapper.Map <Task>(input); task.CreationTime = Clock.Now; if (input.AssignedPersonId.HasValue) { task.AssignedPerson = _userRepository.Load(input.AssignedPersonId.Value); var message = "You hava been assigned one task into your todo list."; //TODO:需要重新配置QQ邮箱密码 //SmtpEmailSender emailSender = new SmtpEmailSender(_smtpEmialSenderConfig); //emailSender.Send("*****@*****.**", task.AssignedPerson.EmailAddress, "New Todo item", message); _notificationPublisher.Publish("NewTask", new MessageNotificationData(message), null, NotificationSeverity.Info, new[] { task.AssignedPerson.ToUserIdentifier() }); } //Saving entity with standard Insert method of repositories. return(_taskRepository.InsertAndGetId(task)); }
public override void Execute(SendNotificationJobArgs args) { var targetUser = _userRepository.Get(args.TargetUserId); _notificationPublisher.Publish(args.NotificationTitle, args.NotificationData, null, args.NotificationSeverity, new[] { targetUser.ToUserIdentifier() }); }
public void RenameFile(RenameFileOperation operation) { var configName = RavenFileNameHelper.RenameOperationConfigNameForFile(operation.Name); notificationPublisher.Publish(new FileChangeNotification { File = FilePathTools.Cannoicalise(operation.Name), Action = FileChangeAction.Renaming }); storage.Batch(accessor => { var previousRenameTombstone = accessor.ReadFile(operation.Rename); if (previousRenameTombstone != null && previousRenameTombstone.Metadata[SynchronizationConstants.RavenDeleteMarker] != null) { // if there is a tombstone delete it accessor.Delete(previousRenameTombstone.FullPath); } accessor.RenameFile(operation.Name, operation.Rename, true); accessor.UpdateFileMetadata(operation.Rename, operation.MetadataAfterOperation); // copy renaming file metadata and set special markers var tombstoneMetadata = new RavenJObject(operation.MetadataAfterOperation).WithRenameMarkers(operation.Rename); accessor.PutFile(operation.Name, 0, tombstoneMetadata, true); // put rename tombstone accessor.DeleteConfig(configName); search.Delete(operation.Name); search.Index(operation.Rename, operation.MetadataAfterOperation); }); notificationPublisher.Publish(new ConfigurationChangeNotification { Name = configName, Action = ConfigurationChangeAction.Set }); notificationPublisher.Publish(new FileChangeNotification { File = FilePathTools.Cannoicalise(operation.Rename), Action = FileChangeAction.Renamed }); }
public void HandleEvent(TaskAssignedEventData eventData) { var message = "You hava been assigned one task into your todo list."; //TODO:需要重新配置QQ邮箱密码 //_smtpEmailSender.Send("*****@*****.**", eventData.Task.AssignedPerson.EmailAddress, "New Todo item", message); _notificationPublisher.Publish("NewTask", new MessageNotificationData(message), null, NotificationSeverity.Info, new[] { eventData.User.ToUserIdentifier() }); }
private void SendNotification(ICommand command, bool success = true, string message = "", Exception exception = null) { HandlerNotification notification = new HandlerNotification(); notification.ClientId = command.ClientId; notification.CommandId = command.CommandId; notification.Success = success; notification.Message = message; if (exception != null) { notification.ExceptionMessage = string.Format("{0}: {1}", exception.GetType().Name, exception.Message); } _publisher.Publish(notification); }
public void HandleEvent(UserCreatedEventData eventData) { var user = _userRepository.Get(eventData.UserId); // зачислить на счёт 500 PW var transaction = new Transaction { Amount = 500, RecipientUser = user, CreatorUser = user, // todo: создатель может быть "админ" или "система" Type = 1, // остальные поля аудита заполняются автоматически }; _transactionRepository.Insert(transaction); _notificationPublisher.Publish("BalanceChanged", new BalanceChangedNotificationData(transaction.Amount), userIds: new[] { new UserIdentifier(user.TenantId, user.Id), }); }
public void HandleEvent(OrderEventData eventData) { //发送邮箱 if (eventData is OrderEventData) { var order = eventData.Order; var user = _userRepository.Get(order.CreatorUserId.Value); if (!string.IsNullOrEmpty(user.Email)) { var body = $"<div>订单编号:<a href='https://e.mdsd.cn:9100/Order/Index'>{order.OrderNo}</a></div><div>状态变更:<span style='color:blue;'>{eventData.OldStatus.GetDescription()}</span>-><span style='color:blue;'>{order.OrderStatus.GetDescription()}</span></div>"; Task.Run(() => { //1:邮箱通知 _emailSender.Send(user.Email, "积分商城-商品到货", body); //2.给用户发送邮件通知,提示人员已经接单 UserIdentifier userIdentifier = new UserIdentifier(null, order.CreatorUserId.Value); _notificationPublisher.Publish("订单审批完成通知", new MessageNotificationData("订单申请已审批通过"), null, NotificationSeverity.Success, new UserIdentifier[] { userIdentifier }); }); } } }
public int CreateTask(CreateTaskInput input) { Logger.Info("Creating a task for input:" + input); //获取当前用户 var currentUser = AsyncHelper.RunSync(this.GetCurrentUserAsync); //判断用户是否有权限 if (input.AssignedPersonId.HasValue && input.AssignedPersonId.Value != currentUser.Id) { PermissionChecker.Authorize(PermissionNames.Pages_Tasks_AssignPerson); } var task = Mapper.Map <MyTask>(input); int result = taskRespository.InsertAndGetId(task); //只有创建成功才发送邮件通知 if (result > 0) { task.CreationTime = Clock.Now; if (task.AssignedPersonId.HasValue) { task.AssignedPerson = userRepository.Load(input.AssignedPersonId.Value); var message = "You have been assigned one task into your todo list."; notificationPublisher.Publish("NewTask", new MessageNotificationData(message), null, NotificationSeverity.Info, new[] { task.AssignedPerson.ToUserIdentifier() }); } } return(result); //var task = new MyTask //{ // Title = input.Title, // Description = input.Description, // State = input.State, // CreationTime = Clock.Now //}; //return taskRespository.InsertAndGetId(task); }
public void PublisNotice() { var data = new LocalizableMessageNotificationData(new LocalizableString("通知", ArtSolutionConsts.LocalizationSourceName)); _notiticationPublisher.Publish("通知", data, severity: NotificationSeverity.Warn); }
/// <summary> /// Publishes a new error notification. /// </summary> /// <param name="self">Object to be extended.</param> /// <param name="message">The displayed text message.</param> /// <param name="title">The displayed title.</param> /// <param name="displayDuration">Display duration. No auto-remove if null.</param> public static void PublishError(this INotificationPublisher self, string message, string title = null, TimeSpan?displayDuration = null) { Guard.Against.ArgumentNullOrEmpty(message, "message"); self.Publish(new Notification(message, title, NotificationLevel.Error, displayDuration)); }
public Task <ApiResponse <Unit> > PublishNotification <T>(T notification) where T : INotification { return(_notificationPublisher.Publish(this, notification)); }