mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Lots of bug corrections
WIP - still lots left
This commit is contained in:
@@ -19,7 +19,7 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
{
|
||||
Uri url;
|
||||
CreateMap<PwEntry, EntryEntity>()
|
||||
//.ForMember(dest => dest.Parent, opt => opt.MapFrom(src => src.ParentGroup))
|
||||
.ForMember(dest => dest.ParentId, opt => opt.MapFrom(src => src.ParentGroup.Uuid.ToHexString()))
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Uuid.ToHexString()))
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField)))
|
||||
.ForMember(dest => dest.UserName, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.UserNameField)))
|
||||
@@ -38,7 +38,6 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
.ForMember(dest => dest.AdditionalFields, opt => opt.MapFrom(src =>
|
||||
src.Strings.Where(s => !PwDefs.GetStandardFields().Contains(s.Key)).ToDictionary(s => s.Key, s => GetEntryValue(src, s.Key))))
|
||||
.ForMember(dest => dest.LastModificationDate, opt => opt.MapFrom(src => new DateTimeOffset(src.LastModificationTime)));
|
||||
//.MaxDepth(1);
|
||||
}
|
||||
|
||||
private void FromModelToDto()
|
||||
|
@@ -15,14 +15,13 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
private void FromDtoToModel()
|
||||
{
|
||||
CreateMap<PwGroup, GroupEntity>()
|
||||
//.ForMember(d => d.Parent, opts => opts.MapFrom(s => s.ParentGroup))
|
||||
.ForMember(d => d.ParentId, opts => opts.MapFrom(s => s.ParentGroup.Uuid.ToHexString()))
|
||||
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Uuid.ToHexString()))
|
||||
.ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name))
|
||||
.ForMember(d => d.Icon, opts => opts.MapFrom(s => IconMapper.MapPwIconToIcon(s.IconId)))
|
||||
.ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime))
|
||||
.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries))
|
||||
.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.Groups));
|
||||
//.MaxDepth(1);
|
||||
.ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime));
|
||||
//.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries))
|
||||
//.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.Groups));
|
||||
}
|
||||
|
||||
private void FromModelToDto()
|
||||
|
@@ -95,7 +95,7 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
_credentials = credentials;
|
||||
_fileAccessToken = fileInfo.Path;
|
||||
|
||||
RootGroup = _mapper.Map<GroupEntity>(_pwDatabase.RootGroup);
|
||||
RootGroup = BuildHierarchy(null, _pwDatabase.RootGroup);
|
||||
return RootGroup;
|
||||
}
|
||||
catch (InvalidCompositeKeyException ex)
|
||||
@@ -125,7 +125,7 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
|
||||
_fileAccessToken = fileInfo.Path;
|
||||
|
||||
RootGroup = _mapper.Map<GroupEntity>(_pwDatabase.RootGroup);
|
||||
RootGroup = BuildHierarchy(null, _pwDatabase.RootGroup);
|
||||
return RootGroup;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,29 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
var fileContents = await _fileService.OpenBinaryFile(fileInfo.Path);
|
||||
return IOConnectionInfo.FromByteArray(fileContents);
|
||||
}
|
||||
|
||||
private GroupEntity BuildHierarchy(GroupEntity parentGroup, PwGroup pwGroup)
|
||||
{
|
||||
var group = _mapper.Map<GroupEntity>(pwGroup);
|
||||
group.Parent = parentGroup;
|
||||
group.Entries = pwGroup.Entries.Select(e =>
|
||||
{
|
||||
var entry = _mapper.Map<EntryEntity>(e);
|
||||
entry.Parent = group;
|
||||
return entry;
|
||||
}).ToList();
|
||||
group.SubGroups = pwGroup.Groups.Select(g => BuildHierarchy(group, g)).ToList();
|
||||
|
||||
/*var group = new GroupEntity
|
||||
{
|
||||
Id = pwGroup.Uuid.ToHexString(),
|
||||
Name = pwGroup.Name,
|
||||
Icon = IconMapper.MapPwIconToIcon(pwGroup.IconId),
|
||||
Entries = pwGroup.Entries.Select(e => _mapper.Map<EntryEntity>(e)).ToList(),
|
||||
SubGroups = pwGroup.Groups.Select(BuildHierarchy).ToList()
|
||||
};*/
|
||||
return group;
|
||||
}
|
||||
|
||||
private PwUuid BuildIdFromString(string id)
|
||||
{
|
||||
return new PwUuid(MemUtil.HexStringToByteArray(id));
|
||||
|
Reference in New Issue
Block a user