Beispiel #1
0
        public static List <String> ChatId()
        //создает лист с колонкой ChatId(номер чата) из ChatRelation
        {
            List <string> ChatId = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT  * FROM ChatRelation";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var chatid = dt.Columns["ChatID"];
                foreach (DataRow dr in dt.Rows)
                {
                    ChatId.Add(dr[chatid].ToString());
                }

                connection.Close();
            }
            catch { }
            return(ChatId);
        }
Beispiel #2
0
        public AddResources(SQLiteConnection sql)
        {
            fact = new SQLiteFactory();

            command  = sql.CreateCommand();
            this.sql = sql;
        }
Beispiel #3
0
        //create database with profiles (if not exixsts) and open window to create profile
        private void button_create_profile_Click(object sender, EventArgs e)
        {
            if (!File.Exists(db_name))
            {
                SQLiteConnection.CreateFile(db_name);
                SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");

                using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection())
                {
                    connection.ConnectionString = "Data Source = " + db_name;
                    connection.Open();

                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        command.CommandText = "CREATE TABLE IF NOT EXISTS [profiles] (" +
                                              "[id] INTEGER PRIMARY KEY AUTOINCREMENT," +
                                              "[login] TEXT," +
                                              "[password] TEXT" +
                                              ")";

                        command.CommandType = CommandType.Text;
                        command.ExecuteNonQuery();
                    }
                    connection.Close();
                }
            }

            //open window to create new profile
            Form_Creare_Profile new_form = new Form_Creare_Profile();

            new_form.ShowDialog();
        }
Beispiel #4
0
 public fmDB(bool _bSilent = false)
 {
     bSilent = _bSilent;
     if (bSilent)
     {
         if (!EventLog.SourceExists(source))
         {
             EventLog.CreateEventSource(source, "Application");
         }
     }
     try
     {
         factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
     }
     catch (Exception ex)
     {
         if (!bSilent)
         {
             MessageBox.Show("Не установлен System.Data.SQLite (1.0.103)" + Environment.NewLine + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         }
         else
         {
             EventLog.WriteEntry(source, "Не установлен System.Data.SQLite(1.0.103)", EventLogEntryType.Error);
         }
         Application.Exit();
     }
 }
Beispiel #5
0
        public static List <String> ContactIdMsg()
        //создает лист с колонкой ContactId(номер пользователя) из MessageInfo
        {
            List <string> ContactIdMsg = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT * FROM MessageInfo ORDER BY TimeStamp";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var contactid = dt.Columns["ContactID"];
                foreach (DataRow dr in dt.Rows)
                {
                    ContactIdMsg.Add(dr[contactid].ToString());
                }

                connection.Close();
            }
            catch { }
            return(ContactIdMsg);
        }
Beispiel #6
0
        protected virtual void InitializeAndBuildTable()
        {
            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }

            DbProviderFactory fact = new SQLiteFactory();

            m_dbConnection = fact.CreateConnection();

            if (m_dbConnection == null)
            {
                return;
            }

            m_dbConnection.ConnectionString = "Data Source=" + FileName;

            try
            {
                m_dbConnection.Open();
            }
            catch (Exception ex)
            {
                Logger.Instance.AddEntry("SQLitePeakListExporter failed. Details: " + ex.Message, true);
                throw;
            }

            BuildTable();
        }
Beispiel #7
0
        public static List <String> Default()
        {
            List <string> def = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT  * FROM Accounts";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var num = dt.Columns["IsDefault"];

                foreach (DataRow dr in dt.Rows)
                {
                    def.Add(dr[num].ToString());
                }

                connection.Close();
            }
            catch { }
            return(def);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            string baseName = "playerdb.db3";

            SQLiteConnection.CreateFile(baseName);

            SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");

            using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection())
            {
                connection.ConnectionString = "Data Source = " + baseName;
                connection.Open();

                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    command.CommandText = @"CREATE TABLE [players] (
                    [id] integer PRIMARY KEY NOT NULL,
                    [xcoordinate] integer NOT NULL,
                    [ycoordinate] integer NOT NULL,
                    [size] integer NOT NULL
                    );";

                    command.CommandType = CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
