Skip to content

Commit

Permalink
Merge pull request #138 from VPKSoft/userDataBackup
Browse files Browse the repository at this point in the history
Add user data backup
  • Loading branch information
Petteri Kautonen authored Oct 10, 2022
2 parents e1e8ca1 + 3f7bf0f commit 37f6977
Show file tree
Hide file tree
Showing 51 changed files with 1,505 additions and 98 deletions.
22 changes: 22 additions & 0 deletions Help/amp-en/docs/command_line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Command line arguments
The software supports command line arguments mostly for backup and restore backup purposes.

The command line help can be accessed via the `--help` argument.

```
amp.EtoForms 1.0.1.3
Copyright © VPKSoft 2022
-p, --pid A process identifier (PID) to wait for exit before starting
the application.
-b, --backup A file name to backup the application data before complete
startup.
-r, --restore Restores a backup from a zipped file into the program
application data folder overriding the existing.
--help Display this help screen.
--version Display version information.
```
Binary file modified Help/amp-en/docs/img/img_linux/settings5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Help/amp-en/docs/img/img_macos/settings5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Help/amp-en/docs/img/img_windows/settings5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion Help/amp-en/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ A value indicating whether to visualize the audio levels vertical or horizontal.
On this tab there are the miscellaneous settings which do not belong to any specific category directly.

**Actions after the queue has finished**
Tow actions can be defined to in the programs which are run when the queue has finished playing.

Two actions can be defined to in the programs which are run when the queue has finished playing.

The actions are:

Expand All @@ -97,6 +98,18 @@ The actions are:

If the first action can not be run, the second action is run. Otherwise the first action is run and the situation is re-evaluated after the queue has finished playing again.

**Backup application data**

Allows user to backup the SQLite database and setting files of the software into a single zip file. The backup does not require application restart, only the playback is required to be stopped.

Before the backup is made the following information is displayed: *"The playback will be stopped for the backup."* followed by *"Backup completed"* message.

**Restore application data**

Allows user to restore backed up application data from a zip file. The zip file contents will not validated. The playback will be stopped during the restore and afterwards the application will exit and it has to be started again manually.

Before the backup is restored a following information is displayed: *"The application will shut down after the backup has been restored. Start the software again manually."*. After the backup has been restored a following message is displayed: *"Backup restore completed."*.

*The Miscellaneous tab*

![image](img/settings5.png)
1 change: 1 addition & 0 deletions Help/amp-en/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nav:
- Icon settings: icon_settings.md
- Keyboard shortcuts: keyboard_shortcuts.md
- Data storing: data_storing.md
- Command line arguments: command_line.md
- License: license.md

copyright: Copyright © 2022 VPKSoft
22 changes: 22 additions & 0 deletions Help/amp-fi/docs/command_line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Komentoriviparametrit
Sovellus tukee komentoriviparametrejä enimmäkseen varmuuskopiointia ja varmuuskopion palautusta varten.

Komentoriviparametrien aputekstin saa näkyviin käyttämällä `--help`-valitsinta.

```
amp.EtoForms 1.0.1.3
Copyright © VPKSoft 2022
-p, --pid Prosessitunniste (PID) jonka päättymistä
odottaa ennen sovelluksen käynnistämistä.
-b, --backup Tiedostonimi johon varmuuskopioida sovelluksen
tiedot ennen käynnistymistä.
-r, --restore Palauttaa ZIP-pakatun varmuuskopioin sovelluksen
tietokansioon kirjoittaen yli olemassa olevat tiedostot.
--help Näytä tämä apunäkymä.
--version Näytä versiotiedot.
```
Binary file modified Help/amp-fi/docs/img/img_linux/settings5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Help/amp-fi/docs/img/img_macos/settings5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Help/amp-fi/docs/img/img_windows/settings5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions Help/amp-fi/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Arvo, millä ilmaistaan visualisoidaanko äänen voimakkuus vaaka- vai pystysuun
Tällä välilehdellä on sekalaiset asetukset jotka eivät suoraan kuulu mihinkään kategoriaan.

**Toimenpiteet jonon loputtua**

Ohjelmassa voi määritellä 2 toimenpidettä, jotka suoritetaan jonon loputtua.

Toimenpiteet ovat:
Expand All @@ -98,6 +99,17 @@ Toimenpiteet ovat:

