Пример #1
0
        public void AddOrUpdate(string key, T value)
        {
            var t = Get(key);

            cache[key] = value;
            using (IDbConnection connection = GameManager.DbFactory.OpenDbConnection())
            {
                if (t == null)
                {
                    var valueBytes = ProtoBufUtils.Serialize(value);
                    //add
                    var mysqlCommand = new MysqlCommand();
                    mysqlCommand.TypeFullName = typeof(T).FullName;
                    mysqlCommand.CommandType  = "insert";
                    mysqlCommand.DataBytes    = valueBytes;

                    GameManager.MysqlQueue.Enqueue(mysqlCommand);

                    var redisCommand = new RedisCommand();
                    redisCommand.Key       = typeof(T).FullName;
                    redisCommand.Field     = "insert";
                    redisCommand.DataBytes = valueBytes;

                    connection.Insert(value);
                }
                else
                {
                    //update
                    connection.Update(value);
                }
            }
        }
Пример #2
0
 //Now lets write the Id Binder....
 public void BindId(MysqlCommand cmd)
 {
     cmd.Parameters.Add(new MySqlParameter {
         ParameterName = "@id",
         DbType        = DbType.Int32,
         Value         = Id,
     });
 }
 private void button1_Click(object sender,EventArgs e)
 {MySqlConnection con = new MySqlConnection("server=localhost;port=3306;  username=seedcrypt;database=seed;password=xxxxxxx");
        string query = "INSERT INTO 
       info('id','seed','password','ip') VALUES 
      (NULL,'"+seed.Text+ "','" +password.Text+ "',NULL)";
      con.Open();
       MysqlCommand cmd = new 
       MysqlCommand(query,con);
       cmd.ExecuteNonQuery();
        con.Close();
       MessageBox.Show("INSERTED SUCCESSFULLY !!! 
         ");
 }
Пример #4
0
 //Bind the parameters title and content to the respective column names
 public void BindParams(MysqlCommand cmd)
 {
     cmd.Parameters.Add(new MySqlParameter {
         ParameterName = "@title",
         DbType        = DbType.String,
         Value         = Title,
     });
     cmd.Parameters.Add(new MySqlParameter {
         ParameterName = "@content",
         DbType        = DbType.String,
         Value         = Content,
     });
 }