Beispiel #9
0
 public static BindingSource DownloadBD()
 {
     try
     {
         DataColumn column = new DataColumn {
             AutoIncrementSeed = 1L,
             AutoIncrement     = true,
             ColumnName        = "№"
         };
         dt.Columns.Add(column);
         factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
         connection = (SQLiteConnection)factory.CreateConnection();
         connection.ConnectionString = "Data Source = " + path_config;
         connection.Open();
         SQLiteCommand command = new SQLiteCommand(connection)
         {
             CommandText = "SELECT * FROM Accounts",
             CommandType = CommandType.Text
         };
         command.ExecuteNonQuery();
         sql.SelectCommand = command;
         sql.Fill(dt);
         bs.DataSource = dt;
         connection.Close();
     }
     catch
     {
     }
     return(bs);
 }
Beispiel #10
0
        public static bool TrySQLiteCommandExecute(string _DBFilename, string CommandText)
        {
            bool error = false;

            try
            {
                SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection())
                {
                    connection.ConnectionString = "Data Source = " + _DBFilename;
                    connection.Open();

                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        command.CommandText = @CommandText;
                        command.CommandType = CommandType.Text;
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                error = true;
            }
            return(!error);
        }
Beispiel #11
0
        private void CreateDB()
        {
            string Name = ConfigurationSettings.AppSettings.Get("DB_Name");

            SQLiteConnection.CreateFile(Name);

            SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");

            using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection())
            {
                connection.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectStr"].ConnectionString.ToString();
                connection.Open();

                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    command.CommandText = @"CREATE TABLE [Files] (
                    [id] integer PRIMARY KEY AUTOINCREMENT NOT NULL,
                    [FileName] char(100) NOT NULL,
                    [Data] Blob NOT NULL
                    );"; // varchar(MAX) → error
                    command.CommandType = CommandType.Text;
                    command.ExecuteNonQuery();
                }
            }
        }
Beispiel #12
0
        public static List <String> TimeStamps()
        //Создает лист TimeStamps, содержащий время отправки и получения сообщений в unix времени
        // Встроен конвертер unixtime в обычное время
        {
            List <string> TimeStamps = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT * FROM MessageInfo ORDER BY TimeStamp";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var TimeStamp = dt.Columns["TimeStamp"];
                foreach (DataRow dr in dt.Rows)
                {
                    TimeStamps.Add(dr[TimeStamp].ToString());
                }
                connection.Close();
            }
            catch { }
            return(TimeStamps);
        }
Beispiel #13
0
 public static BindingSource DownloadBD()
 {
     try
     {
         DataColumnCollection columns = WorkBD.dt.Columns;
         DataColumn           column  = new DataColumn();
         column.AutoIncrementSeed = 1L;
         int num = 1;
         column.AutoIncrement = num != 0;
         string str = "№";
         column.ColumnName = str;
         columns.Add(column);
         WorkBD.factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
         WorkBD.connection = (SQLiteConnection)WorkBD.factory.CreateConnection();
         WorkBD.connection.ConnectionString = "Data Source = " + WorkBD.path_config;
         WorkBD.connection.Open();
         SQLiteCommand sqLiteCommand = new SQLiteCommand(WorkBD.connection);
         sqLiteCommand.CommandText = "SELECT * FROM Accounts";
         sqLiteCommand.CommandType = CommandType.Text;
         sqLiteCommand.ExecuteNonQuery();
         WorkBD.sql.SelectCommand = sqLiteCommand;
         WorkBD.sql.Fill(WorkBD.dt);
         WorkBD.bs.DataSource = (object)WorkBD.dt;
         WorkBD.connection.Close();
     }
     catch
     {
     }
     return(WorkBD.bs);
 }
Beispiel #14
0
        public static List <String> IdMes()
        //создает лист c информацией о сообщении
        {
            List <string> IdMes = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT * FROM MessageInfo ORDER BY TimeStamp";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var type = dt.Columns["EventID"];
                foreach (DataRow dr in dt.Rows)
                {
                    IdMes.Add(dr[type].ToString());
                }

                connection.Close();
            }
            catch { }
            return(IdMes);
        }
