Esempio n. 1
0
        public static void LoadTables(IObjectDatabase Database,string DatabaseName)
        {
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    if (type.IsClass != true)
                        continue;

                    try
                    {
                        DataTable[] attrib = (DataTable[])type.GetCustomAttributes(typeof(DataTable), true);
                        if (attrib.Length > 0 && attrib[0].DatabaseName == DatabaseName)
                        {
                            Log.Info("DBManager", "Registering table: " + type.FullName);
                            Database.RegisterDataObject(type);
                        }
                    }
                    catch(Exception e)
                    {
                        Log.Error("DBManager", "Can not load : " + e.ToString());
                    }
                }
            }
        }
Esempio n. 2
0
 public ImageFileViewModel(
     DataReference rawDataReference,
     IObjectDatabase <ShortId> shortIdDatabase,
     IDataApiClient dataApiClient)
 {
     ShortIdEditViewModel = new ShortIdEditViewModel(rawDataReference, shortIdDatabase, dataApiClient);
 }
 public void TestGetAll()
 {
     List<TestObj> testObjs = new List<TestObj>();
     for (int i = 0; i < 10; i++)
     {
         testObjs.Add(new TestObj(i.ToString(), i)); 
     }
     var records = database.SaveAll(testObjs);
     foreach (var record in records)
     {
         Assert.IsTrue(testObjs.Contains(record.Value), "IObjectDatabase.SaveAll failed");
     }
     records = database.GetAll<TestObj>();
     foreach (var record in records)
     {
         Assert.IsTrue(testObjs.Contains(record.Value), "IObjectDatabase.GetAll failed to return an object from memory");
     }
     database.Dispose();
     database = new SQLiteObjectDatabase(databaseFile);
     var newRecords = database.GetAll<TestObj>();
     foreach (var record in records)
     {
         Assert.IsTrue(records.FirstOrDefault(i => newRecords.Select(g => g.UniqueId).Contains(i.UniqueId)) != null, "IObjectDatabase.GetAll failed to return an object from storage");
     }
 }
        public static void LoadTables(IObjectDatabase Database, string DatabaseName)
        {
            List <string> typeNames = new List <string>();

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    if (type.IsClass != true)
                    {
                        continue;
                    }

                    try
                    {
                        DataTable[] attrib = (DataTable[])type.GetCustomAttributes(typeof(DataTable), true);
                        if (attrib.Length > 0 && attrib[0].DatabaseName == DatabaseName)
                        {
                            Database.RegisterDataObject(type);
                            typeNames.Add(type.Name);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error("DBManager", "Can not load : " + e);
                    }
                }
            }
            Log.Info("DBManager", "Registered table: " + string.Join(", ", typeNames));
        }
Esempio n. 5
0
        static public void LoadTables(IObjectDatabase Database, string DatabaseName)
        {
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in assembly.GetTypes())
                {
                    if (type.IsClass != true)
                    {
                        continue;
                    }

                    try
                    {
                        DataTable[] attrib = (DataTable[])type.GetCustomAttributes(typeof(DataTable), true);
                        if (attrib.Length > 0 && attrib[0].DatabaseName == DatabaseName)
                        {
                            Log.Info("DBManager", "Registering table: " + type.FullName);
                            Database.RegisterDataObject(type);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error("DBManager", "Can not load : " + e.ToString());
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Create a new Instance of <see cref="MobAmbientBehaviourManager"/>
        /// </summary>
        public MobAmbientBehaviourManager(IObjectDatabase database)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }

            AmbientBehaviour = database.SelectAllObjects <MobXAmbientBehaviour>().ToList();
        }
		/// <summary>
		/// Create a new Instance of <see cref="MobAmbientBehaviourManager"/>
		/// </summary>
		public MobAmbientBehaviourManager(IObjectDatabase Database)
		{
			if (Database == null)
				throw new ArgumentNullException("Database");
			
			this.Database = Database;
			
			AmbientBehaviour = new Dictionary<string, MobXAmbientBehaviour[]>();
		}
Esempio n. 8
0
 public CsvFileViewModel(
     DataReference csvDataReference,
     Table <string> data,
     IObjectDatabase <ShortId> shortIdDatabase,
     IDataApiClient dataApiClient)
 {
     Data = CreateDataGridColumns(data);
     ShortIdEditViewModel = new ShortIdEditViewModel(csvDataReference, shortIdDatabase, dataApiClient);
 }
Esempio n. 9
0
        public CsvFileHandler(
            IObjectDatabase <CsvFile> csvFileDatabase,
            IObjectDatabase <ShortId> shortIdDatabase,
            IDataApiClient dataApiClient)
        {
            this.csvFileDatabase = csvFileDatabase;
            this.shortIdDatabase = shortIdDatabase;

            this.dataApiClient = dataApiClient;
        }
Esempio n. 10
0
		/// <summary>
		/// Create a new Instance of <see cref="FriendsManager"/>
		/// </summary>
		public FriendsManager(IObjectDatabase Database)
		{
			this.Database = Database;
			PlayersFriendsListsCache = new ReaderWriterDictionary<GamePlayer, string[]>();
			PlayersFriendsStatusCache = new ReaderWriterDictionary<GamePlayer, FriendStatus[]>();
			GameEventMgr.AddHandler(GameClientEvent.StateChanged, OnClientStateChanged);
			GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, OnPlayerGameEntered);
			GameEventMgr.AddHandler(GamePlayerEvent.Quit, OnPlayerQuit);
			GameEventMgr.AddHandler(GamePlayerEvent.ChangeAnonymous, OnPlayerChangeAnonymous);
		}
