Example #1
0
        public static List <string> GetEuis(object conn, XMLRealiser.LexiconType lexiconType, string inflVar)
        {
            switch (lexiconType)
            {
            case XMLRealiser.LexiconType.NIHDB_HSQL:
                throw new NotImplementedException("HSQLdb disabled");
                string query = "SELECT eui FROM INFL_VARS where (inflVarLc = '" +
                               DbBase.FormatSqlStr(inflVar.ToLower()) + "')";
            //Statement statement = ((Connection) conn).createStatement();
            //ResultSet rs = statement.executeQuery(query);
            //List<string> outs = new List<string>();
            //while (rs.next())
            //{
            //    string eui = rs.getString("eui");
            //    outs.Add(eui);
            //}

            //rs.close();
            //statement.close();
            //return outs;
            case XMLRealiser.LexiconType.NIHDB_SQLITE:
                List <string> euis    = new List <string>();
                SQLiteCommand command = new SQLiteCommand("SELECT eui FROM INFL_VARS where (inflVarLc = @INFLVAR)",
                                                          (SQLiteConnection)conn);
                command.Parameters.AddWithValue("@INFLVAR", DbBase.FormatSqlStr(inflVar.ToLower()));
                SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command,
                                               reader => euis.Add(reader["eui"] as string));
                return(euis);
            }

            return(null);
        }
Example #2
0
        public static List <string> GetRecordsByBase(object conn, XMLRealiser.LexiconType lexiconType, string @base, int baseBy)
        {
            List <string> recordStringList = new List <string>();

            switch (lexiconType)
            {
            case XMLRealiser.LexiconType.NIHDB_HSQL:
                throw new NotImplementedException("HSQLdb disabled");
                string query = "SELECT lexRecord FROM LEX_RECORD where (base = '" + DbBase.FormatSqlStr(@base) +
                               "' and lastAction <> 3)";

                switch (baseBy)
                {
                case 4:
                    query = "SELECT lexRecord FROM LEX_RECORD where (base = '" + DbBase.FormatSqlStr(@base) +
                            "' and lastAction <> 3)";
                    break;

                case 3:
                    query = "SELECT lexRecord FROM LEX_RECORD where (base like '%" + DbBase.FormatSqlStr(@base) +
                            "' and lastAction <> 3)";
                    break;

                case 1:
                    query = "SELECT lexRecord FROM LEX_RECORD where (base like '" + DbBase.FormatSqlStr(@base) +
                            "%' and lastAction <> 3)";
                    break;

                case 2:
                    query = "SELECT lexRecord FROM LEX_RECORD where (base like '%" + DbBase.FormatSqlStr(@base) +
                            "%' and lastAction <> 3)";
                    break;
                }
                //Statement statement = ((Connection)conn).createStatement();
                //ResultSet rs = statement.executeQuery(query);
                //while (rs.next())
                //{
                //    string lexRecord = rs.getString("lexRecord");
                //    recordStringList.Add(lexRecord);
                //}
                break;

            case XMLRealiser.LexiconType.NIHDB_SQLITE:
                SQLiteCommand command;
                switch (baseBy)
                {
                case 3:
                    @base   = "%" + @base;
                    command = new SQLiteCommand("SELECT lexRecord FROM LEX_RECORD where (base like @BaseForm and lastAction <> 3)", (SQLiteConnection)conn);
                    break;

                case 1:
                    @base   = @base + "%";
                    command = new SQLiteCommand("SELECT lexRecord FROM LEX_RECORD where (base like @BaseForm and lastAction <> 3)", (SQLiteConnection)conn);
                    break;

                case 2:
                    @base   = "%" + @base + "%";
                    command = new SQLiteCommand("SELECT lexRecord FROM LEX_RECORD where (base like @BaseForm and lastAction <> 3)", (SQLiteConnection)conn);
                    break;

                case 4:
                default:
                    command = new SQLiteCommand("SELECT lexRecord FROM LEX_RECORD where (base = @BaseForm and lastAction <> 3)", (SQLiteConnection)conn);
                    break;
                }
                command.Parameters.Add("@BaseForm", DbType.String).Value = @base;
                SqliteAccess.ProcessDataReader((SQLiteConnection)conn, command, reader => recordStringList.Add(reader["lexRecord"] as string));
                break;
            }

            return(recordStringList);
        }