public frmEnviarChaveRSAEmail(Usuario usuarioLogado, string chaveExportar, string tipoChave, string caminhoArquivo, bool DarkTheme) { InitializeComponent(); banco = Db4oFactory.OpenFile(caminhoBanco); usuario = usuarioLogado; this.chaveExportar = chaveExportar; this.tipoChave = tipoChave; this.caminhoArquivo = caminhoArquivo; if (caminhoArquivo.Equals("")) { cboxSalvarNovamente.Checked = true; cboxSalvarNovamente.Hide(); } if (DarkTheme) { this.BackColor = SystemColors.ControlDarkDark; //TextBoxes temaEscuro.darkTextBox(txtAssunto, true); temaEscuro.darkTextBox(txtDestinatario, true); temaEscuro.darkTextBox(txtEmail, true); temaEscuro.darkTextBox(txtMensagem, true); temaEscuro.darkTextBox(txtSenha, true); //ComboBox temaEscuro.darkComboBox(cboxMetodoEnvio); this.DarkTheme = true; } }
public virtual void Configure() { var config = Db4oFactory.Configure(); config.AllowVersionUpdates(true); ConfigureForTest(config); }
public virtual void CreateDatabaseFor(string versionName) { _db4oVersion = versionName; var config = Db4oFactory.Configure(); try { ConfigureForStore(config); } catch { } // Some old database engines may throw NoSuchMethodError // for configuration methods they don't know yet. Ignore, // but tell the implementor: // System.out.println("Exception in configureForStore for " + versionName + " in " + getClass().getName()); try { CreateDatabase(FileName(versionName)); } finally { DeconfigureForStore(config); } }
public override void Initialize(string name, NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (String.IsNullOrEmpty(name)) { name = PROVIDER_NAME; } if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "db4o ASP.NET Role provider"); } base.Initialize(name, config); applicationName = Utils.DefaultIfBlank(config["applicationName"], HostingEnvironment.ApplicationVirtualPath); connectionString = ConnectionStringStore.GetConnectionString(config["connectionStringName"]); if (connectionString == null) { throw new ProviderException("Connection string cannot be blank."); } Db4oFactory.Configure().ObjectClass(new Role("", "")).CascadeOnUpdate(true); Db4oFactory.Configure().ObjectClass(new EnrolledUser("", "")).CascadeOnUpdate(true); }
/// <exception cref="System.IO.IOException"></exception> private void RunDefrag(string testFileName) { var config = Db4oFactory.NewConfiguration(); config.AllowVersionUpdates(true); ConfigureForTest(config); var oc = Db4oFactory.OpenFile(config, testFileName); oc.Close(); var backupFileName = Path.GetTempFileName(); try { var defragConfig = new DefragmentConfig(testFileName, backupFileName ); defragConfig.ForceBackupDelete(true); ConfigureForTest(defragConfig.Db4oConfig()); defragConfig.ReadOnly(!DefragmentInReadWriteMode()); Db4o.Defragment.Defragment.Defrag(defragConfig); } finally { File4.Delete(backupFileName); } }
private void BtnAGREGAR_Click(object sender, EventArgs e) { if (TxtTitulo.Text != string.Empty && TxtTitulo.Text != string.Empty && TxtISBN.Text != string.Empty) { IObjectContainer BD = Db4oFactory.OpenFile(Util.NombreArchivo); Autor a = new Autor(""); Libro L = new Libro(""); L.Titulo = TxtTitulo.Text; a.Nombre = TxtAutor.Text; L.Autor = a; L.ISBN = int.Parse(TxtISBN.Text); try { BD.Store(L); BD.Commit(); } finally { BD.Close(); } MessageBox.Show("EXITO!!! Se Guardo"); TxtTitulo.Clear(); TxtISBN.Clear(); TxtAutor.Clear(); } else { MessageBox.Show("Hay campos Vacios"); } }
private IConfiguration CreateConfiguration() { var config = Db4oFactory.NewConfiguration(); Configure(config); return(config); }
private void btnUpdate_Click(object sender, EventArgs e) { DB = Db4oFactory.OpenFile("User Database.yap"); if (!isValidEmail(upEmailTXT.Text)) { MessageBox.Show("Please enter a valid email"); } else { IObjectSet result = DB.QueryByExample(new User() { Email = currentUser.Email, Age = currentUser.Age, Gender = currentUser.Gender, ID = currentUser.ID, Password = currentUser.Password }); User found = (User)result.Next(); found.Email = upEmailTXT.Text; found.Password = upPassTXT.Text; this.currentUser = found; DB.Store(found); DB.Close(); MessageBox.Show("Update Success"); } }
public db4oCharacterDB(string host, int port, string user, string pass) { this.host = host; this.port = port; this.dbuser = user; this.dbpass = pass; this.isconnected = false; Db4oFactory.Configure().GenerateVersionNumbers(System.Int32.MaxValue); Db4oFactory.Configure().GenerateUUIDs(System.Int32.MaxValue); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorPC)).CascadeOnActivate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorPC)).CascadeOnUpdate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorPC)).CascadeOnDelete(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorPC)).StoreTransientFields(false); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorNPC)).CascadeOnActivate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorNPC)).CascadeOnUpdate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorNPC)).CascadeOnDelete(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Actors.ActorNPC)).StoreTransientFields(false); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Items.Inventory)).CascadeOnActivate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Items.Inventory)).CascadeOnUpdate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Items.Inventory)).CascadeOnDelete(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Items.Item)).CascadeOnActivate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Items.Item)).CascadeOnUpdate(true); Db4oFactory.Configure().ObjectClass(typeof(SagaDB.Items.Item)).CascadeOnDelete(true); }
public virtual void Run(string filename) { if (new File(filename).Exists()) { IObjectContainer con = null; try { var config = Db4oFactory.NewConfiguration(); config.MessageLevel(-1); con = Db4oFactory.OpenFile(config, filename); PrintHeader("STATISTICS"); Runtime.Out.WriteLine("File: " + filename); PrintStats(con, filename); con.Close(); } catch (Exception e) { Runtime.Out.WriteLine("Statistics failed for file: '" + filename + "'"); Runtime.Out.WriteLine(e.Message); Runtime.PrintStackTrace(e); } } else { Runtime.Out.WriteLine("File not found: '" + filename + "'"); } }
// It is also regression test for COR-634. /// <exception cref="System.Exception"></exception> public virtual void Test() { if (WorkspaceServices.WorkspaceRoot == null) { Runtime.Err.WriteLine("Build environment not available. Skipping test case..." ); return; } if (!File.Exists(SourceFile())) { Runtime.Err.WriteLine("Test source file " + SourceFile() + " not available. Skipping test case..." ); return; } var oldDatabaseFilePath = OldDatabaseFilePath(); Assert.Expect(typeof(OldFormatException), new _ICodeBlock_43(this, oldDatabaseFilePath )); IObjectContainer container = null; try { container = Db4oFactory.OpenFile(NewConfiguration(true), oldDatabaseFilePath); } finally { if (container != null) { container.Close(); } } }
internal static IConfiguration NewInMemoryConfiguration() { IConfiguration config = Db4oFactory.NewConfiguration(); config.Storage = new MemoryStorage(); return(config); }
private static TimeSpan Benchmark(IConfiguration configuration) { const string fname = "default.db4o"; System.IO.File.Delete(fname); using (IObjectContainer container = Db4oFactory.OpenFile(configuration, fname)) { DateTime start = DateTime.Now; const int objects = 5000; for (int i = 0; i < objects; ++i) { container.Set(new Item("Item " + i, i)); } const int queries = objects / 10; for (int i = 0; i < queries; ++i) { container.Ext().Purge(); foreach (Item item in container.Query <Item>()) { item.ToString(); } } return(DateTime.Now - start); } }
private static IConfiguration NewConfiguration() { IConfiguration config = Db4oFactory.NewConfiguration(); config.Io(new MemoryIoAdapter()); return(config); }
protected virtual IConfiguration MemoryIoConfiguration() { IConfiguration config = Db4oFactory.NewConfiguration(); config.Storage = new MemoryStorage(); return(config); }
private void button2_Click(object sender, EventArgs e) { DB = Db4oFactory.OpenFile("dbConcessionaria.yap"); string parametro = maskedTextBox1.Text; try { IList <classeFuncionario> resultFuncionario = DB.Query <classeFuncionario>(P => P.cpfFuncionario == parametro); foreach (classeFuncionario item in resultFuncionario) { DB.Delete(item); MessageBox.Show("Fornecedor removido com sucesso!"); } } catch (Exception ex) { MessageBox.Show("Fornecedor não encontrado!"); } finally { DB.Close(); exibir(); limpar(); } }
public object Run() { IConfiguration config = Db4oFactory.NewConfiguration(); config.Freespace().UseRamSystem(); return(config); }
/// <exception cref="System.IO.IOException"></exception> public DefragmentServicesImpl(DefragmentConfig defragConfig, IDefragmentListener listener) { _listener = listener; Config4Impl originalConfig = (Config4Impl)defragConfig.Db4oConfig(); IStorage storage = defragConfig.BackupStorage(); if (defragConfig.ReadOnly()) { storage = new NonFlushingStorage(storage); } Config4Impl sourceConfig = PrepareConfig(originalConfig, storage, defragConfig.ReadOnly ()); _sourceDb = (LocalObjectContainer)Db4oFactory.OpenFile(sourceConfig, defragConfig .TempPath()).Ext(); _sourceDb.ShowInternalClasses(true); defragConfig.Db4oConfig().BlockSize(_sourceDb.BlockSize()); if (!originalConfig.GenerateCommitTimestamps().DefiniteNo()) { defragConfig.Db4oConfig().GenerateCommitTimestamps(_sourceDb.Config().GenerateCommitTimestamps ().DefiniteYes()); } _targetDb = FreshTargetFile(defragConfig); _mapping = defragConfig.Mapping(); _mapping.Open(); _defragConfig = defragConfig; }
private void BtnEliminar_Click(object sender, EventArgs e) { if (TxtTitulo.Text != string.Empty) { IObjectContainer BD = Db4oFactory.OpenFile(Util.NombreArchivo); string nom = TxtTitulo.Text; try { IList <Libro> consulta = BD.Query <Libro>(z => z.Titulo == nom); foreach (Libro item in consulta) { BD.Delete(item); MessageBox.Show("Registro eliminado"); TxtTitulo.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); MessageBox.Show("No hay registros que coincidan"); } finally { BD.Close(); } } else { MessageBox.Show("Inserta la clave"); } }
public frmCodigoMorse(Usuario usuarioLogado, bool DarkTheme) { InitializeComponent(); cbxModo.SelectedIndex = 0; usuario = usuarioLogado; if (DarkTheme) { this.BackColor = SystemColors.ControlDarkDark; temaEscuro.darkRichTextBox(rtbxCripto); temaEscuro.darkRichTextBox(rtbxTPuro); temaEscuro.darkComboBox(cbxModo); this.DarkTheme = true; } try { banco.Close(); } catch { } finally { banco = Db4oFactory.OpenFile(caminhoBanco); } }
public static IList <Rooms> GetFreeRooms() { IObjectContainer db = Db4oFactory.OpenFile("C:\baza"); var FreeRooms = db.Query <Rooms>(x => x.Booked == false); return(FreeRooms); }
public virtual IList <T> GetByProperty(string propertyName, object value) { Type tipo = typeof(T); var instance = Activator.CreateInstance(tipo); var properties = tipo.GetProperties(); //var instanceQuery = (T)defineInstanciaGuid(guid, tipo, propertyName); foreach (PropertyInfo property in properties) { if (property.Name.Equals(propertyName)) { property.SetValue(instance, value, null); } } IObjectContainer db = Db4oFactory.OpenFile(nomeBanco); try { IObjectSet result = db.QueryByExample(instance); return(result.Cast <T>().ToList()); } finally { db.Close(); } }
private IObjectContainer OpenJavaDataFile() { IConfiguration configuration = Db4oFactory.NewConfiguration(); ConfigureAliases(configuration); return(Db4oFactory.OpenFile(configuration, GetJavaDataFile())); }
public virtual void TestReadAsKeyIsolation() { Config4Impl config1 = (Config4Impl)Db4oFactory.NewConfiguration(); Config4Impl config2 = (Config4Impl)Db4oFactory.NewConfiguration(); Assert.AreNotSame(config1.ReadAs(), config2.ReadAs()); }
private void WithDatabase(string file, IFunction4 function) { Configure(); var objectContainer = Db4oFactory.OpenFile(file).Ext(); try { function.Apply(objectContainer); } finally { objectContainer.Close(); } var server = Db4oFactory.OpenServer(ClientServerFileName(file), -1); server.GrantAccess(Username, Password); objectContainer = Db4oFactory.OpenClient("localhost", server.Ext().Port(), Username , Password).Ext(); try { function.Apply(objectContainer); } finally { objectContainer.Close(); server.Close(); } }
/// <exception cref="System.IO.IOException"></exception> public virtual void Test() { string originalFilePath = OriginalFilePath(); string dbFilePath = DbFilePath(); if (!System.IO.File.Exists(originalFilePath)) { TestPlatform.EmitWarning(originalFilePath + " does not exist. Can not run " + GetType ().FullName); return; } File4.Copy(originalFilePath, dbFilePath); Db4oFactory.Configure().AllowVersionUpdates(true); Db4oFactory.Configure().ExceptionsOnNotStorable(false); IObjectContainer oc = Db4oFactory.OpenFile(dbFilePath); try { Assert.IsNotNull(oc); } finally { oc.Close(); Db4oFactory.Configure().ExceptionsOnNotStorable(true); Db4oFactory.Configure().AllowVersionUpdates(false); } }
private void Deconfigure() { var config = Db4oFactory.Configure(); config.AllowVersionUpdates(false); DeconfigureForTest(config); }
private void InitDatabase() { #if DB4O_8_0 DatabaseConfiguration = Db4oEmbedded.NewConfiguration(); DatabaseConfiguration.Common.AllowVersionUpdates = true; DatabaseConfiguration.Common.ActivationDepth = 0; //DatabaseConfiguration.Common.Queries.EvaluationMode(QueryEvaluationMode.Lazy); DatabaseConfiguration.Common.WeakReferenceCollectionInterval = 60 * 1000; //DatabaseConfiguration.Common.Diagnostic.AddListener(new DiagnosticToConsole()); var msgConf = DatabaseConfiguration.Common.ObjectClass(typeof(MessageModel)); msgConf.CascadeOnActivate(true); msgConf.CascadeOnDelete(true); msgConf.Indexed(true); msgConf.ObjectField("f_TimeStamp").Indexed(true); #else DatabaseConfiguration = Db4oFactory.Configure(); DatabaseConfiguration.AllowVersionUpdates(true); DatabaseConfiguration.ObjectClass(typeof(MessageModel)). ObjectField("f_TimeStamp").Indexed(true); #endif try { OpenDatabase(); } catch (Exception ex) { #if LOG4NET Logger.Error("InitDatabase(): failed to open message " + "database: " + DatabaseFile, ex); #endif throw; } }
private AppHost() { LogManager.LogFactory = new Log4NetFactory(true); var factory = new FactoryProvider(FactoryUtils.ObjectFactory, LogManager.LogFactory); var providerManager = new Db4oFileProviderManager(Config.ConnectionString); var configDb4o = Db4oFactory.Configure(); configDb4o.ActivationDepth(5); configDb4o.UpdateDepth(5); configDb4o.OptimizeNativeQueries(true); factory.Register(providerManager); //Keep the manager from disposing providers it created factory.Register(providerManager.GetProvider()); // Create the ApplicationContext injected with the static service implementations ApplicationContext.SetInstanceContext(new ApplicationContext { Factory = factory, Cache = new MemoryCacheClient(), Resources = new ConfigurationResourceManager(), }); SetConfig(new EndpointHostConfig { ServiceName = Config.ServiceName, OperationsNamespace = Config.OperationNamespace, ServiceModelFinder = ServiceModelFinder.Instance, ServiceController = new ServiceController(new ServiceResolver()), }); }
public static void DeleteByObject(String nombreTesis) { try { db = Db4oFactory.OpenFile(NombreArchivo); Tesis oDelete = new Tesis(nombreTesis, null, null); IObjectSet result = db.QueryByExample(oDelete); if (result.Count != 0) { Tesis found = (Tesis)result.Next(); db.Delete(found); Console.WriteLine("Eliminación éxitosa"); RetrieveAll(db); } else { Console.WriteLine("No se encontro la tesis"); } db.Close(); } catch (Db4oException e) { Console.WriteLine("Se produjo el siguiente error" + e.Message); } }