Skip to content

Commit

Permalink
v1.2更新完毕
Browse files Browse the repository at this point in the history
  • Loading branch information
GMYXDS committed Nov 1, 2022
1 parent 13b7a0f commit 31dfd29
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 27 deletions.
2 changes: 1 addition & 1 deletion MstscManager/Controls/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MstscManager.Controls {
public partial class About : UIPage {
string now_version = "1.2";
string now_version = Share.now_version;
string update_url = "";
public About() {
InitializeComponent();
Expand Down
19 changes: 15 additions & 4 deletions MstscManager/FMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 122 additions & 19 deletions MstscManager/FMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;

namespace MstscManager {
public partial class FMain : UIForm {
Expand Down Expand Up @@ -61,20 +62,26 @@ public FMain() {
check();
}
//迁移到v1.2
private void move_to_1_2() {
string? check = DbInihelper.GetIniData(iniconfig_action, "is_ask_move_1_2", iniconfig_path);
if (check == "1") return;
//1.询问,选择数据库位置

//2.导入数据库

//3.清除注册表
RegistryKey rkey = Registry.CurrentUser;
rkey.CreateSubKey(@"SOFTWARE\MstscManager");
rkey.DeleteSubKey(@"SOFTWARE\MstscManager");
//4.存储询问标志
DbInihelper.SetIniData(iniconfig_action, "is_ask_move_1_2", "1", iniconfig_path);
}
//private void move_to_1_2() {
// if (Share.now_version != "1.2") return;
// string? check = DbInihelper.GetIniData(iniconfig_action, "is_ask_move_1_2", iniconfig_path);
// if (check == "1") return;
// //1.询问,选择数据库位置
// if (ShowAskDialog("检测到首次打开v1.2是否自动导入v1.1数据!", false)) {
// //2.导入数据库
// string file_path = show_dialog_db();
// if (file_path == "") return;
// } else {
// DbInihelper.SetIniData(iniconfig_action, "is_ask_move_1_2", "1", iniconfig_path);
// return;
// }
// //3.清除注册表
// //RegistryKey rkey = Registry.CurrentUser;
// //rkey.CreateSubKey(@"SOFTWARE\MstscManager");
// //rkey.DeleteSubKey(@"SOFTWARE\MstscManager");
// //4.存储询问标志
// DbInihelper.SetIniData(iniconfig_action, "is_ask_move_1_2", "1", iniconfig_path);
//}

private void check() {
//注册表拿到是否需要开启输入密码配置
Expand Down Expand Up @@ -175,7 +182,7 @@ private void init_db() {
//Stopwatch watch = new Stopwatch();
//watch.Start();
//DbSqlHelper.common_transaction = DbSqlHelper.common_conn.BeginTransaction();
DbSqlHelper.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS Group_setting( ID integer PRIMARY KEY AUTOINCREMENT , group_name TEXT);");
DbSqlHelper.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS Group_setting( ID integer PRIMARY KEY AUTOINCREMENT , group_name TEXT,group_head_id TEXT);");
DbSqlHelper.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS Commom_setting( ID integer PRIMARY KEY AUTOINCREMENT , key TEXT, val TEXT);");
DbSqlHelper.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS User_setting( ID integer PRIMARY KEY AUTOINCREMENT , user_name TEXT, user_pass TEXT, mark_text TEXT);");
DbSqlHelper.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS Server_setting( ID integer PRIMARY KEY AUTOINCREMENT , server_name TEXT, group_id integer, connect_type TEXT, ip TEXT, port TEXT, user_name TEXT, user_pass TEXT, end_date TEXT,mark_text TEXT,user_id integer,connect_setting TEXT,connect_string TEXT);");
Expand Down Expand Up @@ -225,14 +232,28 @@ private void init_group_name() {
this.uiTreeView1.Nodes.Add("all", "全部分类", 0, 1);
this.uiComboBox2.Items.Add("全部分类");
this.uiComboBox2.Text = "全部分类";

SqliteDataReader reader = DbSqlHelper.ExecuteReader("select * from Group_setting");
//if (DbSqlHelper.common_conn.State != ConnectionState.Open) DbSqlHelper.common_conn.Open();
//DbSqlHelper.common_transaction = DbSqlHelper.common_conn.BeginTransaction();
SqliteDataReader reader = DbSqlHelper.ExecuteReader2("select * from Group_setting where group_head_id = -1");
while (reader.Read()) {
string group_name = (string)reader["group_name"];
this.uiTreeView1.Nodes.Add(group_name, group_name, 0, 1);
uiComboBox2.Items.Add(group_name);
//添加子分类
TreeNode parent_node = this.uiTreeView1.Nodes[group_name];
//Console.WriteLine(parent_node.Text);
SqliteDataReader reader2 = DbSqlHelper.ExecuteReader2("select * from Group_setting where group_head_id = ?", Convert.ToInt32(reader["id"]));
if (reader2 == null) continue;
while (reader2.Read()) {
string goup_name_sec = (string)reader2["group_name"];
parent_node.Nodes.Add(goup_name_sec, goup_name_sec, 0, 1);
uiComboBox2.Items.Add(goup_name_sec);
}
reader2.Close();
}
reader.Close();
//DbSqlHelper.common_transaction.Commit();
//DbSqlHelper.common_transaction = null;
}
public void init_server_table() {
clear_old_info();
Expand Down Expand Up @@ -313,11 +334,76 @@ private void FMain_Load(object sender, EventArgs e) {
Share.fm = this;
}
private void 添加分类ToolStripMenuItem_Click(object sender, EventArgs e) {
TreeNode parent_node = uiTreeView1.SelectedNode.Parent;
//如果父节点不为顶级节点,需要查询父节点id
int head_group_id = -1;
if (parent_node != null) {
SqliteDataReader reader = DbSqlHelper.ExecuteReader("select * from Group_setting where group_name = ?", parent_node.Text.ToString());
bool flag = reader.Read();
if (flag) {
head_group_id = Convert.ToInt32(reader["id"]);
}
reader.Close();
if (head_group_id == -1) {
ShowErrorTip("没有查询到该父级分组!");
return;
}
}
string group_name = "";
if (this.InputStringDialog(ref group_name, true, "请输入分组名称:", false)) {
if (group_name == "") return;
DbSqlHelper.ExecuteNonQuery("insert into Group_setting (group_name) values (?)", group_name);
this.uiTreeView1.Nodes.Add(group_name, group_name, 0, 1);

//创建一个节点对象,并初始化
TreeNode tmp = new TreeNode(group_name, 0, 1);
//在TreeView组件中加入子节点
uiTreeView1.SelectedNode.Nodes.Add(tmp);
uiTreeView1.SelectedNode = tmp;
//uiTreeView1.ExpandAll();

DbSqlHelper.ExecuteNonQuery("insert into Group_setting (group_name,group_head_id) values (?,?)", group_name, head_group_id);
if(parent_node==null)
uiTreeView1.Nodes.Add(group_name, group_name, 0, 1);
else
uiTreeView1.SelectedNode.Parent.Nodes.Add(tmp);
uiComboBox2.Items.Add(group_name);
}
}
private void 添加子分类ToolStripMenuItem_Click(object sender, EventArgs e) {
TreeNode parent_node = uiTreeView1.SelectedNode.Parent;
if (parent_node!= null) {
ShowInfoTip("暂只支持2级分类");
return;
}
string head_group_name = uiTreeView1.SelectedNode.Text.ToString();
if (head_group_name == "全部分类") {
ShowInfoTip("全部分类下不支持添加子分类");
return;
}
string group_name = "";
if (this.InputStringDialog(ref group_name, true, "请输入分组名称:", false)) {
if (group_name == "") return;
//拿到head节点,head节点id
SqliteDataReader reader = DbSqlHelper.ExecuteReader("select * from Group_setting where group_name = ?", head_group_name);
int head_group_id = -1;
bool flag = reader.Read();
if (flag) {
head_group_id = Convert.ToInt32(reader["id"]);
}
reader.Close();
if (head_group_id == -1) {
ShowErrorTip("没有查询到该分组!");
return;
}

//创建一个节点对象,并初始化
TreeNode tmp = new TreeNode(group_name, 0, 1);
//在TreeView组件中加入子节点
uiTreeView1.SelectedNode.Nodes.Add(tmp);
uiTreeView1.SelectedNode = tmp;
//uiTreeView1.ExpandAll();

DbSqlHelper.ExecuteNonQuery("insert into Group_setting (group_name,group_head_id) values (?,?)", group_name, head_group_id);
//this.uiTreeView1.Nodes.Add(group_name, group_name, 0, 1);
this.uiComboBox2.Items.Add(group_name);
}
}
Expand All @@ -329,6 +415,10 @@ private void 删除分类ToolStripMenuItem_Click(object sender, EventArgs e) {
UIMessageDialog.ShowMessageDialog("全部分类无需删除!", "提示", false, Style,false);
return;
}
if (uiTreeView1.SelectedNode.Nodes.Count != 0 ) {
ShowInfoTip("请先删除此节点中的子节点!");
return;
}
if (ShowAskDialog("确定要删除<"+select_name+">分类吗?",false)) {
SqliteDataReader reader = DbSqlHelper.ExecuteReader("select * from Group_setting where group_name = ?", select_name);
int group_id = -1;
Expand Down Expand Up @@ -398,6 +488,7 @@ private void uiTreeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventAr
if (flag) { group_id = Convert.ToInt32(reader["id"]); current_group_id = reader["id"].ToString(); }
reader.Close();
if (group_id == -1) { ShowErrorTip("没有查询到该分组!"); return; }
if (uiTreeView1.SelectedNode.Nodes.Count != 0) uiTreeView1.SelectedNode.ExpandAll();
Share.now_group_name = group_name;
load_server_table("select * from Server_setting where group_id = ?", group_id);
}
Expand Down Expand Up @@ -513,6 +604,15 @@ private string show_dialog() {
ofd.ShowDialog();
return ofd.FileName;
}
private string show_dialog_db() {
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "请选择对应的数据库文件";
//ofd.Multiselect = true;
ofd.InitialDirectory = System.Environment.CurrentDirectory;
ofd.Filter = "所有文件|*.db|所有文件|*.*";
ofd.ShowDialog();
return ofd.FileName;
}
//其他功能-mstsc一键导入
public void simple_import() {
string tip_msg = "注意:一键导入只包括ip和端口,账号密码需要自己重新设置!";
Expand Down Expand Up @@ -1156,6 +1256,7 @@ private void FMain_FormClosing(object sender, FormClosingEventArgs e) {
e.Cancel = true;
tool_tip_show_once = "1";
} else {
if (File.Exists("data/MstscManager_temp.rdp")) File.Delete("data/MstscManager_temp.rdp");
return;
}
}
Expand Down Expand Up @@ -1246,5 +1347,7 @@ private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) {
internal void set_hide_behind(string status) {
is_hide_behind = status;
}


}
}
17 changes: 17 additions & 0 deletions MstscManager/Utils/DbSqlHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,29 @@ public static int ExecuteNonQuery(string cmdText, params object[] p) {
}
//}
}
public static int ExecuteNonQuery2(string cmdText, params object[] p) {
//if (common_conn == null) common_conn = new SqliteConnection(ConnectionString);
using (SqliteConnection conn = new SqliteConnection(ConnectionString)) {
using (SqliteCommand command = new SqliteCommand()) {
PrepareCommand(command, conn, cmdText, p);
return command.ExecuteNonQuery();
}
}
}
public static SqliteDataReader ExecuteReader(string cmdText, params object[] p) {
if(common_conn==null) common_conn = new SqliteConnection(ConnectionString);
SqliteCommand command = new SqliteCommand();
PrepareCommand(command, common_conn, cmdText, p);
return command.ExecuteReader(CommandBehavior.CloseConnection);

}
public static SqliteDataReader ExecuteReader2(string cmdText, params object[] p) {
//if (common_conn == null) common_conn = new SqliteConnection(ConnectionString);
SqliteConnection conn = new SqliteConnection(ConnectionString);
SqliteCommand command = new SqliteCommand();
PrepareCommand(command, conn, cmdText, p);
return command.ExecuteReader(CommandBehavior.CloseConnection);

}
//public static string ExecuteScalar(string cmdText, params object[] p) {
// using (SqliteConnection conn = new SqliteConnection(ConnectionString)) {
Expand Down
1 change: 1 addition & 0 deletions MstscManager/Utils/Share.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public static class Share {
public static string iniconfig_path = @"data\MstscManager.ini";
public static string iniconfig_action = "Settings";
public static string now_group_name = "全部分类";
public static string now_version = "1.2";
}
}
2 changes: 1 addition & 1 deletion MstscManager/Utils/common_tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static string pinghost(string host) {
}
public static string md5(string str) {
MD5 md5 = MD5.Create();
byte[] buffer = Encoding.Default.GetBytes(str);
byte[] buffer = Encoding.Default.GetBytes(str+"gmyxds");
byte[] MD5Buffer = md5.ComputeHash(buffer);
string strNew = "";
for (int i = 0; i < MD5Buffer.Length; i++) {
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ MSTSC远程管理器
- [x] 支持自定义命令
- [x] 三方EXE和数据库可以自由指定位置

### v1.2更新

- [x] 添加加配置导出自定义命令
- [x] 添加对MobaXterm,todesk的支持
- [x] 添加对putty-ssh,MobaXterm 密钥连接的支持
- [x] 添加对多级(二级)菜单分类的支持
- [x] 添加了对dpi缩放适配
- [x] 添加了当前分类详细情况的统计
- [x] 添加了托盘功能
- [x] 添加了批量检测
- [x] 优化导入导出txt卡顿问题,将txt导入导出改成了csv导入导出
- [x] 优化整体软件交互速度

## 如何下载

1)你可以下载源码,自行编译后使用。
Expand Down
18 changes: 16 additions & 2 deletions Updates.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
## v1.2

- 修复进入关于页面报错的问题
-
- [x] 修复进入关于页面报错的问题
- [x] 修复路径名有空格问题
- [x] 修复右下角临时连接服务器密码错误问题
- [x] 修复窗口最小尺寸问题
- [x] 所有配置当前目录化
- [x] 添加加配置导出自定义命令
- [x] 添加对MobaXterm,todesk的支持
- [x] 添加对putty-ssh,MobaXterm 密钥连接的支持
- [x] 添加对多级(二级)菜单分类的支持
- [x] 添加了对dpi缩放适配
- [x] 添加了当前分类详细情况的统计
- [x] 添加了托盘功能
- [x] 添加了批量检测
- [x] 优化导入导出txt卡顿问题,将txt导入导出改成了csv导入导出
- [x] 优化整体软件交互速度

0 comments on commit 31dfd29

Please sign in to comment.