Jos ensimmäistä toimenpidettä ei voida suorittaa, suoritetaan seuraava, muussa tapauksessa pysähdytään ensimmäiseen toimenpiteeseen ja arvioidaan tilanne uudelleen jonon loputtua.

**Varmuuskopioi sovelluksen tiedot**
Antaa käyttäjän varmuuskopioida SQLite-tietokanta ja asetustiedostot ohjelmasta yksittäiseen zip-tiedostoon. Varmuuskopiointi ei tarvitse sovelluksen uudelleen käynnistämistä, pelkkä toiston pysäyttäminen riittää.

Ennen varmuuskopioinnin suorittamista näytetään seuraava viesti:
*"Toisto pysäytetään varmuuskopiointia varten."* jota seuraa *"Varmuuskopiointi valmis."* viesti.

**Palauta sovelluksen tiedot**
Antaa käyttäjän palauttaa sovelluksen tiedot zip-tiedostosta. Zip-tiedoston sisältöä ei tarkasteta. Toisto pysäytetään varmuuskopiota palautettaessa ja sovellus sulkeutuu ja se pitää käynnistää uudelleen manuaalisesti.

Ennen varmuuskopion palauttamista näytetään seuraava viesti: *"Sovellus sammutetaan varmuuskopion palauttamisen jälkeen. Käynnistä sovellus uudelleen manuaalisesti."*. Kun varmuuskopion palautus on valmis näytetään vielä viesti: *"Varmuuskopioinnin palautus valmis."*.

*Sekalaista-välilehti*

![image](img/settings5.png)
1 change: 1 addition & 0 deletions Help/amp-fi/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nav:
- Ikonien asetukset: icon_settings.md
- Näppäinoikotiet: keyboard_shortcuts.md
- Tiedon tallennus: data_storing.md
- Komentoriviparametrit: command_line.md
- Lisenssi: license.md

copyright: Copyright © 2022 VPKSoft
34 changes: 17 additions & 17 deletions amp.DataAccessLayer/DtoClasses/AudioTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public sealed class AudioTrack : IAudioTrack, INotifyPropertyChanged
private int? playedByUser;
private int? skippedEarlyCount;
private string fileName = string.Empty;
private string filePath = string.Empty;
private string? artist;
private string? album;
private string? track;
Expand All @@ -57,7 +58,6 @@ public sealed class AudioTrack : IAudioTrack, INotifyPropertyChanged
private string? overrideName;
private string? tagFindString;
private bool? tagRead;
private string? fileNameNoPath;
private string? title;
private byte[]? trackImageData;
private MusicFileType musicFileType;
Expand Down Expand Up @@ -89,7 +89,7 @@ public void UpdateDataModel(amp.Database.DataModel.AudioTrack? audioTrack)
audioTrack.MusicFileType = MusicFileType;
audioTrack.TagFindString = TagFindString;
audioTrack.TagRead = TagRead;
audioTrack.FileNameNoPath = FileNameNoPath;
audioTrack.FilePath = FilePath;
audioTrack.Title = Title;
audioTrack.TrackImageData = TrackImageData;
audioTrack.OverrideName = OverrideName;
Expand Down Expand Up @@ -189,6 +189,21 @@ public string FileName
}
}

/// <inheritdoc cref="IAudioTrack.FilePath"/>
public string FilePath
{
get => filePath;
set
{
if (filePath != value)
{
filePath = value;
OnPropertyChanged();
}
}

}

/// <inheritdoc cref="IAudioTrack.Artist"/>
public string? Artist
{
Expand Down Expand Up @@ -354,21 +369,6 @@ public bool? TagRead
}
}

/// <inheritdoc cref="IAudioTrack.FileNameNoPath"/>
public string? FileNameNoPath
{
get => fileNameNoPath;

set
{
if (fileNameNoPath != value)
{
fileNameNoPath = value;
OnPropertyChanged();
}
}
}

