コード例 #1
0
ファイル: TermBaseTBX.cs プロジェクト: crashracer/EasyTerm
        // ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="nodeLangset"></param>
        /// <param name="langset"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        private void ReadLangset(XmlNode nodeLangset, TermInfo.LangSet langset)
        {
            // Read description
            ReadProps(nodeLangset, ref langset._Props);


            // Read terms
            foreach (XmlNode nodeTig in nodeLangset.SelectNodes("./tig"))
            {
                XmlNode nodeTerm = nodeTig.SelectSingleNode("./term");
                if (nodeTerm == null)
                {
                    return;
                }

                TermInfo.Term term = langset.AddTerm(nodeTerm.InnerText);

                ReadProps(nodeTig, ref term._Props);
            }

            // Read terms
            foreach (XmlNode nodeTig in nodeLangset.SelectNodes("./ntig"))
            {
                XmlNode nodeTerm = nodeTig.SelectSingleNode("./termGrp/term");
                if (nodeTerm == null)
                {
                    return;
                }

                TermInfo.Term term = langset.AddTerm(nodeTerm.InnerText);

                ReadProps(nodeTig, ref term._Props);
            }
        }
コード例 #2
0
ファイル: TermBaseTBX.cs プロジェクト: crashracer/EasyTerm
        // ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        internal override bool GetTermInfo(int termID, out TermInfo info, IAbortTermQuery abort)
        {
            info = null;

            if (termID < 0 || termID >= _Langset1.Count)
            {
                return(false);
            }

            try
            {
                info        = new TermInfo();
                info.TermID = termID;

                XmlNode nodeLangset1 = _Langset1[termID];

                // Entry
                XmlNode nodeEntry = nodeLangset1.ParentNode;
                ReadProps(nodeEntry, ref info._Props);

                // Language 1
                int lcid1 = GetLCIDFromAttributeName(_LangAttribute1);
                if (lcid1 < 0)
                {
                    return(false);
                }

                TermInfo.LangSet langset1 = info.AddLanguage(lcid1);
                ReadLangset(nodeLangset1, langset1);


                // Language 2
                int lcid2 = GetLCIDFromAttributeName(_LangAttribute2);
                if (lcid2 < 0)
                {
                    return(true);
                }


                string  xpath        = string.Format("./langSet[@xml:lang='{0}']", _LangAttribute2);
                XmlNode nodeLangset2 = nodeLangset1.ParentNode.SelectSingleNode(xpath, _NamespaceManager);

                if (nodeLangset2 != null)
                {
                    TermInfo.LangSet langset2 = info.AddLanguage(lcid2);
                    ReadLangset(nodeLangset2, langset2);
                }


                return(true);
            }
            catch (Exception ex)
            {
                info                   = new TermInfo();
                info._Props            = new TermInfo.Properties();
                info._Props.Definition = ex.Message;
                return(true);
            }
        }
コード例 #3
0
ファイル: TermBaseCSV.cs プロジェクト: crashracer/EasyTerm
        // ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        internal override bool GetTermInfo(int termID, out TermInfo info, IAbortTermQuery abort)
        {
            info = null;

            if (_LangIndex1 < 0 || _LangIndex2 < 0)
            {
                return(false);
            }

            if (termID < 0 || termID >= _Terms.Count)
            {
                return(false);
            }

            info        = new TermInfo();
            info.TermID = termID;

            TermInfo.LangSet langset1 = info.AddLanguage(_Languages[_LangIndex1]);
            if (langset1 == null)
            {
                return(false);
            }

            langset1.AddTerm(_Terms[termID].Item1);

            TermInfo.LangSet langset2 = info.AddLanguage(_Languages[_LangIndex2]);
            if (langset2 == null)
            {
                return(false);
            }

            langset2.AddTerm(_Terms[termID].Item2);


            return(true);
        }
コード例 #4
0
ファイル: TermBaseDB.cs プロジェクト: crashracer/EasyTerm
        // ********************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <param name="abort"></param>
        /// <returns></returns>
        /// <created>UPh,01.11.2015</created>
        /// <changed>UPh,01.11.2015</changed>
        // ********************************************************************************
        internal override bool GetTermInfo(int termID, out TermInfo info, IAbortTermQuery abort)
        {
            info = null;

            if (_DataBase == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(_LangAttribute1))
            {
                return(false);
            }

            try
            {
                string sql = "SELECT text FROM mtConcepts WHERE conceptid = @id";

                using (OleDbCommand cmd = new OleDbCommand(sql, _DataBase))
                {
                    cmd.Parameters.AddWithValue("@id", termID);

                    string text = cmd.ExecuteScalar() as string;

                    XmlDocument doc = new XmlDocument();
                    doc.XmlResolver = null;
                    doc.LoadXml(text);


                    info        = new TermInfo();
                    info.TermID = termID;

                    XmlNode nodeProps = doc.SelectSingleNode("./cG");
                    if (nodeProps != null)
                    {
                        ReadProps(nodeProps, ref info._Props);
                    }


                    // Language 1
                    string  xpath1       = string.Format("/cG/lG/l[@type='{0}']", _LangAttribute1);
                    XmlNode nodeLangset1 = doc.SelectSingleNode(xpath1);

                    if (nodeLangset1 != null)
                    {
                        int lcid1 = GetLCIDFromAttributeName(_LangAttribute1);
                        if (lcid1 >= 0)
                        {
                            TermInfo.LangSet langset1 = info.AddLanguage(lcid1);
                            ReadLangset(nodeLangset1.ParentNode, langset1);
                        }
                    }


                    // Language 2
                    string  xpath2       = string.Format("/cG/lG/l[@type='{0}']", _LangAttribute2);
                    XmlNode nodeLangset2 = doc.SelectSingleNode(xpath2);

                    if (nodeLangset2 != null)
                    {
                        int lcid2 = GetLCIDFromAttributeName(_LangAttribute2);
                        if (lcid2 >= 0)
                        {
                            TermInfo.LangSet langset2 = info.AddLanguage(lcid2);
                            ReadLangset(nodeLangset2.ParentNode, langset2);
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }