2025-07-24 20:40:21 +09:00
|
|
|
#nullable enable
|
2025-07-22 19:58:14 +09:00
|
|
|
using Best.HTTP;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using SampleProject.Config;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2025-07-24 20:40:21 +09:00
|
|
|
using UVC.Data;
|
2025-07-22 19:58:14 +09:00
|
|
|
using UVC.Network;
|
|
|
|
|
|
|
|
|
|
namespace UVC.Factory.Playback
|
|
|
|
|
{
|
|
|
|
|
public class PlaybackRepository
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private PlaybackSQLiteService? sqliteService = null;
|
|
|
|
|
|
|
|
|
|
public async UniTask<Dictionary<string, Dictionary<string, string>>?> RequestPlaybackDateList()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//local
|
|
|
|
|
//string path = System.IO.Path.Combine(Application.streamingAssetsPath, "playbackList.json");
|
|
|
|
|
//string json = System.IO.File.ReadAllText(path);
|
|
|
|
|
|
|
|
|
|
//HttpResponseModel<Dictionary<string, Dictionary<string, string>>> localData = JsonHelper.FromJson<HttpResponseModel<Dictionary<string, Dictionary<string, string>>>>(json);
|
|
|
|
|
//return new EntityWithState<Dictionary<string, Dictionary<string, string>>>(APIState.Loaded, localData.data);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return await UniTask.RunOnThreadPool<Dictionary<string, Dictionary<string, string>>?>(async () =>
|
|
|
|
|
{
|
2025-07-24 20:40:21 +09:00
|
|
|
var response = await HttpRequester.RequestGet<HttpResponseModel<Dictionary<string, Dictionary<string, string>>>>(URLList.Get("playbackList"));
|
2025-07-22 19:58:14 +09:00
|
|
|
if (response.message.ToLower() == "success")
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<string, Dictionary<string, string>>(response.data);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log($"Exception {e.ToString()}");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HTTPRequest? DownloadPlaybackData(string fileName, string savePath, Action<long, long> OnProgress, Action OnComplete, Action<string> OnError)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return HttpRequester.Download($"{Constants.PlaybackDomain}/playback/{fileName}", savePath, OnComplete, OnProgress, OnError);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Debug.Log($"Exception {e.ToString()}");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// selectTime보다 +- second 사이의 데이터 요청. selectTime, second 포함
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="date"></param>
|
|
|
|
|
/// <param name="sqlFileName"></param>
|
|
|
|
|
/// <param name="selectTime">yyyy-MM-ddTHH:mm:ss.fffZ format string</param>
|
|
|
|
|
/// <param name="second"></param>
|
|
|
|
|
/// <param name="orderAsc">true: 오래된 시간이 먼저, false: 최근 시간이 먼저</param>
|
|
|
|
|
/// <param name="limit"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async UniTask<List<PlaybackSQLiteDataEntity>> SelectBySecondAsync(string date, string sqlFileName, string selectTime, int second, bool orderAsc = true, int limit = 0)
|
|
|
|
|
{
|
|
|
|
|
validationSqliteService(date, sqlFileName);
|
|
|
|
|
return await sqliteService!.SelectBySecond(selectTime, second, orderAsc, limit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// selectTime보다 +- second 사이의 데이터 요청. selectTime, second 포함
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="date"></param>
|
|
|
|
|
/// <param name="sqlFileName"></param>
|
|
|
|
|
/// <param name="selectTime">yyyy-MM-ddTHH:mm:ss.fffZ format string</param>
|
|
|
|
|
/// <param name="second"></param>
|
|
|
|
|
/// <param name="orderAsc">true: 오래된 시간이 먼저, false: 최근 시간이 먼저</param>
|
|
|
|
|
/// <param name="limit"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async UniTask<List<PlaybackSQLiteDataEntity>> SelectBySecondBaseInfo(string date, string sqlFileName, string selectTime, int second = 59, bool orderAsc = true, int limit = 1)
|
|
|
|
|
{
|
|
|
|
|
validationSqliteService(date, sqlFileName);
|
|
|
|
|
return await sqliteService!.SelectBySecondBaseInfo(selectTime, second, orderAsc, limit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void validationSqliteService(string date, string sqlFileName)
|
|
|
|
|
{
|
|
|
|
|
if (sqliteService == null) sqliteService = new PlaybackSQLiteService();
|
|
|
|
|
if (sqliteService.Connected)
|
|
|
|
|
{
|
|
|
|
|
if (sqliteService.Date != date || sqliteService.SqliteFileName != sqlFileName)
|
|
|
|
|
{
|
|
|
|
|
sqliteService.CloseDB();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sqliteService.Connect(date, sqlFileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|