Ejemplo n.º 1
0
 public EntityRepository(IOrganizationService orgService, IRetryExecutor retryExecutor, IEntityMetadataCache entMetadataCache, RepositoryCachingMode cachingMode = RepositoryCachingMode.None)
 {
     this.orgService     = orgService;
     this.retryExecutor  = retryExecutor;
     this.metadataCache  = entMetadataCache;
     this.mapLookupCache = cachingMode == RepositoryCachingMode.Lookup ? new EntityMapLookupCache(orgService) : null;
 }
        public void HandleObfuscation(Entity entity, FieldToBeObfuscated field, IEntityMetadataCache metaData)
        {
            entity.ThrowArgumentNullExceptionIfNull(nameof(entity));
            field.ThrowArgumentNullExceptionIfNull(nameof(field));
            metaData.ThrowArgumentNullExceptionIfNull(nameof(metaData));

            // Get the min and maximum values for the field using the meta data cache
            DoubleAttributeMetadata doubleMetaData = (DoubleAttributeMetadata)metaData.GetAttribute(entity.LogicalName, field.FieldName);

            int min = (int)doubleMetaData.MinValue.GetValueOrDefault(0);
            int max = (int)doubleMetaData.MaxValue.GetValueOrDefault(10);

            if (field.CanBeFormatted)
            {
                Dictionary <string, object> metadataParameters = new Dictionary <string, object>
                {
                    { "min", min },
                    { "max", max }
                };

                entity[field.FieldName] = formattingClient.CreateFormattedValue((double)entity[field.FieldName], field, metadataParameters);
                return;
            }

            entity[field.FieldName] = doubleScramblerClient.ExecuteScramble((double)entity[field.FieldName], min, max);
        }
        public void HandleObfuscation(Entity entity, FieldToBeObfuscated field, IEntityMetadataCache metaData)
        {
            // Get the min and maximum values for the field using the meta data cache
            IntegerAttributeMetadata intMetaData = (IntegerAttributeMetadata)metaData.GetAttribute(entity.LogicalName, field.FieldName);
            int min = intMetaData.MinValue.GetValueOrDefault(0);
            int max = intMetaData.MaxValue.GetValueOrDefault(10);

            entity[field.FieldName] = intScramblerClient.ExecuteScramble((int)entity[field.FieldName], min, max);
        }
 public MapEntityProcessor(MappingConfiguration mappingConfig, ILogger logger, IEntityRepository targetRepo, List <string> passOneReferences = null)
 {
     mappingConfiguration   = mappingConfig ?? new MappingConfiguration();
     targetBusinessUnitId   = targetRepo == null ? Guid.Empty : targetRepo.GetParentBuId();
     organizationId         = targetRepo == null ? Guid.Empty : targetRepo.GetOrganizationId();
     this.logger            = logger;
     this.targetRepo        = targetRepo;
     metCache               = targetRepo?.GetEntityMetadataCache;
     this.passOneReferences = passOneReferences ?? this.passOneReferences;
 }
        public void HandleObfuscation(Entity entity, FieldToBeObfuscated field, IEntityMetadataCache metaData)
        {
            entity.ThrowArgumentNullExceptionIfNull(nameof(entity));
            field.ThrowArgumentNullExceptionIfNull(nameof(field));
            metaData.ThrowArgumentNullExceptionIfNull(nameof(metaData));

            DecimalAttributeMetadata decimalMetaData = (DecimalAttributeMetadata)metaData.GetAttribute(entity.LogicalName, field.FieldName);
            int min = (int)decimalMetaData.MinValue.GetValueOrDefault(0);
            int max = (int)decimalMetaData.MaxValue.GetValueOrDefault(10);

            entity[field.FieldName] = decimalScramblerClient.ExecuteScramble((decimal)entity[field.FieldName], min, max);
        }
        public void HandleObfuscation(Entity entity, FieldToBeObfuscated field, IEntityMetadataCache metaData)
        {
            entity.ThrowArgumentNullExceptionIfNull(nameof(entity));
            field.ThrowArgumentNullExceptionIfNull(nameof(field));
            metaData.ThrowArgumentNullExceptionIfNull(nameof(metaData));

            StringAttributeMetadata stringMetaData = (StringAttributeMetadata)metaData.GetAttribute(entity.LogicalName, field.FieldName);

            if (field.CanBeFormatted)
            {
                Dictionary <string, object> metadataParams = new Dictionary <string, object>();

                if (stringMetaData.MaxLength != null)
                {
                    metadataParams.Add("maxlength", stringMetaData.MaxLength);
                }

                entity[field.FieldName] = formattingClient.CreateFormattedValue((string)entity[field.FieldName], field, metadataParams);
                return;
            }

            entity[field.FieldName] = strScramblerClient.ExecuteScramble((string)entity[field.FieldName]);
        }
Ejemplo n.º 7
0
 public EntityRepositoryFake(IOrganizationService orgService, IRetryExecutor retryExecutor, IEntityMetadataCache entMetadataCache)
     : base(orgService, retryExecutor, entMetadataCache)
 {
 }
 public EntityRepositorySingle(IOrganizationService orgService, IRetryExecutor retryExecutor, IEntityMetadataCache entMetadataCache, RepositoryCachingMode cachingMode)
     : base(orgService, retryExecutor, entMetadataCache, cachingMode)
 {
 }
Ejemplo n.º 9
0
 public EntityRepository(IOrganizationService orgService, IRetryExecutor retryExecutor, IEntityMetadataCache entMetadataCache)
 {
     this.orgService    = orgService;
     this.retryExecutor = retryExecutor;
     metadataCache      = entMetadataCache;
 }
 public ObfuscateFieldsProcessor(IEntityMetadataCache metaDataCache, List <EntityToBeObfuscated> fieldsToObfuscate)
 {
     this.fieldsToObfuscate    = fieldsToObfuscate;
     this.metaDataCache        = metaDataCache;
     this.crmObfuscateHandlers = GetObfuscateHandlers();
 }
 public ReferenceFieldsProcessor(IEntityMetadataCache metCache, List <string> passOneReferences = null)
 {
     this.metCache          = metCache;
     this.passOneReferences = passOneReferences ?? this.passOneReferences;
 }