private void 过滤KeyToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode select = treeView1.SelectedNode; if (select == null) { return; } if (select.ImageKey != "redis_db") { return; } if (select.Tag is DbSettings dbSettings) { using (FormInputString formInput = new FormInputString( )) { formInput.TextInfo = "请输入新的过滤条件:"; formInput.InputValue = dbSettings.Filter; if (formInput.ShowDialog( ) == DialogResult.OK) { dbSettings.Filter = formInput.InputValue; RefreshDbKeys(select, true); } } } }
private void Button_move_Click(object sender, EventArgs e) { if (redisClient != null) { using (FormInputString formInput = new FormInputString( )) { formInput.TextInfo = "等待输入新的DB块号:"; if (formInput.ShowDialog( ) == DialogResult.OK) { if (int.TryParse(formInput.InputValue, out int db)) { OperateResult ttl = redisClient.MoveKey(keyName, db); if (!ttl.IsSuccess) { MessageBox.Show("移动关键字失败!" + ttl.Message); } else { MessageBox.Show("移动关键字成功!"); } } else { MessageBox.Show("移动关键字失败,在DB块里需要输入数字!"); } } } } }
private void 修改密码ToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode select = treeView1.SelectedNode; if (select == null) { return; } if (select.ImageKey != "VirtualMachine") { return; } if (select.Tag is RedisSettings redisSettings) { if (redisSettings.Redis == null) { redisSettings.Redis = redisSettings.GetClient( ); OperateResult connect = redisSettings.Redis.ConnectServer( ); if (!connect.IsSuccess) { MessageBox.Show($"连接Redis[{redisSettings.Name}] IpAddress:{redisSettings.IpAddress} 失败!"); return; } } FormInputString form = new FormInputString( ); form.TextInfo = "请输入新的密码:"; if (form.ShowDialog() == DialogResult.OK) { OperateResult change; if (string.IsNullOrEmpty(form.InputValue)) { change = redisSettings.Redis.ReadCustomer("CONFIG SET requirepass "); } else { change = redisSettings.Redis.ReadCustomer("CONFIG SET requirepass " + form.InputValue); } if (change.IsSuccess) { MessageBox.Show("修改密码成功!"); redisSettings.Password = form.InputValue; if (redisSettings.Redis != null) { redisSettings.Redis.ConnectClose( ); redisSettings.Redis = null; } SaveRedisSettings( ); RefreshRedisKey(select, true); } else { MessageBox.Show("修改密码失败!" + change.Message); } } } }
private void Button_ttl_Click(object sender, EventArgs e) { if (redisClient != null) { using (FormInputString formInput = new FormInputString( )) { formInput.TextInfo = "等待输入新的超时时间,单位秒,-1为永久:"; if (formInput.ShowDialog( ) == DialogResult.OK) { if (formInput.InputValue == "-1") { OperateResult ttl = redisClient.PersistKey(keyName); if (!ttl.IsSuccess) { MessageBox.Show("设置永久失败!" + ttl.Message); } else { MessageBox.Show("设置永久成功!"); } } else { if (int.TryParse(formInput.InputValue, out int seconds)) { OperateResult ttl = redisClient.ExpireKey(keyName, seconds); if (!ttl.IsSuccess) { MessageBox.Show("设置过期时间失败!" + ttl.Message); } else { MessageBox.Show("设置过期时间成功!"); } } else { MessageBox.Show("过期时间输入失败,需要输入数字!"); } } } } } }
private void ActivateToolStripMenuItem_Click(object sender, EventArgs e) { FormInputString form = new FormInputString( ); form.TextInfo = "请输入激活码:"; if (form.ShowDialog( ) == DialogResult.OK) { if (HslCommunication.Authorization.SetAuthorizationCode(form.InputValue)) { File.WriteAllText(Path.Combine(Application.StartupPath, "code.txt"), HslCommunication.BasicFramework.SoftSecurity.MD5Encrypt(form.InputValue, "1234asdf"), Encoding.UTF8); activateToolStripMenuItem.Text = "Activated"; activateToolStripMenuItem.ForeColor = Color.White; } else { MessageBox.Show("Wrong Code"); } } }
private void Button_rename_Click(object sender, EventArgs e) { if (redisClient != null) { using (FormInputString formInput = new FormInputString( )) { formInput.TextInfo = "等待输入新的关键字名称:"; if (formInput.ShowDialog( ) == DialogResult.OK) { OperateResult rename = redisClient.RenameKey(keyName, formInput.InputValue); if (!rename.IsSuccess) { MessageBox.Show("重命名失败!" + rename.Message); } else { MessageBox.Show("重命名成功"); } } } } }