Update
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
## 18-02-2025
|
||||
* Refactor: Обновлен settings.json
|
||||
* Feat: массовая перезагрузка ПК посредством запуска программы с определенным параметром (остался вопрос с работой с авторизацией)
|
||||
|
||||
## 17-02-2025
|
||||
* Fix: Исправлен баг с проверкой ввода на пустоту или пробелы
|
||||
* Refactor: Изменены регулярные выражения для форматирования имени ПК
|
||||
@@ -18,7 +22,7 @@
|
||||
|
||||
## 08-10-2024
|
||||
* Fix: Убраны проверки при вводе в ShowDomainUserInfo
|
||||
* Fix: Убрана очистка окна при ввода команды для выполнения в ExecuteCommandViaSSH
|
||||
* Fix: Убрана очистка окна при вводе команды для выполнения в ExecuteCommandViaSSH
|
||||
* Fix: Исправлен удаленный перезапуск ПК на Windows
|
||||
* Refactor: Небольшое изменение поведения ShowDomainUserInfo
|
||||
* Feat: Изменен заголовок окна программы на имя проекта
|
||||
|
||||
45
Program.cs
45
Program.cs
@@ -439,7 +439,7 @@ namespace domain_utility
|
||||
{
|
||||
string remote = InputData("\nВведите IP адрес или имя компьютера (пр. 10.234.16.129, 'IT04', '630300IT04', 'R54-630300IT04')\nall - для массового изменения",
|
||||
ChangeRemote802Password, withChecks: false);
|
||||
remote = remote.ToLower();
|
||||
remote = remote.Trim().ToLower();
|
||||
if (remote != "all")
|
||||
{
|
||||
if (!IsStringContainIp(remote))
|
||||
@@ -559,6 +559,16 @@ namespace domain_utility
|
||||
}
|
||||
}
|
||||
|
||||
private class JsonFile
|
||||
{
|
||||
//public string username = ""; // как получать и где хранить? задавать в файле?
|
||||
//public string password = ""; // где хранить и хранить ли?
|
||||
public int sleep_time = 0;
|
||||
public int restart_time = 0;
|
||||
public string message = "";
|
||||
public Dictionary<string, List<int>> everyday_reboot = null;
|
||||
}
|
||||
|
||||
private static void StartRestartComputers()
|
||||
{
|
||||
string path = Path.Combine(Environment.CurrentDirectory, "settings.json");
|
||||
@@ -568,28 +578,37 @@ namespace domain_utility
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
var data = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(path));
|
||||
string remote;
|
||||
int sleep_time = Convert.ToInt32(data.sleep_time);
|
||||
foreach (string item in data.pc_list)
|
||||
JsonFile data = JsonConvert.DeserializeObject<JsonFile>(File.ReadAllText(path));
|
||||
string remote, unitKey;
|
||||
int sleep_time = data.sleep_time;
|
||||
foreach (var unit in data.everyday_reboot)
|
||||
{
|
||||
remote = CheckComputerName(item.ToString());
|
||||
if (remote == string.Empty)
|
||||
unitKey = unit.Key;
|
||||
foreach (int position in unit.Value)
|
||||
{
|
||||
Console.WriteLine($"{item}: имя ПК не распознано.");
|
||||
continue;
|
||||
remote = CheckComputerName($"{unitKey}{(position < 10 ? $"0{position}" : position.ToString())}");
|
||||
if (remote == string.Empty)
|
||||
{
|
||||
Console.WriteLine($"{unitKey}{(position < 10 ? $"0{position}" : position.ToString())}: имя ПК не распознано.");
|
||||
continue;
|
||||
}
|
||||
//Console.WriteLine($"{remote}: shutdown -r +{data.restart_time} \"{data.message}\"");
|
||||
ExecuteCommandViaSSH(remote, $"sudo shutdown -r +{data.restart_time} \"{data.message}\"");
|
||||
Thread.Sleep(sleep_time);
|
||||
}
|
||||
//Console.WriteLine($"{remote}: shutdown -r +{data.restart_time} \"{data.message}\"");
|
||||
ExecuteCommandViaSSH(remote, $"sudo shutdown -r +{data.restart_time} \"{data.message}\"");
|
||||
Thread.Sleep(sleep_time);
|
||||
}
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
static void Main()
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Console.Title = typeof(Program).Assembly.GetName().Name;
|
||||
Console.Title = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyTitleAttribute>().Title;
|
||||
if (args[0] == "reboot")
|
||||
{
|
||||
StartRestartComputers();
|
||||
return;
|
||||
}
|
||||
Menu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"sleep_time" : 500,
|
||||
"sleep_time": 100,
|
||||
"restart_time": 1,
|
||||
"message": "Плановая перезагрузка компьютера через 1 минуту!",
|
||||
"pc_list" : [
|
||||
"IT01",
|
||||
"IT02",
|
||||
"630870MMP01",
|
||||
"R54-630870MMP02"
|
||||
]
|
||||
"everyday_reboot": {
|
||||
"PIS": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 30, 31, 32],
|
||||
|
||||
"OBR": [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 34, 37, 40, 78, 79, 81, 82, 83, 84, 85, 86, 88, 89, 93, 94, 95, 97, 98, 99],
|
||||
|
||||
"OBM": [9, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
|
||||
|
||||
"MMP": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 65, 66, 68, 70, 71, 72, 73, 74, 75, 77, 78, 81, 82, 83, 84, 85, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user