private void mnuDelete_Click(object sender, EventArgs e) { try { IObjectContainer dbcliente = Db4oFactory.OpenFile(_InstancesFile); IList <Instancia> instancias = dbcliente.Query <Instancia>(delegate(Instancia instancia) { return(NombreArchivo(instancia.File) == treeFiles.SelectedNode.Text); }); foreach (Instancia Ins in instancias) { RunServer _tempServer = new RunServer(Ins); if (_tempServer.IsRunning()) { _tempServer.Stop(); } foreach (TreeNode nodo in treeFiles.Nodes[0].Nodes) { if (nodo.Text == NombreArchivo(Ins.File)) { nodo.Remove(); } } dbcliente.Delete(Ins); } dbcliente.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void StopServer() { try { servidor.Stop(); Offline(); } catch (Exception ex) { Message(ex.Message); } }
public void StopServer() { try { if (servidor.Stop()) { Offline(); } else { MessageBox.Show(sStopError); } } /*catch (DatabaseClosedException ex) * { * MessageBox.Show("La base de datos ya esta detenida"); * }*/ catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AgregoInstancia() { try { if (!bEdit) {//es una bonita alta IObjectContainer dbcliente = Db4oFactory.OpenFile(_InstancesFile); Instancia _tmpInstancia = new Instancia(); _tmpInstancia.File = txtFile.Text; _tmpInstancia.AutoInit = chkStart.Checked; _tmpInstancia.Password = txtPassword.Text; _tmpInstancia.Port = txtPort.Text; _tmpInstancia.Server = txtServer.Text; _tmpInstancia.User = txtUser.Text; _tmpInstancia.FileUsers = _UsersFile; dbcliente.Set(_tmpInstancia); dbcliente.Commit(); dbcliente.Close(); } else {//es un bonito edit if (instanciasEdit != null && sOldFile.Trim().Length > 0) { foreach (Instancia Ins in instanciasEdit) { RunServer _tempServer = new RunServer(Ins); if (_tempServer.IsRunning())//detengo el servicio { _tempServer.Stop(); } Ins.File = txtFile.Text.Trim(); Ins.Password = txtPassword.Text; Ins.User = txtUser.Text.Trim(); Ins.Port = txtPort.Text.Trim(); Ins.Server = txtServer.Text.Trim(); Ins.AutoInit = chkStart.Checked; if (Ins.FileUsers == null) { Ins.FileUsers = _UsersFile; } dbclienteEdit.Set(Ins); foreach (TreeNode nodo in treeFiles.Nodes[0].Nodes) { if (nodo.Text == NombreArchivo(sOldFile)) { nodo.Remove(); nodo.Text = NombreArchivo(Ins.File); } } } dbclienteEdit.Commit(); dbclienteEdit.Close(); ClearEdit(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } /*finally * { * dbclienteEdit.Close(); * }*/ }