public void GenerateDfa(TextWriter ostr, int kind) { String s; IDictionary<string, KindInfo> temp; KindInfo info; int len; if (maxStrKind <= Ordinal) maxStrKind = Ordinal + 1; if ((len = Image.Length) > maxLen) maxLen = len; char c; for (int i = 0; i < len; i++) { if (Options.getIgnoreCase()) s = ("" + (c = Image[i])).ToLower(); else s = "" + (c = Image[i]); if (!NfaState.unicodeWarningGiven && c > 0xff && !Options.getUnicodeEscape() && !Options.getUserCharStream()) { NfaState.unicodeWarningGiven = true; CSharpCCErrors.Warning(LexGen.curRE, "Non-ASCII characters used in regular expression." + "Please make sure you use the correct TextReader when you create the parser, " + "one that can handle your character set."); } if (i >= charPosKind.Count) // Kludge, but OK charPosKind.Add(temp = new Dictionary<string, KindInfo>()); else temp = (IDictionary<string, KindInfo>) charPosKind[i]; if (!temp.TryGetValue(s, out info)) temp[s] = info = new KindInfo(LexGen.maxOrdinal); if (i + 1 == len) info.InsertFinalKind(Ordinal); else info.InsertValidKind(Ordinal); if (!Options.getIgnoreCase() && LexGen.ignoreCase[Ordinal] && c != Char.ToLower(c)) { s = ("" + Image[i]).ToLower(); if (i >= charPosKind.Count) // Kludge, but OK charPosKind.Add(temp = new Dictionary<string, KindInfo>()); else temp = (IDictionary<string, KindInfo>) charPosKind[i]; if (!temp.TryGetValue(s, out info)) temp[s] = info = new KindInfo(LexGen.maxOrdinal); if (i + 1 == len) info.InsertFinalKind(Ordinal); else info.InsertValidKind(Ordinal); } if (!Options.getIgnoreCase() && LexGen.ignoreCase[Ordinal] && c != Char.ToUpper(c)) { s = ("" + Image[i]).ToUpper(); if (i >= charPosKind.Count) // Kludge, but OK charPosKind.Add(temp = new Dictionary<string, KindInfo>()); else temp = (IDictionary<string, KindInfo>) charPosKind[i]; if (!temp.TryGetValue(s, out info)) temp[s] = info = new KindInfo(LexGen.maxOrdinal); if (i + 1 == len) info.InsertFinalKind(Ordinal); else info.InsertValidKind(Ordinal); } } maxLenForActive[Ordinal/64] = Math.Max(maxLenForActive[Ordinal/64], len - 1); allImages[Ordinal] = Image; }
//更新信息 public static KindInfo KindInfoUpload(KindInfo kindInfo, out AlertMessage alertMessage) { //权限检查 if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (kindInfo.ID == 0 ? "Create" : "Modify")).FirstOrDefault(), out string Message)) { alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning }; return(null); } //表单检查 if (string.IsNullOrWhiteSpace(kindInfo.Name)) { alertMessage = new AlertMessage { Message = "品类代码不能为空。", Type = AlertType.warning }; return(null); } if (string.IsNullOrWhiteSpace(kindInfo.Title)) { alertMessage = new AlertMessage { Message = "品类名称不能为空。", Type = AlertType.warning }; return(null); } using (var EF = new EF()) { //修改是否存在?代码、名称唯一? KindInfo kind_exist = null; KindInfo kind_name_exist = null; KindInfo kind_title_exist = null; if (kindInfo.ID == 0) { kind_name_exist = EF.KindInfos.Where(i => i.Name == kindInfo.Name).FirstOrDefault(); kind_title_exist = EF.KindInfos.Where(i => i.Title == kindInfo.Title).FirstOrDefault(); } else { kind_exist = EF.KindInfos.Where(i => i.ID == kindInfo.ID).FirstOrDefault(); if (kind_exist == null) { alertMessage = new AlertMessage { Message = string.Format("品牌编号[{0}]不存在。", kindInfo.ID), Type = AlertType.warning }; return(null); } kind_name_exist = EF.KindInfos.Where(i => i.ID != kindInfo.ID && i.Name == kindInfo.Name).FirstOrDefault(); kind_title_exist = EF.KindInfos.Where(i => i.ID != kindInfo.ID && i.Title == kindInfo.Title).FirstOrDefault(); } if (kind_name_exist != null && kind_name_exist.ID > 0) { alertMessage = new AlertMessage { Message = string.Format("品牌代码[{0}]已被ID[{1}]使用。", kindInfo.Name, kind_name_exist.ID), Type = AlertType.warning }; return(null); } if (kind_title_exist != null && kind_title_exist.ID > 0) { alertMessage = new AlertMessage { Message = string.Format("品牌名称[{0}]已被ID[{1}]使用。", kindInfo.Title, kind_title_exist.ID), Type = AlertType.warning }; return(null); } //数据保存 if (kindInfo.ID == 0) { kind_exist = EF.KindInfos.Add(new KindInfo { Enabled = true, }); } kind_exist.ParentID = kindInfo.ParentID; kind_exist.OrderBy = kindInfo.OrderBy; kind_exist.Name = kindInfo.Name; kind_exist.Title = kindInfo.Title; kind_exist.LogoFileID = kindInfo.LogoFileID; EF.SaveChanges(); //更新完成 alertMessage = null; return(kind_exist); } }