Beispiel #15
0
        public static List <String> ViberContacts()
        //Создает лист ViberContacts , в котором указано, использует ли контакт Viber; 1-использует, 0 - не использует
        {
            List <string> ViberContacts = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT  * FROM Contact";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var ViberContact = dt.Columns["ViberContact"];
                foreach (DataRow dr in dt.Rows)
                {
                    ViberContacts.Add(dr[ViberContact].ToString());
                }

                connection.Close();
            }
            catch { }
            ViberContacts.RemoveAt(0);
            return(ViberContacts);
        }
Beispiel #16
0
        public Database(string file, string checkSql, string createSql)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (checkSql == null)
            {
                throw new ArgumentNullException("checkSql");
            }
            if (createSql == null)
            {
                throw new ArgumentNullException("createSql");
            }
            var dir = new System.IO.FileInfo(file).Directory;

            if (!dir.Exists)
            {
                dir.Create();
            }
            factory    = new SQLiteFactory();
            Connection = (SQLiteConnection)factory.CreateConnection();
            Connection.ConnectionString = "Data Source=" + file;
            Connection.Open();
            if (!CheckValidity(checkSql))
            {
                CreateTables(createSql);
            }
        }
Beispiel #17
0
        public static long LastMessageTime()
        //создает лист c информацией о сообщении
        {
            List <string> LastMessageTime = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = CheckMessage.db";
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT  * FROM Message";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var type = dt.Columns["Time"];
                foreach (DataRow dr in dt.Rows)
                {
                    LastMessageTime.Add(dr[type].ToString());
                }
                connection.Close();
            }
            catch { }
            return(Convert.ToInt64(LastMessageTime.Last()));
        }
Beispiel #18
0
        public static List <String> Avatars()
        //создает лист аватарами
        {
            List <string> Avatars = new List <string>();

            try
            {
                DataTable dt = new DataTable();
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT  * FROM Contact";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var type = dt.Columns["DownloadID"];
                foreach (DataRow dr in dt.Rows)
                {
                    Avatars.Add(dr[type].ToString());
                }

                connection.Close();
            }
            catch { }
            Avatars.RemoveAt(0);
            return(Avatars);
        }
Beispiel #19
0
        public static List <String> Number()
        {
            List <string> IDs = new List <string>();

            try
            {
                factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                connection = (SQLiteConnection)factory.CreateConnection();

                connection.ConnectionString = "Data Source = " + path_config;
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                command.CommandText = @"SELECT  * FROM Accounts";
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                sql.SelectCommand = command;
                sql.Fill(dt);

                bs.DataSource = dt;
                var ID = dt.Columns["ID"];

                foreach (DataRow dr in dt.Rows)
                {
                    IDs.Add(dr[ID].ToString());
                }

                connection.Close();
            }
            catch { }
            return(IDs);
        }
        public void SQLConnect(string baseName, out string exept)
        {
            //string baseName = "CompanyWorkers.db3";
            try
            {
                SQLiteConnection.CreateFile(baseName);
                SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                exept = "\nCreate db file corect\n";
                try
                {
                    connection = (SQLiteConnection)factory.CreateConnection();

                    connection.ConnectionString = "Data Source = " + baseName;
                    connection.Open();

                    command = new SQLiteCommand(connection);

                    exept = "\nConect to db corect\n";
                }
                catch (Exception ex2)
                {
                    exept = "\n" + ex2.Message + "\n";
                }
            }
            catch (Exception ex1)
            {
                exept = "\n" + ex1.Message + "\n";
            }
        }
Beispiel #21
0
        public Database()
        {
            // Initialize SQLite.
            SQLiteConnection.CreateFile(DbName);

            // Create connection factory.
            _connectionFactory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
        }
Beispiel #22
0
        void OpenConnection()
        {
            if (factory != null || connection != null)
            {
                return;
            }

            factory    = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
            connection = (SQLiteConnection)factory.CreateConnection();
            connection.ConnectionString = "Data Source = " + DB_PATH;
            connection.Open();
        }
Beispiel #23
0
 internal static void ExecuteNonQuery(string command, DbConnection conn, SQLiteFactory factory, DbTransaction trans)
 {
     using (DbDataAdapter adpt = factory.CreateDataAdapter())
     {
         using (DbCommand cmd = conn.CreateCommand())
         {
             cmd.Transaction = trans;
             cmd.CommandText = command;
             cmd.ExecuteNonQuery();
         }
     }
 }
