示例#1
0
    /// <summary>
    /// 获得拼音缓存的实例
    /// </summary>
    /// <returns>返回拼音缓存实例</returns>
    public static SpellCache getInstance()
    {
      if(obj_SpellCache == null)
      {
        obj_SpellCache = new SpellCache();
      }

      return obj_SpellCache;
    }
示例#2
0
        /// <summary>
        /// 获得拼音缓存的实例
        /// </summary>
        /// <returns>返回拼音缓存实例</returns>
        public static SpellCache getInstance()
        {
            if (obj_SpellCache == null)
            {
                obj_SpellCache = new SpellCache();
            }

            return(obj_SpellCache);
        }
示例#3
0
 /// <summary>
 /// 构造函数
 /// </summary>
 private SpellCache()
 {
   try
   {
     if(obj_SpellCache==null)
       init();
   }
   catch(Exception e)
   {
     obj_SpellCache = null;
   }
 }
示例#4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 private SpellCache()
 {
     try
     {
         if (obj_SpellCache == null)
         {
             init();
         }
     }
     catch (Exception e)
     {
         obj_SpellCache = null;
     }
 }
示例#5
0
        /// <summary>
        /// 生成字典文件
        /// </summary>
        /// <param name="dicname">字典名称</param>
        public void createDicFile(string dicname)
        {
            //先刷新字典缓存
            this.refresh(dicname);

            string      strXML = Common.XML_HEADINFO + "<data/>";
            XmlDocument doc    = new XmlDocument();

            doc.LoadXml(strXML);

            ArrayList arr_DicContent = (ArrayList)m_htb_Dic[dicname];

            SpellCache spellcache = SpellCache.getInstance();

            foreach (object dicObj in arr_DicContent)
            {
                string[] str_DicItem = (string[])dicObj;
                string   sCode       = str_DicItem[0];
                string   sText       = str_DicItem[1];
                string   sValid      = str_DicItem[2];

                // 从拼音缓存中做拼音翻译
                string spell  = spellcache.getSpell(sText);
                string aspell = spellcache.getASpell(sText);

                // 拼音翻译
                // Spell.getAllSpell(sText, ref spell, ref aspell);

                if (sValid.Equals("1"))
                {
                    XmlElement el = doc.CreateElement("row");
                    doc.DocumentElement.AppendChild(el);
                    el.SetAttribute(Field.DIC_CODE, sCode);
                    el.SetAttribute(Field.DIC_TEXT, sText);
                    el.SetAttribute(Field.DIC_SPELL, spell);
                    el.SetAttribute(Field.DIC_ASPELL, aspell);

                    el = null;
                }
            }

            string sPath = getDicPath() + "\\" + dicname + ".xml";

            doc.Save(sPath);
        }
示例#6
0
        /// <summary>
        /// 根据表结构需要动态创建字典
        /// </summary>
        /// <param name="dicname">字典名称</param>
        /// <param name="sql">查询sql语句
        /// (如:select gid,gname from gtable order by gid)
        /// select语句只需要查询出编码和描述就可以了
        /// </param>
        public void createDicFile(string dicname, string sql)
        {
            OleDbDataReader rst     = null;
            int             rs_open = 0;

            if (CommonQuery.qryRst(sql, ref rst) == "0")
            {
                rs_open = 1;
                SpellCache  spellcache = SpellCache.getInstance();
                string      strXML     = Common.XML_HEADINFO + "<data/>";
                XmlDocument doc        = new XmlDocument();
                doc.LoadXml(strXML);

                while (rst.Read())
                {
                    string str_DicCode = rst[0].ToString();
                    string str_DicText = rst[1].ToString();

                    // 从拼音缓存中做拼音翻译
                    string spell  = spellcache.getSpell(str_DicText);
                    string aspell = spellcache.getASpell(str_DicText);

                    XmlElement el = doc.CreateElement("row");
                    doc.DocumentElement.AppendChild(el);
                    el.SetAttribute(Field.DIC_CODE, str_DicCode);
                    el.SetAttribute(Field.DIC_TEXT, str_DicText);
                    el.SetAttribute(Field.DIC_SPELL, spell);
                    el.SetAttribute(Field.DIC_ASPELL, aspell);

                    el = null;
                }
                string sPath = getDicPath() + "\\" + dicname + ".xml";

                doc.Save(sPath);
            }
            if (rs_open == 1)
            {
                rst.Close();
            }
        }