private void FillEntityColumnValues(Entity entity, EntityEventAsyncOperationArgs arguments)
 {
     foreach (var column in arguments.EntityColumnValues)
     {
         entity.SetColumnValue(column.Key, column.Value);
     }
 }
        /// <summary>
        /// <see cref="IEntityEventAsyncOperation.Execute"/>
        /// </summary>
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            var manager = GetSectionManager("SSP", userConnection);

            manager.Save(arguments.EntityId);
            SendSocketMessage(userConnection);
        }
 private void ManageOpportunityOwnerRights(EntityEventAsyncOperationArgs arguments)
 {
     _rightsRegulator.ManageEntityOwnerRights(
         arguments.EntityId,
         arguments.EntityColumnValues.GetTypedValue <Guid>("OwnerId"),
         arguments.OldEntityColumnValues.GetTypedValue <Guid>("OwnerId"));;
 }
        /// <summary>
        /// Calls workplaces rights changed async operation.
        /// </summary>
        /// <param name="entity">Rights detail changed entity.</param>
        /// <param name="e">Entity change event arguments.</param>
        private void OnWorkplaceRightsChanged(Entity entity, EntityAfterEventArgs e)
        {
            var userConnection = entity.UserConnection;
            var asyncExecutor  = ClassFactory.Get <IEntityEventAsyncExecutor>(new ConstructorArgument("userConnection", userConnection));
            var operationArgs  = new EntityEventAsyncOperationArgs(entity, e);

            asyncExecutor.ExecuteAsync <UserInRoleEventAsyncOperation>(operationArgs);
        }
Exemple #5
0
        private static void ExecuteStageHistoryAsyncOperation(EntityAfterEventArgs e, Entity entity)
        {
            var asyncExecutor = ClassFactory.Get <IEntityEventAsyncExecutor>(
                new ConstructorArgument("userConnection", entity.UserConnection));
            var operationArgs = new EntityEventAsyncOperationArgs(entity, e);

            asyncExecutor.ExecuteAsync <SaveStageHistoryAsyncOperation>(operationArgs);
        }
        /// <summary>
        /// Handles entity Saved event.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">The <see cref="T:Terrasoft.Core.Entities.EntityAfterEventArgs" /> instance containing the
        /// event data.</param>
        public override void OnSaved(object sender, EntityAfterEventArgs e)
        {
            base.OnSaved(sender, e);
            UserConnection            userConnection = ((Entity)sender).UserConnection;
            IEntityEventAsyncExecutor asyncExecutor  = ClassFactory.Get <IEntityEventAsyncExecutor>(new ConstructorArgument("userConnection", userConnection));
            var operationArgs = new EntityEventAsyncOperationArgs((Entity)sender, e);

            asyncExecutor.ExecuteAsync <OpportunityRightsAsyncRegulator>(operationArgs);
        }
Exemple #7
0
        private bool IsOwnerChanged(EntityEventAsyncOperationArgs arguments)
        {
            var ownerId    = arguments.EntityColumnValues.GetTypedValue <Guid>(OwnerColumnName);
            var oldOwnerId = arguments.OldEntityColumnValues.GetTypedValue <Guid>(OwnerColumnName);

            return(ownerId != oldOwnerId &&
                   ownerId != Guid.Empty &&
                   oldOwnerId != Guid.Empty);
        }
