Fix some bugs

This commit is contained in:
Namhyeon Go 2025-02-09 22:05:43 +09:00
parent 4fd38e75c3
commit a3289cc81d
4 changed files with 37 additions and 20 deletions

View File

@ -60,7 +60,7 @@
// columnHeader2 // columnHeader2
// //
this.columnHeader2.Text = "FirstDeployTime"; this.columnHeader2.Text = "FirstDeployTime";
this.columnHeader2.Width = 180; this.columnHeader2.Width = 160;
// //
// btnDelete // btnDelete
// //

View File

@ -32,11 +32,11 @@ namespace WelsonJS.Launcher
foreach (string dir in Directory.GetDirectories(instancesRoot)) foreach (string dir in Directory.GetDirectories(instancesRoot))
{ {
string launcherFile = Path.Combine(dir, ".welsonjs_launcher"); string timestampFile = Path.Combine(dir, ".welsonjs_first_deploy_time");
if (File.Exists(launcherFile)) if (File.Exists(timestampFile))
{ {
string firstDeployTime = File.ReadAllText(launcherFile).Trim(); string firstDeployTime = File.ReadAllText(timestampFile).Trim();
ListViewItem item = new ListViewItem(new[] { ListViewItem item = new ListViewItem(new[] {
Path.GetFileName(dir), Path.GetFileName(dir),
firstDeployTime firstDeployTime
@ -56,6 +56,9 @@ namespace WelsonJS.Launcher
string selectedInstance = listView1.SelectedItems[0].Text; string selectedInstance = listView1.SelectedItems[0].Text;
string workingDirectory = Path.Combine(instancesRoot, selectedInstance); string workingDirectory = Path.Combine(instancesRoot, selectedInstance);
// If it is created the sub-directory
workingDirectory = Program.GetFinalDirectory(workingDirectory);
Task.Run(() => Task.Run(() =>
{ {
try try
@ -69,6 +72,10 @@ namespace WelsonJS.Launcher
} }
}); });
} }
else
{
MessageBox.Show("No selected an instance");
}
} }
private void btnDelete_Click(object sender, EventArgs e) private void btnDelete_Click(object sender, EventArgs e)
@ -84,6 +91,10 @@ namespace WelsonJS.Launcher
LoadInstances(); LoadInstances();
} }
} }
else
{
MessageBox.Show("No selected an instance");
}
} }
private void btnOpenWithExplorer_Click(object sender, EventArgs e) private void btnOpenWithExplorer_Click(object sender, EventArgs e)
@ -98,6 +109,10 @@ namespace WelsonJS.Launcher
System.Diagnostics.Process.Start("explorer", workingDirectory); System.Diagnostics.Process.Start("explorer", workingDirectory);
} }
} }
else
{
MessageBox.Show("No selected an instance");
}
} }
private void checkBox1_CheckedChanged(object sender, EventArgs e) private void checkBox1_CheckedChanged(object sender, EventArgs e)

View File

@ -27,6 +27,7 @@ namespace WelsonJS.Launcher
button1.Enabled = true; button1.Enabled = true;
button2.Enabled = true; button2.Enabled = true;
checkBox1.Enabled = true; checkBox1.Enabled = true;
checkBox2.Enabled = true;
if (checkBox1.Checked) if (checkBox1.Checked)
{ {
textBox1.Enabled = true; textBox1.Enabled = true;
@ -39,6 +40,7 @@ namespace WelsonJS.Launcher
button1.Enabled = false; button1.Enabled = false;
button2.Enabled = false; button2.Enabled = false;
checkBox1.Enabled = false; checkBox1.Enabled = false;
checkBox2.Enabled = false;
textBox1.Enabled = false; textBox1.Enabled = false;
} }
@ -87,7 +89,7 @@ namespace WelsonJS.Launcher
RecordFirstDeployTime(workingDirectory); RecordFirstDeployTime(workingDirectory);
// If it is created the sub-directory // If it is created the sub-directory
workingDirectory = GetFinalDirectory(workingDirectory); workingDirectory = Program.GetFinalDirectory(workingDirectory);
// Run the appliction // Run the appliction
Program.RunCommandPrompt(workingDirectory, entryFileName, scriptName, checkBox1.Checked, checkBox2.Checked); Program.RunCommandPrompt(workingDirectory, entryFileName, scriptName, checkBox1.Checked, checkBox2.Checked);
@ -110,7 +112,7 @@ namespace WelsonJS.Launcher
{ {
try try
{ {
string filePath = Path.Combine(directory, ".welsonjs_launcher"); string filePath = Path.Combine(directory, ".welsonjs_first_deploy_time");
string text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
File.WriteAllText(filePath, text); File.WriteAllText(filePath, text);
@ -137,19 +139,6 @@ namespace WelsonJS.Launcher
return filePath; return filePath;
} }
private string GetFinalDirectory(string path)
{
string[] directories = Directory.GetDirectories(path);
while (directories.Length == 1)
{
path = directories[0];
directories = Directory.GetDirectories(path);
}
return path;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e) private void checkBox1_CheckedChanged(object sender, EventArgs e)
{ {
textBox1.Enabled = checkBox1.Checked; textBox1.Enabled = checkBox1.Checked;

View File

@ -16,7 +16,7 @@ namespace WelsonJS.Launcher
Application.Run(new MainForm()); Application.Run(new MainForm());
} }
public static void RunCommandPrompt(string workingDirectory, string entryFileName, string scriptName, bool isConsoleApplication = true, bool isInteractiveServiceAapplication = false) public static void RunCommandPrompt(string workingDirectory, string entryFileName, string scriptName, bool isConsoleApplication = false, bool isInteractiveServiceAapplication = false)
{ {
if (!isConsoleApplication) if (!isConsoleApplication)
{ {
@ -75,5 +75,18 @@ namespace WelsonJS.Launcher
process.StandardInput.Close(); process.StandardInput.Close();
process.WaitForExit(); process.WaitForExit();
} }
public static string GetFinalDirectory(string path)
{
string[] directories = Directory.GetDirectories(path);
while (directories.Length == 1)
{
path = directories[0];
directories = Directory.GetDirectories(path);
}
return path;
}
} }
} }