示例#1
0
        /// <summary>
        /// Update Glossary terms
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="dt">Table with terms to update</param>
        /// <param name="lTerms">Type, Term, Meaning</param>
        /// <param name="col0NameTyp">Column name of 'Type'</param>
        /// <param name="col1NameTerm">Column name of 'Term'</param>
        /// <param name="col2NameMeaning">Column name of 'Meaning'</param>
        private static int UpdateGlossaryTerms(Repository rep, DataTable dt, List <Tuple <string, string, string, short> > lTerms,
                                               string col0NameTyp,
                                               string col1NameTerm,
                                               string col2NameMeaning)
        {
// Find records to update
            var updateTerms = from DataRow termNew in dt.Rows
                              from termOld in lTerms
                              where (string)termNew[col0NameTyp] == termOld.Item1 &&
                              (string)termNew[col1NameTerm] == termOld.Item2 &&
                              (string)termNew[col2NameMeaning] != termOld.Item3
                              select new { itemNew = termNew, Index = termOld.Item4 };

            // update EA Glossary
            int updateCount = 0;

            foreach (var item in updateTerms)
            {
                EA.Term term = (EA.Term)rep.Terms.GetAt(item.Index);
                term.Meaning = (string)item.itemNew[col2NameMeaning];
                term.Update();
                updateCount += 1;
            }
            rep.Terms.Refresh();
            return(updateCount);
        }
示例#2
0
        /// <summary>
        /// Append Glossary terms
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="dt">Table with terms to append</param>
        /// <param name="lTerms">Type, Term, Meaning</param>
        /// <param name="col0NameTyp">Column name of 'Type'</param>
        /// <param name="col1NameTerm">Column name of 'Term'</param>
        /// <param name="col2NameMeaning">Column name of 'Meaning'</param>
        private static int  AppendGlossaryTerms(Repository rep, DataTable dt, List <Tuple <string, string, string, short> > lTerms, string col0NameTyp,
                                                string col1NameTerm, string col2NameMeaning)
        {
// New Glossary items
            var newTerms = from DataRow termNew in dt.Rows
                           where !lTerms.Any(i1 => i1.Item1 == (string)termNew[col0NameTyp] &&
                                             i1.Item2 == (string)termNew[col1NameTerm]
                                             )
                           select new { termNew };
            // update EA Glossary
            int insertCount = 0;

            foreach (var item in newTerms)
            {
                EA.Term term = (EA.Term)rep.Terms.AddNew((string)item.termNew[col1NameTerm], "Term");
                term.Type    = (string)item.termNew[col0NameTyp];
                term.Term    = (string)item.termNew[col1NameTerm];
                term.Meaning = (string)item.termNew[col2NameMeaning];
                term.Update();
                insertCount += 1;
            }
            rep.Terms.Refresh();
            return(insertCount);
        }