public async Task UploadSaveFileIncidentAsync(List <Exception> exceptionList, string st, bool notCriticalError) { var uploadSaveFileDbUrl = ConfigPopup.BaseUrl + "/save"; ProgressMessage.instance.Open("\\저장 파일 문제 업로드 중...".Localized()); var errorDeviceId = GetOrCreateErrorDeviceId(); var url = $"{uploadSaveFileDbUrl}/{errorDeviceId}"; var saveFile = new ErrorFile(); var uploadDate = DateTime.UtcNow; try { saveFile.fields.uploadDate.timestampValue = uploadDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); } catch { // ignored } try { saveFile.fields.stackTraceMessage.stringValue = string.Join("///", exceptionList.Select(e => e.ToString())); } catch { // ignored } try { saveFile.fields.appMetaInfo.stringValue = ConfigPopup.GetAppMetaInfo(); } catch { // ignored } try { saveFile.fields.userId.stringValue = ConfigPopup.GetUserId(); } catch { // ignored } try { LoadSaveDataSafe(ref saveFile.fields.saveData); } catch (Exception e) { // 문제가 있는 파일을 업로드하는 것 조차 실패했다. 이건 수가 없네... ProgressMessage.instance.Close(); ConfirmPopup.instance.Open($"SAVE FILE UPLOAD FAILED: {e}", () => { if (notCriticalError == false) { Application.Quit(); } else { ConfirmPopup.instance.Close(); } }); return; } try { using var httpClient = new HttpClient(); var patchData = JsonUtility.ToJson(saveFile); using var patchContent = new StringContent(patchData); ConDebug.Log($"HttpClient PATCH TO {url}..."); // PATCH 시작하고 기다린다. var patchTask = await httpClient.PatchAsync(new Uri(url), patchContent); ConDebug.Log($"HttpClient Result: {patchTask.ReasonPhrase}"); if (patchTask.IsSuccessStatusCode) { var msg = @"\$저장 데이터 개발팀으로 제출 결과$" .Localized(errorDeviceId, patchData.Length, saveFile.fields.uploadDate.timestampValue); if (notCriticalError == false) { ConfirmPopup.instance.OpenTwoButtonPopup(msg, () => ConfigPopup.instance.OpenCommunity(), () => SaveLoadManager.EnterRecoveryCode(exceptionList, st, false), "\\업로드 완료".Localized(), "\\공식 카페 이동".Localized(), "\\복구 코드 입력".Localized()); } else { ConfirmPopup.instance.OpenTwoButtonPopup(msg, () => ConfirmPopup.instance.Close(), () => SaveLoadManager.EnterRecoveryCode(exceptionList, st, true), "\\업로드 완료".Localized(), "\\닫기".Localized(), "\\복구 코드 입력".Localized()); } } else { ShortMessage.instance.Show($"{patchTask.ReasonPhrase}"); if (notCriticalError == false) // 다시 안내 팝업 보여주도록 한다. { SaveLoadManager.ProcessCriticalLoadError(exceptionList, st); } else { ConfirmPopup.instance.Open($"SAVE FILE UPLOAD FAILED: {patchTask.ReasonPhrase}"); } } } catch (Exception e) { if (Debug.isDebugBuild) { Debug.LogException(e); } ConfirmPopup.instance.Open(e.Message, () => { if (notCriticalError == false) // 다시 안내 팝업 보여주도록 한다. { SaveLoadManager.ProcessCriticalLoadError(exceptionList, st); } else { ConfirmPopup.instance.Close(); } }); } finally { // 어떤 경우가 됐든지 마지막으로는 진행 상황 창을 닫아야 한다. ProgressMessage.instance.Close(); } }
public async Task <string> UploadPlayLogAsync(byte[] playLogBytes, int uncompressedBytesLength, string progressMessage, string receiptDomain, string receiptId, string receipt) { var hasReceipt = string.IsNullOrEmpty(receiptDomain) == false && string.IsNullOrEmpty(receiptId) == false && string.IsNullOrEmpty(receipt) == false; var uploadPlayLogFileOrReceiptDbUrl = ConfigPopup.BaseUrl + "/" + (hasReceipt ? receiptDomain : "playLog"); var ownProgressMessage = string.IsNullOrEmpty(progressMessage) == false; if (ownProgressMessage) { ProgressMessage.instance.Open(progressMessage); } var errorDeviceId = ErrorReporter.instance.GetOrCreateErrorDeviceId(); var url = string.Format("{0}/{1}", uploadPlayLogFileOrReceiptDbUrl, hasReceipt ? receiptId : errorDeviceId); var saveFile = new PlayLogFile(); var uploadDate = DateTime.UtcNow; try { saveFile.fields.uploadDate.timestampValue = uploadDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); } catch { saveFile.fields.uploadDate.timestampValue = "ERROR"; } try { saveFile.fields.appMetaInfo.stringValue = ConfigPopup.GetAppMetaInfo(); } catch { saveFile.fields.appMetaInfo.stringValue = "ERROR"; } try { saveFile.fields.userId.stringValue = ConfigPopup.GetUserId(); } catch { saveFile.fields.userId.stringValue = "ERROR"; } try { saveFile.fields.saveData.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData.bytesValue = "ERROR"; } try { saveFile.fields.playLogData.bytesValue = Convert.ToBase64String(playLogBytes); } catch { saveFile.fields.playLogData.bytesValue = "ERROR"; } try { saveFile.fields.playLogUncompressedSizeData.integerValue = uncompressedBytesLength; } catch { saveFile.fields.playLogUncompressedSizeData.integerValue = 0; } try { saveFile.fields.gemStr.stringValue = BlackContext.instance.Gem.ToString("n0"); } catch { saveFile.fields.gemStr.stringValue = "ERROR"; } try { saveFile.fields.socialUserName.stringValue = Social.localUser.userName; } catch { saveFile.fields.socialUserName.stringValue = "ERROR"; } try { saveFile.fields.receiptDomain.stringValue = receiptDomain; } catch { saveFile.fields.receiptDomain.stringValue = "ERROR"; } try { saveFile.fields.receiptId.stringValue = receiptId; } catch { saveFile.fields.receiptId.stringValue = "ERROR"; } try { saveFile.fields.receipt.stringValue = receipt; } catch { saveFile.fields.receipt.stringValue = "ERROR"; } var reasonPhrase = ""; try { using (var httpClient = new HttpClient()) { var patchData = JsonUtility.ToJson(saveFile); using (var patchContent = new StringContent(patchData)) { ConDebug.Log($"HttpClient PATCH TO {url}..."); // PATCH 시작하고 기다린다. var patchTask = await httpClient.PatchAsync(new Uri(url), patchContent); ConDebug.Log($"HttpClient Result: {patchTask.ReasonPhrase}"); if (patchTask.IsSuccessStatusCode) { ConDebug.Log("Play log uploaded successfully."); //var msg = string.Format("\\업로드가 성공적으로 완료됐습니다.\\n\\n업로드 코드: {0}\\n용량: {1:n0}바이트\\nTS: {2}\\n\\n<color=brown>본 화면의 스크린샷을 찍어 공식 카페에 버그 신고를 부탁 드립니다.</color>\\n\\n업로드된 데이터를 분석 후, 카페를 통해 이후 진행을 안내드리겠습니다.\\n\\n공식 카페로 이동하거나, 안내 받은 복구 코드를 입력하세요.".Localized(), errorDeviceId, patchData.Length, saveFile.fields.uploadDate.timestampValue); //ConfirmPopup.instance.OpenTwoButtonPopup(msg, () => ConfigPopup.instance.OpenCommunity(), () => SaveLoadManager.EnterRecoveryCode(exceptionList, st), "\\업로드 완료".Localized(), "\\공식 카페 이동".Localized(), "\\복구 코드 입력".Localized()); } else { Debug.LogError($"Play log upload failed: status code={patchTask.StatusCode}"); reasonPhrase = patchTask.ReasonPhrase; } } } } catch (Exception e) { Debug.LogError($"Play log upload exception: {e}"); } finally { if (ownProgressMessage) { // 어떤 경우가 됐든지 마지막으로는 진행 상황 창을 닫아야 한다. ProgressMessage.instance.Close(); } } return(reasonPhrase); }