Esempio n. 11
0
 /// <summary>
 /// Create a new Instance of <see cref="FriendsManager"/>
 /// </summary>
 public FriendsManager(IObjectDatabase Database)
 {
     this.Database             = Database;
     PlayersFriendsListsCache  = new ReaderWriterDictionary <GamePlayer, string[]>();
     PlayersFriendsStatusCache = new ReaderWriterDictionary <GamePlayer, FriendStatus[]>();
     GameEventMgr.AddHandler(GameClientEvent.StateChanged, OnClientStateChanged);
     GameEventMgr.AddHandler(GamePlayerEvent.GameEntered, OnPlayerGameEntered);
     GameEventMgr.AddHandler(GamePlayerEvent.Quit, OnPlayerQuit);
     GameEventMgr.AddHandler(GamePlayerEvent.ChangeAnonymous, OnPlayerChangeAnonymous);
 }
        /// <summary>
        /// Create a new Instance of <see cref="MobAmbientBehaviourManager"/>
        /// </summary>
        public MobAmbientBehaviourManager(IObjectDatabase database)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }

            AmbientBehaviour = database.SelectAllObjects <MobXAmbientBehaviour>()
                               .GroupBy(x => x.Source)
                               .ToDictionary(key => key.Key.ToLower(), value => value.ToArray());
        }
Esempio n. 13
0
        /// <summary>
        /// Create a new Instance of <see cref="MobAmbientBehaviourManager"/>
        /// </summary>
        public MobAmbientBehaviourManager(IObjectDatabase Database)
        {
            if (Database == null)
            {
                throw new ArgumentNullException("Database");
            }

            this.Database = Database;

            AmbientBehaviour = new Dictionary <string, MobXAmbientBehaviour[]>();
        }
 public void TestGetGUID()
 {
     var testObj = new TestObj("This is a simple test hope shit does not go wrong!!", 666);
     var record = database.Save(testObj);
     Assert.IsTrue(Object.ReferenceEquals(testObj, record.Value), "IObjectDatabase.Save failed to return the same object that was passed to it in the returned record");
     record = database.Get<TestObj>(record.UniqueId);
     Assert.IsTrue(Object.ReferenceEquals(testObj, record.Value), "IObjectDatabase.Get(GUID) failed to return an object from memory");
     database.Dispose();
     database = new SQLiteObjectDatabase(databaseFile);
     var newRecord = database.Get<TestObj>(record.UniqueId);
     Assert.IsTrue(record.UniqueId == newRecord.UniqueId && testObj.Value1 == newRecord.Value.Value1 && testObj.Value2 == newRecord.Value.Value2, "IObjectDatabase.Get(GUID) failed to return an object from storage");
 }
Esempio n. 15
0
        public MainViewModel(
            IClosable mainWindow,
            IDataApiClient dataApiClient,
            UploadedFileProcessor uploadedFileProcessor,
            IObjectDatabase <DataSet> dataSetDatabase,
            IObjectDatabase <DataTag> tagDatabase,
            IObjectDatabase <DataProject> projectDatabase,
            IObjectDatabase <DataCollectionProtocol> protocolDatabase,
            IObjectDatabase <DataCollectionProtocolParameter> protocolParameterDatabase)
        {
            this.mainWindow                = mainWindow;
            this.dataApiClient             = dataApiClient;
            this.uploadedFileProcessor     = uploadedFileProcessor;
            this.dataSetDatabase           = dataSetDatabase;
            this.tagDatabase               = tagDatabase;
            this.projectDatabase           = projectDatabase;
            this.protocolDatabase          = protocolDatabase;
            this.protocolParameterDatabase = protocolParameterDatabase;

            var passwordBoxSpawner = new WpfPasswordBoxSpawner();
            var loginViewSpawner   = new WpfWindowSpawner <LoginViewModel>(vm => new LoginWindow {
                ViewModel = vm
            });
            var changePasswordViewSpawner = new WpfWindowSpawner <ChangePasswordViewModel>(vm => new ChangePasswordWindow {
                ViewModel = vm
            });

            UserSwitchViewModel = new UserSwitchViewModel(
                dataApiClient,
                LoginSuccessful,
                LoginFailed,
                passwordBoxSpawner,
                loginViewSpawner,
                changePasswordViewSpawner);
            ProjectAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataProject>(
                x => x.Id,
                projectDatabase,
                new DataProjectAutoCompleteMatcher());
            ProjectAutoCompleteViewModel.PropertyChanged += ProjectAutoCompleteViewModel_PropertyChanged;
            DataSetAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataSet>(
                x => x.Id,
                dataSetDatabase,
                new DataSetAutoCompleteMatcher(),
                allowNewValue: true,
                objectBuilder: id => new DataSet(id));
            CreateNewProjectCommand          = new RelayCommand(CreateNewProject);
            AddSelectedFilesToDataSetCommand = new AsyncRelayCommand(AddSelectedFilesToDataSet, CanAddSelectedFilesToDataSet);
            SelectAllCommand       = new RelayCommand(SelectAll, CanSelectAll);
            DeselectAllCommand     = new RelayCommand(DeselectAll, CanDeselectAll);
            OpenAboutWindowCommand = new RelayCommand(OpenAboutWindow);
        }
Esempio n. 16
0
        public ShortIdEditViewModel(
            DataReference dataReference,
            IObjectDatabase <ShortId> shortIdDatabase,
            IDataApiClient dataApiClient)
        {
            OriginalId = dataReference.Id;
            DataType   = dataReference.DataType;

            this.shortIdDatabase = shortIdDatabase;
            this.dataApiClient   = dataApiClient;
            ExistingShortIds     = new ObservableCollection <ShortId>();
            Task.Run(() => LoadExistingShortIds(dataReference));
            StoreShortIdCommand = new AsyncRelayCommand(StoreShortId, () => !string.IsNullOrEmpty(UserSpecificId));
        }
