Replace sparkbooth upload with photobooth uploader
This commit is contained in:
33
PhotoboothUploader/Models/PhotoboothConnectResponse.cs
Normal file
33
PhotoboothUploader/Models/PhotoboothConnectResponse.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PhotoboothUploader.Models;
|
||||
|
||||
public sealed class PhotoboothConnectResponse
|
||||
{
|
||||
[JsonPropertyName("data")]
|
||||
public PhotoboothConnectPayload? Data { get; set; }
|
||||
|
||||
[JsonPropertyName("message")]
|
||||
public string? Message { get; set; }
|
||||
}
|
||||
|
||||
public sealed class PhotoboothConnectPayload
|
||||
{
|
||||
[JsonPropertyName("event_name")]
|
||||
public string? EventName { get; set; }
|
||||
|
||||
[JsonPropertyName("upload_url")]
|
||||
public string? UploadUrl { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string? Username { get; set; }
|
||||
|
||||
[JsonPropertyName("password")]
|
||||
public string? Password { get; set; }
|
||||
|
||||
[JsonPropertyName("expires_at")]
|
||||
public string? ExpiresAt { get; set; }
|
||||
|
||||
[JsonPropertyName("response_format")]
|
||||
public string? ResponseFormat { get; set; }
|
||||
}
|
||||
26
PhotoboothUploader/Models/PhotoboothProfile.cs
Normal file
26
PhotoboothUploader/Models/PhotoboothProfile.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace PhotoboothUploader.Models;
|
||||
|
||||
public sealed class PhotoboothProfile
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
public string? EventName { get; set; }
|
||||
public string? BaseUrl { get; set; }
|
||||
public string? UploadUrl { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public string? ResponseFormat { get; set; }
|
||||
public string? WatchFolder { get; set; }
|
||||
public string? IncludePatterns { get; set; }
|
||||
public string? ExcludePatterns { get; set; }
|
||||
public int MaxConcurrentUploads { get; set; } = 2;
|
||||
public int UploadDelayMs { get; set; } = 500;
|
||||
|
||||
public string DisplayName
|
||||
=> !string.IsNullOrWhiteSpace(Label)
|
||||
? Label
|
||||
: !string.IsNullOrWhiteSpace(EventName)
|
||||
? EventName
|
||||
: UploadUrl ?? BaseUrl ?? "Profil";
|
||||
}
|
||||
29
PhotoboothUploader/Models/PhotoboothSettings.cs
Normal file
29
PhotoboothUploader/Models/PhotoboothSettings.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PhotoboothUploader.Models;
|
||||
|
||||
public sealed class PhotoboothSettings
|
||||
{
|
||||
public string? BaseUrl { get; set; }
|
||||
public string? EventName { get; set; }
|
||||
public string? UploadUrl { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? Password { get; set; }
|
||||
public string? ResponseFormat { get; set; }
|
||||
public string? WatchFolder { get; set; }
|
||||
public string? IncludePatterns { get; set; }
|
||||
public string? ExcludePatterns { get; set; }
|
||||
public List<string> PendingUploads { get; set; } = new();
|
||||
public Dictionary<string, string> UploadedFiles { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
public List<PhotoboothProfile> Profiles { get; set; } = new();
|
||||
public string? ConnectExpiresAt { get; set; }
|
||||
public string? LastSeenFile { get; set; }
|
||||
public string? LastSeenAt { get; set; }
|
||||
public string? LastError { get; set; }
|
||||
public string? LastErrorAt { get; set; }
|
||||
public int MaxConcurrentUploads { get; set; } = 2;
|
||||
public int UploadDelayMs { get; set; } = 500;
|
||||
public double WindowWidth { get; set; }
|
||||
public double WindowHeight { get; set; }
|
||||
}
|
||||
74
PhotoboothUploader/Models/UploadItem.cs
Normal file
74
PhotoboothUploader/Models/UploadItem.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace PhotoboothUploader.Models;
|
||||
|
||||
public enum UploadStatus
|
||||
{
|
||||
Queued,
|
||||
Uploading,
|
||||
Success,
|
||||
Failed,
|
||||
}
|
||||
|
||||
public sealed class UploadItem : INotifyPropertyChanged
|
||||
{
|
||||
private UploadStatus _status;
|
||||
private DateTimeOffset _updatedAt;
|
||||
|
||||
public UploadItem(string path)
|
||||
{
|
||||
Path = path;
|
||||
FileName = System.IO.Path.GetFileName(path);
|
||||
UpdatedAt = DateTimeOffset.Now;
|
||||
Status = UploadStatus.Queued;
|
||||
}
|
||||
|
||||
public string Path { get; }
|
||||
|
||||
public string FileName { get; }
|
||||
|
||||
public UploadStatus Status
|
||||
{
|
||||
get => _status;
|
||||
set
|
||||
{
|
||||
if (_status != value)
|
||||
{
|
||||
_status = value;
|
||||
UpdatedAt = DateTimeOffset.Now;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(StatusLabel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTimeOffset UpdatedAt
|
||||
{
|
||||
get => _updatedAt;
|
||||
private set
|
||||
{
|
||||
_updatedAt = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(UpdatedLabel));
|
||||
}
|
||||
}
|
||||
|
||||
public string StatusLabel => Status switch
|
||||
{
|
||||
UploadStatus.Uploading => "Upload läuft",
|
||||
UploadStatus.Success => "Fertig",
|
||||
UploadStatus.Failed => "Fehlgeschlagen",
|
||||
_ => "Wartet",
|
||||
};
|
||||
|
||||
public string UpdatedLabel => $"{UpdatedAt:HH:mm}";
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user