Exemplo n.º 1
0
        public List <string[][]> getMovies()
        {
            connection.Open();
            List <string[][]> movies = new List <string[][]>();

            string[][] movie = new string[2][];
            using (SQLiteCommand command = connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM Movie";
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    int count = 0;
                    while (reader.Read())
                    {
                        movie[0][count] = reader.GetInt32(0).ToString();
                        movie[1][count] = reader.GetString(1);
                        movies.Add(movie);
                        count++;
                    }
                }
            }
            connection.Close();
            return(movies);
        }
Exemplo n.º 2
0
        public static UserAccess AuthenticateUser(string username, string password)
        {
            UserAccess access = UserAccess.ANYONE;

            try
            {
                SQLiteDataReader reader = ExecuteQuery("SELECT * FROM users WHERE username='******'");
                if (reader.HasRows)
                {
                    if (reader.Read())
                    {
                        if (reader.GetString(1).Equals(password))
                        {
                            return(UserAccessAttr.GetByAccess(reader.GetInt32(2)));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(access);
        }
        public ObservableCollection <SGClassWrapper> GetAllStaticGestureClasses()
        {
            var    gestures = new ObservableCollection <SGClassWrapper>();
            string sql      = "SELECT id, name, gesture_json, sample_instance_json FROM StaticGestureClasses";

            using (var connection = new SQLiteConnection(_connString))
            {
                connection.Open();
                using (SQLiteCommand command = new SQLiteCommand(sql, connection))
                {
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            //gestures.Add(new StaticGestureClassWrapper()
                            //{
                            //	Id = reader.GetInt32(0),
                            //	Name = reader.GetString(1),
                            //	Gesture = JsonConvert.DeserializeObject<StaticGestureClass>(reader.GetString(2)),
                            //	SampleInstance = JsonConvert.DeserializeObject<StaticGestureInstance>(reader.GetString(3))
                            //});

                            var currGest = new SGClassWrapper()
                            {
                                Id             = reader.GetInt32(0),
                                Name           = reader.GetString(1),
                                Gesture        = JsonConvert.DeserializeObject <SGClass>(reader.GetString(2)),
                                SampleInstance = JsonConvert.DeserializeObject <SGInstance>(reader.GetString(3))
                            };
                            gestures.Add(currGest);
                        }
                    }
                }
            }
            return(gestures);
        }
Exemplo n.º 4
0
        public static List <BonusMove> getAllBonusMoves()
        {
            List <BonusMove> bonusMoves = new List <BonusMove>();
            String           text       = $"SELECT {BONUS_MOVE_TABLE_NAME}.id, {BONUS_MOVE_TABLE_NAME}.sum, {BONUS_MOVE_TABLE_NAME}.bonusType, {BONUS_MOVE_TABLE_NAME}.date, " +
                                          $"{USERS_TABLE_NAME}.firstName, {USERS_TABLE_NAME}.secondName, " +
                                          $"{USERS_TABLE_NAME}.phone, {BONUS_MOVE_TABLE_NAME}.moveType from {BONUS_MOVE_TABLE_NAME} LEFT JOIN {USERS_TABLE_NAME} " +
                                          $"ON {BONUS_MOVE_TABLE_NAME}.user_id={USERS_TABLE_NAME}.id;";

            using (SQLiteConnection conn = getConnection())
            {
                conn.Open();
                SQLiteCommand cmd = createComand(text, conn);
                try
                {
                    using (SQLiteDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                String    firstName = reader.IsDBNull(4) ? null : reader.GetString(4);
                                String    lastName  = reader.IsDBNull(5) ? null : reader.GetString(5);
                                String    phone     = reader.IsDBNull(6) ? null : reader.GetString(6);
                                BonusMove bonusMove = new BonusMove(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), firstName, lastName, phone, reader.GetDateTime(3), reader.GetInt32(7));
                                bonusMoves.Add(bonusMove);
                            }
                        }
                    }
                }
                catch (SQLiteException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(bonusMoves);
        }
        // The user profile page
        public ActionResult Index()
        {
            if (Session["LoggedUserID"] == null)
            {
                Logging.Log("User profile page", Logging.AccessType.Anonymous);
                return(RedirectToAction("Index", "Login"));
            }
            User user             = null;
            var  connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["SQLiteConnection"].ConnectionString;

            using (var m_dbConnection = new SQLiteConnection(connectionString))
            {
                m_dbConnection.Open();
                SQLiteCommand command = new SQLiteCommand("SELECT * FROM tblusers WHERE id = @userid", m_dbConnection);
                command.Parameters.AddWithValue("@userid", int.Parse(Session["LoggedUserID"].ToString()));
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            // adding messages to the list
                            user           = new User();
                            user.ID        = int.Parse(AntiXssEncoder.HtmlEncode(reader.GetInt32(0).ToString(), true));
                            user.Username  = AntiXssEncoder.HtmlEncode(reader.GetString(1).Trim(), true);
                            user.FirstName = AntiXssEncoder.HtmlEncode(reader.GetString(3).Trim(), true);
                            user.LastName  = AntiXssEncoder.HtmlEncode(reader.GetString(4).Trim(), true);
                            user.Email     = AntiXssEncoder.HtmlEncode(reader.GetString(5).Trim(), true);
                            user.Phone     = (!reader.IsDBNull(6)) ? AntiXssEncoder.HtmlEncode(reader.GetString(6).Trim(), true) : string.Empty;
                        }
                    }
                }
            }
            Logging.Log("User profile page", Logging.AccessType.Valid);
            return(View(user));
        }