/// <inheritdoc cref="IAudioTrack.Title"/>
public string? Title
{
Expand Down
2 changes: 1 addition & 1 deletion amp.DataAccessLayer/amp.DataAccessLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="11.0.1" />
<PackageReference Include="AutoMapper" Version="12.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 27 additions & 1 deletion amp.Database/AmpContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,22 @@ public AmpContext()
QueueSnapshots = base.Set<QueueSnapshot>();
QueueTracks = base.Set<QueueTrack>();
QueueStashes = base.Set<QueueStash>();
VersionInfo = base.Set<VersionInfo>();
SoftwareMigrationVersion = base.Set<SoftwareMigrationVersion>();
}

/// <summary>
/// Initializes a new instance of the <see cref="AmpContext"/> class with a custom SQLite database file.
/// </summary>
/// <param name="databaseFile">The custom SQLite database file.</param>
public AmpContext(string databaseFile)
: this()
{
this.databaseFile = databaseFile;
}

private readonly string? databaseFile;

// ReSharper disable five times MemberCanBePrivate.Global, these entities will be used.
// ReSharper disable five times UnusedAutoPropertyAccessor.Global, these entities will be used.

Expand Down Expand Up @@ -92,10 +106,22 @@ public AmpContext()
/// <value>The stashed queue tracks.</value>
public DbSet<QueueStash> QueueStashes { get; }

/// <summary>
/// Gets the version information for the <see cref="FluentMigrator"/>.
/// </summary>
/// <value>The version information for the <see cref="FluentMigrator"/>.</value>
public DbSet<VersionInfo> VersionInfo { get; }

/// <summary>
/// Gets the software migration versions.
/// </summary>
/// <value>The software migration versions.</value>
public DbSet<SoftwareMigrationVersion> SoftwareMigrationVersion { get; }

/// <inheritdoc cref="DbContext.OnConfiguring"/>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite(Globals.ConnectionString);
optionsBuilder.UseSqlite(databaseFile ?? Globals.ConnectionString);
optionsBuilder.EnableSensitiveDataLogging();
#if DEBUG
optionsBuilder.LogTo(s =>
Expand Down
38 changes: 19 additions & 19 deletions amp.Database/DataModel/AudioTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,55 +47,55 @@ public class AudioTrack : IAudioTrack, IRowVersionEntity
/// <inheritdoc cref="IAudioTrack.FileName"/>
public string FileName { get; set; } = string.Empty;

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.FilePath"/>
public string FilePath { get; set; } = string.Empty;

/// <inheritdoc cref="IAudioTrack.Artist"/>
public string? Artist { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.Album"/>
public string? Album { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.Track"/>
public string? Track { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.Year"/>
public string? Year { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.Lyrics"/>
public string? Lyrics { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.Rating"/>
public int? Rating { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IPlayBackStatistics.PlayedByRandomize"/>
public int? PlayedByRandomize { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IPlayBackStatistics.PlayedByUser"/>
public int? PlayedByUser { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.FileSizeBytes"/>
public long? FileSizeBytes { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.PlaybackVolume"/>
public double PlaybackVolume { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.OverrideName"/>
public string? OverrideName { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.TagFindString"/>
public string? TagFindString { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.TagRead"/>
public bool? TagRead { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
public string? FileNameNoPath { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IPlayBackStatistics.SkippedEarlyCount"/>
public int? SkippedEarlyCount { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.Title"/>
public string? Title { get; set; }

/// <inheritdoc cref="IAudioTrack.FileName"/>
/// <inheritdoc cref="IAudioTrack.TrackImageData"/>
public byte[]? TrackImageData { get; set; }

/// <inheritdoc cref="IAudioTrack.MusicFileType"/>
Expand Down
46 changes: 46 additions & 0 deletions amp.Database/DataModel/SoftwareMigrationVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#region License
/*
MIT License
Copyright(c) 2022 Petteri Kautonen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#endregion

using amp.Shared.Interfaces;

namespace amp.Database.DataModel;

/// <summary>
/// An entity to store version info of the software migrations.
/// Implements the <see cref="amp.Shared.Interfaces.IEntityBase{T}" />
/// </summary>
/// <seealso cref="amp.Shared.Interfaces.IEntityBase{T}" />
public class SoftwareMigrationVersion : IEntityBase<long>
{
/// <inheritdoc />
public long Id { get; set; }

/// <summary>
/// Gets or sets the software migration version.
/// </summary>
/// <value>The software migration version.</value>
public int Version { get; set; }
}
Loading

0 comments on commit 37f6977

Please sign in to comment.