public Dictionary <string, string> Setting_Data_Deserialize() { Stream stream = null; Dictionary <string, string> data = new Dictionary <string, string>(); try { IFormatter formatter = new BinaryFormatter(); stream = new FileStream(Application.StartupPath + "\\BIN\\Monitor_setting_data.bin", FileMode.Open, FileAccess.Read, FileShare.None); Setting_Data setting_data = (Setting_Data)formatter.Deserialize(stream); data = setting_data.strData; } catch { } finally { if (stream != null) { stream.Close(); } } return(data); }
public void Setting_Data_Serialize(Dictionary <string, string> data) { Setting_Data setting_data = new Setting_Data(); Stream stream = null; setting_data.strData = data; try { string dir_y = Directory.GetCurrentDirectory() + @"\BIN\"; DirectoryInfo di_y = new DirectoryInfo(dir_y); if (di_y.Exists != true) { Directory.CreateDirectory(dir_y); } IFormatter formatter = new BinaryFormatter(); stream = new FileStream(Application.StartupPath + "\\BIN\\Monitor_setting_data.bin", FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, setting_data); } catch { } finally { if (stream != null) { stream.Close(); } } }
public ActionResult <ApiResultObjectModel> SettingSet( [FromForm] Setting_Data s_dTossData) { ApiResultReady rrResult = new ApiResultReady(this); ApiResultObjectModel armResult = new ApiResultObjectModel(); rrResult.ResultObject = armResult; //유저 정보 추출 ClaimModel cm = new ClaimModel(((ClaimsIdentity)User.Identity).Claims); //이 유저가 해당 관리 등급이 있는지 확인한다. ManagementClassCheckType typePC = GlobalStatic.MgtA.MgtClassCheck(cm.id_int , ManagementClassType.Root); if (typePC == ManagementClassCheckType.Ok) { using (SpaNetCoreFoundationContext db1 = new SpaNetCoreFoundationContext()) { //수정할 개체 선택 Setting_Data s_dSelect = db1.Setting_Data .Where(m => m.idSetting_Data == s_dTossData.idSetting_Data) .FirstOrDefault(); if (null != s_dSelect) { //데이터 수정 s_dSelect.Number = s_dTossData.Number; s_dSelect.Name = s_dTossData.Name; s_dSelect.OpenType = s_dTossData.OpenType; s_dSelect.ValueData = s_dTossData.ValueData; s_dSelect.Description = s_dTossData.Description; //DB 저장 db1.SaveChanges(); } else { rrResult.InfoCode = "1"; rrResult.Message = "수정할 대상이 없습니다."; } }//end using db1 } else { //에러 rrResult.InfoCode = ApiResultType.PermissionCheckError.ToString(); } return(rrResult.ToResult(armResult)); }