private void btnCadastrar_Click(object sender, EventArgs e) { if (validarSMTP()) { Usuario usuario = new Usuario(); usuario.nome = tbxNome.Text; IObjectSet pesquisaSMTP = banco.QueryByExample(usuario); if (pesquisaSMTP.HasNext()) { usuario = (Usuario)pesquisaSMTP.Next(); try { ServidorSMTP smtp = new ServidorSMTP(); smtp.emailSMTP = txtEmailSMTP.Text; smtp.senhaSMTP = txtSenhaSMTP.Text; smtp.servidorSMTP = txtServidor.Text; smtp.portaSMTP = Convert.ToInt32(txtPorta.Text); smtp.SSL = cboxSSL.Checked; usuario.servidorSMTP = smtp; banco.Store(usuario); MessageBox.ShowMessageBoxOK("correct", "Servidor SMTP cadastrado com sucesso!", "Servidor cadastrado", DarkTheme); banco.Close(); banco = Db4oFactory.OpenFile(caminhoBanco); reiniciarSistema(); } catch (FormatException) { MessageBox.ShowMessageBoxOK("error", "A porta deve ser um número!", "Formato incorreto", DarkTheme); txtPorta.Focus(); return; } } } }
/// <summary> /// Retrieve all the projects from the database. This method don't return the /// the whole <see cref="LongoMatch.DB.Project"/> but the projects fields to /// create a <see cref="LongoMatch.DB.ProjectDescription"/> to make the seek /// faster. /// </summary> /// <returns> /// A <see cref="List"/> /// </returns> public List <ProjectDescription> GetAllProjects() { List <ProjectDescription> list = new List <ProjectDescription>(); IObjectContainer db = Db4oFactory.OpenFile(DBFile); Log.Debug("Getting all projects"); try { IQuery query = db.Query(); query.Constrain(typeof(ProjectDescription)); IObjectSet result = query.Execute(); Log.Debug(String.Format("Found {0} projects", result.Count)); while (result.HasNext()) { try { ProjectDescription desc = (ProjectDescription)result.Next(); list.Add(desc); } catch (Exception e) { Log.Warning("Error retreiving project. Skip"); Log.Exception(e); } } } catch (Exception ex) { Log.Exception(ex); } finally { CloseDB(db); } return(list); }
public CifraCesar(Usuario usuarioLogado, bool DarkTheme) { InitializeComponent(); tbxChave.Text = "0"; cbxModo.SelectedIndex = 0; rtbxTPuro.Focus(); usuario = usuarioLogado; if (DarkTheme) { this.BackColor = SystemColors.ControlDarkDark; temaEscuro.darkRichTextBox(rtbxTPuro); temaEscuro.darkRichTextBox(rtbxTextoCifrado); temaEscuro.darkComboBox(cbxModo); temaEscuro.darkTextBox(tbxChave, true); this.DarkTheme = true; } try { banco.Close(); } catch { } finally { banco = Db4oFactory.OpenFile(caminhoBanco); } }
private void btnGuardar_Click(object sender, EventArgs e) { IObjectContainer BD = Db4oFactory.OpenFile(Util.NombreArchivo); Estudiante pel = new Estudiante("", ""); pel.NoControl = TxtNumcontrol.Text; IList <Estudiante> resultados = BD.Query <Estudiante>(x => x.NoControl == TxtNumcontrol.Text); if (resultados.Count > 0) { // IObjectSet result = BD.QueryByExample(pel); Estudiante v = new Estudiante("", ""); v = resultados.First <Estudiante>(); //Estudiante v = new Estudiante("",""); v.NoControl = TxtNumcontrol.Text; v.Nombre = TxtNombre.Text; BD.Store(v); BD.Commit(); MessageBox.Show("Exito!!! Se Modifico"); TxtNumcontrol.Clear(); TxtNombre.Clear(); } else { MessageBox.Show("Error!!! No se Modifico"); } BD.Close(); TxtNumcontrol.Clear(); TxtNombre.Clear(); btnGuardar.Visible = false; BD.Close(); }
private void BtnAGREGAR_Click(object sender, EventArgs e) { if (TxtNumcontrol.Text != string.Empty && TxtNombre.Text != string.Empty) { IObjectContainer BD = Db4oFactory.OpenFile(Util.NombreArchivo); Estudiante E = new Estudiante("", ""); E.NoControl = TxtNumcontrol.Text; E.Nombre = TxtNombre.Text; try { BD.Store(E); BD.Commit(); } finally { BD.Close(); } MessageBox.Show("EXITO!!! Se Guardo"); TxtNumcontrol.Clear(); TxtNombre.Clear(); } else { MessageBox.Show("Hay campos Vacios"); } }
public static List <PersonModel> GetPersonSuccessors(PersonModel person) { List <PersonModel> personDescendants = new List <PersonModel>(); if (person.Children == null) { return(personDescendants); } else { foreach (var child in person.Children) { IObjectContainer db = Db4oFactory.OpenFile("person.data"); var childAsPersonModel = db.QueryByExample(new PersonModel(child)).Next() as PersonModel; db.Close(); if (childAsPersonModel.DeathDate == null) { personDescendants.Add(childAsPersonModel); } else { personDescendants.AddRange(GetPersonSuccessors(childAsPersonModel)); } } return(personDescendants); } }
// It is also regression test for COR-634. /// <exception cref="System.Exception"></exception> public virtual void Test() { if (WorkspaceServices.WorkspaceRoot == null) { Sharpen.Runtime.Err.WriteLine("Build environment not available. Skipping test case..." ); return; } if (!System.IO.File.Exists(SourceFile())) { Sharpen.Runtime.Err.WriteLine("Test source file " + SourceFile() + " not available. Skipping test case..." ); return; } string 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(); } } }
public static void saveData(SavedData data) { IObjectContainer db = Db4oFactory.OpenFile(staticClass.configFilePath); try { IList <SavedData> list = db.Query <SavedData>(delegate(SavedData cf) { return(data.name == cf.name); } ); if (list.Count <= 0) { db.Store(data); } else { list[0].copy(data); db.Store(list[0]); } } finally { db.Close(); } }
void PopulateTrackIDCombo() { IObjectContainer dbTrack = Db4oFactory.OpenFile(m_strTrackingDBFileName); try{ GPSTrackID trackID = new GPSTrackID(); trackID.CreateTrackID(); // need dummy track id IQuery query = dbTrack.Query(); query.Constrain(typeof(GPSTrackID)); query.Descend("m_dtCreationDate").OrderAscending(); IObjectSet result = query.Execute(); // should be one for each track... foreach (object item in result) { trackID = (GPSTrackID)item; this.cbTrackIds.Items.Add(trackID.GetTrackID()); } } catch (Exception ex) { LogException(ex, "PopulateTrackIDCombo"); } finally { dbTrack.Close(); } }
public static List <string> ListOfAncestors(string personName) { IObjectContainer db = Db4oFactory.OpenFile("person.data"); var person = db.QueryByExample(new PersonModel(personName)).Next() as PersonModel; db.Close(); List <string> personAncestors = new List <string>(); if (person.Father != null) { personAncestors.Add(person.Father); foreach (var ancestor in ListOfAncestors(person.Father)) { personAncestors.Add(ancestor); } } if (person.Mother != null) { personAncestors.Add(person.Mother); db.Close(); foreach (var ancestor in ListOfAncestors(person.Mother)) { personAncestors.Add(ancestor); } } return(personAncestors); }
public static List <SavedData> getAllSavedData() { List <SavedData> listR = new List <SavedData>(); IObjectContainer db = Db4oFactory.OpenFile(staticClass.configFilePath); try { IList <SavedData> list = db.Query <SavedData>(delegate(SavedData cf) { return(cf.name != string.Empty); } ); foreach (SavedData sd in list) { listR.Add(sd); } } finally { db.Close(); } return(listR); }
private void btnOk_Click(object sender, EventArgs e) { try { if (ValidoDatos()) { IObjectContainer dbcliente = Db4oFactory.OpenFile(MiCliente.FileUsers); Usuario user = new Usuario(); if (user.CreoUsuario(txtUser.Text, txtPassword.Text, lblServer.Text, lblFile.Text)) { dbcliente.Set(user); dbcliente.Commit(); } else { MessageBox.Show(sMessageError); } dbcliente.Close(); Clear(); } else { MessageBox.Show(sMessageData); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public virtual void Run(string filename) { if (new Sharpen.IO.File(filename).Exists()) { IObjectContainer con = null; try { IConfiguration config = Db4oFactory.NewConfiguration(); config.MessageLevel(-1); con = Db4oFactory.OpenFile(config, filename); PrintHeader("STATISTICS"); Sharpen.Runtime.Out.WriteLine("File: " + filename); PrintStats(con, filename); con.Close(); } catch (Exception e) { Sharpen.Runtime.Out.WriteLine("Statistics failed for file: '" + filename + "'"); Sharpen.Runtime.Out.WriteLine(e.Message); Sharpen.Runtime.PrintStackTrace(e); } } else { Sharpen.Runtime.Out.WriteLine("File not found: '" + filename + "'"); } }
private bool OpenTrackDB() { if (m_dbTrack == null) { m_dbTrack = Db4oFactory.OpenFile(m_strTrackDBName); } return(m_dbTrack != null); // // m_swOutputFile = File.AppendText(p_strTrackFileName); // // m_swOutputFile.WriteLine(""); // m_swOutputFile.WriteLine("H COORDINATE SYSTEM"); // m_swOutputFile.WriteLine("U LAT LON DEG"); // m_swOutputFile.WriteLine(""); // m_swOutputFile.WriteLine("H LATITUDE LONGITUDE DATE TIME ALT ;track"); // m_swOutputFile.Flush(); // accessDb4o // try // { // // do something with db4o // } // finally // { // db.Close(); // } }
//Initialize Shoe Database public void initShoeDB() { DB = Db4oFactory.OpenFile("Shoe Database.yap"); IList <ShoeClass> dtList = DB.Query <ShoeClass>(typeof(ShoeClass)); if (dtList.Count() <= 0) { ShoeClass AP = new ShoeClass() { ShoeID = "AP001", ShoeName = "Air Presto Off-White", Price = 1900 }; ShoeClass AJ = new ShoeClass() { ShoeID = "AJ001", ShoeName = "Air Jordan 1 Retro High Off-White Chicago", Price = 2000 }; ShoeClass NMD = new ShoeClass() { ShoeID = "NM001", ShoeName = "Adidas Human Race NMD Pharrell x Chanel Black", Price = 8000 }; DB.Store(NMD); DB.Store(AJ); DB.Store(AP); } DB.Close(); }
/// <summary> /// 加载数据库信息 /// </summary> private static void LoadingDbInfo() { DbSavePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "luowanliPhoto.yap"); bool IsFirsInit = false; if (!File.Exists(DbSavePath)) { IsFirsInit = true; } IObjectContainer db = Db4oFactory.OpenFile(DbSavePath); try { if (IsFirsInit) { RootAlbum rootalbum = new RootAlbum(); rootalbum.LastUpDateTime = DateTime.Now; db.Store(rootalbum);//初始化数据 } } finally { db.Close(); //关闭 } }
public frmEsqueciSenha(bool DarkTheme) { InitializeComponent(); cboxDarkTheme.Checked = DarkTheme; this.DarkTheme = DarkTheme; banco = Db4oFactory.OpenFile(caminhoBanco); }
public void cadastrar() { IObjectContainer db = Db4oFactory.OpenFile("E:\\Nova pasta\\Desenvolvimento\\Fontes\\dados.yap"); db.Store(this); db.Commit(); }
private bool ValidoUsuario() { bool bRetorno = false; try { if (MiCliente.FileUsers != null) { IObjectContainer dbcliente = Db4oFactory.OpenFile(MiCliente.FileUsers); IObjectSet objetitos = dbcliente.Get(new Usuario(MiCliente.User, MiCliente.Password, MiCliente.Server, MiCliente.File)); if (objetitos.Count > 0) { bRetorno = true; } dbcliente.Close(); } } catch (Exception) { //Publisher LanzarEvento = new Publisher(); pub.SinAcceso(); } return(bRetorno); }
public Esteganografia(Usuario usuarioLogado, bool DarkTheme) { InitializeComponent(); usuario = usuarioLogado; banco = Db4oFactory.OpenFile(caminhoBanco); if (DarkTheme) { this.DarkTheme = true; this.BackColor = SystemColors.ControlDarkDark; //DataGrids metodosDarkTheme.darkDataGrid(dgvAnexos); metodosDarkTheme.darkDataGrid(dgvArquivoFinal); metodosDarkTheme.darkDataGrid(dgvArquivoOriginal); metodosDarkTheme.darkDataGrid(dgvFileHide); //TextBoxes metodosDarkTheme.darkTextBox(txtArquivoOriginal, true); metodosDarkTheme.darkTextBox(txtAssunto, true); metodosDarkTheme.darkTextBox(txtCaminhoAnexo, true); metodosDarkTheme.darkTextBox(txtDestinatario, true); metodosDarkTheme.darkTextBox(txtDiretorioFinal, true); metodosDarkTheme.darkTextBox(txtEmail, true); metodosDarkTheme.darkTextBox(txtFileHide, true); metodosDarkTheme.darkTextBox(txtMensagem, true); metodosDarkTheme.darkTextBox(txtNomeArquivo, true); metodosDarkTheme.darkTextBox(txtSalvarArquivo, true); metodosDarkTheme.darkTextBox(txtSenha, true); //Botões metodosDarkTheme.darkButton(btnPasta); metodosDarkTheme.darkButton(btnFileHide); metodosDarkTheme.darkButton(btnArquivoOriginal); metodosDarkTheme.darkButton(btnSelecionarAnexo); cor = SystemColors.ScrollBar; } }
private void BtnActualizar_Click(object sender, EventArgs e) { if (TxtNumcontrol.Text != string.Empty) { IObjectContainer BD = Db4oFactory.OpenFile(Util.NombreArchivo); string Num = TxtNumcontrol.Text; Estudiante p = new Estudiante("", ""); p.NoControl = TxtNumcontrol.Text; IList <Estudiante> resultados = BD.Query <Estudiante>(a => a.NoControl == Num); if (resultados.Count > 0) { foreach (Estudiante a in resultados) { TxtNumcontrol.Text = a.NoControl; TxtNombre.Text = a.Nombre; btnGuardar.Visible = true; //btncancelm.Visible = true; } } else { MessageBox.Show("No Existe"); } //TxtClavep.Clear(); BD.Close(); } else { MessageBox.Show("Ingrese EL num CONTROL"); } }
/// <exception cref="System.IO.IOException"></exception> private void RunDefrag(string testFileName) { IConfiguration config = Db4oFactory.NewConfiguration(); config.AllowVersionUpdates(true); ConfigureForTest(config); IObjectContainer oc = Db4oFactory.OpenFile(config, testFileName); oc.Close(); string backupFileName = Path.GetTempFileName(); try { DefragmentConfig defragConfig = new DefragmentConfig(testFileName, backupFileName ); defragConfig.ForceBackupDelete(true); ConfigureForTest(defragConfig.Db4oConfig()); defragConfig.ReadOnly(!DefragmentInReadWriteMode()); Db4objects.Db4o.Defragment.Defragment.Defrag(defragConfig); } finally { File4.Delete(backupFileName); } }
private void BtnEliminar_Click(object sender, EventArgs e) { if (TxtNumcontrol.Text != string.Empty) { IObjectContainer BD = Db4oFactory.OpenFile(Util.NombreArchivo); string nom = TxtNumcontrol.Text; try { IList <Estudiante> consulta = BD.Query <Estudiante>(z => z.NoControl == nom); foreach (Estudiante item in consulta) { BD.Delete(item); MessageBox.Show("Registro eliminado"); TxtNumcontrol.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"); } }
private void WithDatabase(string file, IFunction4 function) { Configure(); IExtObjectContainer objectContainer = Db4oFactory.OpenFile(file).Ext(); try { function.Apply(objectContainer); } finally { objectContainer.Close(); } IObjectServer 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(); } }
public void ListObjects() { Dictionary <Type, int> dict = new Dictionary <Type, int>(); IObjectContainer db = Db4oFactory.OpenFile(DBFile); IQuery query = db.Query(); query.Constrain(typeof(object)); IObjectSet result = query.Execute(); while (result.HasNext()) { var res = result.Next(); Type type = res.GetType(); if (dict.ContainsKey(type)) { dict[type]++; } else { dict.Add(type, 1); } } foreach (Type t in dict.Keys) { Log.Information(t.ToString() + ":" + dict[t]); } CloseDB(db); }
private void Btn_add_Click(object sender, EventArgs e) { db = Db4oFactory.OpenFile("Nhanvien.yup"); NhanVien nhanVien = new NhanVien() { ID = Guid.NewGuid(), HoTen = txt_name.Text, Skill = txt_skill.Text, HomeBase = listcom.SelectedItem.ToString(), Luong = (double)num_salary.Value }; int employes = db.Query <NhanVien>(delegate(NhanVien employe1) { return(num_salary.Value < 300 || txt_name.Text.Length <= 0); }).Count; if (employes == 0) { db.Store(nhanVien); } else { MessageBox.Show("Nhập Không Hợp lệ"); } db.Close(); }
/// <summary> /// Updates a project in the database. Because a <see cref="LongoMatch.DB.Project"/> has /// many objects associated, a simple update would leave in the databse many orphaned objects. /// Therefore we need to delete the old project a replace it with the changed one. /// </summary> /// <param name="project"> /// A <see cref="Project"/> to update /// </param> /// <param name="previousFileName"> /// A <see cref="System.String"/> with the old file path /// </param> public void UpdateProject(Project project) { // Configure db4o to cascade on delete for each one of the objects stored in a Project SetDeleteCascadeOptions(); IObjectContainer db = Db4oFactory.OpenFile(DBFile); project.Description.LastModified = DateTime.Now; Log.Debug("Updating project " + project); try { IQuery query = GetQueryProjectById(db, project.UUID); IObjectSet result = query.Execute(); //Get the stored project and replace it with the new one if (result.Count == 1) { Project fd = (Project)result.Next(); db.Delete(fd); db.Store(project); db.Commit(); } else { Log.Warning("Project with ID " + project.UUID + "not found"); } } catch (Exception e) { Log.Error("Could not update project"); Log.Exception(e); } finally { CloseDB(db); } }
protected void Page_Load(object sender, EventArgs e) { Config path = new Config(); DB = Db4oFactory.OpenFile(path.addressOfDiscardedDocument); IList <Discarded_Document_model> discarded_Document = DB.Query <Discarded_Document_model>(); if (discarded_Document.Count > 0) { foreach (Discarded_Document_model dD1 in discarded_Document) { ListBox1.Items.Add("....................................................................................................................."); ListBox1.Items.Add("Document Name and Version: " + dD1.DocumentTitle + " v" + dD1.DocumentVersion); ListBox1.Items.Add("....................................................................................................................."); ListBox1.Items.Add(""); ListBox1.Items.Add("Reason of regecting document: " + dD1.ReasonToDiscard); ListBox1.Items.Add(""); ListBox1.Items.Add("Reviewer who discarded the document: " + dD1.NameOfReviever); ListBox1.Items.Add(""); } } else { ListBox1.Items.Add(""); ListBox1.Items.Add(""); ListBox1.Items.Add("There is no Item to display"); ListBox1.Items.Add(""); ListBox1.Items.Add(""); } ListBox1.Items.Add("--------------------------------------------------------------------END-------------------------------------------------------"); }
public static void saveConfig(SQLConnConfig config) { IObjectContainer db = Db4oFactory.OpenFile(SQLConnConfig.configFilePath); try { IList <SQLConnConfig> list = db.Query <SQLConnConfig>(delegate(SQLConnConfig cf) { return(cf.dbType == config.dbType); } ); if (list.Count <= 0) { db.Store(config); } else { SQLConnConfig.copy(config, list[0]); db.Store(list[0]); } } finally { db.Close(); } }
/// <exception cref="System.IO.IOException"></exception> public virtual void Test() { var originalFilePath = OriginalFilePath(); var dbFilePath = DbFilePath(); if (!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); var oc = Db4oFactory.OpenFile(dbFilePath); try { Assert.IsNotNull(oc); } finally { oc.Close(); Db4oFactory.Configure().ExceptionsOnNotStorable(true); Db4oFactory.Configure().AllowVersionUpdates(false); } }