private void OpenDB()
        {
            SQLiteConnection SQLConnect = null;

            try
            {
                SQLConnect = new SQLiteConnection(ConfigurationManager.ConnectionStrings["ConnectStr"].ConnectionString.ToString());
                SQLConnect.Open();
                SQLiteCommand command = new SQLiteCommand("", SQLConnect);
                ObservableCollection <Models.File> Files = new ObservableCollection <Models.File>();
                command.CommandText = "SELECT * FROM Files";
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Files.Add(new Models.File()
                        {
                            FileName = reader["FileName"].ToString(), FileData = FileByteToData(reader["Data"])
                        });                                                                                                                  //сабстринг убирает инфо о фйле которое откудато считывется
                    }
                    LoadFromDB s = null;
                    Dispatcher.Invoke(new Action(() =>
                    {
                        s = new LoadFromDB(Files);
                        if (s.ShowDialog() == true)
                        {
                            Text.Text = Files.Where(x => x == s._picked_file).FirstOrDefault().FileData;
                        }
                    }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name + $" {this.GetType().Name}");
            }
            finally { SQLConnect.Close(); }
        }
예제 #2
0
 /// <summary>
 /// Crea una chiave per un oggetto in Cache con un metodo di caricamento
 /// </summary>
 /// <param name="value">Valore chiave</param>
 /// <param name="isInCache">Indica se l'oggetto sarà salvato in Cache</param>
 /// <param name="lfdbh">Metodo delegato per il caricamento dell'oggetto</param>
 private SessionKeys(string value, bool isInCache, LoadFromDB lfdbh)
 {
     Value             = value;
     IsInCache         = isInCache;
     LoadFromDBhandler = lfdbh;
 }