/// <summary> /// 检查ID是否可用 /// </summary> /// <param name="ID"></param> public static void ValidID(string ID) { if (ID.Trim() == "" || !CommUtil.IsNumStr(ID)) { throw new Exception("参数传递错误!"); } }
/// <summary> /// 上传文件方法(路径存在postfile里)€ /// </summary> /// <param name="postedFile">文件访问</param> /// <param name="type">文件类型</param> /// <returns>是否上传成功</returns> public bool DoUpload(HttpPostedFile postedFile, string type) { bool result = true; int maxFileSize = this._maxFileSize; string allowFileExtens = this._allowFileExtens; bool flag = false; try { if (postedFile.ContentLength > 0) { if (postedFile.ContentLength > maxFileSize * 1000) { this._resultMessage = "上文件大小超过限定值!(最大<b>" + this.CaculatorSize(maxFileSize * 1000) + "</b>)"; flag = true; this._resultFileName = ""; result = false; } if (!flag && !this.IsAllowFileExtens(allowFileExtens, this.GetFileExtens(postedFile.FileName.ToLower()))) { this._resultMessage = "上传的文件类型不正确!(只允许上传<b>" + allowFileExtens + "</b>)"; flag = true; this._resultFileName = ""; result = false; } if (!flag && !this.IsRightFile(postedFile)) { this._resultMessage = "上传文件出错!"; flag = true; this._resultFileName = ""; result = false; } if (!flag) { this._resultMessage = "上传成功!"; string text = CommUtil.GetDataTimeRandomFileName() + "." + this.GetFileExtens(postedFile.FileName); string filename = this._filePath + type + text; postedFile.SaveAs(filename); this._resultFileName = text; result = true; } } else { this._resultMessage = "请选择文件!"; this._resultFileName = ""; result = false; } } catch { this._resultMessage = "上传文件出错!"; this._resultFileName = ""; result = false; } return(result); }
/// <summary> /// 加密字符串 /// </summary> /// <param name="str"></param> /// <returns></returns> public static string EnCrypt(string str) { int num = int.Parse(ConfigurationSettings.AppSettings["SafeStartIndex"]); str = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5"); string str2 = CommUtil.Reverse(str.Substring(num, str.Length - num)); string str3 = CommUtil.Reverse(str.Substring(0, num)); return(str2 + str3); }
public static string TSEncode(string input, string exclueStr) { string text = input; if (exclueStr.IndexOf("',") < 0) { text = text.Replace("'", CommUtil.ToSBC("'")); } if (exclueStr.IndexOf("%,") < 0) { text = text.Replace("%", CommUtil.ToSBC("%")); } if (exclueStr.IndexOf(" ,") < 0) { text = text.Replace(" ", CommUtil.ToSBC(" ")); } if (exclueStr.IndexOf("-,") < 0) { text = text.Replace("-", CommUtil.ToSBC("-")); } if (exclueStr.IndexOf("+,") < 0) { text = text.Replace("+", CommUtil.ToSBC("+")); } if (exclueStr.IndexOf("&,") < 0) { text = text.Replace("&", CommUtil.ToSBC("&")); } if (exclueStr.IndexOf("$,") < 0) { text = text.Replace("$", CommUtil.ToSBC("$")); } if (exclueStr.IndexOf(".,") < 0) { text = text.Replace(".", CommUtil.ToSBC(".")); } if (exclueStr.IndexOf("=,") < 0) { text = text.Replace("=", CommUtil.ToSBC("=")); } if (exclueStr.IndexOf("(,") < 0) { text = text.Replace("(", CommUtil.ToSBC("(")); } if (exclueStr.IndexOf("),") < 0) { text = text.Replace(")", CommUtil.ToSBC(")")); } if (exclueStr.IndexOf("<,") < 0) { text = text.Replace("<", CommUtil.ToSBC("<")); } if (exclueStr.IndexOf(">,") < 0) { text = text.Replace(">", CommUtil.ToSBC(">")); } if (exclueStr.IndexOf("@,") < 0) { text = text.Replace("@", CommUtil.ToSBC("@")); } if (exclueStr.IndexOf("#,") < 0) { text = text.Replace("#", CommUtil.ToSBC("#")); } if (exclueStr.IndexOf(",,") < 0) { text = text.Replace(",", CommUtil.ToSBC(",")); } if (exclueStr.IndexOf(":,") < 0) { text = text.Replace(":", CommUtil.ToSBC(":")); } if (exclueStr.IndexOf(";,") < 0) { text = text.Replace(";", CommUtil.ToSBC(";")); } if (exclueStr.IndexOf("!,") < 0) { text = text.Replace("!", CommUtil.ToSBC("!")); } if (exclueStr.IndexOf("|,") < 0) { text = text.Replace("|", CommUtil.ToSBC("|")); } return(text); }