Esempio n. 1
0
        public override void Load(bool useAsyncMode)
        {
            // prepare data conversion parameters if it's still not done yet (done only once per server run)
            if (colGetTypeInfo == null)
            {
                for (int t = 0; t < DBTableLoadOrder.Count; t++)
                {
                    colGetTypeInfo.Add(DBStructure[DBTableLoadOrder[t]]);
                }
            }

            // fill the queue of commands / subsequent sql-database-requests
            var commandQueue = new List <string>();
            var cgi          = GetColGetTypeInfo();

            for (int t = 0; t < cgi.Count; t++)
            {
                StringBuilder commandSB = new StringBuilder();

                // select columns in order (by their names) --> SELECT col1, col2, ... coln
                commandSB.Append("SELECT ");
                int lastColumnIndex = cgi[t].Count - 1;
                for (int c = 0; c < cgi[t].Count; c++)
                {
                    if (c != lastColumnIndex)
                    {
                        commandSB.Append(cgi[t][c].colName + ",");
                    }
                    else
                    {
                        commandSB.Append(cgi[t][c].colName);
                    }
                }

                // always sort by <nameOfTable>ID --> e.g. FROM WorldEffect WHERE 1 ORDER BY WorldEffectID;
                commandSB.AppendFormat(" FROM {0} WHERE 1 ORDER BY {1}ID;", DBTableLoadOrder[t],
                                       DBTableLoadOrder[t]);
                commandQueue.Add(commandSB.ToString());
            }

            // send out a asynchronous / parallel working DBAgent which informs back when finished with the queue
            DBAgent dbAgent = new DBAgent(GetDBFilePath(), commandQueue, false, useAsyncMode);

            dbAgent.SetObjName(GetObjName() + "-DBAgent");
            dbAgent.FinishedQueue += VobDefFromSQLResults;
            dbAgent.Start();
        }
Esempio n. 2
0
        partial void pLoad(bool useAsyncMode)
        {
            lock (loadLock)
            {
                InitLoad();

                // fill the queue of commands / subsequent sql-database-requests
                List <string> commandQueue = PrepareLoadCommandQueue();
                //foreach (var cmd in commandQueue) { Log.Logger.Log(cmd); }

                // send out DBAgent which might work asynchronously
                // ...use AutoResetEvent for that case (forces thread to wait until continue is signalled)
                DBAgent dbAgent = new DBAgent(dbFilePath, commandQueue, false, useAsyncMode);
                dbAgent.SetObjName("DBAgent (VisualLoader)");
                dbAgent.FinishedQueue += VisualsFromSQLResults;
                dbAgent.Start();
            }
        }
Esempio n. 3
0
        public override void Load(bool useAsyncMode)
        {
            lock (loadLock)
            {
                // start prepared, fresh and clean as morning dew
                InitLoad();
                // fill the queue of commands / subsequent sql-database-requests
                List <string> commandQueue = PrepareLoadCommandQueue();
                //foreach (var cmd in commandQueue) { Log.Logger.Log(cmd); }

                // send out DBAgent which might work asynchronously
                // ...use AutoResetEvent for that case (forces thread to wait until continue is signalled)
                DBAgent dbAgent = new DBAgent(dbFilePath, commandQueue, false, useAsyncMode);
                dbAgent.SetObjName("DBAgent (EffectLoader)");
                dbAgent.FinishedQueue += EffectsFromSQLResults;
                //dbAgent.waitHandle.WaitOne();
                dbAgent.Start();
            }
        }
Esempio n. 4
0
        partial void pLoad()
        {
            // prepare data conversion parameters if it's still not done yet
            if (colGetTypeInfo == null)
            {
                colGetTypeInfo = new List <List <DBTables.ColumnGetTypeInfo> >();

                for (int t = 0; t < DBTableLoadOrder.Count; t++)
                {
                    colGetTypeInfo.Add(DBStructure[DBTableLoadOrder[t]]);
                }
            }

            // fill the queue of commands / subsequent sql-database-requests
            List <string> commandQueue = new List <string>();

            for (int t = 0; t < ColGetTypeInfo.Count; t++)
            {
                StringBuilder commandSB = new StringBuilder();

                // select columns in order (by their names) --> SELECT col1, col2, ... coln
                commandSB.Append("SELECT ");
                int lastColumnIndex = ColGetTypeInfo[t].Count - 1;
                for (int c = 0; c < ColGetTypeInfo[t].Count; c++)
                {
                    if (c != lastColumnIndex)
                    {
                        commandSB.Append(ColGetTypeInfo[t][c].colName + ",");
                    }
                    else
                    {
                        commandSB.Append(ColGetTypeInfo[t][c].colName);
                    }
                }

                // always sort by <nameOfTable>ID --> e.g. FROM WorldEffect WHERE 1 ORDER BY WorldEffectID;
                if (t < ColGetTypeInfo.Count - 1)
                {
                    commandSB.AppendFormat(" FROM {0} WHERE 1 ORDER BY {1}ID;", DBTableLoadOrder[t],
                                           DBTableLoadOrder[t]);
                }
                else
                {
                    // last must always be the static-dynamic-job
                    // filter out only those of the world itself (not the vobs)
                    commandSB.AppendFormat(" FROM {0} WHERE {1} ORDER BY {2}ID;", DBTableLoadOrder[t],
                                           "TableName == WorldEffect OR TableName == WorldChange", DBTableLoadOrder[t]);
                }

                commandQueue.Add(commandSB.ToString());
            }

            foreach (string cmd in commandQueue)
            {
                MakeLog(cmd);
            }


            // send out a parallel working DBAgent which informs back when finished with the queue
            DBAgent dbAgent = new DBAgent(DBFilePath, commandQueue, false);

            dbAgent.SetObjName(GetObjName() + "-DBAgent");
            //dbAgent.FinishedQueue += WorldDefFromSQLResults;
            dbAgent.Start();
        }