Activities of "liangshiwei"

Has your first problem been solved? Please create a new post to discuss. Thanks.

Hi,

Please use the following method to get the token:

Hi,

I create a simple implementation, but I don't know about AWS-CloudWatch, I hope I can help you.

[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IAuditingStore))]
public class CustomAuditingStore : AuditingStore
{
    private readonly LogEventBatch _repo = new LogEventBatch();
    private readonly IAmazonCloudWatchLogs _client;
    private int _requestCount = 5;

    private static readonly Regex InvalidSequenceTokenRegex = new
        Regex(@"The given sequenceToken is invalid. The next expected sequenceToken is: (\d+)");

    public CustomAuditingStore(
        IAuditLogRepository auditLogRepository,
        IGuidGenerator guidGenerator,
        IUnitOfWorkManager unitOfWorkManager,
        IOptions<AbpAuditingOptions> options)
        : base(auditLogRepository, guidGenerator, unitOfWorkManager, options)
    {
        _client = new AmazonCloudWatchLogsClient(..your config);
    }

    public override async Task SaveAsync(AuditLogInfo auditInfo)
    {
        AddSingleMessage(JsonConvert.SerializeObject(auditInfo));
        await SendMessages();
        await base.SaveAsync(auditInfo);
    }

    private void AddSingleMessage(string message)
    {
        _repo.AddMessage(new InputLogEvent()
        {
            Timestamp = DateTime.Now,
            Message = message,
        });
    }

    private async Task SendMessages()
    {
        try
        {
            //Make sure the log events are in the right order.
            _repo._request.LogEvents.Sort((ev1, ev2) => ev1.Timestamp.CompareTo(ev2.Timestamp));
            var response = await _client.PutLogEventsAsync(_repo._request).ConfigureAwait(false);
            _repo.Reset(response.NextSequenceToken);
            _requestCount = 5;
        }
        catch (InvalidSequenceTokenException ex)
        {
            //In case the NextSequenceToken is invalid for the last sent message, a new stream would be
            //created for the said application.
            if (_requestCount > 0)
            {
                _requestCount--;
                var regexResult = InvalidSequenceTokenRegex.Match(ex.Message);
                if (regexResult.Success)
                {
                    _repo._request.SequenceToken = regexResult.Groups[1].Value;
                    await SendMessages().ConfigureAwait(false);
                }
            }
        }
    }
}

/// <summary>
/// Class to handle PutLogEvent request and associated parameters.
/// Also has the requisite checks to determine when the object is ready for Transmission.
/// </summary>
public class LogEventBatch
{
    public TimeSpan TimeIntervalBetweenPushes { get; private set; }
    public int MaxBatchSize { get; private set; }

    public bool ShouldSendRequest(int maxQueuedEvents)
    {
        if (_request.LogEvents.Count == 0)
        {
            return false;
        }

        if (_nextPushTime < DateTime.UtcNow)
        {
            return true;
        }

        if (maxQueuedEvents <= _request.LogEvents.Count)
        {
            return true;
        }

        return false;
    }

    int _totalMessageSize { get; set; }
    DateTime _nextPushTime;
    public PutLogEventsRequest _request = new PutLogEventsRequest();

    public LogEventBatch(string logGroupName, string streamName, int timeIntervalBetweenPushes, int maxBatchSize)
    {
        _request.LogGroupName = logGroupName;
        _request.LogStreamName = streamName;
        TimeIntervalBetweenPushes = TimeSpan.FromSeconds(timeIntervalBetweenPushes);
        MaxBatchSize = maxBatchSize;
        Reset(null);
    }

    public LogEventBatch()
    {
    }

    public int CurrentBatchMessageCount
    {
        get { return this._request.LogEvents.Count; }
    }

    public bool IsEmpty => _request.LogEvents.Count == 0;

    public bool IsSizeConstraintViolated(string message)
    {
        Encoding unicode = Encoding.Unicode;
        int prospectiveLength = _totalMessageSize + unicode.GetMaxByteCount(message.Length);
        if (MaxBatchSize < prospectiveLength)
            return true;

        return false;
    }

    public void AddMessage(InputLogEvent ev)
    {
        Encoding unicode = Encoding.Unicode;
        _totalMessageSize += unicode.GetMaxByteCount(ev.Message.Length);
        _request.LogEvents.Add(ev);
    }

    public void Reset(string SeqToken)
    {
        _request.LogEvents.Clear();
        _totalMessageSize = 0;
        _request.SequenceToken = SeqToken;
        _nextPushTime = DateTime.UtcNow.Add(TimeIntervalBetweenPushes);
    }
}

Yes you can.

You can custom AuditingStore to save auditlog to AWS-CloudWatch.

Hi

You can create a host application, which contains identity management module and localization management module

Hi,

The current design of the menu does not consider persistence to the database, you need to do some work for this.

1. You need to create an entity that is compatible with ApplicationMenu.

2. Create a service that persists all menus to the database when the application is initialized(If the menu is not in the database table)

3. Custom DatabaseMenuManager to replace MenuManager and get the menu from the database(should be filtered based on the current user).

Hi

Try:

Configure<IdentityOptions>(options =>
{
    //null allows all characters
    options.User.AllowedUserNameCharacters = null;
});

I created an issue https://github.com/abpframework/abp/issues/4232 for this.

Hi,

Downlown the source code and find configuration.dom .... line , replace it with the following

var dom = '<"dataTable_filters"f>rt<"row dataTable_footer"<"col-auto"l><"col-auto"i><"col"p>>';

if(configuration.dom){
    configuration.dom += dom;
}else{
    configuration.dom = dom;
}

Use BundleContributor Replace files:

public class DataTablesScriptBundleContributor : BundleContributor
{
    public override void ConfigureBundle(BundleConfigurationContext context)
    {
        context.Files.ReplaceOne(
            "/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js",
            "/js/databales-extensions.js");
    }
}

In your index.js

var _dataTable = _$table.DataTable(abp.libs.datatables.normalizeConfiguration({
    ......
    dom :"B",
    buttons: [
        'copyHtml5',
        'excelHtml5',
        'csvHtml5',
        'pdfHtml5'
    ]
}));

Now, it works.

Do you have Teamviewer? You can send connection id to my email: liangshiw@outlook.com, Thanks.

Showing 4661 to 4670 of 4800 entries
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11