Ejemplo n.º 1
0
 public void HandleEvent(EntityCreatedEventData <Friendship> eventData)
 {
     _userFriendsCache.AddFriend(
         eventData.Entity.ToUserIdentifier(),
         _objectMapper.Map <FriendCacheItem>(eventData.Entity)
         );
 }
        public void HandleEvent(EntityCreatedEventData <Event> eventData)
        {
            //Todo Send email to all tenant users as a notification

            var users = new List <User>();

            try
            {
                users = _userManager.Users.Where(u => u.TenantId == eventData.Entity.TenantId).ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                //throw;
            }


            foreach (var user in users)
            {
                var message = string.Format("Hey! There is a new event '{0}' on {1}! Want to register?",
                                            eventData.Entity.Title, eventData.Entity.Date);

                Logger.Debug(string.Format("TODO: Send email to {0} -> {1}", user.EmailAddress, message));
            }
        }
Ejemplo n.º 3
0
 public virtual void HandleEvent(EntityCreatedEventData <AbpUserBase> eventData)
 {
     using (_unitOfWorkManager.Current.SetTenantId(null))
     {
         var userAccount =
             _userAccountRepository.FirstOrDefault(
                 ua => ua.TenantId == eventData.Entity.TenantId && ua.UserId == eventData.Entity.Id);
         if (userAccount == null)
         {
             _userAccountRepository.Insert(new UserAccount
             {
                 TenantId     = eventData.Entity.TenantId,
                 UserName     = eventData.Entity.UserName,
                 UserId       = eventData.Entity.Id,
                 EmailAddress = eventData.Entity.EmailAddress
             });
         }
         else
         {
             userAccount.UserName     = eventData.Entity.UserName;
             userAccount.EmailAddress = eventData.Entity.EmailAddress;
             _userAccountRepository.Update(userAccount);
         }
     }
 }
Ejemplo n.º 4
0
 public void HandleEvent(EntityCreatedEventData <Friendship> eventData)
 {
     _userFriendsCache.AddFriend(
         eventData.Entity.ToUserIdentifier(),
         eventData.Entity.MapTo <FriendCacheItem>()
         );
 }
        public async Task HandleEventAsync(EntityCreatedEventData <UserEto> eventData)
        {
            // 获取默认语言
            var userDefaultCultureName = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);

            if (userDefaultCultureName.IsNullOrWhiteSpace())
            {
                userDefaultCultureName = CultureInfo.CurrentUICulture.Name;
                // CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(userDefaultCultureName);
            }
            using (CultureHelper.Use(userDefaultCultureName, userDefaultCultureName))
            {
                // 订阅用户欢迎消息
                await _notificationStore.InsertUserSubscriptionAsync(eventData.Entity.TenantId,
                                                                     eventData.Entity.Id, UserNotificationNames.WelcomeToApplication);

                var userWelcomeNotifiction = new NotificationInfo
                {
                    CreationTime         = DateTime.Now,
                    Name                 = UserNotificationNames.WelcomeToApplication,
                    NotificationSeverity = NotificationSeverity.Info,
                    NotificationType     = NotificationType.System,
                    TenantId             = eventData.Entity.TenantId
                };
                userWelcomeNotifiction.Data.Properties["message"] = L("WelcomeToApplicationFormUser", eventData.Entity.UserName);

                await _notificationDispatcher.DispatcheAsync(userWelcomeNotifiction);
            }
        }
Ejemplo n.º 6
0
        public virtual void HandleEvent(EntityCreatedEventData <TacticPerson> eventData)
        {
            var person = _personManager.Repository.GetAll().IgnoreQueryFilters().Where(o => o.Id == eventData.Entity.PersonId).Single();
            var tactic = _tacticManager.Repository.GetAll().IgnoreQueryFilters().Where(o => o.Id == eventData.Entity.TacticId).Single();

            //先产生一条提醒记录
            var remindLog = new RemindLog()
            {
                RemindType = "策略绑定提醒",
                Name       = person.Name,
                TenantId   = tactic.TenantId,
                Message    = ""
            };
            var remindLogId = RemindLogManager.InsertAndGetIdAsync(remindLog).Result;
            var arg         = new SendTacticBindWeiXinMessageJobArgs()
            {
                BindType    = 1,
                TacticId    = tactic.Id,
                PersonId    = person.Id,
                RemindLogId = remindLogId
            };


            _backgroundJobManager.Enqueue <SendTacticBindWeiXinMessageJob, SendTacticBindWeiXinMessageJobArgs>(arg);
        }
