Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date issue on log in admin #2055

Closed
corymisc opened this issue Jan 23, 2017 · 3 comments
Closed

date issue on log in admin #2055

corymisc opened this issue Jan 23, 2017 · 3 comments

Comments

@corymisc
Copy link

when you go to the admin > system > log. You'll see a different timezone date than in the detail view. The UTC is not converted correctly to the users' time. I corrected the bug by updating the script from

var gridModel = new DataSourceResult
{
Data = logItems.Select(x => new LogModel
{
Id = x.Id,
LogLevel = x.LogLevel.GetLocalizedEnum(_localizationService, _workContext),
ShortMessage = x.ShortMessage,
little hack here:
ensure that FullMessage is not returned
otherwise, we can get the following error if log records have too long FullMessage:
"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
also it improves performance
FullMessage = x.FullMessage,
FullMessage = "",
IpAddress = x.IpAddress,
CustomerId = x.CustomerId,
CustomerEmail = x.Customer != null ? x.Customer.Email : null,
PageUrl = x.PageUrl,
ReferrerUrl = x.ReferrerUrl,
CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc)
}),
Total = logItems.TotalCount
};

to

var logs = new List();
foreach(var log in logItems)
{
logs.Add(new LogModel {
Id = log.Id,
LogLevel = log.LogLevel.GetLocalizedEnum(_localizationService,_workContext),
ShortMessage = log.ShortMessage,
FullMessage="",
IpAddress=log.IpAddress,
CustomerId=log.CustomerId,
CustomerEmail = log.Customer !=null ? log.Customer.Email:null,
PageUrl = log.PageUrl,
ReferrerUrl=log.ReferrerUrl,
CreatedOn = _dateTimeHelper.ConvertToUserTime(log.CreatedOnUtc,DateTimeKind.Utc)
});
}

        var gridModel = new DataSourceResult
        {
            Data = logs,
            Total = logItems.TotalCount
        };

works now

@AndreiMaz
Copy link
Member

Hi,

So what is the difference with the time now? Nothing seems to be logically changed

@corymisc
Copy link
Author

although it may appear that logically nothing changed, but for some reason as I was scratching my head, the convert to local time for this particular call was not working. Please use the debug mode, you'll see for yourself, unless I'm wrong.

@AndreiMaz
Copy link
Member

I don't think this issue could be resolved this way (this code doesn't change anything). I'm more than sure that it's related to #33 (duplicated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants