保存优化&本地记录自动上传

This commit is contained in:
lishuo 2022-02-21 16:16:35 +08:00
parent f5294b0d39
commit 0c1c2ed382
3 changed files with 35 additions and 23 deletions

View File

@ -62,6 +62,7 @@ public class CyclingController : DeviceServiceMonoBase
#endregion
GameObject loadingcanvas;
AbstratctLoadingController loadingController;
private async Task Login()
{
var result = await new UserApi().Login("15261826280", "123456", "");
@ -73,6 +74,8 @@ public class CyclingController : DeviceServiceMonoBase
public GraphChartBase graph { get; set; }
private float activeSeconds { get; set; }//移动端用户进入骑行超过2min界面进入沉浸状态
public int RankingId;
public string recordId;
protected override void Awake()
{
base.Awake();
@ -83,6 +86,7 @@ public class CyclingController : DeviceServiceMonoBase
}
#endif
//获取路书信息
recordId = Guid.NewGuid().ToString();
mapApi = ConfigHelper.mapApi;
routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633;
competitionId = App.CompetionId;
@ -1196,14 +1200,14 @@ public BaseUIManager singleUIManager;
var tempContent = Newtonsoft.Json.JsonConvert.SerializeObject(tempRecordData);
System.IO.File.WriteAllText(filePath, tempContent);
}
public int RankingId;
public void Save(double totalDistance)
{
ClearTempFile();
cyclingController.recorderData.EndTime = UIManager.Now.GetDateTime();
isQuit = true;
isStart = false;
string recordId = Guid.NewGuid().ToString();
//string recordId = Guid.NewGuid().ToString();
//var path = Helper.GetDataDir("MapWorkoutRecords/"+ recordId);
var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId;
Helper.CreateDirectoryIfNotExsit(path);

View File

@ -88,33 +88,41 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH
listFileName.Add(item);
}
}
DeleteLocalRecord();
}
void DeleteLocalRecord(bool showMessage=false)
{
//自动上传
try
{
MapInterruptRecordApi service = ConfigHelper.mapInterruptRecordApi;
var result = service.Add(record, listFileName);
//删除文件
if (result.result)
{
Helper.DelectDir(path);
Destroy(gameObject);
}
if (showMessage)
{
Utils.showToast(gameObject, result.errMsg);
}
}
catch (Exception e)
{
Utils.showToast(gameObject, e.Message);
}
}
void GoUplaod()
{
UIManager.ShowConfirm("Upload", "Upload the local record?", () =>
{
try
{
MapInterruptRecordApi service = new MapInterruptRecordApi();
var result = service.Add(record, listFileName);
//删除文件
UIManager.CloseConfirm();
if (result.result)
{
Helper.DelectDir(path);
DestroyImmediate(gameObject);
}
else
{
Utils.showToast(gameObject, result.errMsg);
}
}
catch (Exception e)
{
Utils.showToast(gameObject, e.Message);
}
DeleteLocalRecord(true);
//删除文件
UIManager.CloseConfirm();
});
}
void GoDelete()

View File

@ -264,7 +264,7 @@ public class ResultListController : PFUIPanel
{
if (Directory.Exists(item))
{
var d = new DirectoryInfo(item);
//var d = new DirectoryInfo(item);
//var createTime = d.CreationTime;//create time
//var newTime = createTime.AddSeconds(30D);
//if (newTime < DateTime.Now)