Exemplo n.º 1
0
        public void LoadPrimitives(ILocalStorageReceiver receiver)
        {
            IObjectSet result = db.Get(typeof(PrimData));

            OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is " + result.Count);
            foreach (PrimData prim in result)
            {
                receiver.PrimFromStorage(prim);
            }
        }
Exemplo n.º 2
0
        internal void Delete(string p)
        {
            MapClass map = new MapClass();

            map.PicUrl = p;
            IObjectSet result = db.Get(map);

            foreach (MapClass obj in result)
            {
                db.Delete(obj);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        private async Task <SshCommand> ExecuteWithTimeout(AsyncCodeActivityContext context, CancellationToken cancellationToken = default)
        {
            SshClient        sshClient;
            IObjectContainer scopeObjectContainer = context.DataContext.GetProperties()[SSHConnectScope.ParentContainerPropertyTag].GetValue(context.DataContext) as IObjectContainer;

            if (SSHClient.Expression == null)
            {
                if (scopeObjectContainer == null)
                {
                    throw new ArgumentException("SSHClient was not provided and cannot be retrieved from the container.");
                }

                sshClient = scopeObjectContainer.Get <SshClient>();
            }
            else
            {
                sshClient = SSHClient.Get(context);
            }

            var sshCommand = sshClient.CreateCommand(Command.Get(context));

            sshCommand.CommandTimeout = TimeSpan.FromMilliseconds(SSHTimeoutMS.Get(context));
            sshCommand.Execute();

            return(sshCommand);
        }
Exemplo n.º 6
0
        public ActorPC GetChar(uint charID)
        {
            ActorPC result = null;

            try
            {
                IObjectSet queryResult = db.Get(new ActorPC(charID, worldID));
                if (queryResult.Count > 0)
                {
                    result = (ActorPC)queryResult[0];
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error: can't get char from database");
                this.isconnected = false;
                throw new Exception("can't get char from database");
            }
            finally
            {
            }
            if (result.Weapons == null)
            {
                Weapon newweapon = new Weapon();
                result.Weapons        = new List <Weapon>();
                newweapon.name        = result.weaponName;
                newweapon.level       = 1;
                newweapon.type        = (ushort)result.weaponType;
                newweapon.augeSkillID = 150001;
                newweapon.U1          = 1;
                newweapon.exp         = 0;
                newweapon.durability  = 1000;
                newweapon.active      = 1;
                result.Weapons.Add(newweapon);
            }
            if (result.ShorcutIDs == null)
            {
                result.ShorcutIDs = new Dictionary <byte, ActorPC.Shortcut>();
            }

            return(result);
        }
Exemplo n.º 7
0
        public override object Resolve(CreationContext context, IReleasePolicy releasePolicy)
        {
            var result = _container.Get(_perWebRequestObjectId);

            if (result == null)
            {
                result = base.Resolve(context, releasePolicy);
                _container.Set(_perWebRequestObjectId, result);
            }
            return(result);
        }
Exemplo n.º 8
0
        private async Task <string> ExecuteWithTimeout(AsyncCodeActivityContext context, CancellationToken cancellationToken = default)
        {
            ShellStream      shellStream;
            Regex            expectedShellPromptRegex;
            IObjectContainer scopeObjectContainer = context.DataContext.GetProperties()[SSHConnectScope.ParentContainerPropertyTag]
                                                    .GetValue(context.DataContext) as IObjectContainer;

            if (ShellStream.Expression == null)
            {
                if (scopeObjectContainer == null)
                {
                    throw new ArgumentException("ShellStream was not provided and cannot be retrieved from the container.");
                }

                shellStream = scopeObjectContainer.Get <ShellStream>();
            }
            else
            {
                shellStream = ShellStream.Get(context);
            }

            if (ShellExpectedPrompt.Expression == null)
            {
                if (scopeObjectContainer == null)
                {
                    throw new ArgumentException("Shell Expected Prompt was not provided and cannot be retrieved from the container.");
                }

                expectedShellPromptRegex = scopeObjectContainer.Get <Regex>();
            }
            else
            {
                expectedShellPromptRegex = new Regex(ShellExpectedPrompt.Get(context), RegexOptions.Compiled);
            }

            return(SSHHelpers.Execute(shellStream,
                                      expectedShellPromptRegex,
                                      Command.Get(context),
                                      TimeSpan.FromMilliseconds(SSHTimeoutMS.Get(context)),
                                      CheckExitCode.Get(context)));
        }
Exemplo n.º 9
0
        public static ILoggerFactory GetLoggerFactory()
        {
            lock (LockObject)
            {
                var factory = Container.Get(DefaultLogFactoryKey) as ILoggerFactory;

                if (factory == null)
                {
                    factory = new LoggerFactory();
                    Container.Set(DefaultLogFactoryKey, factory);
                }
                return(factory);
            }
        }
Exemplo n.º 10
0
        public User GetUser(User user)
        {
            User result = null;

            try
            {
                IObjectSet queryResult = db.Get(user);
                if (queryResult.Count > 0)
                {
                    result = (User)queryResult[0];
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error: can't get user from database");
                this.isconnected = false;
                throw new Exception("can't get user from database");
            }
            finally
            {
            }

            return(result);
        }
Exemplo n.º 11
0
        private void AgregoUsuarios(ref IObjectServer server)
        {
            string sMessage = "Error al accesar a ese Servidor/Archivo";

            try
            {
                IObjectContainer dbcliente = Db4oFactory.OpenFile(MiCliente.FileUsers);
                IObjectSet       objetitos = dbcliente.Get(new Usuario()); //todos los usuarios

                while (objetitos.HasNext())
                {
                    Usuario _miniUser = (Usuario)objetitos.Next();
                    server.GrantAccess(_miniUser.User, _miniUser.Password);
                }
                dbcliente.Close();
            }
            catch (Exception)
            {
                throw new Exception(sMessage);
            }
        }
Exemplo n.º 12
0
        public override void InitConfig()
        {
            try
            {
                db = Db4oFactory.OpenFile("openuser.yap");
                IObjectSet result = db.Get(typeof(DbUserConfig));
                if (result.Count == 1)
                {
                    m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Found a UserConfig object in the local database, loading");
                    foreach (DbUserConfig cfg in result)
                    {
                        this.GridServerURL     = cfg.GridServerURL;
                        this.GridSendKey       = cfg.GridSendKey;
                        this.GridRecvKey       = cfg.GridRecvKey;
                        this.DefaultStartupMsg = cfg.DefaultStartupMsg;
                    }
                }
                else
                {
                    m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
                    LoadDefaults();
                    m_log.Info("[DBUSERCONFIG]: Writing out default settings to local database");
                    db.Set(this);
                    db.Close();
                }
            }
            catch (Exception e)
            {
                m_log.Warn("DbUserConfig.cs:InitConfig() - Exception occured");
                m_log.Warn(e.ToString());
            }

            m_log.Info("[DBUSERCONFIG]: User settings loaded:");
            m_log.Info("[DBUSERCONFIG]: Default startup message: " + this.DefaultStartupMsg);
            m_log.Info("[DBUSERCONFIG]: Grid server URL: " + this.GridServerURL);
            m_log.Info("[DBUSERCONFIG]: Key to send to grid: " + this.GridSendKey);
            m_log.Info("[DBUSERCONFIG]: Key to expect from grid: " + this.GridRecvKey);
        }
Exemplo n.º 13
0
        public override void InitConfig()
        {
            try
            {
                db = Db4oFactory.OpenFile("openuser.yap");
                IObjectSet result = db.Get(typeof(DbUserConfig));
                if (result.Count == 1)
                {
                    m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Found a UserConfig object in the local database, loading");
                    foreach (DbUserConfig cfg in result)
                    {
                        this.GridServerURL=cfg.GridServerURL;
                        this.GridSendKey=cfg.GridSendKey;
                        this.GridRecvKey=cfg.GridRecvKey;
                        this.DefaultStartupMsg=cfg.DefaultStartupMsg;
                    }
                }
                else
                {
                    m_log.Info("[DBUSERCONFIG]: DbUserConfig.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
                    LoadDefaults();
                    m_log.Info("[DBUSERCONFIG]: Writing out default settings to local database");
                    db.Set(this);
                    db.Close();
                }
            }
            catch(Exception e)
            {
                m_log.Warn("DbUserConfig.cs:InitConfig() - Exception occured");
                m_log.Warn(e.ToString());
            }

            m_log.Info("[DBUSERCONFIG]: User settings loaded:");
            m_log.Info("[DBUSERCONFIG]: Default startup message: " + this.DefaultStartupMsg);
            m_log.Info("[DBUSERCONFIG]: Grid server URL: " + this.GridServerURL);
            m_log.Info("[DBUSERCONFIG]: Key to send to grid: " + this.GridSendKey);
            m_log.Info("[DBUSERCONFIG]: Key to expect from grid: " + this.GridRecvKey);
        }
Exemplo n.º 14
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);
            }
        }
Exemplo n.º 15
0
 public IExtensionPort <TContract> GetExtensionPort <TContract>()
 {
     return(_container.Get <IExtensionPort <TContract> >());
 }
 public override object DoGet(string key)
 {
     return(_container.Get(key));
 }
Exemplo n.º 17
0
 public IObjectSet Get(object template)
 {
     return(container.Get(template));
 }