コード例 #1
0
        public void SaveBans(Dictionary <String, Unturned.IBanEntry> bans)
        {
            MySqlTransaction transaction = m_Connection.BeginTransaction();
            MySqlCommand     cmd         = new MySqlCommand(
                "INSERT INTO `bans` " +
                "(`steamid`, " +
                "`ban_date`, " +
                "`nickname`, " +
                "`banned_by`, " +
                "`ban_time`, " +
                "`reason`" +
                ") VALUES (@SteamID, @BanDate, @Nick, @BannedBy, @BanTime, @Reason)",
                m_Connection, transaction);

            cmd.Prepare();

            foreach (KeyValuePair <String, IBanEntry> entry in bans)
            {
                IBanEntry ban = entry.Value as Unturned.IBanEntry;
                cmd.Parameters.AddWithValue("@SteamID", ban.SteamID);
                cmd.Parameters.AddWithValue("@BanDate", ban.BanTime);
                cmd.Parameters.AddWithValue("@Nick", ban.Name);
                cmd.Parameters.AddWithValue("@BannedBy", ban.BannedBy);
                cmd.Parameters.AddWithValue("@BanTime", System.DateTime.Now);
                cmd.Parameters.AddWithValue("@Reason", ban.Reason);
                cmd.ExecuteNonQuery();
            }

            transaction.Commit();
        }
コード例 #2
0
        public void AddBan(IBanEntry banEntry)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(BanEntry));
            MemoryStream  mStream    = new MemoryStream();

            serializer.Serialize(mStream, banEntry);
            mStream.Seek(0, SeekOrigin.Begin);
            Stream reader = new HttpRequest(m_host + m_banUrl).DoPost(new StreamReader(mStream).ReadToEnd());

            reader.Close();
        }
コード例 #3
0
        public void SaveBans(Dictionary <String, IBanEntry> bans)
        {
            FileStream   banFile = new FileStream(BAN_DATABASE_FILE, FileMode.Create);
            StreamWriter writer  = new StreamWriter(banFile);

            foreach (KeyValuePair <String, IBanEntry> pair in bans)
            {
                IBanEntry bannedPlayer = pair.Value;
                writer.WriteLine("{0} {1} {2} [{3}] [{4}]",
                                 bannedPlayer.SteamID,
                                 bannedPlayer.BanTime.ToString(DATE_PATTERN),
                                 bannedPlayer.BannedBy,
                                 bannedPlayer.Name,
                                 bannedPlayer.Reason);
            }

            writer.Flush();
            writer.Close();
            banFile.Close();
        }
コード例 #4
0
 public void AddBan(IBanEntry banEntry)
 {
     throw new NotImplementedException();
 }