Beispiel #24
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try {
                SQLiteConnection.CreateFile(dbName);

                SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
                //using(SQLiteFactory factory = (SQLiteFactory) DbProviderFactories.GetFactory("System.Data.SQLite")) {
                using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection()) {
                    connection.ConnectionString = $"Data Source = {dbName}";
                    connection.Open();

                    using (SQLiteCommand command = new SQLiteCommand(connection)) {
                        command.CommandText = @"CREATE TABLE Students (
								Id integer PRIMARY KEY AUTOINCREMENT,
								FirstName NVARCHAR(32) NOT NULL,
								SecondName NVARCHAR(32) NOT NULL,
								Course tinyint NOT NULL
							);"                            ;
                        command.CommandType = CommandType.Text;
                        command.ExecuteNonQuery();

                        command.CommandText = @"INSERT INTO Students
								(FirstName, SecondName, Course)
								VALUES
								('Dude1', 'Moonlighter', 1),
								('Dude2', 'Grayrat', 1),
								('Dude3', 'Whitehourse', 1),
								('Dude4', 'Nightmarehouse', 2),
								('Dude5', 'Redsocks', 2)
							"                            ;
                        command.ExecuteNonQuery();

                        command.CommandText = @"INSERT INTO Student
								(FirstName, SecondName, Course)
								VALUES
								('Dude1', 'Moonlighter', 1),
								('Dude2', 'Grayrat', 1),
								('Dude3', 'Whitehourse', 1),
								('Dude4', 'Nightmarehouse', 2),
								('Dude5', 'Redsocks', 2)
							"                            ;
                    }
                }
                //}
            }
            catch (Exception ex) {
                MessageBox.Show(this, ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }

            CreateBtn.IsEnabled = false;
            LinkBtn.IsEnabled   = true;
        }
Beispiel #25
0
        static public List <FullRow> ReadSQLite(SQLiteFactory factory)
        {
            List <FullRow> result   = new List <FullRow>();
            string         baseName = "inputdatabase.db3";

            using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection())
            {
                connection.ConnectionString = "Data Source = " + baseName;
                connection.Open();
                try
                {
                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        command.CommandText =
                            "select name_model, number_airplane, code_seat, id_seat, " +
                            "code_airport_in, city_airport_in, country_airport_in, " +
                            "code_airport_out, city_airport_out, country_airport_out, " +
                            "number_flight, date_time_flight, number_passenger from [all];";
                        command.CommandType = CommandType.Text;
                        using (SQLiteDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                FullRow info = new FullRow(
                                    reader.GetString(reader.GetOrdinal("name_model")),
                                    reader.GetInt64(reader.GetOrdinal("number_airplane")),
                                    reader.GetString(reader.GetOrdinal("code_seat")),
                                    reader.GetInt64(reader.GetOrdinal("id_seat")),
                                    reader.GetString(reader.GetOrdinal("code_airport_in")),
                                    reader.GetString(reader.GetOrdinal("city_airport_in")),
                                    reader.GetString(reader.GetOrdinal("country_airport_in")),
                                    reader.GetString(reader.GetOrdinal("code_airport_out")),
                                    reader.GetString(reader.GetOrdinal("city_airport_out")),
                                    reader.GetString(reader.GetOrdinal("country_airport_out")),
                                    reader.GetInt64(reader.GetOrdinal("number_flight")),
                                    reader.GetString(reader.GetOrdinal("date_time_flight")),
                                    reader.GetInt64(reader.GetOrdinal("number_passenger")));
                                result.Add(info);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Ошибка при чтении SQLite: " + e.Message);
                }
                connection.Close();
            }
            return(result);
        }