Exemple #8
0
        /// <summary>
        /// <see cref="IEntityEventAsyncOperation.Execute"/>
        /// <remarks>Executes operation by changing process elements data owner.</remarks>
        /// </summary>
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            var operationArgs    = (EntityOwnerEventAsyncOperationArgs)arguments;
            var ownerProcessInfo = new SysProcessElementDataOwnerInfo {
                EntityId   = operationArgs.EntityId,
                NewOwnerId = operationArgs.EntityColumnValues.GetTypedValue <Guid>(operationArgs.OwnerColumnName),
                OldOwnerId = operationArgs.OldEntityColumnValues.GetTypedValue <Guid>(operationArgs.OwnerColumnName),
            };

            new SysProcessElementDataOwner(userConnection).Change(ownerProcessInfo);
        }
        // Обработчик события перед сохранением записи.
        public override void OnSaving(object sender, EntityBeforeEventArgs e)
        {
            base.OnSaving(sender, e);

            // Экземпляр класса для асинхронного выполнения.
            var asyncExecutor = ClassFactory.Get <IEntityEventAsyncExecutor>();
            // Параметры для асинхронного выполнения.
            var operationArgs = new EntityEventAsyncOperationArgs((Entity)sender, e);

            // Выполнение в асинхронном режиме.
            asyncExecutor.ExecuteAsync <OnSavingAsync>(operationArgs);
        }
        /// <summary>
        /// <see cref="IEntityEventAsyncOperation.Execute"/>
        /// <remarks>Executes operation by transfering activities of entity owner to the new entity owner.</remarks>
        /// </summary>
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            var operationArgs   = (EntityOwnerEventAsyncOperationArgs)arguments;
            var ownerEntityInfo = new EntityActivitiesOwnerInfo {
                EntityId         = operationArgs.EntityId,
                NewOwnerId       = operationArgs.EntityColumnValues.GetTypedValue <Guid>(operationArgs.OwnerColumnName),
                OldOwnerId       = operationArgs.OldEntityColumnValues.GetTypedValue <Guid>(operationArgs.OwnerColumnName),
                EntitySchemaName = operationArgs.EntitySchemaName
            };

            new EntityActivitiesOwner(userConnection).Change(ownerEntityInfo);
        }
        /// <summary>
        /// Clears sections repository <see cref="ICacheStore"/> instance.
        /// </summary>
        /// <param name="sysModule"><see cref="Entity"/> instance.</param>
        /// <param name="e"><paramref name="sysModule"/> event arguments instance.</param>
        protected void ClearSectionRepositoryCache(Entity sysModule, EntityAfterEventArgs e)
        {
            var userConnection = sysModule.UserConnection;

            if (!sysModule.GetIsColumnValueLoaded("Type") || sysModule.GetTypedColumnValue <int>("Type") != (int)SectionType.General)
            {
                return;
            }
            var asyncExecutor = ClassFactory.Get <IEntityEventAsyncExecutor>(new ConstructorArgument("userConnection", userConnection));
            var operationArgs = new EntityEventAsyncOperationArgs(sysModule, e);

            asyncExecutor.ExecuteAsync <SysModuleGeneralEventAsyncOperation>(operationArgs);
        }
        /// <summary>
        /// Registers section as self-service portal if <paramref name="sysModule"/> type equals <see cref="SectionType"/> SSP.
        /// </summary>
        /// <param name="sysModule"><see cref="Entity"/> instance.</param>
        /// <param name="e"><paramref name="sysModule"/> event arguments instance.</param>
        protected void RegisterSectionAsSsp(Entity sysModule, EntityAfterEventArgs e)
        {
            var userConnection = sysModule.UserConnection;

            if (!userConnection.GetIsFeatureEnabled("SspSectionWizard") || !sysModule.GetIsColumnValueLoaded("Type") ||
                sysModule.GetTypedColumnValue <int>("Type") != (int)SectionType.SSP)
            {
                return;
            }
            var asyncExecutor = ClassFactory.Get <IEntityEventAsyncExecutor>(new ConstructorArgument("userConnection", userConnection));
            var operationArgs = new EntityEventAsyncOperationArgs(sysModule, e);

            asyncExecutor.ExecuteAsync <SysModuleSSPEventAsyncOperation>(operationArgs);
        }
        /// <summary>
        /// <see cref="IEntityEventAsyncOperation.Execute"/>
        /// </summary>
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            if (!userConnection.GetIsFeatureEnabled("ExchangeCalendarWithoutMetadata"))
            {
                return;
            }
            var synchronizationArgs = (SyncEntityEventAsyncOperationArgs)arguments;
            var parameters          = GetSynchronizationParams(userConnection, synchronizationArgs);

            foreach (var controllerName in synchronizationArgs.Controllers)
            {
                var controller = ClassFactory.Get <ISynchronizationController>(controllerName);
                controller.Execute(userConnection, parameters);
            }
        }
        private IEnumerable <EntityColumnValue> GetEntityColumnOldValues(UserConnection userConnection,
                                                                         EntityEventAsyncOperationArgs arguments)
        {
            var columnValues = arguments.EntityColumnValues.Select(e => {
                arguments.OldEntityColumnValues.TryGetValue(e.Key, out var oldValue);
                return(new EntityColumnValue(userConnection)
                {
                    Value = e.Value,
                    OldValue = oldValue,
                    Name = e.Key,
                    IsLoaded = true
                });
            });

            return(columnValues);
        }
        /// <inheritdoc />
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            var entitySchema = userConnection.EntitySchemaManager.GetInstanceByName(arguments.EntitySchemaName);
            var setting      = GetActiveStageHistorySetting(userConnection, entitySchema.UId);

            if (setting == null || entitySchema == null)
            {
                return;
            }
            var entity = entitySchema.CreateEntity(userConnection);

            FillEntityColumnValues(entity, arguments);
            entity.SetColumnValue(entitySchema.PrimaryColumn.Name, arguments.EntityId);
            var columnOldValues = GetEntityColumnOldValues(userConnection, arguments);
            var stageManager    = GetEntityStageManager(userConnection, setting);

            stageManager.SynchronizeStage(entity, columnOldValues);
        }
 public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
 {
     _rightsRegulator = new SspEntityRightsRegulator(userConnection, arguments.EntitySchemaName);
     ManageLeadOrganizationRights(arguments);
     ManageLeadOwnerRights((LeadEntityEventAsyncOperationArgs)arguments);
 }
        /// <summary>
        /// <see cref="IEntityEventAsyncOperation.Execute"/>
        /// </summary>
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            var manager = GetSectionManager("General", userConnection);

            manager.Save(arguments.EntityId);
        }
 private void ManageLeadOrganizationRights(EntityEventAsyncOperationArgs arguments)
 {
     _rightsRegulator.ManageEntityOrganizationRights(arguments.EntityId,
                                                     arguments.EntityColumnValues.GetTypedValue <Guid>("PartnerId"),
                                                     arguments.OldEntityColumnValues.GetTypedValue <Guid>("PartnerId"));
 }
 // Стартовый метод класса.
 public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
 {
     //
 }
Exemple #20
0
        /// <inheritdoc cref="IEntityEventAsyncOperation.Execute"/>
        public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments)
        {
            var manager = GetWorkplaceManager(userConnection);

            manager.ReloadWorkplaces();
        }