protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HtmlForm form1 = (HtmlForm)Master.FindControl("form1"); form1.Method = "post"; form1.Enctype = "multipart/form-data"; //form1.Action = "Test.aspx"; Common_NTx_Dac ddlSet = new Common_NTx_Dac(); // 게시판 카테고리 필드 DataTable BoardCategorydt = null; BoardCategorydt = ddlSet.TOTALBBS_BOARD_CATEGORY_INFO_SEL(0); int ddlBoardCategorySeletedValue = IntegerUtil.intValid(this.ddlBoardCategory.SelectedValue, 0); // 게시판 카테고리 필드 - DropDownList if (BoardCategorydt.Rows.Count == 0) { this.ddlWriteCategory.Items.Clear(); this.ddlBoardCategory.Items.Add(new ListItem("등록된 카테고리가 없습니다.", "")); this.ddlBoardCategory.Enabled = false; } else { this.ddlBoardCategory.Items.Clear(); //this.ddlBoardCategory.Items.Add(new ListItem("선택하세요", "0")); // 기본값 //DropDownListUtil.SetDropDownList(BoardCategorydt, this.ddlBoardCategory, "strCateName", "intIdx"); DropDownListUtil.SetDropDownListValue(BoardCategorydt, this.ddlBoardCategory, this.ddlBoardCategory.SelectedValue, DropDownListUtil.DropDownFlag.Select); } } }
private static TLObject ParseMessageContainer(BinaryReader reader) { try { var RawObject = new JArray(); var MessageCount = IntegerUtil.Deserialize(reader); for (int i = 0; i < MessageCount; i++) { RawObject.Add(new JObject { ["msg_id"] = LongUtil.Deserialize(reader), ["seqno"] = IntegerUtil.Deserialize(reader), ["bytes"] = IntegerUtil.Deserialize(reader), ["body"] = TLObject.Deserialize(reader) }); } return(new TLObject(JObject.FromObject(new { _ = "msg_container", messages = RawObject }))); } catch { return(null); } }
private void GetListInfo(int PagePerData, int CurrentPage, int intIdx) { Board_NTx_Dac oWS = new Board_NTx_Dac(); if (IntegerUtil.intValid(this.ParamPageViewRow.Value, 10) > 10) { PagePerData = IntegerUtil.intValid(this.ParamPageViewRow.Value, 10); } List <BoardReplyBean> GetList = oWS.TOTALBBS_BOARD_REPLY_INFO_SEL(PagePerData, CurrentPage, "L", intIdx); int BoardTotalCnt = oWS.TOTALBBS_BOARD_REPLY_INFO_COUNT_SEL(PagePerData, CurrentPage, "T", intIdx); NoDataTotalCnt = BoardTotalCnt; TotalCnt = BoardTotalCnt - ((CurrentPage - 1) * PagePerData); this.ltTotalCnt.Text = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", BoardTotalCnt) + "개"; //Repeater 바인딩 if (NoDataTotalCnt == 0) { this.rptGetList.DataSource = GetList; this.rptGetList.DataBind(); } else { this.rptGetList.DataSource = GetList; this.rptGetList.DataBind(); } PagingHelper1.VirtualItemCount = NoDataTotalCnt; ParamPage.Value = CurrentPage.ToString(); }
protected void ddlBoardCaregory_itemSelected(object sender, EventArgs e) { try { int ddlBoardCategorySeletedValue = IntegerUtil.intValid(this.ddlBoardCategory.SelectedValue, 0); this.ddlWriteCategory.Enabled = true; Common_NTx_Dac ddlSet = new Common_NTx_Dac(); DataTable WriteCategorydt = null; WriteCategorydt = ddlSet.TOTALBBS_WRITE_CATEGORY_INFO_SEL(ddlBoardCategorySeletedValue); // 게시글 카테고리 필드 - DropDownList if (WriteCategorydt.Rows.Count == 0) { this.ddlWriteCategory.Items.Clear(); this.ddlWriteCategory.Items.Add(new ListItem("등록된 카테고리가 없습니다.", "")); this.ddlWriteCategory.Enabled = false; } else { this.ddlWriteCategory.Items.Clear(); this.ddlWriteCategory.Items.Add(new ListItem("선택하세요", "0")); // 기본값 DropDownListUtil.SetDropDownList(WriteCategorydt, this.ddlWriteCategory, "strCateName", "intIdx"); } } catch (Exception ex) { #region [Error Logger] 로그인을 한경우 //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex); #endregion } }
private int DeleteBoard() { try { Board_Tx_Dac oWS = new Board_Tx_Dac(); Board_NTx_Dac oWSN = new Board_NTx_Dac(); int RemoveIdx = IntegerUtil.intValid(WebUtil.SCRequestFormString("hdfIdx", string.Empty), 0); int ReturnValue = 0; DataSet ds = oWSN.TOTALBBS_BOARD_VIEW_FILE_INFO_SEL(RemoveIdx); int FileDelCnt = ds.Tables[0].Rows.Count; ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_VIEW_DEL(RemoveIdx, FileDelCnt); if (ReturnValue > 0) { DataTable dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { LocalFileControls.FileDelete(FileUploadPath, dr["strFileName"].ToString()); } } return(ReturnValue); } catch (Exception ex) { #region [Error Logger] 로그인을 한경우 //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex, admin.MemberId, admin.MemberNm); #endregion return(0); } }
private void GetPageDefaultSetting() { this.ltTitle.Text = "게시글 관리"; this.ltTotalPosts.Text = "전체 게시글 수"; #region [버튼 설정] this.lbtnCreate.Text = "<span>등록</span>"; this.lbtnSearch.Text = "<span>검색</span>"; #endregion #region [DropDownList 설정] this.FIELD.Items.Clear(); this.FIELD.Items.Add(new ListItem("작성자", "WRITER")); this.FIELD.Items.Add(new ListItem("제목", "SUBJECT")); Common_NTx_Dac ddlSet = new Common_NTx_Dac(); // 게시판 카테고리 필드 BoardCategorydt = ddlSet.TOTALBBS_BOARD_CATEGORY_INFO_SEL(-1); int ddlBoardCategorySeletedValue = IntegerUtil.intValid(this.ddlBoardCategory.SelectedValue, -1); // 게시판 카테고리 필드 - DropDownList if (BoardCategorydt.Rows.Count == 0) { this.ddlBoardCategory.Items.Add(new ListItem("등록된 카테고리가 없습니다.", "")); this.ddlBoardCategory.Enabled = false; } else { this.ddlBoardCategory.Items.Clear(); DropDownListUtil.SetDropDownListValue(BoardCategorydt, this.ddlBoardCategory, this.ddlBoardCategory.SelectedValue, DropDownListUtil.DropDownFlag.Select); } #endregion }
/// <summary> /// Turns the current Helper into a serialized byte array /// </summary> public byte[] Serialize() { using (var memory = new MemoryStream()) using (var writer = new BinaryWriter(memory)) { if (AuthInfo == null) { BoolUtil.Serialize(false, writer); } else { BoolUtil.Serialize(true, writer); if (AuthInfo.AuthKey == null) { BoolUtil.Serialize(false, writer); } else { BoolUtil.Serialize(true, writer); BytesUtil.Serialize(AuthInfo.AuthKey.Key, writer); } IntegerUtil.Serialize(AuthInfo.TimeOffset, writer); } return(memory.ToArray()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HtmlForm form1 = (HtmlForm)Master.FindControl("form1"); form1.Method = "post"; form1.Enctype = "multipart/form-data"; #region [등록 및 수정 하기위한 데이터 처리] object obj_BoardCreate = Cache["BoardCreate"]; object obj_BoardModify = Cache["BoardModify"]; string[] ParameterData = new string[5]; if (obj_BoardCreate != null && obj_BoardModify != null) { Response.Redirect(DefaultPage, false); } else { if (obj_BoardCreate != null) { //등록 페이지 ParameterData = obj_BoardCreate as string[]; if (ParameterData != null) { ParamBoardCategory = ParameterData[0]; ParamField = ParameterData[1]; ParamKey = ParameterData[2]; iIdx = IntegerUtil.intValid(ParameterData[3], 0); iPage = IntegerUtil.intPage(ParameterData[4], 1); this.GetPageInfoSetting(ParamBoardCategory, ParamField, ParamKey, iIdx, iPage, "C"); } } else { //수정 페이지 if (obj_BoardModify != null) { ParameterData = obj_BoardModify as string[]; if (ParameterData != null) { ParamBoardCategory = ParameterData[0]; ParamField = ParameterData[1]; ParamKey = ParameterData[2]; iIdx = IntegerUtil.intValid(ParameterData[3], 0); iPage = IntegerUtil.intPage(ParameterData[4], 1); this.GetPageInfoSetting(ParamBoardCategory, ParamField, ParamKey, iIdx, iPage, "M"); } } } } #endregion } }
private void ParameterSetting() { strField = WebUtil.SCRequestFormString("FIELD", "ALL"); strKey = WebUtil.SCRequestFormString("KEY", string.Empty); strTxTEndDate = WebUtil.SCRequestFormString("TxTEndDate", string.Empty); iPage = IntegerUtil.intPage(WebUtil.SCRequestFormString("ParamPage", string.Empty), 1); intPageViewRow = IntegerUtil.intPage(WebUtil.SCRequestFormString("ParamPageViewRow", string.Empty), PageSize); strBoardCategory = WebUtil.SCRequestFormString("ddlBoardCategory", "-1"); }
private void ParameterSetting() { strField = WebUtil.SCRequestFormString("FIELD", "ALL"); strKey = WebUtil.SCRequestFormString("KEY", string.Empty); iPage = IntegerUtil.intPage(WebUtil.SCRequestFormString("ParamPage", string.Empty), 1); intPageViewRow = IntegerUtil.intPage(WebUtil.SCRequestFormString("ParamPageViewRow", string.Empty), PageSize); intIdx = WebUtil.RequestInt("intIdx", 0); this.ParamIdx.Value = Convert.ToString(intIdx); }
protected void ddlPageViewRow_itemSelected(object sender, EventArgs e) { try { int ddlPageViewRowSeletedValue = IntegerUtil.intValid(this.ddlPageViewRow.SelectedValue, 10); PagingHelper1.PageSize = ddlPageViewRowSeletedValue; this.ParamPageViewRow.Value = ddlPageViewRowSeletedValue.ToString(); this.GetListInfo(ddlPageViewRowSeletedValue, iPage, strBoardCategory, strSort, strField, strKey); } catch (Exception ex) { #region [Error Logger] 로그인을 한경우 //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex); #endregion } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HtmlForm form1 = (HtmlForm)Master.FindControl("form1"); form1.Method = "post"; form1.Enctype = "multipart/form-data"; #region [상세보기를 위한 데이터 처리] object obj_BoardModify = Cache["BoardModify"]; string[] ParameterData = new string[5]; if (obj_BoardModify != null) { Response.Redirect(DefaultPage, false); } else { if (obj_BoardModify != null) { //수정 페이지 ParameterData = obj_BoardModify as string[]; if (ParameterData != null) { ParamBoardCategory = ParameterData[0]; ParamField = ParameterData[1]; ParamKey = ParameterData[2]; iIdx = IntegerUtil.intValid(ParameterData[3], 0); iPage = IntegerUtil.intPage(ParameterData[4], 1); this.GetPageInfoSetting(ParamBoardCategory, ParamField, ParamKey, iIdx, iPage, "V"); } } else { StringBuilder sbError = new StringBuilder(); sbError.Append("alert('데이터 조회에 실패하였습니다.');history.go(-1);"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageError", sbError.ToString(), true); } } #endregion } }
protected void PagingHelper1_OnPageIndexChanged(object sender, PagingEventArgs e) { try { if (intIdx.Equals(null) || intIdx == -1) { intIdx = IntegerUtil.intPage(WebUtil.SCRequestFormString("ParamIdx", string.Empty), -1); } this.GetListInfo(PageSize, e.PageIndex, intIdx); } catch (Exception ex) { #region [Error Logger] 로그인을 한경우 //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex, admin.MemberId, admin.MemberNm); #endregion } }
public void Initialize() { IList <string> inputRange = FileUtil.ReadAllLines("day_4_password_range.txt"); IList <int> inputs = IntegerUtil.ParseInts(inputRange[0]); int lowerBound = inputs[0]; int upperBound = inputs[1]; int validPasswords = 0; for (int i = lowerBound; i <= upperBound; i++) { if (passwordChecker.CheckPassword(i)) { validPasswords++; } } outputWriter.WriteLine($"{validPasswords}"); }
protected void Page_Load(object sender, EventArgs e) { try { this.GetPageDefaultSetting(); this.ltTitle.Text = "게시물 관리"; PagingHelper1.PageSize = PageSize; if (!IsPostBack) { this.ParameterSetting(); //슈퍼관리자이면 //if (admin.MemberAuth.Equals("1")) { if (Request.QueryString["Page"] != null) { //페이지값을 유지하기위해서 iPage = IntegerUtil.intValid(Request.QueryString["Page"].ToString(), 1); this.GetListInfo(PageSize, iPage, strBoardCategory, strSort, strField, strKey); Page_Move(iPage, PagingHelper1); } else { this.GetListInfo(PageSize, 1, strBoardCategory, strSort, strField, strKey); Page_Move(1, PagingHelper1); } } //} //else //{ // JavaScript.AccessAlertLocation("접근권한이 없습니다."); //} } } catch (Exception ex) { StringBuilder sbError = new StringBuilder(); sbError.Append("alert('데이터 조회에 실패하였습니다.');"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageError", sbError.ToString(), true); } }
/// <summary> /// Turns the current session into a serialized byte array /// </summary> public byte[] Serialize() { using var memory = new MemoryStream(); using var writer = new BinaryWriter(memory); if (Helper == null) { BoolUtil.Serialize(false, writer); } else { BoolUtil.Serialize(true, writer); BytesUtil.Serialize(Helper.Serialize(), writer); } if (TLUser == null) { BoolUtil.Serialize(false, writer); } else { BoolUtil.Serialize(true, writer); TLUser.Serialize(writer); } IntegerUtil.Serialize(SessionExpires, writer); if (DataCenter == null) { BoolUtil.Serialize(false, writer); } else { BoolUtil.Serialize(true, writer); BytesUtil.Serialize(DataCenter.Serialize(), writer); } BytesUtil.Serialize(KnownPeers.Serialize(), writer); return(memory.ToArray()); }
/// <summary> /// Deserilizes an MTProtoHelper object from a stream /// </summary> /// <param name="reader">The stream containing the raw MTProtoHelper data</param> public static MTProtoHelper Deserialize(BinaryReader reader) { ServerAuthentication AuthInfo = null; if (BoolUtil.Deserialize(reader)) { byte[] AuthInfoKey = null; if (BoolUtil.Deserialize(reader)) { AuthInfoKey = BytesUtil.Deserialize(reader); } AuthInfo = new ServerAuthentication() { AuthKey = new AuthKey(AuthInfoKey), TimeOffset = IntegerUtil.Deserialize(reader) }; } return(new MTProtoHelper(AuthInfo)); }
protected void Page_Load(object sender, EventArgs e) { try { this.GetPageDefaultSetting(); this.ltTitle.Text = "댓글 관리"; PagingHelper1.PageSize = PageSize; if (!IsPostBack) { this.ParameterSetting(); { if (intIdx.Equals(null) || intIdx == -1) { intIdx = IntegerUtil.intPage(WebUtil.SCRequestFormString("ParamIdx", string.Empty), -1); } if (Request.QueryString["Page"] != null) { //페이지값을 유지하기위해서 iPage = IntegerUtil.intValid(Request.QueryString["Page"].ToString(), 1); this.GetListInfo(PageSize, iPage, intIdx); Page_Move(iPage, PagingHelper1); } else { this.GetListInfo(PageSize, 1, intIdx); Page_Move(1, PagingHelper1); } } } } catch (Exception ex) { StringBuilder sbError = new StringBuilder(); sbError.Append("alert('데이터 조회에 실패하였습니다.');"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "PageError", sbError.ToString(), true); } }
private void GetListInfo(int PagePerData, int CurrentPage, string BoardCategory, string ORDERBY, string FIELD, string KEY) { Board_NTx_Dac oWS = new Board_NTx_Dac(); string strKey = TextControl.TextCutString(HttpUtility.HtmlEncode(KEY), 20, ""); if (IntegerUtil.intValid(this.ParamPageViewRow.Value, 10) > 10) { PagePerData = IntegerUtil.intValid(this.ParamPageViewRow.Value, 10); } List <BoardBean> GetNotiList = oWS.TOTALBBS_BOARD_NOTICE_INFO_SEL(PagePerData, "L"); List <BoardBean> GetList = oWS.TOTALBBS_BOARD_INFO_SEL(PagePerData, CurrentPage, BoardCategory, "L", "IDX", FIELD, strKey); GetNotiList.AddRange(GetList); int BoardTotalCnt = oWS.TOTALBBS_BOARD_INFO_COUNT_SEL(PagePerData, CurrentPage, BoardCategory, "T", ORDERBY, FIELD, strKey); NoDataTotalCnt = BoardTotalCnt; TotalCnt = BoardTotalCnt - ((CurrentPage - 1) * PagePerData); this.ltTotalCnt.Text = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", BoardTotalCnt) + "개"; //Repeater 바인딩 if (NoDataTotalCnt == 0) { this.rptGetList.DataSource = GetNotiList; this.rptGetList.DataBind(); } else { this.rptGetList.DataSource = GetNotiList; this.rptGetList.DataBind(); } PagingHelper1.VirtualItemCount = NoDataTotalCnt; ParamPage.Value = CurrentPage.ToString(); }
/// <summary> /// Deserilizes a Session object from a stream /// </summary> /// <param name="reader">The stream containing the raw Session data</param> public static Session Deserialize(string FileName, BinaryReader reader) { Network.MTProtoHelper Helper = null; if (BoolUtil.Deserialize(reader)) { Helper = MTProtoHelper.Deserialize(BytesUtil.Deserialize(reader)); } TLObject TLUser = null; if (BoolUtil.Deserialize(reader)) { TLUser = TLObject.Deserialize(reader); } var SessionExpires = IntegerUtil.Deserialize(reader); DataCenter DataCenter = null; if (BoolUtil.Deserialize(reader)) { DataCenter = DataCenter.Deserialize(BytesUtil.Deserialize(reader)); } var session = new Session(FileName) { Helper = Helper, TLUser = TLUser, SessionExpires = SessionExpires, DataCenter = DataCenter }; PeerManager.Deserialize(reader).ToList().ForEach(x => session.KnownPeers.AddOrUpdatePeer(x.AsTLObject())); return(session); }
private void GetPageInfoSetting(string ParamBoardCategory, string ParamField, string ParamKey, int Idx, int PageNo, string CMD) { //페이지 HTML 언어 세팅 this.ltBoardCategory.Text = "게시판 카테고리"; this.ltWriteCategory.Text = "게시글 카테고리"; this.ltUserId.Text = "작성자 아이디"; this.ltWriter.Text = "작성자 이름"; this.ltSubject.Text = "제목"; this.ltContent.Text = "내용"; this.ltRegiDate.Text = "등록일"; this.ltViewCnt.Text = "조회수"; #region [DropDownList 설정] Common_NTx_Dac ddlSet = new Common_NTx_Dac(); // 게시판 카테고리 필드 DataTable BoardCategorydt = null; BoardCategorydt = ddlSet.TOTALBBS_BOARD_CATEGORY_INFO_SEL(-1); int ddlBoardCategorySeletedValue = IntegerUtil.intValid(this.ddlBoardCategory.SelectedValue, -1); // 게시판 카테고리 필드 - DropDownList if (BoardCategorydt.Rows.Count == 0) { this.ddlWriteCategory.Items.Clear(); this.ddlBoardCategory.Items.Add(new ListItem("등록된 카테고리가 없습니다.", "")); this.ddlBoardCategory.Enabled = false; } else { this.ddlBoardCategory.Items.Clear(); DropDownListUtil.SetDropDownListValue(BoardCategorydt, this.ddlBoardCategory, this.ddlBoardCategory.SelectedValue, DropDownListUtil.DropDownFlag.Select); } // 게시글 카테고리 필드 DataTable WriteCategorydt = null; WriteCategorydt = ddlSet.TOTALBBS_WRITE_CATEGORY_INFO_SEL(ddlBoardCategorySeletedValue); // 게시글 카테고리 필드 - DropDownList if (WriteCategorydt.Rows.Count == 0) { this.ddlWriteCategory.Items.Clear(); this.ddlWriteCategory.Items.Add(new ListItem("등록된 카테고리가 없습니다.", "")); this.ddlWriteCategory.Enabled = false; } else { this.ddlWriteCategory.Items.Clear(); DropDownListUtil.SetDropDownListValue(WriteCategorydt, this.ddlWriteCategory, this.ddlWriteCategory.SelectedValue, DropDownListUtil.DropDownFlag.Select); } #endregion DataSet ds = null; if (CMD.Equals("M")) { Board_NTx_Dac oWS = new Board_NTx_Dac(); ds = oWS.TOTALBBS_BOARD_VIEW_SEL(Idx); } else { this.trVisible_2.Attributes.Add("style", "display:none"); this.trVisible_2.Visible = false; } this.GetPageSetting(Idx, ds, CMD); }
private int UpdateBoard() { try { Board_Tx_Dac oWS = new Board_Tx_Dac(); Board_NTx_Dac oWSN = new Board_NTx_Dac(); int ModIdx = IntegerUtil.intValid(WebUtil.SCRequestFormString("hdfIdx", string.Empty), 0); int intBoardCategory = Convert.ToInt32(WebUtil.SCRequestFormString("ddlBoardCategory", "1")); int intWriteCategory = Convert.ToInt32(WebUtil.SCRequestFormString("ddlWriteCategory", "1")); string strUserId = WebUtil.SCRequestFormString("txtUserId", string.Empty); string strWriter = WebUtil.SCRequestFormString("txtWriter", string.Empty); string strSubject = WebUtil.SCRequestFormString("txtSubject", string.Empty); string strContent = WebUtil.SCRequestFormString("txtContent", string.Empty); string ChkBoxListData = string.Empty; DataSet ds = null; DataTable dt = null; // 삭제할 목록 조회 DataTable dt1 = null; // 삭제하지 않는 목록 조회 int NoDeleteFileCnt = 0; // 삭제하지 않는 파일 수 //파일 리스트 조회(삭제할 목록과 삭제 하지 않을 목록 분리하여 가져옴) //체크박스 선택 여부 if (ModIdx > 0 && Request.Form["chkAttached_" + ModIdx + ""] != null) { ChkBoxListData = Request.Form["chkAttached_" + ModIdx + ""].ToString(); ds = oWSN.TOTALBBS_BOARD_FILE_INFO_SEL(ModIdx, ChkBoxListData); } else { ChkBoxListData = "0"; ds = oWSN.TOTALBBS_BOARD_FILE_INFO_SEL(ModIdx, ChkBoxListData); } string OldFileName = string.Empty; string NewFileName = string.Empty; string FileUploadPath = string.Empty; if (ds != null) { dt = ds.Tables[0]; // 삭제할 목록 조회 dt1 = ds.Tables[1]; // 삭제하지 않는 목록 조회 if (dt1.Rows.Count > 0) { NoDeleteFileCnt = dt1.Rows.Count; } } int iData = 0; List <FileBean> GecAttachedList = new List <FileBean>(); if (ds != null) { //삭제 하지 않을 목록을 조회 하여 처리 foreach (DataRow dr in dt1.Rows) { if (iData == 0) { OldFileName = dr["strRealFileName"].ToString(); NewFileName = dr["strFileName"].ToString(); FileUploadPath = dr["strFilePath"].ToString(); } iData = iData + 1; FileBean AFBean = new FileBean(); AFBean.strRealFileName = dr["strRealFileName"].ToString(); // 파일 원본 이름 AFBean.strFileName = dr["strFileName"].ToString(); // 파일 업로드후 생성된 새이름 AFBean.strFilePath = dr["strFilePath"].ToString(); // 파일 업로드 경로 디비에 넣지 않는경우 /FileUpload/ + FileUploadPath경로 수동 입력 해도됨 AFBean.intFileSort = iData; GecAttachedList.Add(AFBean); } if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { for (int i = 0; i < 1; i++) { FileUploadPath = dr["strFilePath"].ToString(); } } } } HttpFileCollection files = HttpContext.Current.Request.Files; int FileTotalCnt = files.Count; int FileSort = 0; // 웹 취약성 추가 파일 첨부시 aspx 에서 검사 후 cs 단에서 한번 더 검사 string[] ContentType = null; // 첨부파일 타입 구분배열 변수 #region [파일 업로드 정보를 조회] if (FileTotalCnt > 0) { for (int i = 0; i < FileTotalCnt; i++) { HttpPostedFile postedFile = files[i]; FileBean AFBean = new FileBean(); FileSort = iData + i; string[] FilesInfo1 = new string[3]; ContentType = postedFile.ContentType.Split('/'); //빈파일일때 if (postedFile.ContentLength > 1) { FilesInfo1 = FileName(postedFile); if (FilesInfo1 != null) { if (FileSort == 0) { OldFileName = FilesInfo1[0]; NewFileName = FilesInfo1[1]; FileUploadPath = FilesInfo1[2]; } AFBean.strRealFileName = FilesInfo1[0]; // 파일 원본 이름 AFBean.strFileName = FilesInfo1[1]; // 파일 업로드후 생성된 새이름 AFBean.strFilePath = FilesInfo1[2]; // 파일 업로드 경로 디비에 넣지 않는경우 /FileUpload/ + FileUploadPath경로 수동 입력 해도됨 AFBean.intFileSort = FileSort + 1; GecAttachedList.Add(AFBean); } else { FileTotalCnt = 0; } } else { FileTotalCnt = 0; } } } #endregion int MasterReturnValue = 0; int ReturnValue = 0; MasterReturnValue = oWS.TOTALBBS_BOARD_INFO_UPD(ModIdx, intBoardCategory, intWriteCategory, strUserId, strWriter, strSubject, strContent); if (MasterReturnValue > 0) { if (GecAttachedList.Count > 0) { foreach (FileBean Item in GecAttachedList) { ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_UPD(ModIdx, Item.strRealFileName, Item.strFileName, Item.strFilePath, Item.intFileSort); } } else { //전체 제크 및 한개만 있을때 체크 했을때 ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_DEL_SELECTED(ChkBoxListData); } } //첨부파일 등록이 하나도 없을시 if (GecAttachedList.Count.Equals(0)) { ReturnValue = -10; } //체크박스 선택 파일 삭제 시키기 if (!ChkBoxListData.Equals("0")) { //삭제 foreach (DataRow dr in dt.Rows) { //경로를 넘기는데 \\ 수가 맞지 않아 메서드 추가함 수정시 삭제에 사용 LocalFileControls.FileDelete_New(FileUploadPath, dr["strFileName"].ToString()); } } return(ReturnValue); } catch (Exception ex) { #region [Error Logger] 로그인을 한경우 //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex, admin.MemberId, admin.MemberNm); #endregion return(0); } }
private void GetPageSetting(int Idx, DataSet ds, string CMD) { if (CMD.Equals("C")) { this.lbtnValidationSave.Text = "<span class='btn btn-default'>확인</span>"; this.lbtnValidationSave.CssClass = "buttons"; this.lbtnCancel.Text = "<span class='btn btn-default'>취소</span>"; this.lbtnCancel.CssClass = "buttons mg_l5"; this.lbtnValidationDelete.Visible = false; if (!admin.MemberId.Equals(null) || !admin.MemberId.Equals("")) { this.txtUserId.Text = admin.MemberId.ToString(); } if (!admin.MemberNm.Equals(null) || !admin.MemberNm.Equals("")) { this.txtWriter.Text = admin.MemberNm.ToString(); } this.ifrmReply.Visible = false; } else if (CMD.Equals("M")) { this.lbtnValidationModify.Text = "<span class='btn btn-primary'>수정</span>"; this.lbtnValidationModify.CssClass = "buttons fl_r"; this.lbtnCancel.Text = "<span class='btn btn-default'>목록</span>"; this.lbtnCancel.CssClass = "buttons fl_l"; this.lbtnValidationDelete.Text = "<span class='btn btn-success'>삭제</span>"; this.lbtnValidationDelete.CssClass = "buttons mg_l5 fl_r"; this.lbtnValidationDelete.OnClientClick = "return fnDelConfirm();"; DataTable dt1 = ds.Tables[0]; DataTable dt2 = ds.Tables[1]; this.ddlBoardCategory.SelectedValue = dt1.Rows[0]["intBoardCategory"].ToString(); Common_NTx_Dac ddlSet = new Common_NTx_Dac(); // 게시판 카테고리 필드 int ddlBoardCategorySeletedValue = IntegerUtil.intValid(this.ddlBoardCategory.SelectedValue, -1); // 게시글 카테고리 필드 DataTable WriteCategorydt = null; WriteCategorydt = ddlSet.TOTALBBS_WRITE_CATEGORY_INFO_SEL(ddlBoardCategorySeletedValue); // 게시글 카테고리 필드 - DropDownList if (WriteCategorydt.Rows.Count == 0) { this.ddlWriteCategory.Items.Clear(); this.ddlWriteCategory.Items.Add(new ListItem("등록된 카테고리가 없습니다.", "")); this.ddlWriteCategory.Enabled = false; } else { this.ddlWriteCategory.Enabled = true; this.ddlWriteCategory.Items.Clear(); DropDownListUtil.SetDropDownListValue(WriteCategorydt, this.ddlWriteCategory, dt1.Rows[0]["intWriteCategory"].ToString(), DropDownListUtil.DropDownFlag.Select); } this.ddlWriteCategory.SelectedValue = dt1.Rows[0]["intWriteCategory"].ToString(); this.txtUserId.Text = dt1.Rows[0]["strUserId"].ToString(); this.txtWriter.Text = dt1.Rows[0]["strWriter"].ToString(); this.txtSubject.Text = dt1.Rows[0]["strSubject"].ToString(); this.txtContent.Text = TextControl.Delete_Tag(dt1.Rows[0]["strContent"].ToString()); this.ltRegiDateValue.Text = dt1.Rows[0]["dateRegDate"].ToString(); this.ltViewCntValue.Text = dt1.Rows[0]["intViewCount"].ToString(); //this.ifrmReply.Src = "/BackOffice/Board/BoardReplyList.aspx?intIdx=" + dt1.Rows[0]["intIdx"]; ifrmReply.Attributes["src"] = "/BackOffice/Board/BoardReplyList?intIdx=" + dt1.Rows[0]["intIdx"]; this.ifrmReply.Visible = true; //첨부파일 세팅 if (dt2.Rows.Count == 0) { this.rptBoard_Attached.DataSource = dt2; this.rptBoard_Attached.DataBind(); } else { AttachedFileCnt = 1; this.rptBoard_Attached.DataSource = dt2; this.rptBoard_Attached.DataBind(); } } this.hdfIdx.Value = Idx.ToString(); this.hdfCMD.Value = CMD; }
private static TLObject ParseRPCResult(BinaryReader reader) { try { ulong LocalMsgID = reader.ReadUInt64(); uint RPCCode = reader.ReadUInt32(); var RawObject = JObject.FromObject(new { _ = "rpc_result", req_msg_id = LocalMsgID }); if (!Enum.IsDefined(typeof(RPCCodes), RPCCode)) { reader.BaseStream.Position -= 4; RawObject["result"] = TLObject.Deserialize(reader); return(new TLObject(RawObject)); } switch ((RPCCodes)RPCCode) { case RPCCodes.rpc_error: RawObject["result"] = JObject.FromObject(new { _ = "rpc_error", error_code = IntegerUtil.Deserialize(reader), error_message = StringUtil.Read(reader) }); //if (errorMessage.StartsWith("FLOOD_WAIT_")) //{ // var resultString = Regex.Match(errorMessage, @"\d+").Value; // var seconds = int.Parse(resultString); // throw new FloodException(TimeSpan.FromSeconds(seconds)); //} //else if (errorMessage.StartsWith("PHONE_MIGRATE_")) //{ // var resultString = Regex.Match(errorMessage, @"\d+").Value; // var dcIdx = int.Parse(resultString); // throw new PhoneMigrationException(dcIdx); //} //else if (errorMessage.StartsWith("FILE_MIGRATE_")) //{ // var resultString = Regex.Match(errorMessage, @"\d+").Value; // var dcIdx = int.Parse(resultString); // throw new FileMigrationException(dcIdx); //} //else if (errorMessage.StartsWith("USER_MIGRATE_")) //{ // var resultString = Regex.Match(errorMessage, @"\d+").Value; // var dcIdx = int.Parse(resultString); // throw new UserMigrationException(dcIdx); //} //else if (errorMessage.StartsWith("NETWORK_MIGRATE_")) //{ // var resultString = Regex.Match(errorMessage, @"\d+").Value; // var dcIdx = int.Parse(resultString); // throw new NetworkMigrationException(dcIdx); //} //else if (errorMessage == "AUTH_RESTART") //{ // throw new AuthRestartException("The session is already logged in but is trying to log in again"); //} //else if (errorMessage == "PHONE_CODE_INVALID") //{ // throw new InvalidPhoneCodeException("The numeric code used to authenticate does not match the numeric code sent by SMS/Telegram"); //} //else if (errorMessage == "SESSION_PASSWORD_NEEDED") //{ // throw new CloudPasswordNeededException("This Account has Cloud Password !"); //} //else //{ // throw new InvalidOperationException(errorMessage); //} break; case RPCCodes.gzip_packed: RawObject["result"] = JObject.Parse(ParseGZipPacked(reader).ToString()); break; default: reader.BaseStream.Position -= 4; RawObject["result"] = JObject.Parse(TLObject.Deserialize(reader).ToString()); break; } return(new TLObject(RawObject)); } catch { return(null); } }
/// <summary> /// Inverse of <see cref="EncryptMessageData"/> for incoming server messages. /// </summary> public TLObject DecryptMessageData(byte[] body, bool client = false) { if (body.Length < 8) { throw new Exception("Cannot decrypt a message of 8 bytes."); } using (var memory = new MemoryStream(body)) using (var reader = new BinaryReader(memory)) using (var sha = new SHA256Managed()) { var serverKeyID = reader.ReadUInt64(); if (serverKeyID != AuthInfo.AuthKey.KeyID) { throw new Exception($"Server replied with an invalid auth key: {serverKeyID}"); } var MessageKey = reader.ReadBytes(16); (var AES_Key, var AES_ID) = CalcKey(AuthInfo.AuthKey.Key, MessageKey, client); body = AES.DecryptIGE(reader.ReadBytes(body.Length - 24), AES_Key, AES_ID); // https://core.telegram.org/mtproto/security_guidelines // Sections "checking sha256 hash" and "message length" var SHAHash = sha.ComputeHash(AuthInfo.AuthKey.Key .Skip(client ? 88 : 96).Take(32) .Concat(body) .ToArray()); var SHASlice = SHAHash.Skip(8).Take(16); if (!SHASlice.SequenceEqual(MessageKey)) { throw new Exception("The message key could not be validated."); } } TLObject obj = null; byte[] RawObject = null; var remote_msg_id = -1L; var remote_sequence = -1L; using (var memory = new MemoryStream(body)) using (var reader = new BinaryReader(memory)) { // The salt could be 0 if we are starting anew and haven't received one yet if (Salt != LongUtil.Deserialize(reader) && Salt != 0) { throw new Exception("The salt could not be validated"); } if (ID != LongUtil.Deserialize(reader)) { throw new Exception("The session ID could not be validated"); } remote_msg_id = LongUtil.Deserialize(reader); // ToDo: Check sequence_number remote_sequence = IntegerUtil.Deserialize(reader); RawObject = reader.ReadBytes(IntegerUtil.Deserialize(reader)); obj = TLObject.Deserialize(RawObject); } return(new TLObject(JToken.FromObject(new { _ = "Message", msg_id = remote_msg_id, seqno = remote_sequence, bytes = RawObject, body = JToken.Parse(obj.ToString()) }))); }
public bool SavePoll(List <PollViewModel> itemsPoll, Guid idAccount) { bool isSuccess; using (var transaction = Context.Database.BeginTransaction()) { try { foreach (var itemSection in itemsPoll) { var tempSection = _serviceDetailDao.GetOne(itemSection.IdSection, idAccount); tempSection.SectionTitle = itemSection.Title; tempSection.Weight = IntegerUtil.GetValue(itemSection.Weight); tempSection.IsDynamic = itemSection.IsDynamic; Context.ServiceDetails.Add(tempSection); Context.Entry(tempSection).State = EntityState.Modified; foreach (var itemQuestion in itemSection.ItemsQuestion) { var tempQuestion = _questionDao.GetOne(itemQuestion.IdQuestion); tempQuestion.Title = itemQuestion.Title; tempQuestion.IdTypePoll = itemQuestion.IdTypePoll; tempQuestion.Weight = IntegerUtil.GetValue(itemQuestion.Weight); tempQuestion.HasPhoto = itemQuestion.HasPhotos; tempQuestion.CountPhoto = IntegerUtil.GetValue(itemQuestion.CountPhotos); Context.Questions.Add(tempQuestion); Context.Entry(tempQuestion).State = EntityState.Modified; foreach (var itemAnswer in itemQuestion.ItemsAnswer) { var tempAnswer = _questionDetailDao.GetOne(itemAnswer.IdAnswer); tempAnswer.Answer = itemAnswer.Title; tempAnswer.Weight = IntegerUtil.GetValue(itemAnswer.Weight); Context.QuestionDetails.Add(tempAnswer); Context.Entry(tempAnswer).State = EntityState.Modified; } } } Context.SaveChanges(); transaction.Commit(); isSuccess = true; } catch { isSuccess = false; transaction.Rollback(); } } return(isSuccess); }
/// <summary> /// Leet Code #13 - Roman to Integer /// /// Problem: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. /// /// Proposed Solution: Traverse array to sum each digit and handle special cases where a substraction is needed. /// </summary> /// <returns>Integer value of a roman numeral.</returns> public static int RomanToInt(string s) { return(IntegerUtil.RomanToInteger(s)); }