Esempio n. 17
0
		public void SetUp()
		{
			var CodeBase = new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).Directory;
			var connectionString = string.Format("Data Source={0};Version=3;Pooling=False;Cache Size=1073741824;Journal Mode=Off;Synchronous=Off;Foreign Keys=True;Default Timeout=60",
			                                     Path.Combine(CodeBase.Parent.FullName, "dol-database-tests-only.sqlite3.db"));
			
			Database = ObjectDatabase.GetObjectDatabase(ConnectionType.DATABASE_SQLITE, connectionString);
			
			Console.WriteLine("DB Configured : {0}, {1}", ConnectionType.DATABASE_SQLITE, connectionString);
			
			log4net.Config.BasicConfigurator.Configure(
				new log4net.Appender.ConsoleAppender {
					Layout = new log4net.Layout.SimpleLayout()});
		}
Esempio n. 18
0
 public UploadedFileProcessor(
     ICollection <IFileHandler> fileHandlers,
     IDataApiClient dataApiClient,
     IObjectDatabase <DataBlob> dataBlobDatabase,
     IObjectDatabase <DataProjectUploadInfo> dataProjectUploadInfoDatabase,
     IClipboard clipboard,
     IAdditionalInformationViewSpawner additionalInformationViewSpawner)
 {
     this.dataApiClient    = dataApiClient;
     this.dataBlobDatabase = dataBlobDatabase;
     this.dataProjectUploadInfoDatabase = dataProjectUploadInfoDatabase;
     this.clipboard = clipboard;
     this.additionalInformationViewSpawner = additionalInformationViewSpawner;
     this.fileHandlers = BuildFileHandlerDictionary(fileHandlers);
 }
Esempio n. 19
0
 public MainViewModel(
     IDataApiClient dataApiClient,
     IObjectDatabase <DataServiceDefinition> dataServiceDefinitionDatabase,
     IClosable mainWindow,
     IDataTypeList dataTypeList,
     IUsernameProxy usernameProxy,
     ISqlExpressionValidator sqlExpressionValidator)
 {
     this.mainWindow     = mainWindow;
     UserSwitchViewModel = new UserSwitchViewModelFactory(
         dataApiClient,
         LoginSuccessful,
         LoginFailed).Create();
     SqlExportViewModel = new SqlExportViewModel(dataServiceDefinitionDatabase, dataTypeList, usernameProxy, sqlExpressionValidator);
     ExitCommand        = new RelayCommand <IClosable>(closable => closable.Close(true));
 }
Esempio n. 20
0
        public static void SetDatabaseConnection(IProgress <int> progress = null)
        {
            //Create a connection string using the string builder
            MySqlConnectionStringBuilder sb = ConnectionStringService.ConnectionString;

            sb.ConnectionTimeout = 2;
            var connectionString = sb.ConnectionString;

            Database = new MySQLObjectDatabase(connectionString);

            for (int i = 0; i < RegisteredObjects.Length; i++)
            {
                Database.RegisterDataObject(RegisteredObjects[i]);
                var perc = ((i + 1) / (decimal)RegisteredObjects.Length) * 100;
                progress?.Report((int)perc);
            }
        }
        public CreateProtocolViewModel(
            IDataApiClient dataApiClient,
            IObjectDatabase <DataCollectionProtocol> protocolDatabase,
            IObjectDatabase <DataCollectionProtocolParameter> protocolParameterDatabase,
            DataCollectionProtocol dataCollectionProtocol = null)
        {
            this.dataApiClient = dataApiClient;

            this.protocolDatabase          = protocolDatabase;
            this.protocolParameterDatabase = protocolParameterDatabase;
            if (dataCollectionProtocol != null)
            {
                IsNewProtocol = false;
                ProtocolId    = dataCollectionProtocol.Id;
                Parameters    = new ObservableCollection <ProtocolParameterViewModel>(
                    dataCollectionProtocol.Parameters.Select(
                        x => new ProtocolParameterViewModel(
                            dataApiClient,
                            protocolParameterDatabase,
                            x)));
                DataPlaceholders = new ObservableCollection <DataPlaceholdersViewModel>(
                    dataCollectionProtocol.ExpectedData.Select(x => new DataPlaceholdersViewModel(x)));
            }
            else
            {
                IsNewProtocol = true;
                Parameters    = new ObservableCollection <ProtocolParameterViewModel>
                {
                    new ProtocolParameterViewModel(dataApiClient, protocolParameterDatabase)
                };
                DataPlaceholders = new ObservableCollection <DataPlaceholdersViewModel>
                {
                    new DataPlaceholdersViewModel()
                };
            }
            AddParameterCommand          = new RelayCommand(AddParameter);
            DeleteParameterCommand       = new RelayCommand(DeleteParameter, () => SelectedParameter != null);
            AddDataPlaceholderCommand    = new RelayCommand(AddDataPlaceholder);
            DeleteDataPlaceholderCommand = new RelayCommand(DeleteDataPlaceholder, () => SelectedDataPlaceholder != null);
            SaveCommand   = new AsyncRelayCommand <IClosable>(Save, CanSave);
            CancelCommand = new RelayCommand <IClosable>(closable => closable.Close(false));
        }
Esempio n. 22
0
 public SqlExportViewModel(
     IObjectDatabase <DataServiceDefinition> dataServiceDefinitionDatabase,
     IDataTypeList dataTypeList,
     IUsernameProxy usernameProxy,
     ISqlExpressionValidator sqlExpressionValidator)
 {
     this.dataServiceDefinitionDatabase = dataServiceDefinitionDatabase;
     this.dataTypeList           = dataTypeList;
     this.usernameProxy          = usernameProxy;
     this.sqlExpressionValidator = sqlExpressionValidator;
     Fields = new ObservableCollection <FieldViewModel>();
     if (!Fields.Any())
     {
         Fields.Add(new FieldViewModel());
     }
     CreateDataServiceCommand = new AsyncRelayCommand(CreateDataService, CanCreateDataService);
     TestFilterCommand        = new AsyncRelayCommand(TestFilter, CanTestFilter);
     AddFieldCommand          = new RelayCommand(AddField);
     DeleteFieldCommand       = new RelayCommand(DeleteField, () => SelectedField != null);
 }
