bool checkHis(His his) { if (DBHelper.searchHis(his) > 0) { return(false); } else { return(true); } }
public bool checkValid(His his) { string id = his.Vid; if (id == null || id == "") { return(true); } id = id.ToLower(); bool flag = true; string letter = ""; string number = ""; bool isEndofLetter = false; for (int i = 0; i < id.Length; i++) //修改 对于出现KIDM235A KIDM235B { if (reg1.IsMatch(id[i].ToString())) { if (isEndofLetter) { break; } else { letter += id[i]; } } else { number += id[i]; isEndofLetter = true; } } string[] searchStr = { letter, number }; Regex r = new Regex("[^a-z]" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "[^0-9]|^" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "$|[^a-z]" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "$|^" + searchStr[0] + @"(\s){0,3}[-_]?(\s){0,3}(0){0,3}" + searchStr[1] + "[^0-9]"); for (int i = 0; i < list.Count; i++) { flag = true; string fileName = Path.GetFileNameWithoutExtension(list[i].FileName.ToLower()); string directoryName = list[i].Directory.ToLower(); string extension = list[i].Extension; double len = list[i].Length; //if (((fileName.Contains(searchStr[0]) && fileName.Contains(searchStr[1]) && checkDistance(fileName, searchStr[0], searchStr[1]) || directoryName.Contains(searchStr[0]) && directoryName.Contains(searchStr[1]) && checkDistance(directoryName, searchStr[0], searchStr[1])) && !fileName.Contains("incomplete")) && (len > 400||extension.ToLower()==".mds")) //{ // flag = false; // break; //} if ((len > 400 || extension.ToLower() == ".mds") && (r.IsMatch(fileName) || r.IsMatch(directoryName)) && !fileName.Contains("incomplete")) { flag = false; break; } } if (flag) { flag = checkHis(his); } if (flag) { DBHelper.insertHis(his); } return(flag); }