public MainWindow() : base(Gtk.WindowType.Toplevel)
        {
            Build();

            cliente          = new Cliente();
            cliente.File     = "file.yap";
            cliente.Port     = "1234";
            cliente.User     = "******";
            cliente.Server   = "localhost";
            cliente.Password = "******";

            if (servidor == null)
            {
                servidor = new RunServer(cliente);
            }
            //para saner si tiene acceso o no a la bd.
            servidor.SinAcceso += Excepcion;

            //
            Offline();
            string sSeparador = "/"; //Path.DirectorySeparatorChar;

            _InstancesFile = Utility.RutaSinNombreArchivo(System.Reflection.Assembly.GetExecutingAssembly().Location) + sSeparador + "InstancesFile.yap";
            _UsersFile     = Utility.RutaSinNombreArchivo(System.Reflection.Assembly.GetExecutingAssembly().Location) + sSeparador + "users.yap";
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        private void GetAllInstances()
        {
            try
            {
                IObjectContainer dbcliente = Db4oFactory.OpenFile(_InstancesFile);
                IObjectSet       objetitos = dbcliente.Get(new Instancia());
                //treeFiles.Nodes.Clear();
                while (objetitos.HasNext())
                {
                    Instancia _miniInstancia = (Instancia)objetitos.Next();
                    TreeNode  Nodo           = new TreeNode();
                    Nodo.Text = NombreArchivo(_miniInstancia.File);
                    RunServer _tempServer = new RunServer(_miniInstancia);

                    if (_tempServer.IsRunning())
                    {
                        Nodo.ImageIndex         = 1;
                        Nodo.SelectedImageIndex = 1;
                    }
                    else
                    {
                        Nodo.ImageIndex         = 0;
                        Nodo.SelectedImageIndex = 0;
                    }
                    Nodo.ContextMenu = MenuContextual();
                    treeFiles.Nodes[0].Nodes.Add(Nodo);
                }
                treeFiles.Nodes[0].Expand();
                dbcliente.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #4
0
        public static void Main()
        {
            var server = new RunServer();

            Task.Factory.StartNew(server.Run);

            var client = new RunClient();

            Task.Factory.StartNew(client.Run);

            WriteLine("Press any [Enter] to close the host.");
            ReadLine();
        }
Beispiel #5
0
        public frmPrincipal()
        {
            InitializeComponent();

            cliente = new Cliente();

            if (servidor == null)
            {
                servidor = new RunServer(cliente);
            }
            //para saner si tiene acceso o no a la bd.
            servidor.SinAcceso += Excepcion;
        }
Beispiel #6
0
        public static void BeginAllInstances()
        {
            try
            {
                IObjectContainer dbcliente = Db4oFactory.OpenFile(_InstancesFile);
                IObjectSet       objetitos = dbcliente.Get(new Instancia());//obtengo tooodos los objetos

                while (objetitos.HasNext())
                {
                    Instancia _miniInstancia = (Instancia)objetitos.Next();
                    if (_miniInstancia.AutoInit)
                    {
                        RunServer _tempServer = new RunServer(_miniInstancia);
                        _tempServer.Run();
                    }
                }
                objetitos = null;
                dbcliente.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #7
0
        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();
             * }*/
        }