public EntityChange( string auditLogId, EntityChangeInfo entityChangeInfo, string tenantId = null) { Id = IDUtils.NewIdString(); AuditLogId = auditLogId; TenantId = tenantId; ChangeTime = entityChangeInfo.ChangeTime; ChangeType = entityChangeInfo.ChangeType; EntityId = entityChangeInfo.EntityId.Truncate(EntityChangeConsts.MaxEntityTypeFullNameLength); EntityTypeFullName = entityChangeInfo.EntityTypeFullName.TruncateFromBeginning(EntityChangeConsts.MaxEntityTypeFullNameLength); PropertyChanges = entityChangeInfo .PropertyChanges? .Select(p => new EntityPropertyChange(Id, p, tenantId)) .ToList() ?? new List <EntityPropertyChange>(); ExtraProperties = new ExtraPropertyDictionary(); if (entityChangeInfo.ExtraProperties != null) { foreach (var pair in entityChangeInfo.ExtraProperties) { ExtraProperties.Add(pair.Key, pair.Value); } } }
protected virtual void TrySetGuidId(IEntity <Guid> entity) { if (entity.Id != default) { return; } EntityHelper.TrySetId(entity, IDUtils.NewIdString(), true); }
public EntityPropertyChange( string entityChangeId, EntityPropertyChangeInfo entityChangeInfo, string tenantId = null) { Id = IDUtils.NewIdString(); TenantId = tenantId; EntityChangeId = entityChangeId; NewValue = entityChangeInfo.NewValue.Truncate(EntityPropertyChangeConsts.MaxNewValueLength); OriginalValue = entityChangeInfo.OriginalValue.Truncate(EntityPropertyChangeConsts.MaxOriginalValueLength); PropertyName = entityChangeInfo.PropertyName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyNameLength); PropertyTypeFullName = entityChangeInfo.PropertyTypeFullName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyTypeFullNameLength); }
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey) { var setting = await SettingRepository.FindAsync(name, providerName, providerKey); if (setting == null) { setting = new Setting(IDUtils.NewIdString(), name, value, providerName, providerKey); await SettingRepository.InsertAsync(setting); } else { setting.Value = value; await SettingRepository.UpdateAsync(setting); } await Cache.SetAsync(CalculateCacheKey(name, providerName, providerKey), new SettingCacheItem(setting?.Value), considerUow : true); }
public virtual Task <AuditLog> ConvertAsync(AuditLogInfo auditLogInfo) { var auditLogId = IDUtils.NewIdString(); var extraProperties = new ExtraPropertyDictionary(); if (auditLogInfo.ExtraProperties != null) { foreach (var pair in auditLogInfo.ExtraProperties) { extraProperties.Add(pair.Key, pair.Value); } } var entityChanges = auditLogInfo .EntityChanges? .Select(entityChangeInfo => new EntityChange(auditLogId, entityChangeInfo, tenantId: auditLogInfo.TenantId)) .ToList() ?? new List <EntityChange>(); var actions = auditLogInfo .Actions? .Select(auditLogActionInfo => new AuditLogAction(IDUtils.NewIdString(), auditLogId, auditLogActionInfo, tenantId: auditLogInfo.TenantId)) .ToList() ?? new List <AuditLogAction>(); var remoteServiceErrorInfos = auditLogInfo.Exceptions?.Select(exception => ExceptionToErrorInfoConverter.Convert(exception, true)) ?? new List <RemoteServiceErrorInfo>(); var exceptions = remoteServiceErrorInfos.Any() ? JsonSerializer.Serialize(remoteServiceErrorInfos) : null; var comments = auditLogInfo .Comments? .JoinAsString(Environment.NewLine); var auditLog = new AuditLog( auditLogId, auditLogInfo.ApplicationName, auditLogInfo.TenantId, auditLogInfo.TenantName, auditLogInfo.UserId, auditLogInfo.UserName, auditLogInfo.ExecutionTime, auditLogInfo.ExecutionDuration, auditLogInfo.ClientIpAddress, auditLogInfo.ClientName, auditLogInfo.ClientId, auditLogInfo.CorrelationId, auditLogInfo.BrowserInfo, auditLogInfo.HttpMethod, auditLogInfo.Url, auditLogInfo.HttpStatusCode, auditLogInfo.ImpersonatorUserId, auditLogInfo.ImpersonatorTenantId, extraProperties, entityChanges, actions, exceptions, comments ); return(Task.FromResult(auditLog)); }