Ejemplo n.º 1
0
        /// <summary>
        /// Saves all the items in the hand that have been marked for update. (items that are new in the hand etc)
        /// </summary>
        public void saveHandItems()
        {
            Database dbClient = null;
            MySqlParameter vchrCustomData = null;
            foreach (stripItem lItem in this.handItems)
            {
                if (lItem.requiresUpdate)
                {
                    #region Create database connection
                    if (dbClient == null) // No database connection yet
                    {
                        dbClient = new Database(false, true);
                        dbClient.addParameterWithValue("userid", this.userID);
                        vchrCustomData = new MySqlParameter("customdata", MySqlDbType.VarChar);
                        dbClient.addRawParameter(vchrCustomData);
                        dbClient.Open();

                        if (!dbClient.Ready) // Can't use this database connection for some reason
                            return;
                    }
                    #endregion

                    if (lItem.customData == null)
                        vchrCustomData.Value = DBNull.Value;
                    else
                        vchrCustomData.Value = lItem.customData;
                    dbClient.runQuery("UPDATE items SET ownerid = @userid,roomid = '0',customdata = @customdata WHERE id = '" + lItem.ID + "' LIMIT 1");
                }
            }
            if (dbClient != null)
                dbClient.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes the current chatlog stack and writes it into the 'moderation_chatlog' table of the database.
        /// </summary>
        private void processChatLogStack()
        {
            while (true)
            {
                Thread.Sleep(15000); // Every 15 seconds
                if (this.chatLogStack.Count > 0) // Log chatlogs at min 10 logs @ stack
                {
                    MySqlParameter dtParameter = new MySqlParameter("moment", MySqlDbType.DateTime);
                    MySqlParameter txtParameter = new MySqlParameter("text", MySqlDbType.Text);
                    Database dbClient = new Database(false, false);
                    dbClient.addRawParameter(dtParameter);
                    dbClient.addRawParameter(txtParameter);

                    dbClient.Open();
                    if (dbClient.Ready)
                    {
                        lock (this.chatLogStack)
                        {
                            foreach (chatLog Log in this.chatLogStack)
                            {
                                dtParameter.Value = Log.Timestamp;
                                txtParameter.Value = Log.Text;
                                dbClient.runQuery(Log.ToString());
                            }
                        }
                        dbClient.Close();
                    }
                    chatLogStack.Clear();
                }
            }
        }