UploaderScene
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1352748d12284d14b85934b4f6da672f
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using GhostSystem;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public class BatchUploader : MonoBehaviour
|
||||||
|
{
|
||||||
|
public TMP_InputField fileNameInput;
|
||||||
|
public TMP_Text logText;
|
||||||
|
|
||||||
|
private string _offlinePath;
|
||||||
|
|
||||||
|
public void StartUpload()
|
||||||
|
{
|
||||||
|
string filename = fileNameInput.text + ".jsonl";
|
||||||
|
_offlinePath = Path.Combine(Application.persistentDataPath, filename);
|
||||||
|
|
||||||
|
UploadOfflineDataAsync();
|
||||||
|
}
|
||||||
|
private async UniTask UploadOfflineDataAsync()
|
||||||
|
{
|
||||||
|
if (!File.Exists(_offlinePath))
|
||||||
|
{
|
||||||
|
logText.text += "\r\n" + "Keine Offline-Datei gefunden.";
|
||||||
|
Debug.Log("Keine Offline-Datei gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<FrameModel> offlineBatch = new List<FrameModel>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Datei zeilenweise lesen und deserialisieren
|
||||||
|
string[] lines = await File.ReadAllLinesAsync(_offlinePath);
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FrameModel model = JsonConvert.DeserializeObject<FrameModel>(line);
|
||||||
|
if (model != null)
|
||||||
|
offlineBatch.Add(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logText.text += "\r\n" + $"Fehler beim Deserialisieren einer Zeile: {ex.Message}";
|
||||||
|
Debug.LogWarning($"Fehler beim Deserialisieren einer Zeile: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offlineBatch.Count == 0)
|
||||||
|
{
|
||||||
|
logText.text += "\r\n" + "Keine gültigen Datensätze zum Hochladen gefunden.";
|
||||||
|
Debug.Log("Keine gültigen Datensätze zum Hochladen gefunden.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload zu Supabase
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await SupabaseManager.instance.supabase
|
||||||
|
.From<FrameModel>()
|
||||||
|
.Insert(offlineBatch);
|
||||||
|
|
||||||
|
if (response != null)
|
||||||
|
{
|
||||||
|
logText.text += "\r\n" + $"Erfolgreich {offlineBatch.Count} Datensätze hochgeladen.";
|
||||||
|
Debug.Log($"Erfolgreich {offlineBatch.Count} Datensätze hochgeladen.");
|
||||||
|
File.Delete(_offlinePath); // Datei löschen nach erfolgreichem Upload
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logText.text += "\r\n" + $"Fehler beim Hochladen zur Supabase: {ex.Message}";
|
||||||
|
Debug.LogError($"Fehler beim Hochladen zur Supabase: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logText.text += "\r\n" + $"Fehler beim Lesen der Offline-Datei: {ex.Message}";
|
||||||
|
Debug.LogError($"Fehler beim Lesen der Offline-Datei: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3ea226b6e5ecf314b8cff03760732315
|
||||||
@@ -29,28 +29,28 @@ EditorBuildSettings:
|
|||||||
- enabled: 0
|
- enabled: 0
|
||||||
path: Assets/_Scenes/VRHomeSceneMeta Offline.unity
|
path: Assets/_Scenes/VRHomeSceneMeta Offline.unity
|
||||||
guid: b98b0de9fe670d2469cfbcd6e1d2d8f5
|
guid: b98b0de9fe670d2469cfbcd6e1d2d8f5
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/TrainingObserverMeta.unity
|
path: Assets/_Scenes/TrainingObserverMeta.unity
|
||||||
guid: 0572ea139ec37b84b88a8d21771f7f1a
|
guid: 0572ea139ec37b84b88a8d21771f7f1a
|
||||||
- enabled: 0
|
- enabled: 0
|
||||||
path: Assets/_Scenes/NetworkTest.unity
|
path: Assets/_Scenes/NetworkTest.unity
|
||||||
guid: b5976c62b73452e43a494b19eee50119
|
guid: b5976c62b73452e43a494b19eee50119
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/Scene.unity
|
path: Assets/_Scenes/Scene.unity
|
||||||
guid: 11b18db492095254c9c0a7b292054491
|
guid: 11b18db492095254c9c0a7b292054491
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 1.unity
|
path: Assets/_Scenes/CQB/Room 1.unity
|
||||||
guid: 2e4e9a5b844db9f458416b2581e2578c
|
guid: 2e4e9a5b844db9f458416b2581e2578c
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 2.unity
|
path: Assets/_Scenes/CQB/Room 2.unity
|
||||||
guid: 72daf40eaf586c147b8409af02cc27f2
|
guid: 72daf40eaf586c147b8409af02cc27f2
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 3.unity
|
path: Assets/_Scenes/CQB/Room 3.unity
|
||||||
guid: 12415f6ebf42d2f47ab95cb8fc0274b3
|
guid: 12415f6ebf42d2f47ab95cb8fc0274b3
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 4.unity
|
path: Assets/_Scenes/CQB/Room 4.unity
|
||||||
guid: 9c3e0cbba3a803842b86a08ec509fa92
|
guid: 9c3e0cbba3a803842b86a08ec509fa92
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 5.unity
|
path: Assets/_Scenes/CQB/Room 5.unity
|
||||||
guid: 64645be25f3eeb34782c789128fb4e17
|
guid: 64645be25f3eeb34782c789128fb4e17
|
||||||
- enabled: 0
|
- enabled: 0
|
||||||
@@ -62,21 +62,24 @@ EditorBuildSettings:
|
|||||||
- enabled: 0
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 8.unity
|
path: Assets/_Scenes/CQB/Room 8.unity
|
||||||
guid: fa69debb6d26d964796048ef6f42ebb1
|
guid: fa69debb6d26d964796048ef6f42ebb1
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 9.unity
|
path: Assets/_Scenes/CQB/Room 9.unity
|
||||||
guid: 8b243d14706b2414797a529a14093735
|
guid: 8b243d14706b2414797a529a14093735
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 10.unity
|
path: Assets/_Scenes/CQB/Room 10.unity
|
||||||
guid: c9eb5c51cf179f74fbfb717cfaf47e06
|
guid: c9eb5c51cf179f74fbfb717cfaf47e06
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 11.unity
|
path: Assets/_Scenes/CQB/Room 11.unity
|
||||||
guid: 2e02886277d207e4ba89ce5163286c99
|
guid: 2e02886277d207e4ba89ce5163286c99
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/Room 12.unity
|
path: Assets/_Scenes/CQB/Room 12.unity
|
||||||
guid: 183ff68200b7fb8498ca55bf95de872c
|
guid: 183ff68200b7fb8498ca55bf95de872c
|
||||||
- enabled: 0
|
- enabled: 0
|
||||||
path: Assets/_Scenes/CQB/End.unity
|
path: Assets/_Scenes/CQB/End.unity
|
||||||
guid: 1aa1485b0239d5943aaca87a1154ad67
|
guid: 1aa1485b0239d5943aaca87a1154ad67
|
||||||
|
- enabled: 1
|
||||||
|
path: Assets/_Scenes/Uploader.unity
|
||||||
|
guid: 1352748d12284d14b85934b4f6da672f
|
||||||
m_configObjects:
|
m_configObjects:
|
||||||
Unity.XR.Oculus.Settings: {fileID: 11400000, guid: 734f15aa67f6c994aabd946b919ab4ea,
|
Unity.XR.Oculus.Settings: {fileID: 11400000, guid: 734f15aa67f6c994aabd946b919ab4ea,
|
||||||
type: 2}
|
type: 2}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ PlayerSettings:
|
|||||||
useOnDemandResources: 0
|
useOnDemandResources: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: TH
|
companyName: TH
|
||||||
productName: RoomAware Replay App
|
productName: Offline Batch Uploader
|
||||||
defaultCursor: {fileID: 0}
|
defaultCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
||||||
|
|||||||
Reference in New Issue
Block a user