Esempio n. 23
0
        private void LoadServerProperties()
        {
            // open data connection and grab datas
            sp.Clear();
            sc.Clear();

            try
            {
                db = ObjectDatabase.GetObjectDatabase(currentConfig.DBType, currentConfig.DBConnectionString);
                db.RegisterDataObject(typeof(ServerProperty));
                db.RegisterDataObject(typeof(ServerPropertyCategory));
                sp = db.SelectAllObjects <ServerProperty>().ToList();
                sc = db.SelectAllObjects <ServerPropertyCategory>().ToList();
            }
            catch
            {
                toolstrip_status_label.Text = "Unable to connect/read SQL database !";
                return;
            }

            // reset display
            tv_spShow.Nodes.Clear();

            // no SP_C table
            if (sc.Count == 0)
            {
                foreach (var current in sp)
                {
                    tv_spShow.Nodes.Add(FormatNodeText(0, current.Key, current.Value));
                    tv_spShow.Nodes[tv_spShow.Nodes.Count - 1].ForeColor = Color.Blue;
                }
            }
            else
            {
                // creation of the SP map
                CreateSPMap(null, tv_spShow.Nodes, 0);
            }

            // how many SP we have ? 1.6millions ? :D
            toolstrip_status_label.Text = "Loaded: " + sp.Count() + " server properties.";
        }
        public static IObjectDatabase Start(string sqlconfig, ConnectionType Type, string databaseName, string schemaName)
        {
            Log.Debug("IObjectDatabase", databaseName + "->Start " + sqlconfig + "...");
            IObjectDatabase _database = null;

            try
            {
                _database = ObjectDatabase.GetObjectDatabase(Type, sqlconfig, schemaName);
                if (_database == null)
                {
                    return(null);
                }

                LoadTables(_database, databaseName);

                return(_database);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 25
0
        public static MySQLObjectDatabase Start(string sqlconfig, ConnectionType Type, string DBName)
        {
            Log.Debug("DBManager", DBName + "->Start " + sqlconfig + "...");
            IObjectDatabase _database = null;

            try
            {
                _database = ObjectDatabase.GetObjectDatabase(Type, sqlconfig);
                if (_database == null)
                {
                    return(null);
                }

                List <Type> Registereds = null;
                LoadTables(_database, DBName, ref Registereds);

                return((MySQLObjectDatabase)_database);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 26
0
        public CreateProjectViewModel(
            IDataApiClient dataApiClient,

            IObjectDatabase <DataProject> projectDatabase,
            IObjectDatabase <DataCollectionProtocol> protocolDatabase,
            IObjectDatabase <DataCollectionProtocolParameter> protocolParameterDatabase,
            IViewSpawner <CreateProtocolViewModel> createProtocolViewSpawner)
        {
            this.dataApiClient = dataApiClient;

            this.projectDatabase           = projectDatabase;
            this.protocolDatabase          = protocolDatabase;
            this.protocolParameterDatabase = protocolParameterDatabase;
            this.createProtocolViewSpawner = createProtocolViewSpawner;
            ProtocolsAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataCollectionProtocol>(
                x => x.Id,
                protocolDatabase,
                new DataCollectionProtocolAutoCompleteMatcher());
            CreateNewProtocolCommand = new RelayCommand(CreateNewProtocol);
            EditProtocolCommand      = new RelayCommand(EditProtocol, () => ProtocolsAutoCompleteViewModel.SelectedObject != null);
            SaveCommand   = new AsyncRelayCommand <IClosable>(Save, CanSave);
            CancelCommand = new RelayCommand <IClosable>(closable => closable.Close(false));
        }
Esempio n. 27
0
		private void LoadServerProperties()
		{
			// open data connection and grab datas
			sp.Clear();
			sc.Clear();
			
			try
			{
				db = ObjectDatabase.GetObjectDatabase(currentConfig.DBType, currentConfig.DBConnectionString);
				sp = db.SelectAllObjects<ServerProperty>().ToList();
				sc = db.SelectAllObjects<ServerPropertyCategory>().ToList();
			}
			catch
			{
				toolstrip_status_label.Text="Unable to connect/read SQL database !";
				return;
			}
			
			// reset display
			tv_spShow.Nodes.Clear();
			
			// no SP_C table
			if (sc.Count == 0)
			{
				foreach (var current in sp)
				{
					tv_spShow.Nodes.Add(FormatNodeText(0, current.Key, current.Value));
					tv_spShow.Nodes[tv_spShow.Nodes.Count-1].ForeColor = Color.Blue;
				}
			}
			else
				// creation of the SP map
				CreateSPMap(null, tv_spShow.Nodes,0);
			
			// how many SP we have ? 1.6millions ? :D
			toolstrip_status_label.Text ="Loaded: " + sp.Count() + " server properties.";
		}
Esempio n. 28
0
        /*public static MySQLObjectDatabase Start(FileInfo configfile, ConnectionType Type, string DBName)
         * {
         *  Log.Info("IObjectDatabase", "Starting...");
         *  XMLConfigFile xmlConfig = XMLConfigFile.ParseXMLFile(configfile);
         *  if (xmlConfig == null)
         *  {
         *      Log.Error("IOBjectDatabase", "Invalid file : " + configfile);
         *      return null;
         *  }
         *
         *
         *  string sqlconfig = xmlConfig["Database"]["DBInfo"].GetString("");
         *
         *  if (sqlconfig.Length <= 0)
         *  {
         *      Log.Error("IOBjectDatabase", "Invalid configuration : " + configfile);
         *      return null;
         *  }
         *
         *  return Start(sqlconfig, Type, DBName);
         * }*/

        public static MySQLObjectDatabase Start(string sqlconfig, ConnectionType Type, string DBName)
        {
            Log.Debug("IObjectDatabase", DBName + "->Start " + sqlconfig + "...");
            IObjectDatabase _database = null;

            if (_database == null)
            {
                _database = ObjectDatabase.GetObjectDatabase(Type, sqlconfig);

                try
                {
                    foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                    {
                        foreach (Type type in assembly.GetTypes())
                        {
                            if (type.IsClass != true)
                            {
                                continue;
                            }

                            DataTable[] attrib = (DataTable[])type.GetCustomAttributes(typeof(DataTable), true);
                            if (attrib.Length > 0 && attrib[0].DatabaseName == DBName)
                            {
                                Log.Info("DBManager", "Registering table: " + type.FullName);
                                _database.RegisterDataObject(type);
                            }
                        }
                    }
                }
                catch (DatabaseException e)
                {
                    Log.Error("DBManager", "Error at registering tables " + e.ToString());
                    return(null);
                }
            }
            return((MySQLObjectDatabase)_database);
        }
Esempio n. 29
0
 public void InitDB()
 {
     if (m_database == null)
     {
         m_database = ObjectDatabase.GetObjectDatabase(dolConfig.DBType, dolConfig.DBConnectionString);
         try
         {
             //We will search our assemblies for DataTables by reflection so
             //it is not neccessary anymore to register new tables with the
             //server, it is done automatically!
             foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
             {
                 // Walk through each type in the assembly
                 foreach (Type type in assembly.GetTypes())
                 {
                     // Pick up a class
                     if (type.IsClass != true)
                     {
                         continue;
                     }
                     object[] attrib = type.GetCustomAttributes(typeof(DataTable), true);
                     if (attrib.Length > 0)
                     {
                         //Log.Info("Registering table: " + type.FullName);
                         m_database.RegisterDataObject(type);
                     }
                 }
             }
         }
         catch (DatabaseException e)
         {
             QuestDesignerMain.HandleException(e);
             return;
         }
     }
 }
Esempio n. 30
0
        public ProjectParameterResponsesViewModel(
            IDataApiClient dataApiClient,

            IObjectDatabase <DataProject> dataProjectDatabase,
            DataProject dataProject)
        {
            this.dataProjectDatabase = dataProjectDatabase;
            DataProject = dataProject;
            var valueViewModelFactory = new ParameterValueViewModelFactory(dataApiClient);

            ParameterResponses = dataProject.Protocol.Parameters
                                 .Select(parameter =>
            {
                var response = dataProject.ParameterResponse.ContainsKey(parameter.Name)
                        ? dataProject.ParameterResponse[parameter.Name]
                        : null;
                return(new ProtocolParameterResponseViewModel(parameter, valueViewModelFactory, response));
            })
                                 .ToList();
            ParameterResponses.ForEach(vm => vm.PropertyChanged += ParameterResponse_PropertyChanged);
            ShowParameters = !IsProtocolParametersCompleted;

            SaveCommand = new AsyncRelayCommand(Save, () => IsProtocolParametersCompleted);
        }
 public void Setup()
 {
     BS.Core.Constants.Kernel = new StandardKernel(new BSServerNinjectModule());
     database = new SQLiteObjectDatabase(databaseFile);
 }
Esempio n. 32
0
 public DataServiceTargetWindowViewModel(IObjectDatabase <IDataServiceTarget> dataServiceTargetDatabase)
 {
     this.dataServiceTargetDatabase = dataServiceTargetDatabase;
     EditViewModel = new EditDataServiceTargetViewModel(dataServiceTargetDatabase);
 }
        public static void LoadNewAbilityInfo()
        {
            Log.Info("AbilityMgr", "Loading New Ability Info...");

            IObjectDatabase db = WorldMgr.Database;

            #region Database

            List <DBAbilityInfo> dbAbilities = (List <DBAbilityInfo>)db.SelectAllObjects <DBAbilityInfo>();

            List <AbilityInfo> abVolatiles = AbilityInfo.Convert(dbAbilities);
            Dictionary <ushort, AbilityConstants> abConstants = AbilityConstants.Convert(dbAbilities).ToDictionary(key => key.Entry);
            List <AbilityDamageInfo>  abDmgHeals = AbilityDamageInfo.Convert(db.SelectAllObjects <DBAbilityDamageInfo>().OrderBy(dmg => dmg.ParentCommandID).ThenBy(dmg => dmg.ParentCommandSequence).ToList());
            List <AbilityCommandInfo> abCommands = AbilityCommandInfo.Convert(db.SelectAllObjects <DBAbilityCommandInfo>().OrderBy(cmd => cmd.CommandID).ToList());

            IList <AbilityModifierCheck>  abChecks = db.SelectAllObjects <AbilityModifierCheck>().OrderBy(check => check.ID).ToList();
            IList <AbilityModifierEffect> abMods   = db.SelectAllObjects <AbilityModifierEffect>().OrderBy(mod => mod.Sequence).ToList();

            List <BuffInfo>        buffInfos    = BuffInfo.Convert((List <DBBuffInfo>)db.SelectAllObjects <DBBuffInfo>());
            List <BuffCommandInfo> buffCommands = BuffCommandInfo.Convert(db.SelectAllObjects <DBBuffCommandInfo>().OrderBy(buffcmd => buffcmd.CommandID).ToList());

            IList <AbilityKnockbackInfo> knockbackInfos = db.SelectAllObjects <AbilityKnockbackInfo>().OrderBy(kbinfo => kbinfo.Id).ToList();

            List <AbilityCommandInfo> slaveCommands     = new List <AbilityCommandInfo>();
            List <BuffCommandInfo>    slaveBuffCommands = new List <BuffCommandInfo>();

            Dictionary <ushort, int> damageTypeDictionary = new Dictionary <ushort, int>();
            #endregion

            for (byte i = 0; i < 24; ++i)
            {
                CareerAbilities[i] = new List <AbilityInfo>();
            }

            #region AbilityChecks

            foreach (AbilityModifierCheck check in abChecks)
            {
                switch (check.PreOrPost)
                {
                case 0:
                    if (!AbilityPreCastModifiers.ContainsKey(check.Entry))
                    {
                        AbilityPreCastModifiers.Add(check.Entry, new List <AbilityModifier>());

                        while (AbilityPreCastModifiers[check.Entry].Count < check.ID + 1)
                        {
                            AbilityPreCastModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }

                        AbilityPreCastModifiers[check.Entry][check.ID].AddCheck(check);
                    }

                    else
                    {
                        if (AbilityPreCastModifiers[check.Entry].Count == check.ID)
                        {
                            AbilityPreCastModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }
                        AbilityPreCastModifiers[check.Entry][check.ID].AddCheck(check);
                    }
                    break;

                case 1:
                    if (!AbilityModifiers.ContainsKey(check.Entry))
                    {
                        AbilityModifiers.Add(check.Entry, new List <AbilityModifier>());

                        while (AbilityModifiers[check.Entry].Count < check.ID + 1)
                        {
                            AbilityModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }
                        AbilityModifiers[check.Entry][check.ID].AddCheck(check);
                    }

                    else
                    {
                        if (AbilityModifiers[check.Entry].Count == check.ID)
                        {
                            AbilityModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }
                        AbilityModifiers[check.Entry][check.ID].AddCheck(check);
                    }
                    break;

                case 2:
                    if (!BuffModifiers.ContainsKey(check.Entry))
                    {
                        BuffModifiers.Add(check.Entry, new List <AbilityModifier>());
                        while (BuffModifiers[check.Entry].Count < check.ID + 1)
                        {
                            BuffModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }
                        BuffModifiers[check.Entry][check.ID].AddCheck(check);
                    }

                    else
                    {
                        if (BuffModifiers[check.Entry].Count == check.ID)
                        {
                            BuffModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }
                        BuffModifiers[check.Entry][check.ID].AddCheck(check);
                    }
                    break;

                case 3:
                    if (!AbilityDelayedModifiers.ContainsKey(check.Entry))
                    {
                        AbilityDelayedModifiers.Add(check.Entry, new List <AbilityModifier>());

                        while (AbilityDelayedModifiers[check.Entry].Count < check.ID + 1)
                        {
                            AbilityDelayedModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }

                        AbilityDelayedModifiers[check.Entry][check.ID].AddCheck(check);
                    }

                    else
                    {
                        if (AbilityDelayedModifiers[check.Entry].Count == check.ID)
                        {
                            AbilityDelayedModifiers[check.Entry].Add(new AbilityModifier(check.Entry, check.Affecting));
                        }
                        AbilityDelayedModifiers[check.Entry][check.ID].AddCheck(check);
                    }
                    break;
                }
            }

            #endregion

            #region AbilityModifiers

            foreach (AbilityModifierEffect effect in abMods)
            {
                switch (effect.PreOrPost)
                {
                case 0:
                    if (!AbilityPreCastModifiers.ContainsKey(effect.Entry))
                    {
                        AbilityPreCastModifiers.Add(effect.Entry, new List <AbilityModifier>());
                        AbilityPreCastModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        AbilityPreCastModifiers[effect.Entry][0].AddModifier(effect);
                    }

                    else
                    {
                        if (AbilityPreCastModifiers[effect.Entry].Count == effect.Sequence)
                        {
                            AbilityPreCastModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        }
                        AbilityPreCastModifiers[effect.Entry][effect.Sequence].AddModifier(effect);
                    }
                    break;

                case 1:
                    if (!AbilityModifiers.ContainsKey(effect.Entry))
                    {
                        AbilityModifiers.Add(effect.Entry, new List <AbilityModifier>());
                        AbilityModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        AbilityModifiers[effect.Entry][0].AddModifier(effect);
                    }

                    else
                    {
                        if (AbilityModifiers[effect.Entry].Count == effect.Sequence)
                        {
                            AbilityModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        }
                        AbilityModifiers[effect.Entry][effect.Sequence].AddModifier(effect);
                    }
                    break;

                case 2:
                    if (!BuffModifiers.ContainsKey(effect.Entry))
                    {
                        BuffModifiers.Add(effect.Entry, new List <AbilityModifier>());
                        BuffModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        BuffModifiers[effect.Entry][0].AddModifier(effect);
                    }

                    else
                    {
                        if (BuffModifiers[effect.Entry].Count == effect.Sequence)
                        {
                            BuffModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        }
                        BuffModifiers[effect.Entry][effect.Sequence].AddModifier(effect);
                    }
                    break;

                case 3:
                    if (!AbilityDelayedModifiers.ContainsKey(effect.Entry))
                    {
                        AbilityDelayedModifiers.Add(effect.Entry, new List <AbilityModifier>());
                        AbilityDelayedModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        AbilityDelayedModifiers[effect.Entry][0].AddModifier(effect);
                    }

                    else
                    {
                        if (AbilityDelayedModifiers[effect.Entry].Count == effect.Sequence)
                        {
                            AbilityDelayedModifiers[effect.Entry].Add(new AbilityModifier(effect.Entry, effect.Affecting));
                        }
                        AbilityDelayedModifiers[effect.Entry][effect.Sequence].AddModifier(effect);
                    }
                    break;
                }
            }
            #endregion

            #region CommandInfo

            // Ability commands
            foreach (AbilityCommandInfo abCommand in abCommands)
            {
                if (abCommand.CommandSequence != 0)
                {
                    slaveCommands.Add(abCommand);
                }

                else
                {
                    if (!AbilityCommandInfos.ContainsKey(abCommand.Entry))
                    {
                        AbilityCommandInfos.Add(abCommand.Entry, new List <AbilityCommandInfo>());
                    }

                    AbilityCommandInfos[abCommand.Entry].Add(abCommand);
                }
            }

            foreach (AbilityCommandInfo slaveCommand in slaveCommands)
            {
                if (AbilityCommandInfos.ContainsKey(slaveCommand.Entry))
                {
                    AbilityCommandInfos[slaveCommand.Entry][slaveCommand.CommandID].AddCommandToChain(slaveCommand);
                }
                else
                {
                    Log.Debug("AbilityMgr", "Slave command with entry " + slaveCommand.Entry + " and depending upon master command ID " + slaveCommand.CommandID + " has no master!");
                }
            }

            #endregion

            #region BuffCommands

            foreach (BuffCommandInfo buffCommand in buffCommands)
            {
                if (buffCommand.CommandSequence != 0)
                {
                    slaveBuffCommands.Add(buffCommand);
                }
                else
                {
                    if (!BuffCommandInfos.ContainsKey(buffCommand.Entry))
                    {
                        BuffCommandInfos.Add(buffCommand.Entry, new List <BuffCommandInfo>());
                    }
                    BuffCommandInfos[buffCommand.Entry].Add(buffCommand);
                }
            }

            foreach (BuffCommandInfo slaveBuffCommand in slaveBuffCommands)
            {
                if (BuffCommandInfos.ContainsKey(slaveBuffCommand.Entry))
                {
                    BuffCommandInfos[slaveBuffCommand.Entry][slaveBuffCommand.CommandID].AddCommandToChain(slaveBuffCommand);
                }
                else
                {
                    Log.Debug("AbilityMgr", "Slave buff command with entry " + slaveBuffCommand.Entry + " and depending upon master command ID " + slaveBuffCommand.CommandID + " has no master!");
                }
            }

            #endregion

            #region Damage/Heals

            // Damage and heal info gets tacked onto the command that's going to use it
            foreach (AbilityDamageInfo abDmgHeal in abDmgHeals)
            {
                if (abDmgHeal.DisplayEntry == 0)
                {
                    abDmgHeal.DisplayEntry = abDmgHeal.Entry;
                }
                switch (abDmgHeal.Index)
                {
                case 0:
                    if (AbilityCommandInfos.ContainsKey(abDmgHeal.Entry))
                    {
                        AbilityCommandInfo desiredCommand = AbilityCommandInfos[abDmgHeal.Entry][abDmgHeal.ParentCommandID].GetSubcommand(abDmgHeal.ParentCommandSequence);
                        if (desiredCommand != null)
                        {
                            desiredCommand.DamageInfo = abDmgHeal;
                        }
                    }

                    if (!damageTypeDictionary.ContainsKey(abDmgHeal.Entry))
                    {
                        damageTypeDictionary.Add(abDmgHeal.Entry, (int)abDmgHeal.DamageType);
                    }
                    break;

                case 1:
                    if (BuffCommandInfos.ContainsKey(abDmgHeal.Entry))
                    {
                        try
                        {
                            BuffCommandInfo desiredCommand = BuffCommandInfos[abDmgHeal.Entry][abDmgHeal.ParentCommandID].GetSubcommand(abDmgHeal.ParentCommandSequence);
                            if (desiredCommand != null)
                            {
                                desiredCommand.DamageInfo = abDmgHeal;
                            }
                        }
                        catch
                        {
                            Log.Error("AbilityMgr", "Failed Load: " + abDmgHeal.Entry + " " + abDmgHeal.ParentCommandID);
                        }

                        if (!damageTypeDictionary.ContainsKey(abDmgHeal.Entry))
                        {
                            damageTypeDictionary.Add(abDmgHeal.Entry, (int)abDmgHeal.DamageType);
                        }
                    }
                    break;

                case 2:
                    if (!ExtraDamage.ContainsKey(abDmgHeal.Entry))
                    {
                        ExtraDamage.Add(abDmgHeal.Entry, new List <List <AbilityDamageInfo> >());
                    }
                    if (ExtraDamage[abDmgHeal.Entry].Count == abDmgHeal.ParentCommandID)
                    {
                        ExtraDamage[abDmgHeal.Entry].Add(new List <AbilityDamageInfo>());
                    }
                    ExtraDamage[abDmgHeal.Entry][abDmgHeal.ParentCommandID].Add(abDmgHeal);
                    break;

                default:
                    throw new Exception("Invalid index specified for ability damage with ID " + abDmgHeal.Entry);
                }
            }

            #endregion

            #region KnockbackInfo

            foreach (var kbInfo in knockbackInfos)
            {
                if (!KnockbackInfos.ContainsKey(kbInfo.Entry))
                {
                    KnockbackInfos.Add(kbInfo.Entry, new List <AbilityKnockbackInfo>());
                }
                KnockbackInfos[kbInfo.Entry].Add(kbInfo);
            }

            #endregion

            // Volatiles -> Constants
            //           -> Commands -> DamageHeals
            foreach (AbilityInfo abVolatile in abVolatiles)
            {
                if (!NewAbilityVolatiles.ContainsKey(abVolatile.Entry))
                {
                    NewAbilityVolatiles.Add(abVolatile.Entry, abVolatile);
                }

                if (AbilityCommandInfos.ContainsKey(abVolatile.Entry))
                {
                    abVolatile.TargetType = AbilityCommandInfos[abVolatile.Entry][0].TargetType;
                    if (AbilityCommandInfos[abVolatile.Entry][0].AoESource != 0)
                    {
                        abVolatile.TargetType = AbilityCommandInfos[abVolatile.Entry][0].AoESource;
                    }
                }
            }

            #region ConstantInfo

            foreach (AbilityConstants abConstant in abConstants.Values)
            {
                if (NewAbilityVolatiles.ContainsKey(abConstant.Entry))
                {
                    NewAbilityVolatiles[abConstant.Entry].ConstantInfo = abConstant;

                    if (damageTypeDictionary.ContainsKey(abConstant.Entry))
                    {
                        if (damageTypeDictionary[abConstant.Entry] == (ushort)DamageTypes.Healing || damageTypeDictionary[abConstant.Entry] == (ushort)DamageTypes.RawHealing)
                        {
                            abConstant.IsHealing = true;
                        }
                        else
                        {
                            abConstant.IsDamaging = true;
                        }
                    }

                    uint careerRequirement = abConstant.CareerLine;
                    byte count             = 0;

                    while (careerRequirement > 0 && count < 24)
                    {
                        if ((careerRequirement & 1) > 0)
                        {
                            CareerAbilities[count].Add(NewAbilityVolatiles[abConstant.Entry]);
                        }
                        careerRequirement = careerRequirement >> 1;
                        count++;
                    }
                }
            }

            #endregion

            #region Damage to ConstantInfo linkage

            foreach (AbilityDamageInfo damageInfo in abDmgHeals)
            {
                if (abConstants.ContainsKey(damageInfo.Entry))
                {
                    damageInfo.MasteryTree = abConstants[damageInfo.Entry].MasteryTree;
                }
            }

            #endregion

            #region Buff/Command linkage

            foreach (BuffInfo buffInfo in buffInfos)
            {
                if (!BuffInfos.ContainsKey(buffInfo.Entry))
                {
                    BuffInfos.Add(buffInfo.Entry, buffInfo);
                }

                if (BuffCommandInfos.ContainsKey(buffInfo.Entry))
                {
                    buffInfo.CommandInfo = BuffCommandInfos[buffInfo.Entry];
                }

                if (abConstants.ContainsKey(buffInfo.Entry))
                {
                    buffInfo.MasteryTree = abConstants[buffInfo.Entry].MasteryTree;
                }
            }

            #endregion

            Log.Success("AbilityMgr", "Finished loading " + NewAbilityVolatiles.Count + " abilities and " + BuffInfos.Count + " buffs!");

            LoadCreatureAbilities();
        }
Esempio n. 34
0
		/// <summary>
		/// Initializes the database
		/// </summary>
		/// <returns>True if the database was successfully initialized</returns>
		public bool InitDB()
		{
			if (m_database == null)
			{
				m_database = ObjectDatabase.GetObjectDatabase(Configuration.DBType, Configuration.DBConnectionString);

				try
				{
					//We will search our assemblies for DataTables by reflection so
					//it is not neccessary anymore to register new tables with the
					//server, it is done automatically!
					foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
					{
						// Walk through each type in the assembly
						foreach (Type type in assembly.GetTypes())
						{
							// Pick up a class
							// Aredhel: Ok, I know checking for InventoryArtifact type
							// is a hack, but I currently have no better idea.
							if (type.IsClass != true || type == typeof (InventoryArtifact))
								continue;
							object[] attrib = type.GetCustomAttributes(typeof (DataTable), true);
							if (attrib.Length > 0)
							{
								if (log.IsInfoEnabled)
									log.Info("Registering table: " + type.FullName);
								m_database.RegisterDataObject(type);
							}
						}
					}
				}
				catch (DatabaseException e)
				{
					if (log.IsErrorEnabled)
						log.Error("Error registering Tables", e);
					return false;
				}
			}
			if (log.IsInfoEnabled)
				log.Info("Database Initialization: true");
			return true;
		}
Esempio n. 35
0
 public EditDataServiceTargetViewModel(IObjectDatabase <IDataServiceTarget> dataServiceTargetDatabase)
 {
     this.dataServiceTargetDatabase = dataServiceTargetDatabase;
     SaveCommand = new AsyncRelayCommand(Save, CanSave);
 }
Esempio n. 36
0
 public ImageFileHandler(IObjectDatabase <Image> imageDatabase)
 {
     this.imageDatabase = imageDatabase;
 }
Esempio n. 37
0
		/// <summary>
		/// Initializes the database
		/// </summary>
		/// <returns>True if the database was successfully initialized</returns>
		public bool InitDB()
		{
			if (m_database == null)
			{
				m_database = ObjectDatabase.GetObjectDatabase(Configuration.DBType, Configuration.DBConnectionString);

				try
				{
					//We will search our assemblies for DataTables by reflection so
					//it is not neccessary anymore to register new tables with the
					//server, it is done automatically!
					foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
					{
						// Walk through each type in the assembly
						foreach (Type type in assembly.GetTypes())
						{
							if (!type.IsClass || type.IsAbstract)
								continue;
							
							var attrib = type.GetCustomAttributes<DataTable>(false);
							if (attrib.Any())
							{
								if (log.IsInfoEnabled)
									log.InfoFormat("Registering table: {0}", type.FullName);
								m_database.RegisterDataObject(type);
							}
						}
					}
				}
				catch (DatabaseException e)
				{
					if (log.IsErrorEnabled)
						log.Error("Error registering Tables", e);
					return false;
				}
			}
			if (log.IsInfoEnabled)
				log.Info("Database Initialization: true");
			return true;
		}
Esempio n. 38
0
 public ImageUploader(IObjectDatabase <Image> imageDatabase)
 {
     this.imageDatabase = imageDatabase;
 }
Esempio n. 39
0
 public void SetDatabase(IObjectDatabase database)
 {
     this.database = database;
 }
 public void InitDB()
 {
     if (m_database == null)
     {
         m_database = ObjectDatabase.GetObjectDatabase(dolConfig.DBType, dolConfig.DBConnectionString);
         try
         {
             //We will search our assemblies for DataTables by reflection so
             //it is not neccessary anymore to register new tables with the
             //server, it is done automatically!
             foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
             {
                 // Walk through each type in the assembly
                 foreach (Type type in assembly.GetTypes())
                 {
                     // Pick up a class
                     if (type.IsClass != true)
                         continue;
                     object[] attrib = type.GetCustomAttributes(typeof(DataTable), true);
                     if (attrib.Length > 0)
                     {
                         //Log.Info("Registering table: " + type.FullName);
                         m_database.RegisterDataObject(type);
                     }
                 }
             }
         }
         catch (DatabaseException e)
         {
             QuestDesignerMain.HandleException(e);
             return;
         }
     }
 }