public static IEnumerator DeleteInvalidFile(String fullFilePath) { if (!File.Exists(fullFilePath)) { yield break; } var sleepTable = MyDatabase.Instance.GetSleepTable(); string fileName = Path.GetFileNameWithoutExtension(fullFilePath); //例:20191226231111 //DBから削除する sleepTable.DeleteFromTable(SleepTable.COL_DATE, fileName); File.Delete(fullFilePath); if (HttpManager.IsInternetAvailable()) { var sleepData = sleepTable.SelectFromColumn(SleepTable.COL_DATE, fileName); if (sleepData != null) { string deviceId = HttpManager.getDeviceId(sleepData.file_path); var deleteTask = HttpManager.DeleteFile(deviceId, fileName + "_" + sleepData.file_id + Path.GetExtension(fullFilePath)); yield return(deleteTask.AsCoroutine()); } } yield return(null); }
public IEnumerator DeleteSleepData() { if (myData == null || !File.Exists(myData.filePath)) { // myDataがEmpty、または、ファイルが存在しない場合は何もしない yield break; } if (HttpManager.IsInternetAvailable()) { var sleepTable = MyDatabase.Instance.GetSleepTable(); string fullFilePath = myData.filePath; string fileName = Path.GetFileNameWithoutExtension(fullFilePath); //例:20191226231111 var sleepData = sleepTable.SelectFromColumn(SleepTable.COL_DATE, fileName); if (sleepData != null) { string deviceId = HttpManager.getDeviceId(sleepData.file_path); var deleteTask = HttpManager.DeleteFile(deviceId, fileName + "_" + sleepData.file_id + Path.GetExtension(fullFilePath)); yield return(deleteTask.AsCoroutine()); if (true) //deleteTask.Result { //DBから削除する sleepTable.DeleteFromTable(SleepTable.COL_DATE, fileName); File.Delete(fullFilePath); if (myData.chartInfo != null) { //Update chart everage info ChartPref.updateEverageDataAfterDelete(myData.chartInfo); } } else { yield return(HttpManager.showDialogMessage("データー削除に失敗しました。")); } } else { yield return(HttpManager.showDialogMessage("データーが見つかりません。")); } } else { yield return(HttpManager.showDialogMessage("インターネット未接続のため、データ削除ができません。")); } if (myData.deleteAfterAction != null) { myData.deleteAfterAction(); } }