Exemple #1
0
        public SpaceInstance(uint InstanceId, SpaceInfo Info, SpaceModel Model)
        {
            this.uint_0                 = InstanceId;
            this.spaceInfo_0            = Info;
            this.concurrentDictionary_0 = new ConcurrentDictionary <uint, SpaceActor>();
            this.spaceModel_0           = Model;
            this.string_0               = string.Empty;
            this.list_2                 = new List <uint> {
                1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 0x10,
                0x11, 0x12, 0x13, 20, 0x15
            };
            this.object_2    = new object();
            this.tileState_0 = new TileState[this.spaceModel_0.Heightmap.SizeX, this.spaceModel_0.Heightmap.SizeY];
            this.list_0      = new List <SpaceActor> [this.spaceModel_0.Heightmap.SizeX, this.spaceModel_0.Heightmap.SizeY];
            SqlDatabaseClient mySqlClient = SqlDatabaseManager.GetClient();

            try
            {
                this.InitializeContestWorker(mySqlClient);
            }
            catch (Exception exception)
            {
                Output.WriteLine("[ContestMgr] An exception has been trhown while trying to start the worker. The thread was already destroyed. Stack trace:\r\n" + exception.ToString(), OutputLevel.CriticalError);
            }
            finally
            {
                if (mySqlClient != null)
                {
                    mySqlClient.Dispose();
                }
            }
            this.RegenerateRelativeHeightmap(false);
        }
        public static long InsertNewMemberToDB(User user, SqlDatabaseClient client = null)
        {
            bool clientIsNull = client == null;

            try
            {
                string sql = "INSERT INTO Member (name, role) VALUES(@name, @role);";
                if (clientIsNull)
                {
                    client = SqlDatabaseManager.GetClient();
                }
                else
                {
                    client.SetParameter("@id", 51);
                    sql = "INSERT INTO Member (id, name, role) VALUES(@id, @name, @role);";
                }


                client.SetParameter("@name", user.Name);
                client.SetParameter("@role", user.Role);


                int count = client.ExecuteNonQuery(sql);

                long lastInsertedId = 0;
                if (count > 0)
                {
                    lastInsertedId = client.LastInsertedId();
                }

                if (clientIsNull)
                {
                    client.Dispose();
                }

                return(lastInsertedId);
            }
            catch (DbException e)
            {
                if (!clientIsNull)
                {
                    throw;
                }

                client?.Dispose();

                if (e.Message.Contains("unique_member_name_ck"))
                {
                    return(-2);
                }
                else
                {
                    Logger.WriteLine(e.ToString(), Logger.LOG_LEVEL.WARN);
                }
            }

            return(0);
        }