Exemplo n.º 6
0
        public static Candle GetLast(string instrumentID)
        {
            var command = new SQLiteCommand("SELECT * FROM candle WHERE instrumentid=@InstrumentID order by candletime desc limit 1", DALUtil.Connection);

            command.Parameters.AddWithValue("@InstrumentID", instrumentID);
            SQLiteDataReader reader = command.ExecuteReader();

            if (!reader.Read())
            {
                return(null);
            }
            var candle = new Candle();

            candle.InstrumentID = reader.GetString(0);
            candle.TradingDay   = reader.GetDateTime(1);
            candle.CandleTime   = reader.GetDateTime(2);
            candle.Open         = DALUtil.GetDouble(reader[3]);
            candle.Close        = DALUtil.GetDouble(reader[4]);
            candle.High         = DALUtil.GetDouble(reader[5]);
            candle.Low          = DALUtil.GetDouble(reader[6]);
            candle.Volume       = reader.GetInt32(7);
            candle.OpenInterest = DALUtil.GetDouble(reader[8]);
            return(candle);
        }
        private void LoadChannels()
        {
            using (SQLiteConnection connection = new SQLiteConnection(this.database))
            {
                connection.Open();
                string        strainStatement = "select SensorId,ChannelNo,Length,Mass from Channels where GroupNo ='" + this.deviceId + "'";
                SQLiteCommand command         = new SQLiteCommand(strainStatement, connection);
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        //string  groupId = reader.GetString(0);
                        string sensorId  = reader.GetString(0);
                        int    channelNo = reader.GetInt32(1);
                        double length    = reader.GetDouble(2);
                        double mass      = reader.GetDouble(3);

                        VibrateChannel vc = new VibrateChannel(sensorId, channelNo, length, mass);

                        vibrateChannels.Add(channelNo, vc);
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// gets a list of the average ability scores
        /// </summary>
        public List <string> getAverageAbilityScores()
        {
            List <string> averageScores = new List <string>();

            using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    connection.Open();
                    command.CommandText = "SELECT * FROM averageAbilityScores";

                    using (SQLiteDataReader dbReader = command.ExecuteReader())
                    {
                        while (dbReader.Read())
                        {
                            if (!dbReader.IsDBNull(0))
                            {
                                averageScores.Add(dbReader.GetInt32(0).ToString());
                            }
                        }
                    }
                }

            return(averageScores);
        }
Exemplo n.º 9
0
        //read the data from the database,return the array of string
        public String[] getReaderString(String sql, String[] type, int number)
        {
            SQLiteConnection cnn = new SQLiteConnection(dbConnection);

            cnn.Open();
            SQLiteCommand    mycommand = new SQLiteCommand(sql, cnn);
            SQLiteDataReader reader    = mycommand.ExecuteReader();

            reader.Read();
            String[] stringArray = new String[10];
            for (int i = 0; i != number; ++i)
            {
                if (type[i].Equals("int"))
                {
                    stringArray[i] = reader.GetInt32(i).ToString();
                }
                else if (type[i].Equals("string"))
                {
                    stringArray[i] = reader.GetValue(i).ToString();
                }
            }
            reader.Close();
            return(stringArray);
        }
Exemplo n.º 10
0
        public static List <StudentInfo> AllFromClassroomId(int classroomId)
        {
            List <StudentInfo> studentList = new List <StudentInfo>();

            using SQLiteCommand cmd = GlobalFunction.OpenDbConnection();
            cmd.CommandText         = "SELECT * FROM linkStudentToClassroom WHERE classroomId = @classroomId";
            cmd.Parameters.AddWithValue("classroomId", classroomId);
            cmd.Prepare();
            using SQLiteDataReader rdr = cmd.ExecuteReader();
            List <int> studentIdList = new List <int>();

            while (rdr.Read())
            {
                studentIdList.Add(rdr.GetInt32(1));
            }

            foreach (int studentId in studentIdList)
            {
                StudentInfo student = FromId(studentId);
                studentList.Add(student);
            }

            return(studentList);
        }
Exemplo n.º 11
0
        private void ReadLevels()
        {
            //Application.OpenForms.OfType<EnterForm>().Single().SQLConnect.Open();
            SQLiteCommand SQLCommand = new SQLiteCommand();

            SQLCommand             = Application.OpenForms.OfType <EnterForm>().Single().SQLConnect.CreateCommand();
            SQLCommand.CommandText = "SELECT * FROM LEVELS ORDER BY LevelID;";
            SQLiteDataReader Reader = SQLCommand.ExecuteReader();

            while (Reader.Read())
            {
                try
                {
                    levels.Add(new Level(Reader.GetInt32(0), Reader.GetString(1)));
                }
                catch
                {
                    return;
                }
            }
            Reader.Close();

            SQLCommand.Dispose();
        }
 //Отправка сообщения всем пользователям
 public void SendMessagesToAll(string pathToDB)
 {
     try
     {
         using (SQLiteConnection connection = new SQLiteConnection($"Data Source={pathToDB}"))
         {
             connection.Open();
             using (SQLiteCommand command = new SQLiteCommand("SELECT * FROM ChatIDTable", connection))
             {
                 using (SQLiteDataReader reader = command.ExecuteReader())
                 {
                     while (reader.Read())
                     {
                         SendMessgeToUser(reader.GetInt32(1));
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.Message);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        ///   指定された授業IDでこれまでに記録された質問数を返す。
        /// </summary>
        public int GetNumberOfClassRecords(int classId)
        {
            int nrecords = -1;

            using (SQLiteCommand cmd = new SQLiteCommand(this.connection)) {
                try {
                    cmd.CommandText = (
                        "SELECT count(questionId) FROM Question, Student " +
                        "WHERE Student.studentId = Question.studentId " +
                        "AND classId=@classId;");
                    cmd.Prepare();
                    cmd.Parameters.AddWithValue("@classId", classId);
                    using (SQLiteDataReader reader = cmd.ExecuteReader()) {
                        while (reader.Read())
                        {
                            nrecords = reader.GetInt32(0);
                        }
                    }
                } catch (SQLiteException e) {
                    Console.WriteLine("Database.GetNumberOfClassRecords: " + e);
                }
            }
            return(nrecords);
        }
Exemplo n.º 14
0
        public static TextureInformation[] GetTextureInformationsById(string id)
        {
            List <TextureInformation> result = new List <TextureInformation>();
            SQLiteConnection          con    = GetConnection();

            con.Open();
            SQLiteDataReader reader = getAllWhere("res", "rtype = 'A654495C' and lower(name) = '" + id.ToLower() + "'", con);
            int count = 0;

            while (reader.Read())
            {
                if (count++ % 1000 == 0)
                {
                    Application.DoEvents();
                }
                TextureInformation ti = new TextureInformation();
                ti.name        = reader.GetString(0);
                ti.sha1        = Helpers.HexStringToByteArray(reader.GetString(1));
                ti.bundleIndex = reader.GetInt32(3);
                result.Add(ti);
            }
            con.Close();
            return(result.ToArray());
        }
Exemplo n.º 15
0
        private User FillUserData(SQLiteDataReader reader)
        {
            try
            {
                User aranan = new User();
                aranan.ID = reader.GetInt32(0);
                aranan.Name = (reader["Name"] != null) ? reader["Name"].ToString() : "Default name";
                aranan.Surname = (reader["Surname"] != null) ? reader["Surname"].ToString() : "Default surname";
                aranan.Username = (reader["Username"] != null) ? reader["Username"].ToString() : "Default username";
                aranan.Password = (reader["Password"] != null) ? reader["Password"].ToString() : "Default password";
                aranan.Telephone = (reader["Telephone"] != null) ? reader["Telephone"].ToString() : "Default telephone";
                aranan.Mail = (reader["Mail"] != null) ? reader["Mail"].ToString() : "Default mail";
                aranan.StartDateofEmployment = (reader["StartDateofEmployment"] != null) ? reader["StartDateofEmployment"].ToString() : "Default Start date of employment ";
                aranan.Birthdate = (reader["Birthdate"] != null) ? reader["Birthdate"].ToString() : "Default birthdate";
                aranan.Address = (reader["Address"] != null) ? reader["Address"].ToString() : "Default address";
                aranan.UserRole = (reader["UserRole"] != null) ? (UserRoles)Enum.Parse(typeof(UserRoles), reader["UserRole"].ToString()) : UserRoles.None;
                return aranan;
            }
            catch
            {

            }
            return null;
        }
Exemplo n.º 16
0
        /// Renvoie le nombre d'articles présents dans la bdd
        /// </summary>
        /// <returns></returns>
        public int CountAllArticles()
        {
            int Total = 0;

            //ouverture de la connexion avec la bdd & creation de la requete
            SQLiteConnection M_dbConnection = new SQLiteConnection("Data Source=" + DatabasePath);

            M_dbConnection.Open();

            String Sql = "select COUNT(*) from Articles";

            using (SQLiteCommand Command = new SQLiteCommand(Sql, M_dbConnection))
            {
                using (SQLiteDataReader Reader = Command.ExecuteReader())
                {
                    Reader.Read();
                    Total = Reader.GetInt32(0);
                }
            }

            M_dbConnection.Close();

            return(Total);
        }
Exemplo n.º 17
0
        public void GetSQL(String ConnectionString)
        {
            SQLiteConnection Connection = new SQLiteConnection(ConnectionString);

            Connection.Open();

            TextList = new List <PakTextEntry>();

            using (SQLiteTransaction Transaction = Connection.BeginTransaction())
                using (SQLiteCommand Command = new SQLiteCommand(Connection)) {
                    Command.CommandText = "SELECT english, PointerRef FROM Text ORDER BY PointerRef";
                    SQLiteDataReader r = Command.ExecuteReader();
                    while (r.Read())
                    {
                        String SQLText;

                        try {
                            SQLText = r.GetString(0).Replace("''", "'");
                        } catch (System.InvalidCastException) {
                            SQLText = "";
                        }

                        int PointerRef = r.GetInt32(1);


                        PakTextEntry d = new PakTextEntry();
                        d.OffsetLocation = PointerRef;
                        d.Text           = SQLText;
                        d.Offset         = -1;
                        TextList.Add(d);
                    }

                    Transaction.Rollback();
                }
            return;
        }
Exemplo n.º 18
0
        public IList <ProblemStation> getProblemStations(IList <long> edsmIds, int distanceToBeAProblem)
        {
            IList <ProblemStation> result = new List <ProblemStation>();

            try
            {
                using (var con = SimpleDbConnection())
                {
                    con.Open();
                    var ids = string.Join(",", edsmIds.ToArray());

                    using (var cmd = new SQLiteCommand(con))
                    {
                        cmd.CommandText = string.Format(FIND_PROBLEM_STATIONS_SQL, ids);
                        cmd.Prepare();
                        cmd.Parameters.AddWithValue("@distance", distanceToBeAProblem);
                        using (SQLiteDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                string stationName = rdr.GetString(0);
                                int    distance    = rdr.GetInt32(1);
                                string systemName  = rdr.GetString(2);
                                result.Add(new ProblemStation(stationName, systemName, distance));
                            }
                        }
                    }
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                Logging.Warn("Problem obtaining data: " + ex);
            }
            return(result);
        }
Exemplo n.º 19
0
        public void LoadData()
        {
            string pathToFile = AppDomain.CurrentDomain.BaseDirectory;
            string newPath    = Path.GetFullPath(Path.Combine(pathToFile, @"..\..\"));
            string cs         = @"Data Source=" + newPath + "Coordinates.db" + ";Pooling=true;FailIfMissing=false;Version=3";



            SQLiteConnection con = new SQLiteConnection(cs);

            con.Open();
            string stm = "SELECT Id,Name,Job,Description,Cord FROM Cord";

            SQLiteCommand    cmd = new SQLiteCommand(stm, con);
            SQLiteDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                databaseGritBindingSource.Add(new DatabaseGrit()
                {
                    Id = rdr.GetInt32(0), Name = rdr.GetString(1), Title = rdr.GetString(2), Description = "Danni", Text = rdr.GetString(3)
                });
            }
        }
Exemplo n.º 20
0
        public List <Cliente> ListAll()
        {
            //cria e retorna uma lista com todos os clientes
            List <Cliente>   lista   = new List <Cliente>();
            Cliente          cliente = null;
            SQLiteConnection conexao = Database.GetInstance().GetConnection();

            string qry = "SELECT Cpf, Nome, Telefone, Frequencia FROM Cliente";

            if (conexao.State != System.Data.ConnectionState.Open)
            {
                conexao.Open();
            }

            SQLiteCommand comm = new SQLiteCommand(qry, conexao);

            SQLiteDataReader dr = comm.ExecuteReader();

            while (dr.Read())
            {
                // Cria um objeto Cliente para transferir os dados
                // do banco para a aplicação (DTO)
                cliente            = new Cliente();
                cliente.Cpf        = dr.GetString(0);
                cliente.Nome       = dr.GetString(1);
                cliente.Telefone   = dr.GetString(2);
                cliente.Frequencia = dr.GetInt32(3);

                lista.Add(cliente); // Adiciona o objeto na lista de resultados
            }

            dr.Close();      // para nao dar erro de database locked
            conexao.Close(); // Não esqueça de fechar a conexão

            return(lista);
        }
        public List <String[]> getAllArticles()
        {
            String          request = "SELECT AR_Ref,AR_Design,AR_Coli FROM colisageArticle";
            List <String[]> result  = null;

            using (SQLiteCommand cmd = new SQLiteCommand(request, this.conn))
            {
                using (SQLiteDataReader dr = cmd.ExecuteReader())
                {
                    result = new List <string[]>();
                    String[] temp;
                    while (dr.Read())
                    {
                        temp    = new String[3];
                        temp[0] = dr.GetString(0);
                        temp[1] = dr.GetString(1);
                        temp[2] = dr.GetInt32(2).ToString(CultureInfo.InvariantCulture);

                        result.Add(temp);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 22
0
        public DBOutbox GetDataId(int id)
        {
            DBOutbox data = null;

            SQLiteConnection con = DBConnection.ConnectDatabase();

            try
            {
                SQLiteCommand    cmd    = new SQLiteCommand("SELECT * FROM " + tablename + " WHERE id=" + id, con);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();

                    data           = new DBOutbox();
                    data.ID        = reader.GetInt32(0);
                    data.Date      = reader.GetDateTime(1);
                    data.Recipient = reader.GetString(2);
                    data.Message   = reader.GetString(3);
                    data.Sent      = reader.GetString(4);
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                con.Close();
            }

            return(data);
        }
        private static bool IsInDataBaseInternal <T>(T e) where T : class
        {
            bool returnValue = false;

            using (_connection = OpenConection())
            {
                using (SQLiteCommand command = new SQLiteCommand($"SELECT * FROM COMPANY WHERE ID = {(int)e.GetType().GetProperty("ID").GetValue(e)}", _connection))
                {
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int readerValue = reader.GetInt32(0);
                            returnValue = (int)e.GetType().GetProperty("ID").GetValue(e) == readerValue;
                            if (!reader.HasRows)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            return(returnValue);
        }
Exemplo n.º 24
0
        public static DBOutboxLog GetDataMessage(string message)
        {
            DBOutboxLog data = null;

            SQLiteConnection con = DBConnection.ConnectDatabase();

            try
            {
                SQLiteCommand    cmd    = new SQLiteCommand("SELECT * FROM " + tablename + " WHERE message LIKE '%" + message + "%'", con);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();

                    data           = new DBOutboxLog();
                    data.ID        = reader.GetInt32(0);
                    data.Date      = DateTime.Parse(reader.GetDateTime(1).ToString());
                    data.Recipient = reader.GetString(2);
                    data.Message   = reader.GetString(3);
                    data.Sent      = reader.GetString(4);
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(data);
        }
        /// <summary>
        /// gets the base Weight in metric or imperial for the chosen race
        /// </summary>
        /// <param name="metric">true for metric, false for imperial</param>
        /// <param name="subrace">chosen subrace</param>
        public int getBaseWeight(bool metric, string subrace)
        {
            int baseWeight = 0;

            using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    connection.Open();
                    if (metric)
                    {
                        command.CommandText = "SELECT baseWeightKg FROM size " +
                                              "INNER JOIN races ON size.raceId=races.raceid " +
                                              "WHERE races.subrace=@Subrace";
                    }
                    else
                    {
                        command.CommandText = "SELECT baseWeightLb FROM size " +
                                              "INNER JOIN races ON size.raceId=races.raceid " +
                                              "WHERE races.subrace=@Subrace";
                    }
                    command.Parameters.AddWithValue("@Subrace", subrace);

                    using (SQLiteDataReader dbReader = command.ExecuteReader())
                    {
                        if (dbReader.Read())
                        {
                            if (!dbReader.IsDBNull(0))
                            {
                                baseWeight = dbReader.GetInt32(0);
                            }
                        }
                    }
                }

            return(baseWeight);
        }
Exemplo n.º 26
0
 private void AddGamesToComboBox()
 {
     using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=.\" + databaseName + ";"))
     {
         conn.Open();
         SQLiteCommand    command = new SQLiteCommand("select id_section, name from section;", conn);
         SQLiteDataReader reader  = command.ExecuteReader();
         while (reader.Read())
         {
             sections.Add(new GameBasic()
             {
                 ID = reader.GetInt32(0), Name = reader.GetString(1)
             });
         }
         reader.Close();
     }
     GamesComboBox.Items.Clear();
     GamesComboBox.Items.Add("Všechny hry");
     for (int i = 0; i < sections.Count; i++)
     {
         GamesComboBox.Items.Add(sections.ElementAt(i).Name);
     }
     GamesComboBox.SelectedIndex = 0;
 }
Exemplo n.º 27
0
        public static string[] GetUseCameraDB()
        {
            if (cn.State != System.Data.ConnectionState.Open)
            {
                cn.Open();
            }
            SQLiteCommand cmd = new SQLiteCommand();

            cmd.Connection = cn;
            string cmd_text = String.Format("SELECT * FROM CAMERA WHERE USETAG = 1");

            cmd.CommandText = cmd_text;
            string[] camera = new string[4];
            try
            {
                SQLiteDataReader sr = cmd.ExecuteReader();
                sr.Read();
                camera[0] = sr.GetInt32(0).ToString();
                camera[1] = sr.GetString(2);
                camera[2] = sr.GetString(3);
                camera[3] = sr.GetString(4);
            }catch (Exception ex) { System.Console.WriteLine(ex); return(null); }
            return(camera);
        }
Exemplo n.º 28
0
        public object getObject(string dataSourceId, string objectHashString)
        {
            SQLiteCommand cmd = new SQLiteCommand("SELECT ASSEMBLY_NAME, DOMAIN_OBJECT_SIZE, DOMAIN_OBJECT, QUERY_STRING FROM " + TABLE_NAME_PREFIX + dataSourceId +
                                                  " WHERE QUERY_STRING_HASH = '" + objectHashString + "';", _cxn);

            try
            {
                openConnection();

                SQLiteDataReader rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    string assemblyName     = rdr.GetString(0); // probably don't need this since we know how to cast the object type already
                    Int32  domainObjectSize = rdr.GetInt32(1);
                    byte[] domainObject     = new byte[domainObjectSize];
                    rdr.GetBytes(2, 0, domainObject, 0, domainObjectSize);
                    string dbQueryString = rdr.GetString(3);

                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    return(bf.Deserialize(new MemoryStream(domainObject)));
                }
                else
                {
                    throw new exceptions.MdoException("No record found for that hashcode");
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                closeConnection();
            }
        }
Exemplo n.º 29
0
        public List <Event> GetEvents()
        {
            mutex.WaitOne();
            List <Event>  events    = new List <Event>();
            string        query1    = "SELECT scheduleId, time, amount FROM event";
            SQLiteCommand myCommand = new SQLiteCommand(query1, myConnection);

            OpenConnection();
            myCommand.ExecuteNonQuery();
            SQLiteDataAdapter adapter = new SQLiteDataAdapter(myCommand);
            DataTable         dt      = new DataTable("events");

            adapter.Fill(dt);
            foreach (DataRow row in dt.Rows)
            {
                var   cells  = row.ItemArray;
                Event @event = new Event(Convert.ToInt32(cells.GetValue(0)), Convert.ToInt32(cells.GetValue(1)), Convert.ToInt32(cells.GetValue(2)));
                events.Add(@event);
            }
            CloseConnection();
            for (int i = 0; i < events.Count(); i++)
            {
                string        query      = "SELECT feederId FROM schedule WHERE SheduleId = @scheduleId";
                SQLiteCommand myCommand1 = new SQLiteCommand(query, myConnection);
                myCommand1.Parameters.AddWithValue("@scheduleId", events[i].ScheduleId);
                OpenConnection();
                SQLiteDataReader reader1 = myCommand1.ExecuteReader();
                while (reader1.Read())
                {
                    events[i].FeederId = reader1.GetInt32(0);
                }
                CloseConnection();
            }
            mutex.ReleaseMutex();
            return(events);
        }
Exemplo n.º 30
0
        public List <string[][]> getActors()
        {
            connection.Open();
            List <string[][]> actors = new List <string[][]>();

            string[][] actor = new string[2][];
            using (SQLiteCommand command = connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM Actor";
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    int count = 0;
                    while (reader.Read())
                    {
                        actor[0][count] = reader.GetInt32(0).ToString();
                        actor[1][count] = reader.GetString(1);
                        actors.Add(actor);
                        count++;
                    }
                }
            }
            connection.Close();
            return(actors);
        }