Beispiel #26
0
 /// <summary>
 /// 创建华为备份文件实例
 /// </summary>
 /// <param name="path"></param>
 /// <param name="error"></param>
 /// <returns></returns>
 public static HbFile Create(string path, Action <ErrorResult> error)
 {
     try
     {
         var context = SQLiteFactory.NewContext(path);
         var file    = new HbFile(context, error);
         return(file);
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }
Beispiel #27
0
        private void button1_Click(object sender, EventArgs e)
        {
            SQLiteFactory    factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");
            SQLiteConnection conn    = new SQLiteConnection();

            conn.ConnectionString = @"Data Source = " + Data.baseName;

            try
            {
                conn.Open();
            }
            catch (SQLiteException se)
            {
                MessageBox.Show("Error: {0}", se.Message);
                return;
            }

            SQLiteCommand login = new SQLiteCommand("Select login, pass From Users", conn);

            using (SQLiteDataReader dr = login.ExecuteReader(CommandBehavior.CloseConnection))
            {
                string user     = "";
                string password = "";

                while (dr.Read())
                {
                    user     = dr.GetValue(0).ToString().Trim();
                    password = dr.GetValue(1).ToString().Trim();

                    if (p == 0)
                    {
                        if (textBox1.Text.ToString().Equals(user) && textBox2.Text.ToString().Equals(password))
                        {
                            main main = new main();
                            main.Show();
                            this.Hide();
                            p++;
                        }
                    }
                }

                if (p == 0)
                {
                    MessageBox.Show("Wrong login or password");
                }
            }

            conn.Close();
            conn.Dispose();
        }
        private void LoadLocalization()
        {
            string path = Environment.ExpandEnvironmentVariables(
                @"%USERPROFILE%\AppData\LocalLow\Dire Wolf Digital\The Elder Scrolls_ Legends\LocalizationDB.db");

            if (!File.Exists(path))
            {
                path = Environment.ExpandEnvironmentVariables(
                    @"%USERPROFILE%\AppData\LocalLow\Dire Wolf Digital\The Elder Scrolls_ Legends\LocalizationDB.Steam.db");
            }

            SQLiteFactory factory = (SQLiteFactory)DbProviderFactories.GetFactory("System.Data.SQLite");

            using (SQLiteConnection connection = (SQLiteConnection)factory.CreateConnection())
            {
                connection.ConnectionString = "Data Source = " + path;
                connection.Open();
                SQLiteCommand    command = new SQLiteCommand("SELECT * FROM Lookup WHERE \"key\" LIKE \"%-title\" OR \"key\" LIKE \"%-game_text\";", connection);
                SQLiteDataReader reader  = command.ExecuteReader();
                foreach (DbDataRecord record in reader)
                {
                    string id = record["key"].ToString();
                    if (id.Contains("-title"))
                    {
                        id = id.Replace("-title", "");
                        try{
                            Card c = FindCardById(Guid.Parse(id));
                            if (c != Card.Unknown)
                            {
                                c.Name = record["value"].ToString();
                            }
                        }
                        catch { }
                    }
                    else if (id.Contains("-game_text"))
                    {
                        id = id.Replace("-game_text", "");
                        try
                        {
                            Card c = FindCardById(Guid.Parse(id));
                            if (c != Card.Unknown)
                            {
                                c.Text = HtmlToPlainText(record["value"].ToString());
                            }
                        }
                        catch { }
                    }
                }
            }
        }
Beispiel #29
0
        private DatabaseManager()
        {
            this.db_last_msg = string.Empty;
            this.sql_conn    = new SQLiteConnection(sql_conn_str);
            this.sql_adapter = new SQLiteDataAdapter(sql_adapter_str, this.sql_conn);
            this.sql_adapter.ContinueUpdateOnError = true;             // Ignore errors on failed row update

            // Create SQLite command builder for data adapter
            SQLiteFactory        sql_factory = new SQLiteFactory();
            SQLiteCommandBuilder sql_builder = (SQLiteCommandBuilder)sql_factory.CreateCommandBuilder();

            sql_builder.SetAllValues = false;
            sql_builder.DataAdapter  = this.sql_adapter;

            this.sql_conn.Open();
        }
Beispiel #30
0
        protected override IDisposable Connect()
        {
            DbProviderFactory fact = new SQLiteFactory();
            SQLiteConnection  conn = (SQLiteConnection)fact.CreateConnection();

            if (conn != null)
            {
                var connectionStringBuilder =
                    SessionFactoryFactory.SQLiteConnectionStringBuilderFromFilePath(FilePath);
                connectionStringBuilder.Version = 3;

                conn.ConnectionString = connectionStringBuilder.ToString();
                conn.Open();
            }
            return(conn);
        }