//Method of getting the general information of a game from the database, and sending it up to the user public ActionResult Index() { //declaring list using model GamePO List <GamePO> mappedGame = new List <GamePO>(); //Beginning of processes try { //declaring list using Model GameDO in order to retrieve database information List <GameDO> allGames = _dataAccess.GameReadAll(); //loop to get all objects assigned appropriately foreach (GameDO dataObject in allGames) { //assign our PO list all of the values that were in the DO list via mapper mappedGame.Add(MapGameTF.GameDOtoPO(dataObject)); } } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(mappedGame)); }
//Method to search the database for a player by the name of the player public ActionResult ReadPlayerByName(string winner, int wins) { //declaring list using model GamePO List <PlayerPO> mappedPlayer = new List <PlayerPO>(); //Beginning of processes try { //declaring list using Model PlayerDO in order to retrieve database information List <PlayerDO> player = _dataAccess.PlayerReadByName(winner); //loop to get all objects assigned appropriately foreach (PlayerDO dataObject in player) { //assign our PO list all of the values that were in the DO list via mapper mappedPlayer.Add(MapPlayerTF.PlayerDOtoPO(dataObject)); } } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(mappedPlayer)); }
//Method that allows user to input the information they want to update public ActionResult UpdateUser(int UserId) { //declaring object using model PlayerPO UserPO userToUpdate = new UserPO(); //Beginning of processes try { //declare List using Model UserDO, and use it to store all information on the game recovered by using a DAL access call UserDO item = _dataAccess.UserReadByID(UserId); //assign all data to object using a mapper userToUpdate = MapUserTF.UserDOtoPO(item); } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(userToUpdate)); }
//Method to call data back from the database consisting of the player name, and their win total public ActionResult PlayersByWins() { //declaring list using model WinsPO List <WinsPO> players = new List <WinsPO>(); //Beginning of processes try { //declaring list using Model Wins in order to retrieve database information List <WinsDO> player = _dataAccess.OrderByWinCount(); //loop to get all objects assigned appropriately foreach (WinsDO dataObject in player) { //assign our PO list all of the values that were in the DO list via mapper players.Add(MapWinnersTF.WinsDOtoPO(dataObject)); } } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the User to the View page return(View(players)); }
static void Error(string message) { Log(message); message = LogStamp() + ID + ": " + message; ErrorFile.WriteLine(message); ErrorFile.Flush(); }
public static bool Initialize() { try { if (string.IsNullOrWhiteSpace(OutputPath) || OutputDirectory == null) { throw new ArgumentException("An empty or otherwise invalid path was detected for the Output Directory."); } if (string.IsNullOrWhiteSpace(WorkingPath) || WorkingDirectory == null) { throw new ArgumentException("An empty or otherwise invalid path was detected for the Working Directory."); } if (string.IsNullOrWhiteSpace(LogPath)) { throw new ArgumentException("An empty or otherwise invalid path was detected for the Log directory."); } if (LogFile == null) { throw new ArgumentException("An empty or otherwise invalid path was detected for the Output Log file."); } if (ErrorFile == null) { throw new ArgumentException("An empty or otherwise invalid path was detected for the Output Error file."); } if (!OutputDirectory.Exists) { OutputDirectory.Create(); } if (!WorkingDirectory.Exists) { WorkingDirectory.Create(); } if (!LogDirectory.Exists) { LogDirectory.Create(); } if (!LogFile.Exists) { LogFile.Create(); } if (!ErrorFile.Exists) { ErrorFile.Create(); } return(OutputDirectory.Exists && WorkingDirectory.Exists && LogFile.Exists && ErrorFile.Exists); } catch (Exception e) { Console.WriteLine($"\r\n{e.Message}\r\n{e}"); throw; } }
private void WriteSingleprivate(string PLCName, bool value) { try { int handle = Tcads.CreateVariableHandle(PLCName); Tcads.WriteAny(handle, value); Tcads.DeleteVariableHandle(handle); } catch (Exception ex) { ErrorFile.ErrorLog(ex.Message, ADS.Logfilepath); } }
static void End() { Clock.Stop(); Log("END"); ErrorFile.Flush(); ErrorFile.Close(); LogFile.Flush(); LogFile.Close(); Console.ReadKey(); }
private File <string> ToErrorFile(ErrorFile dropboxFile) { if (dropboxFile == null) { return(null); } var file = GetErrorFile(new ErrorEntry(dropboxFile.ErrorId, dropboxFile.Error)); file.Title = MakeFileTitle(dropboxFile); return(file); }
private File <string> ToErrorFile(ErrorFile boxFile) { if (boxFile == null) { return(null); } var file = GetErrorFile(new ErrorEntry(boxFile.Error, boxFile.ErrorId)); file.Title = MakeFileTitle(boxFile); return(file); }
//Method that governs user login public ActionResult UserLogin(LoginPO form) { //Declaring an action result variable, but assigning it to null to reassign later ActionResult result = View(form); //Checks to see if the UI form is filled out correctly if (ModelState.IsValid) { //Beginning of processes try { //passing the UI form information to make the DAL call, run through our mapper, and assigning it to a DO object LoginPO user = MapLoginTF.LoginDOtoPO(_dataAccess.ValidLogin(form.Username)); //Checks if the password from the user input and the password from the database associated with the username match if (user.Password == form.Password) { //Sets the Session role id equal to the UserRoleId called back from the database Session["UserRoleId"] = user.UserRoleId; //Sets the Username the user inputed equal to the session username Session["Username"] = user.Username; //redirects the user to the specified page result = RedirectToAction("Index", "Home"); //Sets the session timeout for 20 minutes Session.Timeout = 20; } //if passwords do not match else { //sets result to loop back to the form result = View(form); } } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } } //Code that runs if the model state isn't valid else { //sets result to loop back to the form result = View(form); } //sends appropriate response back to the user return(result); }
public T ReadSingle <T>(string PLCName) { string plcname = "." + PLCName; try { int handle = Tcads.CreateVariableHandle(plcname); T returnData = (T)Tcads.ReadAny(handle, typeof(T)); Tcads.DeleteVariableHandle(handle); return(returnData); } catch (Exception ex) { ErrorFile.ErrorLog(ex.Message, ADS.Logfilepath); return(default);
public bool WriteString(string PLCName, string value) { try { int handle = Tcads.CreateVariableHandle(PLCName); Tcads.WriteAny(handle, value, new int[] { 20 }); Tcads.DeleteVariableHandle(handle); return(true); } catch (Exception ex) { ErrorFile.ErrorLog(ex.Message, ADS.Logfilepath); return(false); } }
//Method that adds a user public ActionResult AddUser() { //Beginning of processes try { } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the user to the view return(View()); }
//Takes in the information that a user wants to update about a certain game public ActionResult UpdateGame(int gameId) { //declaring object using model GamePO GamePO gameToUpdate = new GamePO(); //Beginning of processes try { //declare List using Model GameDO, and use it to store all information on the game recovered by using a DAL access call GameDO item = _dataAccess.GameReadByID(gameId); //assign all data to object using a mapper gameToUpdate = MapGameTF.GameDOtoPO(item); //establish list to hold all data on all players as recovered by the DAL access call List <PlayerDO> players = _playerAccess.PlayerReadAll(); //declare list to hold relevant data from full DAL call List <SelectListItem> options = new List <SelectListItem>(); foreach (PlayerDO dataObject in players) { //Declare list to hold player names SelectListItem option = new SelectListItem(); //make list aspect equal dataObject variable option.Text = dataObject.Name; //make list aspect equal dataObject variable option.Value = dataObject.PlayerId.ToString(); //take object "option", and add it to list "options" options.Add(option); } //set object value of PlayersDropDown equal to values of "options" gameToUpdate.PlayersDropDown = options; } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(gameToUpdate)); }
//Method that deletes a user from the database public ActionResult DeleteUser(int UserId) { //Beginning of processes try { //passes playerId in to the player delete method to delete the player assigned to the id _dataAccess.UserDelete(UserId); } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //sends a page redirection to our user return(RedirectToAction("Index", "User")); }
public async Task <T[]> ReadArray <T>(string PLCName, int size) { string plcname = "." + PLCName; return(await Task.Run(() => { try { int handle = Tcads.CreateVariableHandle(plcname); T[] returnData = (T[])Tcads.ReadAny(handle, typeof(T[]), new int[] { size }); Tcads.DeleteVariableHandle(handle); return returnData; } catch (Exception ex) { ErrorFile.ErrorLog(ex.Message, ADS.Logfilepath); return default; } })); }
//Method for deleting a game from the database public ActionResult DeleteGame(int gameId) { //Beginning of processes try { //using DAL access to call on the game delete method, and passing in the game id _dataAccess.GameDelete(gameId); } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //redirects to the specified page return(RedirectToAction("Index", "Game")); }
public DialogResult Show(MessageBoxButtons buttons, string text, Exception ex, Form form) { if (form == null) { StartPosition = FormStartPosition.CenterScreen; } else { StartPosition = FormStartPosition.Manual; Left = form.Left + form.Width / 2 - Width / 2; Top = form.Top + form.Height / 2 - Height / 2; } richTextBox1.WordWrap = false; Text = text; KhongBietDatTenSaoLuon(buttons, text + "\n" + ex.Message + "\n" + ex.StackTrace); //lưu số lần bị lỗi vào file "System.ini" SystemFile.Save((int.Parse(SystemFile.Get(3)) + 1).ToString(), 3); ErrorFile.Save(ex); // return((DialogResult)returner); }
static void Main(string[] args) { //Application.Run(new FormMain()); try { if (args.Length > 0) { Application.Run(new FormMain(args[0])); } else { Application.Run(new FormMain(null)); } } catch (Exception ex) { ErrorFile.Save(ex); SystemFile.Save((int.Parse(SystemFile.Get(3)) + 1).ToString(), 3); throw ex; } }
//Method for taking in the necessary data to add a new game to the database public ActionResult AddGame() { //declaring object using model GamePO GamePO game = new GamePO(); //Beginning of processes try { //declare List using Model PlayerDO, and use it to store all information on all players recovered by using a DAL access call List <PlayerDO> players = _playerAccess.PlayerReadAll(); //Declare list to hold player names List <SelectListItem> options = new List <SelectListItem>(); //loop to get all objects assigned appropriately foreach (PlayerDO dataObject in players) { //Declare new object to temporarily hold data SelectListItem option = new SelectListItem(); //make list aspect equal dataObject variable option.Text = dataObject.Name; //make list aspect equal dataObject variable option.Value = dataObject.PlayerId.ToString(); //take object "option", and add it to list "options" options.Add(option); } //set object value of PlayersDropDown equal to values of "options" game.PlayersDropDown = options; } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //Sends the data in the list to the view to be seen by the user. return(View(game)); }
private File ToErrorFile(ErrorFile boxFile) { if (boxFile == null) { return(null); } return(new File { ID = MakeId(boxFile.ErrorId), CreateBy = BoxProviderInfo.Owner, CreateOn = TenantUtil.DateTimeNow(), ModifiedBy = BoxProviderInfo.Owner, ModifiedOn = TenantUtil.DateTimeNow(), ProviderId = BoxProviderInfo.ID, ProviderKey = BoxProviderInfo.ProviderKey, RootFolderCreator = BoxProviderInfo.Owner, RootFolderId = MakeId(), RootFolderType = BoxProviderInfo.RootFolderType, Title = MakeFileTitle(boxFile), Error = boxFile.Error }); }
//Method to pass information into the database and update the necessary game public ActionResult UpdateGame(GamePO form) { //Declaring an action result variable, but assigning it to null to reassign later ActionResult result = null; //Checks to see if the UI form is filled out correctly if (ModelState.IsValid) { //Beginning of processes try { //passing the UI form information to run through our mapper, and assigning it to a DO object GameDO dataObject = MapGameTF.GamePOtoDO(form); //calling on a DAL access field to allow us to use a specific method within, while passing in the DO object _dataAccess.GameUpdate(dataObject); } //catch to record any exceptions that crop up catch (Exception ex) { //call to method to record necessary information ErrorFile.ErrorHandlerPL(ex); } //finally to tie up any loose ends finally { } //assigns a page redirection to our variable result = RedirectToAction("Index", "Game"); } //section of code that runs if the form is not valid else { //assigning a value to our variable that will be used if the form isn't valid result = View(form); } //runs the portion of code that is necessary for the situation return(result); }
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 = string.Format("{0}/{1}", uploadSaveFileDbUrl, errorDeviceId); var saveFile = new ErrorFile(); var uploadDate = DateTime.UtcNow; try { saveFile.fields.uploadDate.timestampValue = uploadDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); } catch { } try { saveFile.fields.stackTraceMessage.stringValue = string.Join("///", exceptionList.Select(e => e.ToString())); } catch { } try { saveFile.fields.appMetaInfo.stringValue = ConfigPopup.instance.GetAppMetaInfo(); } catch { } try { saveFile.fields.userId.stringValue = ConfigPopup.instance.GetUserId(); } catch { } try { try { saveFile.fields.saveData.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData1.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData1.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData2.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData2.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData3.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData3.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData4.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData4.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData5.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData5.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData6.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData6.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); try { saveFile.fields.saveData7.bytesValue = Convert.ToBase64String(File.ReadAllBytes(SaveLoadManager.LoadFileName)); } catch { saveFile.fields.saveData7.bytesValue = ""; } SaveLoadManager.DecreaseSaveDataSlotAndWrite(); } catch (Exception e) { // 문제가 있는 파일을 업로드하는 것 조차 실패했다. 이건 수가 없네... ProgressMessage.instance.Close(); ConfirmPopup.instance.Open(string.Format("SAVE FILE UPLOAD FAILED: {0}", 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)) { SushiDebug.Log($"HttpClient PATCH TO {url}..."); // PATCH 시작하고 기다린다. var patchTask = await httpClient.PatchAsync(new Uri(url), patchContent); SushiDebug.Log($"HttpClient Result: {patchTask.ReasonPhrase}"); if (patchTask.IsSuccessStatusCode) { 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); if (notCriticalError == false) { ConfirmPopup.instance.OpenTwoButtonPopup(msg, () => ConfigPopup.instance.OpenCommunity(), () => SaveLoadManager.EnterRecoveryCode(exceptionList, st, notCriticalError), "\\업로드 완료".Localized(), "\\공식 카페 이동".Localized(), "\\복구 코드 입력".Localized()); } else { ConfirmPopup.instance.OpenTwoButtonPopup(msg, () => ConfirmPopup.instance.Close(), () => SaveLoadManager.EnterRecoveryCode(exceptionList, st, notCriticalError), "\\업로드 완료".Localized(), "\\닫기".Localized(), "\\복구 코드 입력".Localized()); } } else { ShortMessage.instance.Show(string.Format("{0}", patchTask.ReasonPhrase)); if (notCriticalError == false) // 다시 안내 팝업 보여주도록 한다. { SaveLoadManager.ProcessCriticalLoadError(exceptionList, st); } else { ConfirmPopup.instance.Open(string.Format("SAVE FILE UPLOAD FAILED: {0}", patchTask.ReasonPhrase)); } } } } } catch (Exception e) { ConfirmPopup.instance.Open(e.Message, () => { if (notCriticalError == false) // 다시 안내 팝업 보여주도록 한다. { SaveLoadManager.ProcessCriticalLoadError(exceptionList, st); } else { ConfirmPopup.instance.Close(); } }); } finally { // 어떤 경우가 됐든지 마지막으로는 진행 상황 창을 닫아야 한다. ProgressMessage.instance.Close(); } }
/// <summary> /// 数据库帮助类 /// </summary> /// <param name="connectionString">数据库连接字符串</param> /// <param name="logfilePath">故障记录文件路径</param> public sqlhelper(string connectionString, string logfilePath) { _constring = connectionString; log = new ErrorFile(logfilePath); }
public override void OnReceivedError(WebView view, IWebResourceRequest request, WebResourceError error) { try { base.OnReceivedError(view, request, error); string TextError = Application.Context.GetString(Resource.String.Lbl_Error_Code) + " "; switch (error.ErrorCode) { case ClientError.BadUrl: TextError = ErrorBadUrl.ToString(); break; case ClientError.Connect: TextError += ErrorConnect.ToString(); break; case ClientError.FailedSslHandshake: TextError += ErrorFailedSslHandshake.ToString(); break; case ClientError.File: TextError += ErrorFile.ToString(); break; case ClientError.FileNotFound: TextError += ErrorFileNotFound.ToString(); break; case ClientError.HostLookup: TextError += ErrorHostLookup.ToString(); break; case ClientError.ProxyAuthentication: TextError += ErrorProxyAuthentication.ToString(); break; case ClientError.Timeout: TextError += ErrorTimeout.ToString(); break; case ClientError.TooManyRequests: TextError += ErrorTooManyRequests.ToString(); break; case ClientError.Unknown: TextError += ErrorUnknown.ToString(); break; case ClientError.UnsafeResource: TextError += ErrorUnsafeResource.ToString(); break; case ClientError.UnsupportedScheme: TextError += ErrorUnsupportedAuthScheme.ToString(); break; case ClientError.Io: TextError += ErrorIo.ToString(); break; } OnPageEventReceivedError?.Invoke(view, request, error, TextError); } catch (Exception e) { Crashes.TrackError(e); } }
public async Task <bool> WriteArrayAsync <T>(string PLCName, T[] value) { string plcname = "." + PLCName; return(await Task.Run(() => { try { ITcAdsSymbol5 info = (ITcAdsSymbol5)Tcads.ReadSymbolInfo(plcname); string plctype = info.TypeName.Split(' ')[3]; int handle = Tcads.CreateVariableHandle(plcname); int length = value.Length; int i = 0; if (typeof(T) != typeof(string)) { Tcads.WriteAny(handle, value); } else { switch (plctype) { case "SINT": sbyte[] sbdata = new sbyte[length]; foreach (T svalue in value) { sbdata[i] = Convert.ToSByte(svalue); i++; } Tcads.WriteAny(handle, sbdata); break; case "BYTE": byte[] bydata = new byte[length]; foreach (T svalue in value) { bydata[i] = Convert.ToByte(svalue); i++; } Tcads.WriteAny(handle, bydata); break; case "BOOL": bool[] bdata = new bool[length]; foreach (T svalue in value) { bdata[i] = Convert.ToBoolean(svalue); i++; } Tcads.WriteAny(handle, bdata); break; case "INT": short[] int16data = new short[length]; foreach (T svalue in value) { int16data[i] = Convert.ToInt16(svalue); i++; } Tcads.WriteAny(handle, int16data); break; case "UINT": ushort[] uint16data = new ushort[length]; foreach (T svalue in value) { uint16data[i] = Convert.ToUInt16(svalue); i++; } Tcads.WriteAny(handle, uint16data); break; case "REAL": float[] floatdata = new float[length]; foreach (T svalue in value) { floatdata[i] = Convert.ToSingle(svalue); i++; } Tcads.WriteAny(handle, floatdata); break; case "DINT": int[] intdata = new int[length]; foreach (T svalue in value) { intdata[i] = Convert.ToInt32(svalue); i++; } Tcads.WriteAny(handle, intdata); break; case "UDINT": uint[] uintdata = new uint[length]; foreach (T svalue in value) { uintdata[i] = Convert.ToUInt32(svalue); i++; } Tcads.WriteAny(handle, uintdata); break; case "LINT": long[] longdata = new long[length]; foreach (T svalue in value) { longdata[i] = Convert.ToInt64(svalue); i++; } Tcads.WriteAny(handle, longdata); break; case "ULINT": ulong[] ulongdata = new ulong[length]; foreach (T svalue in value) { ulongdata[i] = Convert.ToUInt64(svalue); i++; } Tcads.WriteAny(handle, ulongdata); break; case "LREAL": double[] doubledata = new double[length]; foreach (T svalue in value) { doubledata[i] = Convert.ToDouble(svalue); i++; } Tcads.WriteAny(handle, doubledata); break; } } Tcads.DeleteVariableHandle(handle); return true; } catch (Exception ex) { ErrorFile.ErrorLog(ex.Message, ADS.Logfilepath); return false; } })); }
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(); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="PLCName">用nameof(属性名),"前提是属性名和PLC变量名一致"</param> /// <param name="value"></param> /// <param name="AutoReset">是否自动复位,只对bool量有效</param> public bool WriteSingle <T>(string PLCName, T value, bool AutoReset = false) { string plcname = "." + PLCName; try { ITcAdsSymbol5 info = (ITcAdsSymbol5)Tcads.ReadSymbolInfo(plcname); int handle = Tcads.CreateVariableHandle(plcname); if (typeof(T) != typeof(string)) { Tcads.WriteAny(handle, value); } else { switch (info.TypeName) { case "SINT": sbyte sbdata = Convert.ToSByte(value); Tcads.WriteAny(handle, sbdata); break; case "BYTE": byte bydata = Convert.ToByte(value); Tcads.WriteAny(handle, bydata); break; case "BOOL": bool bdata = Convert.ToBoolean(value); Tcads.WriteAny(handle, bdata); if (AutoReset) { TobeResetList.Add(plcname); } break; case "INT": short int16data = Convert.ToInt16(value); Tcads.WriteAny(handle, int16data); break; case "UINT": ushort uint16data = Convert.ToUInt16(value); Tcads.WriteAny(handle, uint16data); break; case "REAL": float floatdata = Convert.ToSingle(value); Tcads.WriteAny(handle, floatdata); break; case "DINT": int intdata = Convert.ToInt32(value); Tcads.WriteAny(handle, intdata); break; case "UDINT": uint uintdata = Convert.ToUInt32(value); Tcads.WriteAny(handle, uintdata); break; case "LINT": long longdata = Convert.ToInt64(value); Tcads.WriteAny(handle, longdata); break; case "ULINT": ulong ulongdata = Convert.ToUInt64(value); Tcads.WriteAny(handle, ulongdata); break; case "LREAL": double doubledata = Convert.ToDouble(value); Tcads.WriteAny(handle, doubledata); break; } } Tcads.DeleteVariableHandle(handle); return(true); } catch (Exception ex) { ErrorFile.ErrorLog(ex.Message, ADS.Logfilepath); return(false); } }