Ejemplo n.º 7
0
        public virtual void HandleEvent(EntityCreatedEventData <Tenant> eventData)
        {
            try
            {
                var tactic = _tacticManager.GetAll().IgnoreQueryFilters().Where(o => o.TacticName == "注册提醒" && o.TenantId == null && o.IsActive).FirstOrDefault();
                if (tactic != null)
                {
                    //获取所有的被提醒人
                    var remindPersons = _tacticManager.GetTacticReminders(tactic.Id).Result;
                    foreach (var remindPerson in remindPersons)
                    {
                        var openid = remindPerson.GetPropertyValue <string>("OpenId");
                        var arg    = new SendRegisteredMessageJobArgs()
                        {
                            OpenId      = openid,
                            TenancyName = eventData.Entity.TenancyName,
                            Mobile      = eventData.Entity.GetPropertyValue <string>("Mobile"),
                            PersonName  = eventData.Entity.GetPropertyValue <string>("PersonName")
                        };

                        //发送注册提醒至管理人员
                        _backgroundJobManager.Enqueue <SendRegisteredMessageJob, SendRegisteredMessageJobArgs>(arg);
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 8
0
        public async Task HandleEventAsync(EntityCreatedEventData <UserEto> eventData)
        {
            // 获取默认语言
            var userDefaultCultureName = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);

            if (userDefaultCultureName.IsNullOrWhiteSpace())
            {
                userDefaultCultureName = CultureInfo.CurrentUICulture.Name;
                // CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(userDefaultCultureName);
            }
            using (CultureHelper.Use(userDefaultCultureName, userDefaultCultureName))
            {
                var userIdentifer = new UserIdentifier(eventData.Entity.Id, eventData.Entity.UserName);
                // 订阅用户欢迎消息
                await _notificationSubscriptionManager.SubscribeAsync(eventData.Entity.TenantId,
                                                                      userIdentifer, UserNotificationNames.WelcomeToApplication);

                // Store未检查已订阅
                //await _notificationStore.InsertUserSubscriptionAsync(eventData.Entity.TenantId,
                //    userIdentifer, UserNotificationNames.WelcomeToApplication);

                var userWelcomeNotifictionData = NotificationData.CreateUserNotificationData(eventData.Entity.Id, eventData.Entity.UserName);

                userWelcomeNotifictionData.WriteStandardData(
                    L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
                    L("WelcomeToApplicationFormUser", eventData.Entity.Name ?? eventData.Entity.UserName),
                    DateTime.Now, eventData.Entity.UserName);

                // 换成用户名称,而不是用户名
                // userWelcomeNotifictionData.Properties["message"] = L("WelcomeToApplicationFormUser", eventData.Entity.Name);

                var noticeNormalizerName = NotificationNameNormalizer.NormalizerName(UserNotificationNames.WelcomeToApplication);
                await _notificationDispatcher.DispatchAsync(noticeNormalizerName, userWelcomeNotifictionData, eventData.Entity.TenantId);
            }
        }
Ejemplo n.º 9
0
 public void Handle(EntityCreatedEventData <DataItemEntity> notification)
 {
     Debug.WriteLine("Pong EntityInserted");
     _cacheManager.Remove(ConstHelper.DATAITEM_PATTERN_KEY.FormatCurrent(notification.Entity.Id), ConstHelper.Region);
     _cacheManager.Remove(ConstHelper.DATAITEMDETAIL_ITEMCODE_ALL.FormatCurrent(notification.Entity.ItemCode), ConstHelper.Region);
     _cacheManager.Remove(ConstHelper.DATAITEM_ALL, ConstHelper.Region);
 }
        public async Task HandleEventAsync(EntityCreatedEventData <AppFile> eventData)
        {
            var id = eventData.Entity.Id;

            if (id != AppFileDefaults.RootDirectory.Id && eventData.Entity.ParentId == null)
            {
                var cloneAppFile = new AppFile
                {
                    ParentId    = AppFileDefaults.RootDirectory.Id,
                    Name        = eventData.Entity.Name,
                    IsDirectory = eventData.Entity.IsDirectory,
                    Length      = eventData.Entity.Length
                }.SetId(id)
                .SetPath(
                    PathHelper.TrueCombine(AppFileDefaults.RootDirectory.Path,
                                           eventData.Entity.Name));
                await _AppFileRepository.UpdateAsync(cloneAppFile);
            }
            else if (eventData.Entity.Path.IsNullOrEmpty())
            {
                var parent = await _AppFileRepository.GetAsync(eventData.Entity.ParentId.Value);

                var cloneAppFile = new AppFile
                {
                    ParentId    = parent.Id,
                    Name        = eventData.Entity.Name,
                    IsDirectory = eventData.Entity.IsDirectory,
                    Length      = eventData.Entity.Length
                }.SetId(id)
                .SetPath(
                    PathHelper.TrueCombine(parent.Path,
                                           eventData.Entity.Name));
                await _AppFileRepository.UpdateAsync(cloneAppFile);
            }
        }
Ejemplo n.º 11
0
 public void HandleEvent(EntityCreatedEventData <Task> eventData)
 {
     if (eventData.Entity.AssignedUser.Id != eventData.Entity.CreatorUserId)
     {
         _notificationService.Notify(new AssignedToTaskNotification(eventData.Entity));
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 创建后
 /// </summary>
 /// <param name="eventData"></param>
 public void HandleEvent(EntityCreatedEventData <SysSetting> eventData)
 {
     //新增持久化数据后,此处改变数据不影响写入数据
     //eventData.Entity.Name += "_创建后";
     EntityEventProcessDataList.Add(new EntityEventProcessData {
         DataDate = DateTime.Now, DataContent = "创建后"
     });
 }
Ejemplo n.º 13
0
 public async Task HandleEventAsync(EntityCreatedEventData <Message> eventData)
 {
     await _toolService.SendMessageAsync(new SendMessageInput
     {
         Text = $"消息来自:{eventData.Entity.Name}",
         Desc = eventData.Entity.Content
     });
 }
Ejemplo n.º 14
0
        public virtual void HandleEvent(EntityCreatedEventData <FlowInstance> eventData)
        {
            //var flowInstance = eventData.Entity;
            //var form = Resolve<FlowFormManager>().GetByIdFromCacheAsync(flowInstance.FlowFormId).Result;

            //var flowHandler = Resolve<IFlowHandlerFinder>().FindFlowHandler(form.FormKey);

            //flowHandler.CreateSheet(flowInstance, form).GetAwaiter().GetResult();
        }
Ejemplo n.º 15
0
        public async Task HandleEventAsync(EntityCreatedEventData <PipelineHistory> eventData)
        {
            Console.WriteLine($"pipelinehistory:{eventData.Entity.Id} is created");

            await _backgroundJobManager.EnqueueAsync(new PipelineHistoryCreatedArgs {
                Id      = eventData.Entity.Id,
                Diagram = eventData.Entity.Diagram
            });
        }
Ejemplo n.º 16
0
        public void HandleEvent(EntityCreatedEventData <Event> eventData)
        {
            var users = userManager.Users.Where(user => user.TenantId == eventData.Entity.TenantId).ToList();

            foreach (var user in users)
            {
                var message = string.Format("Hey! There is a new event '{0}' on {1}! Want to register?", eventData.Entity.Title, eventData.Entity.Date);
                Logger.Debug(string.Format("TODO: Send email to {0} -> {1}", user.EmailAddress, message));
            }
        }
Ejemplo n.º 17
0
        public virtual async Task HandleEventAsync(EntityCreatedEventData <Invoice> eventData)
        {
            var entity = eventData.Entity;

            if (string.IsNullOrEmpty(entity.SheetSN))
            {
                entity.SheetSN = InvoiceManager.GenerateSheetSN();
                await InvoiceManager.UpdateAsync(entity);
            }
        }
Ejemplo n.º 18
0
 public void HandleEvent(EntityCreatedEventData <Task> eventData)
 {
     _activityService.AddActivity(
         new CreateTaskActivity
     {
         CreatorUser  = eventData.Entity.CreatorUserId.HasValue ? _userRepository.Load(eventData.Entity.CreatorUserId.Value) : null,
         AssignedUser = eventData.Entity.AssignedUser,
         Task         = eventData.Entity
     });
 }
Ejemplo n.º 19
0
 public async Task HandleEventAsync(EntityCreatedEventData <Gig> eventData)
 {
     try
     {
         await SendGigNotificationAsync(eventData.Entity);
     }
     catch (Exception exception)
     {
         _logger.LogError("Failed to Notify user Reason :" + exception.Message);
     }
 }
Ejemplo n.º 20
0
        public virtual async Task HandleEventAsync(EntityCreatedEventData <UserChatFriend> eventData)
        {
            switch (eventData.Entity.Status)
            {
            case IM.Contract.UserFriendStatus.NeedValidation:
                await SendFriendValidationNotifierAsync(eventData.Entity);

                break;
            }
            await RemoveUserFriendCacheItemAsync(eventData.Entity.UserId);
        }
Ejemplo n.º 21
0
        public async Task HandleEventAsync(EntityCreatedEventData <Signature> eventData)
        {
            var path = Path.Combine(_signatureOptions.Path, eventData.Entity.Url);

            if (File.Exists(path))
            {
                await path.AddWatermarkAndSaveItAsync();
            }

            await Task.CompletedTask;
        }
Ejemplo n.º 22
0
        public void HandleEvent(EntityCreatedEventData <ChatMessage> eventData)
        {
            var message = eventData.Entity;

            if (message.ReadState == ChatMessageReadState.Unread)
            {
                _userFriendsCache.IncreaseUnreadMessageCount(
                    new UserIdentifier(message.TenantId, message.UserId),
                    new UserIdentifier(message.TargetTenantId, message.TargetUserId),
                    1
                    );
            }
        }
Ejemplo n.º 23
0
 public virtual void HandleEvent(EntityCreatedEventData <AbpUserBase> eventData)
 {
     using (_unitOfWorkManager.Current.SetTenantId(null))
     {
         _userAccountRepository.Insert(new UserAccount
         {
             TenantId     = eventData.Entity.TenantId,
             UserName     = eventData.Entity.UserName,
             UserId       = eventData.Entity.Id,
             EmailAddress = eventData.Entity.EmailAddress
         });
     }
 }
        public async Task HandleEventAsync(EntityCreatedEventData <MenuGrant> eventData)
        {
            var cacheKey = CalculateCacheKey(
                eventData.Entity.MenuId,
                eventData.Entity.ProviderName,
                eventData.Entity.ProviderKey
                );

            using (CurrentTenant.Change(eventData.Entity.TenantId))
            {
                await Cache.SetAsync(cacheKey, new MenuGrantCacheItem(eventData.Entity.MenuId, true));
            }
        }
Ejemplo n.º 25
0
    public async Task Should_Invoke_LocalEventHandler_Created_And_Changed_Once()
    {
        var localHandler = new MyLocalEventHandler();
        var eventData    = new EntityCreatedEventData <MyEntity>(new MyEntity());

        await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType());

        await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, typeof(EntityChangedEventData <MyEntity>));

        localHandler.MyEventDataCount.ShouldBe(0);
        localHandler.EntityChangedEventDataCount.ShouldBe(1);
        localHandler.EntityChangedEventDataCount.ShouldBe(1);
    }
Ejemplo n.º 26
0
 public async Task HandleEventAsync(EntityCreatedEventData <CustomerInvoice> eventData)
 {
     //TenantInfo tenantInfo = TenantManager.GetTenantInfo().Result;
     GetCustomerInvoiceForViewDto entity = new GetCustomerInvoiceForViewDto {
         CustomerInvoice = ObjectMapper.Map <CustomerInvoiceDto>(eventData.Entity)
     };
     await _backgroundJobManager.EnqueueAsync <CustomerInvoiceManager, CustomerInvoiceManagerArgs>(
         new CustomerInvoiceManagerArgs
     {
         Created            = true,
         CustomerInvoiceDto = entity.CustomerInvoice,
     });
 }
Ejemplo n.º 27
0
        public virtual void HandleEvent(EntityCreatedEventData <Event> eventData)
        {
            //TODO: Send email to all tenant users as a notification

            var users = _userManager
                        .Users
                        .ToList();

            foreach (var user in users)
            {
                var message = string.Format("Hey! There is a new event '{0}' on {1}! Want to register?", eventData.Entity.Title, eventData.Entity.Date);
                Logger.Debug(string.Format("TODO: Send email to {0} -> {1}", user.EmailAddress, message));
            }
        }
Ejemplo n.º 28
0
 public virtual void HandleEvent(EntityCreatedEventData <Part> eventData)
 {
     try
     {
         //创建零件后进行进度表的同步
         if (eventData.Entity.EnableProcess)
         {
             MESProjectManager.SyncProcessSchedule(eventData.Entity.ProjectId).GetAwaiter().GetResult();
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
     }
 }
        public virtual void HandleEvent(EntityCreatedEventData <FlowSheet> eventData)
        {
            //生成单据编号20190308001
            lock (_obj)
            {
                var entity = eventData.Entity;
                //当天数量
                var todayNum = FlowSheetManager.GetAll().Where(o => o.FormKey == entity.FormKey && o.CreationTime.Year == DateTime.Now.Year && o.CreationTime.Month == DateTime.Now.Month && o.CreationTime.Day == DateTime.Now.Day).Count();
                var newNum   = todayNum + 1;

                entity.SheetSN = entity.FormKey + DateTime.Now.ToString("yyyyMMdd") + newNum.ToString().PadLeft(3, '0');

                FlowSheetManager.UpdateAsync(entity).GetAwaiter().GetResult();
            }
        }
 public async Task HandleEventAsync(EntityCreatedEventData <SupportContract> eventData)
 {
     TenantInfo tenantInfo = TenantManager.GetTenantInfo().Result;
     //List<int> crossTenantPermissions = await TenantManager.GetCrossTenantPermissions(tenantInfo, "SupportContract");
     GetSupportContractForViewDto entity = new GetSupportContractForViewDto {
         SupportContract = ObjectMapper.Map <SupportContractDto>(eventData.Entity)
     };
     await _backgroundJobManager.EnqueueAsync <CrossTenantPermissionManager, CrossTenantPermissionManagerArgs>(
         new CrossTenantPermissionManagerArgs
     {
         //CrossTenantPermissions = crossTenantPermissions,
         SupportContractDto = entity.SupportContract,
         EntityType         = "SupportContract",
         TenantInfo         = tenantInfo
     });
 }