Update
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
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))
|
||||
@@ -558,6 +558,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()
|
||||
{
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user