private DictionaryAtom ExecuteProcedure(DictionaryAtom dbCommand)
        {
            Validation.IsNotNull(dbCommand, "dbCommand");

            var dbSchema      = dbCommand.GetString("schema");
            var dbCommandName = dbCommand.GetString("commandName");
            var proc          = GetProcedure(dbSchema, dbCommandName);

            if (proc == null)
            {
                throw new ObjectNotFoundException(string.Format(Resources.ERR_DB_PROC_NOT_FOUND, dbSchema, dbCommandName));
            }

            var dbParameterSet = dbCommand.GetAtom <DictionaryAtom>("parameters");

            var executor  = new ProcedureExecutor <SqlCommand>(_connection, _log, proc);
            var result    = executor.ExecuteQuery(dbParameterSet?.ToDictionary());
            var dataTable = result.Item2.CastAs <DataTable>();

            var resultSet = new DictionaryAtom();

            resultSet.Set("Results", dataTable.ToListAtom());
            resultSet.Set("Schema", dbSchema);
            resultSet.Set("CommandName", dbCommandName);

            dataTable.Dispose();
            return(resultSet);
        }
Exemple #2
0
        public void GetValueTest()
        {
            const string key   = "test";
            const int    value = 5000;

            var atom = new DictionaryAtom();

            atom.Set(key, value);

            var actual = atom.GetAtom <IntAtom>("test");

            actual.Should().NotBeNull();
            actual.Value.Should().Be(value);
        }
Exemple #3
0
        /// <summary>
        /// Do initialization that cannot be done at construction
        /// </summary>
        public void OnInit(DictionaryAtom args)
        {
            Validation.IsNotNull(args, "args");

            _connectionString = args.GetString("ConnectionString");
            Validation.IsNotNullOrEmpty(_connectionString, "_connectionString");

            _numberServers = args.GetInt("NumberDBServers");
            Validation.Validate <ArgumentOutOfRangeException>(_numberServers >= 1);
            _log.DebugFormat("{0} asked to spin up {1} database servers.", GetType(), _numberServers);

            InitDatabaseLoaders(args);
            _loaderArgs = args.GetAtom <ListAtom>("Loaders");

            _eventManager.RegisterListener(this, typeof(OnGameInitialize), Instance_OnGameInitialize);
        }
Exemple #4
0
        public void SetListAtom()
        {
            var listAtom = new ListAtom {
                "1 2 3 4 5"
            };

            var atom = new DictionaryAtom();

            atom.Set("TestList", listAtom);

            atom.ContainsKey("TestList").Should().BeTrue();

            var foundAtom = atom.GetAtom <ListAtom>("TestList");

            foundAtom.Should().NotBeNull();
            foundAtom.Should().BeAssignableTo <ListAtom>();
            foundAtom.GetString(0).Should().Be("1 2 3 4 5");
        }
Exemple #5
0
        public void SetDictionaryAtom()
        {
            var setAtom = new DictionaryAtom();

            setAtom.Set("Test", "1 2 3 4 5");

            var atom = new DictionaryAtom();

            atom.Set("TestDictionary", setAtom);

            atom.ContainsKey("TestDictionary").Should().BeTrue();

            var foundAtom = atom.GetAtom <DictionaryAtom>("TestDictionary");

            foundAtom.Should().NotBeNull();
            foundAtom.Should().BeAssignableTo <DictionaryAtom>();
            foundAtom.ContainsKey("Test").Should().BeTrue();
        }