public bool Add_Base_PinYin(Base_PinYin _Base_PinYin) { try { return(remoteobj.Add_Base_PinYin(_Base_PinYin)); } catch (Exception ex) { OnError(ex.Message); return(false); } }
public static bool Add_Base_PinYin(Base_PinYin _Base_PinYin) { return(configManage.Add_Base_PinYin(_Base_PinYin)); }
/// <summary> /// 检查中文拼音是否支持,防止出现缺少汉字的情况 /// </summary> /// <param name="content"></param> /// <returns></returns> private bool CheckChinesePinYin(string content) { //先把字节包转换为字符串 string tmpcontent = content; //源字符串长度 int count = tmpcontent.Length; //序号 int index = 0; //汉字的起始、结束字节标志 byte[] beginbuf = { 0x1B, 0x0E }; byte[] endbuf = { 0x1B, 0x0F }; int code = 0; byte tmpbyte; //汉字范围 //范围(0x4e00~0x9fff)转换成int(chfrom~chend) int chfrom = Convert.ToInt32("4e00", 16); int chend = Convert.ToInt32("9fff", 16); bool isChinese = false;//是否汉字 //临时存储连续的汉字 string tmpstr = ""; string tmppinyin = "";//拼音 ArrayList al = new ArrayList(); PublicInfo thepub = new PublicInfo(); bool flag = true; for (int i = 0; i < count; i++) { //获得字符串中指定索引i处字符unicode编码 code = Char.ConvertToUtf32(tmpcontent, i); if (code >= chfrom && code <= chend) { Base_PinYin _Base_PinYin = m_BasePinYinList.Find(delegate(Base_PinYin x) { if (x.HanZi == tmpcontent.Substring(i, 1)) { return(true); } else { return(false); } }); if ((_Base_PinYin == null) || (_Base_PinYin.BianMa.Trim() == "") || (_Base_PinYin.PinYin.Trim() == "")) { if (_Base_PinYin == null) { //添加到数据库 _Base_PinYin = new Base_PinYin(); _Base_PinYin.HanZi = tmpcontent.Substring(i, 1); _Base_PinYin.PinYin = ""; _Base_PinYin.BianMa = ""; _Base_PinYin.Remarks = ""; ManageSpace.Manage.Add_Base_PinYin(_Base_PinYin); } flag = false; } ////检查中文拼音是否支持 //byte[] hanziBt; //tmppinyin = chs2py.convert(tmpcontent.Substring(i, 1), out hanziBt); //if (hanziBt == null) //{ // Log.Record("chinese.log", "不支持汉字:" + tmpcontent.Substring(i, 1) + " ||| " + tmpcontent); // return false; //} } } if (!flag) { Log.Record("chinese.log", "不支持汉字:" + tmpcontent); return(false); } else { return(true); } }