static void Main() { var dirtyString = "sdfdf.dsf8908()=(=(sadfJJLef@ssyd€sdöf////fj()=/§(§&/(\"&sdfdf.dsf8908()=(=(sadfJJLef@ssyd€sdöf////fj()=/§(§&/(\"&sdfdf.dsf8908()=(=(sadfJJLef@ssyd€sdöf"; var sw = new Stopwatch(); sw.Start(); for (var i = 0; i < 1000; i++) { CleanString.UseReplace(dirtyString); } sw.Stop(); Debug.WriteLine("CleanString.UseReplace: " + sw.ElapsedMilliseconds.ToString()); sw.Reset(); sw.Start(); for (var i = 0; i < 1000; i++) { CleanString.UseStringBuilder(dirtyString); } sw.Stop(); Debug.WriteLine("CleanString.UseStringBuilder: " + sw.ElapsedMilliseconds.ToString()); sw.Reset(); sw.Start(); for (var i = 0; i < 1000; i++) { CleanString.UseRegex(dirtyString); } sw.Stop(); Debug.WriteLine("CleanString.UseRegex: " + sw.ElapsedMilliseconds.ToString()); }
protected void Page_Load(object sender, System.EventArgs e) { //权限检查 if (Session["adminName"] == null || Session["adminName"].ToString() == String.Empty) { Response.Write("<font color=#ff0000 style='FONT-SIZE: 12px'>对不起,您没足够权限访问此页!!</font><br>"); Response.Write("<a href=index.aspx target=_top style='FONT-SIZE: 12px'>重新登陆</a><br>"); Response.End(); return; } if (!IsPostBack) { getCategory();//绑定类别下拉列表 if (Request.QueryString["id"] == null) { Response.Write("没有这个鲜花"); Response.End(); } string strID = Request.QueryString["id"].ToString().Trim(); //获取ID对应的鲜花信息 DBConn myDB1 = new DBConn(); string sqlP = "select * from Products where PID=" + strID; SqlDataReader dr = myDB1.getDataReader(sqlP); if (dr.Read()) { myimg.Src = "../showPP.aspx?id=" + dr["PID"].ToString(); ViewState["PID"] = dr["PID"].ToString(); txtName.Text = CleanString.htmlOutputText(dr["PName"].ToString()); txtCPrice.Text = double.Parse(dr["PCPrice"].ToString()).ToString("f2");//小数点后面的位数2位 txtFPrice.Text = double.Parse(dr["PFPrice"].ToString()).ToString("f2"); txtNPrice.Text = double.Parse(dr["PNPrice"].ToString()).ToString("f2"); txtBewrite.Text = CleanString.htmlOutputText(dr["PBewrite"].ToString()); txtUseMode.Text = CleanString.htmlOutputText(dr["PUseMode"].ToString()); txtValidity.Text = CleanString.htmlOutputText(dr["PValidity"].ToString()); try//分类 { ddlCategory.SelectedValue = dr["CID"].ToString(); } catch { ddlCategory.SelectedIndex = 0; } } dr.Close(); myDB1.Close(); } }
/// <summary>Calculates a position of delimiter /// in <see cref="CleanString"/></summary> private void FindDotPos() { if (_dotPos > 0) { return; } _dotPos = CleanString.IndexOf(delimiter); if (_dotPos < 0) { _dotPos = CleanString.Length; } }
private void getAnnounce() { string mySql = "select * from append where id='3'"; DBConn myDB = new DBConn(); SqlDataReader mydr = myDB.getDataReader(mySql); if (mydr.Read()) { txtAnnounce.Text = CleanString.htmlOutputText(mydr["text"].ToString()); } mydr.Close(); myDB.Close(); }
public ActionResult Search(string keywords) { string searchKey = CleanString.InputText(keywords, 100); if (searchKey != "") { // Create a data cache key // If that data is not in the cache then use the business logic tier to fetch the data ProductBO product = new ProductBO(); IList <ProductInfo> productsBySearch = product.GetProductsBySearch(searchKey); // Store the results in a cache return(View(productsBySearch)); } return(View()); }
protected void btnOk_Click(object sender, System.EventArgs e) { string strAnnounce = CleanString.htmlInputText(txtAnnounce.Text); string mySql = "update [Append] set [text]='" + strAnnounce + "' where [id]='3'"; DBConn myDB = new DBConn(); int iNum = myDB.ExecuteNonQuery(mySql); myDB.Close(); if (iNum == 1) { Response.Write("<script>"); Response.Write("alert('[公告栏] 修改成功!!!');"); Response.Write("</script>"); } }
private void getData(string strID) { string mySql = "select * from message where MID=" + strID; DBConn myDB = new DBConn(); SqlDataReader mydr = myDB.getDataReader(mySql); if (mydr.Read()) { lblUName.Text = mydr["UName"].ToString(); lblUPhone.Text = mydr["UPhone"].ToString(); string strUEmail = mydr["UEmail"].ToString(); lblUEmail.Text = "<a href='mailto:" + strUEmail + "'>" + strUEmail + "</a>"; lblMTitle.Text = mydr["MTitle"].ToString(); txtMContent.Text = CleanString.htmlOutputText(mydr["MContent"].ToString()); lblDate.Text = mydr["Pubdate"].ToString(); } mydr.Close(); myDB.Close(); }
public ActionResult ShoppingCart(string Id) { CartController cartController = new CartController(); Cart myCart = cartController.GetCart(true); AccountController accountController = new AccountController(); //Get the user's favourite category string favCategory = accountController.GetFavouriteCategory(); //If we have a favourite category, render the favourites list ViewBag.Favourite = favCategory; if (Id != null) { // Clean the input string Id = CleanString.InputText(Id, 50); myCart.Add(Id); cartController.StoreCart(myCart); } return(View(myCart)); }
public YoutubeDownloadController(CleanString CleanString, IYoutubeDownloadManager youtubeDownloadManager) { this.CleanString = CleanString; this.youtubeDownloadManager = youtubeDownloadManager; }
protected void btnAdd_Click(object sender, System.EventArgs e) { string strName = txtName.Text.Trim(); string strCID = ddlCategory.SelectedValue; string strCPrice = txtCPrice.Text.Trim(); string strFPrice = txtFPrice.Text.Trim(); string strNPrice = txtNPrice.Text.Trim(); string strBewrite = txtBewrite.Text.Trim(); string strUseMode = txtUseMode.Text.Trim(); string strValidity = txtValidity.Text.Trim(); if (strName == String.Empty || strCPrice == String.Empty || strCID == String.Empty || strFPrice == String.Empty || strNPrice == String.Empty) { Response.Write("<script>"); Response.Write("alert('必选项不能为空!!!');"); Response.Write("</script>"); return; } else if (strName.Length > 35) { Response.Write("<script>"); Response.Write("alert('输入鲜花名称太长了!!!');"); Response.Write("</script>"); return; } try { double.Parse(strCPrice); } catch { Response.Write("<script>"); Response.Write("alert('请检查 成本价 的格式!!!');"); Response.Write("</script>"); return; } try { double.Parse(strFPrice); } catch { Response.Write("<script>"); Response.Write("alert('请检查 原价 的格式!!!');"); Response.Write("</script>"); return; } try { double.Parse(strNPrice); } catch { Response.Write("<script>"); Response.Write("alert('请检查 现价 的格式!!!');"); Response.Write("</script>"); return; } if (uploadFile.PostedFile.FileName.Trim() != String.Empty && (Path.GetExtension(uploadFile.PostedFile.FileName) != ".gif" && Path.GetExtension(uploadFile.PostedFile.FileName) != ".jpg")) { Response.Write("<Script>alert('上传的图片格式必须为.gif或.jpg!!')</Script>"); return; } strBewrite = CleanString.htmlInputText(strBewrite); strUseMode = CleanString.htmlInputText(strUseMode); strValidity = CleanString.htmlInputText(strValidity); string sql = "insert into Products(PName,CID,PCPrice,PFPrice,PNPrice,PBewrite,PUseMode,PValidity) values('" + strName + "'," + strCID + "," + strCPrice + "," + strFPrice + "," + strNPrice + ",'" + strBewrite + "','" + strUseMode + "','" + strValidity + "')"; DBConn myDB = new DBConn(); myDB.ExecuteNonQuery(sql); myDB.Close(); if (uploadFile.PostedFile.FileName.Trim() != String.Empty) { Stream imagedatastream; string DBPath = ConfigurationManager.AppSettings["DataBasePath"]; string connStr = (DBPath); SqlConnection myConn = new SqlConnection(connStr); imagedatastream = Request.Files["uploadFile"].InputStream; int imagedatalen = Request.Files["uploadFile"].ContentLength; string imagedatatype = Request.Files["uploadFile"].ContentType; byte[] image = new byte[imagedatalen]; imagedatastream.Read(image, 0, imagedatalen); String Psql = "update Products set PPicture=@imgdata where PID=(select MAX(PID) from products)"; SqlCommand Pcommand = new SqlCommand(Psql, myConn); SqlParameter imgdata = new SqlParameter("@imgdata", SqlDbType.Image); imgdata.Value = image; Pcommand.Parameters.Add(imgdata); myConn.Open(); Pcommand.ExecuteNonQuery(); myConn.Close(); } txtName.Text = ""; txtCPrice.Text = ""; txtFPrice.Text = ""; txtNPrice.Text = ""; txtBewrite.Text = ""; txtUseMode.Text = ""; txtValidity.Text = ""; ddlCategory.SelectedIndex = 0; Response.Write("<script>"); Response.Write("alert('成功添加!!!');"); Response.Write("</script>"); }
protected void btnSubmit_Click1(object sender, EventArgs e) { if (Page.IsValid) { if (this.rbtnYes.Checked == true && this.txtEmail.Text == "" && this.txtPhoneNumber.Text == "") { this.lblMoreInfo.Text = "To be contacted please include a phone number or email address"; } else { if (this.txtIntersection.Text == "" && this.txtRoad.Text == "" && this.txtStreetNumber.Text == "") { lblMoreInfo.Text = "You need to include some sort of address or intersection."; } else { if ((this.chbxAnonymous.Checked == false) && (this.txtFirstName.Text == "" && this.txtLastName.Text == "" && this.txtPhoneNumber.Text == "" && this.txtEmail.Text == "")) { lblMoreInfo.Text = "Please include contact information or select anonymous."; } else { lblMoreInfo.Text = ""; Citizen citizen; if (chbxAnonymous.Checked == true) { citizen = new Citizen("Anonymous", "Anonymous", "Anonymous", "Anonymous"); } else { string cleanEmail = CleanString.CleanInput(txtEmail.Text); string cleanFirstName = CleanString.CleanInput(txtFirstName.Text); string cleanLastName = CleanString.CleanInput(txtLastName.Text); string cleanPhoneNumber = CleanString.CleanInput(txtPhoneNumber.Text); citizen = new Citizen(cleanFirstName.ToUpper(), cleanLastName.ToUpper(), cleanPhoneNumber, cleanEmail); } int citizenId = citizen.InsertCitizen(); Session["Citizen"] = citizen; int contact = 0; int problemTypeId = Category.GetCatagoryId(lblPropblem.Text); string cleanDesc = CleanString.CleanInput(this.txtProblemDetail.Text); string insertedBy = User.Identity.Name; if (rbtnYes.Checked == true) { contact = 1; } else if (rbtnNo.Checked == true) { contact = 0; } if (this.txtIntersection.Text == "") { string cleanNumber = CleanString.CleanInput(this.txtStreetNumber.Text); string direction = this.directionList.SelectedValue; string cleanRoad = CleanString.CleanInput(this.txtRoad.Text); string address = cleanNumber + " " + direction + " " + cleanRoad; Incident incident = new Incident(address.ToUpper(), problemTypeId, cleanDesc.ToUpper(), citizenId, contact); int id = incident.InsertIncident(insertedBy); Session["Incident"] = incident; Session["IncidentId"] = id; if (problemTypeId == 1) { Server.Transfer("ConfirmationWithAssignment.aspx", false); } else { Server.Transfer("Confirmation.aspx", false); } Server.Transfer("Confirmation.aspx", false); } else { string cleanIntersection = CleanString.CleanInput(this.txtIntersection.Text); Incident incident = new Incident(cleanIntersection.ToUpper(), problemTypeId, cleanDesc.ToUpper(), citizenId, contact); int id = incident.InsertIncident(insertedBy); Session["Incident"] = incident; Session["IncidentId"] = id; if (problemTypeId == 1) { Server.Transfer("ConfirmationWithAssignment.aspx", false); } else { Server.Transfer("Confirmation.aspx", false); } Server.Transfer("Confirmation.aspx", false); } } } } } }
public CrawlOtherVideosController(CleanString cleanString, IOtherVideoManager otherVideoManager) { CleanString = cleanString; this.otherVideoManager = otherVideoManager; }
private void btnSearch_Click(object sender, System.EventArgs e) { addressList.Attributes.Add("OnChange", "GetAddressText()"); DataSet addressSet = Utilites.Address.LocateAddressFromParcelTableUsingStreetNum(CleanString.CleanInput(txtAddress.Text)); addressList.DataSource = addressSet.Tables[0]; addressList.DataTextField = addressSet.Tables[0].Columns[1].ToString(); if (addressSet.Tables[0].Rows.Count > 4) { addressList.Rows = addressSet.Tables[0].Rows.Count; } addressList.DataBind(); }
private void SetIncidentValues() { string cleanAddress = CleanString.CleanInput(txtAddress.Text); this._incident.Address = cleanAddress; string cleanDescription = CleanString.CleanInput(txtIncidentDescription.Text); this._incident.IncidentDisc = cleanDescription; string status = ""; if (rbtnOpen.Checked == true) { status = "O"; } else if (rbtnClosed.Checked == true) { status = "C"; } this._incident.Openclose = status; int contact = 0; if (rbtnYes.Checked == true) { contact = 1; } else if (rbtnNo.Checked == true) { contact = 0; } this._incident.Contact = contact; int problemTypeint = Convert.ToInt32(problemTypeList.SelectedValue); this._incident.ProblemTypeId = problemTypeint; System.DateTime pendingDate; if (txtPendingDate.Text == "") { pendingDate = System.DateTime.MinValue; } else { pendingDate = Convert.ToDateTime(txtPendingDate.Text); } this._incident.PendingDate = pendingDate; bool citizenBeenContacted; bool requestClosure; if (this.rbtnCityContactedYes.Checked == true) { citizenBeenContacted = true; } else { citizenBeenContacted = false; } this._incident.HasCitizenBeenContacted = citizenBeenContacted; if (this.rbtnYesClose.Checked == true) { requestClosure = true; } else { requestClosure = false; } this._incident.RequstingClosure = requestClosure; System.DateTime courtDate; if (txtCourtDate.Text == "") { courtDate = System.DateTime.MinValue; } else { courtDate = Convert.ToDateTime(txtCourtDate.Text); } this._incident.CourtDate = courtDate; string councilDist = this.councilDistList.SelectedValue; this._incident.CouncilDist = councilDist; }
private void btnUpdate_Click(object sender, System.EventArgs e) { lblErrorMessage.Visible = false; string cleanAddress = CleanString.CleanInput(txtAddress.Text); string cleanDescription = CleanString.CleanInput(txtIncidentDescription.Text); string status = ""; int contact = 0; if (rbtnOpen.Checked == true) { status = "O"; } else if (rbtnClosed.Checked == true) { status = "C"; } if (rbtnYes.Checked == true) { contact = 1; } else if (rbtnNo.Checked == true) { contact = 0; } int problemTypeint = Convert.ToInt32(problemTypeList.SelectedValue); System.DateTime pendingDate; if (txtPendingDate.Text == "") { pendingDate = System.DateTime.MinValue; } else { pendingDate = Convert.ToDateTime(txtPendingDate.Text); } bool citizenBeenContacted, requestClosure; if (this.rbtnCityContactedYes.Checked == true) { citizenBeenContacted = true; } else { citizenBeenContacted = false; } if (this.rbtnYesClose.Checked == true) { requestClosure = true; } else { requestClosure = false; } System.DateTime courtDate; if (txtCourtDate.Text == "") { courtDate = System.DateTime.MinValue; } else { courtDate = Convert.ToDateTime(txtCourtDate.Text); } Incident incident = new Incident(cleanAddress, problemTypeint, cleanDescription, councilDistList.SelectedValue, status, User.Identity.Name, pendingDate, incidentnumber, contact, courtDate, User.Identity.Name, requestClosure, citizenBeenContacted); if (incident.UpdateIncident()) { } else { } }
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) //判断是否是列表中的项,判断列表中的项是否是与数据绑定的 { //删除确认 LinkButton delBttn = (LinkButton)e.Item.Cells[3].Controls[0]; delBttn.Attributes.Add("onclick", "javascript:return confirm('确定删除[ " + CleanString.htmlOutputText(e.Item.Cells[1].Text) + " ]?');"); } }
private void adminDataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //刉壺 LinkButton delBttn = (LinkButton)e.Item.Cells[0].Controls[0]; if (Session["adminName"].ToString().ToUpper() == e.Item.Cells[1].Text.ToUpper()) { e.Item.Cells[0].Controls[0].Visible = false;//祥珆尨※刉壺§偌聽 } delBttn.Attributes.Add("onclick", "javascript:return confirm('确定删除[ " + CleanString.htmlOutputText(e.Item.Cells[1].Text) + " ]?');"); } }