Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UserLoginHistory {
- private set<Id> userids;
- private Map<Id,User> usermap;
- public List<MyLoginHistory> loginHistories {get; set;}
- public UserLoginHistory(List<LoginHistory> histories){
- this.userids = new set<Id>();
- this.usermap = new Map<Id,User>();
- this.loginHistories = new List<MyLoginHistory>();
- for(LoginHistory history : histories){
- this.userids.add(history.UserId);
- }
- for(User u : [Select Id, Profile.Name, Username from User where Id IN : this.userids]){
- this.usermap.put(u.Id, u);
- }
- for(LoginHistory history : histories){
- MyLoginHistory mlh = new MyLoginHistory(history,usermap.get(history.UserId));
- this.loginHistories.add(mlh);
- }
- }
- public class MyLoginHistory{
- public Id UserId {get;set;}
- public String ApiType {get; set;}
- public String ApiVersion {get; set;}
- public String Application {get; set;}
- public Id AuthenticationServiceId {get; set;}
- public String Browser {get;set;}
- public String CipherSuite {get; set;}
- public String ClientVersion {get; set;}
- public String CountryIso {get; set;}
- public Id Id {get; set;}
- public Id LoginGeoId {get; set;}
- public DateTime LoginTime {get; set;}
- public String LoginType {get; set;}
- public String LoginUrl {get; set;}
- public Id NetworkId {get; set;}
- public String Platform {get; set;}
- public String SourceIp {get; set;}
- public String Status {get; set;}
- public String TlsProtocol {get; set;}
- public String Username {get; set;}
- public String ProfileName {get; set;}
- public MyLoginHistory(LoginHistory lh , User u){
- this.UserId = lh.UserId;
- this.ApiType = lh.ApiType;
- this.ApiVersion = lh.ApiVersion;
- this.Application = lh.Application;
- this.AuthenticationServiceId = lh.AuthenticationServiceId;
- this.Browser = lh.Browser;
- this.CipherSuite = lh.CipherSuite;
- this.ClientVersion = lh.ClientVersion;
- this.CountryIso = lh.CountryIso;
- this.Id = lh.Id;
- this.LoginGeoId = lh.LoginGeoId;
- this.LoginTime = lh.LoginTime;
- this.LoginUrl = lh.LoginUrl;
- this.NetworkId = lh.NetworkId;
- this.Platform = lh.Platform;
- this.SourceIp = lh.SourceIp;
- this.Status = lh.Status;
- this.TlsProtocol = lh.TlsProtocol;
- this.Username = u.Username;
- this.ProfileName = u.Profile.Name;
- }
- }
- }
Add Comment
Please, Sign In to add comment