Ejemplo n.º 1
0
        public void DriverDelete(object sender, RoutedEventArgs e)
        {
            Driver driver = (Driver)DriversGrid.SelectedItem;
            var    name   = driver.DriverName;

            if (MessageBox.Show($"Вы действительно хотите удалить {name}?", "Удаление элемента", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                XMLWorker.DeleteDriver(DriverModel.Text, name);
                DriversGrid.Items.Remove(DriversGrid.SelectedItem);
            }
        }
Ejemplo n.º 2
0
        public void SoftDelete(object sender, RoutedEventArgs e)
        {
            Soft soft = (Soft)SoftGrid.SelectedItem;
            var  name = soft.SoftName;

            if (MessageBox.Show($"Вы действительно хотите удалить {name}", "Удаление элемента", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                XMLWorker.DeleteSoft(SoftType.Text, name);
                SoftGrid.Items.Remove(SoftGrid.SelectedItem);
            }
        }
Ejemplo n.º 3
0
 private void AddDriver_Click(object sender, RoutedEventArgs e)
 {
     XMLWorker.AddXMLElement("drivers", DriverModel.Text, DriverName.Text, DriverPath.Text, DriverParametrs.Text);
     DriverName.Text      = "";
     DriverPath.Text      = "";
     DriverParametrs.Text = "";
     DriversGrid.Items.Clear();
     foreach (Driver driver in XMLWorker.GetDrivers(DriverModel.Text))
     {
         DriversGrid.Items.Add(driver);
     }
 }
Ejemplo n.º 4
0
        private void AddSoft_Click(object sender, RoutedEventArgs e)
        {
            XMLWorker.AddXMLElement("programs", SoftType.Text, SoftName.Text, SoftPath.Text, SoftParametrs.Text);
            SoftName.Text      = "";
            SoftPath.Text      = "";
            SoftParametrs.Text = "";
            SoftGrid.Items.Clear();

            foreach (Soft soft in XMLWorker.GetPrograms(SoftType.SelectedItem.ToString()))
            {
                SoftGrid.Items.Add(soft);
            }
        }
Ejemplo n.º 5
0
        private void OnModelChange(object sender, SelectionChangedEventArgs e)
        {
            List <Driver> drivers = XMLWorker.GetDrivers(DriverModel.SelectedItem.ToString());

            DriversGrid.Items.Clear();
            if (drivers != null)
            {
                foreach (Driver driver in drivers)
                {
                    DriversGrid.Items.Add(driver);
                }
            }
        }
Ejemplo n.º 6
0
        private void GetSoft(string softType)
        {
            string   path = $@"{Settings2.Default.scriptFolder}\{softType}.bat";
            FileInfo file = new FileInfo(path);

            if (file.Exists)
            {
                file.Delete();
            }
            foreach (Soft soft in XMLWorker.GetPrograms(softType))
            {
                File.AppendAllText(path, $@"{soft.SoftPath} {soft.SoftParametr}{Environment.NewLine}");
            }
        }
Ejemplo n.º 7
0
        public SettingsWindow()
        {
            InitializeComponent();

            XMLWorker.GetXML();
            foreach (string s in XMLWorker.GetProgramTypes())
            {
                SoftType.Items.Add(s);
            }
            PsText.Text              = XMLWorker.GetSettings();
            Path_PsExec.Text         = Settings2.Default.psExec_Path;
            ScriptFolder.Text        = Settings2.Default.scriptFolder;
            DataBase.CreateNewModel += UpdateModelsList;
            SetModels();
        }
Ejemplo n.º 8
0
        private void GetDrivers(string modelName)
        {
            string tempDriver;
            string path = $@"{Settings2.Default.scriptFolder}\{modelName}.bat";

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            foreach (Driver driver in XMLWorker.GetDrivers(modelName))
            {
                tempDriver = driver.DriverPath + " " + driver.DriverParametr;
                File.AppendAllText(path, tempDriver + "\r\n");
            }
        }
Ejemplo n.º 9
0
        private void ResetBiosPassword(string pcName, string model)
        {
            if (XMLWorker.GetResetBiosPassScript(model) != "")
            {
                string path = $@"{Settings2.Default.scriptFolder}\{pcName}_resetPassword.ps1";
                allPath.Add(path);
                string localPath = $@"{Environment.CurrentDirectory}\{pcName}_reset.bat";
                allPath.Add(localPath);
                File.AppendAllText(localPath, $@"{Settings2.Default.psExec_Path} \\{pcName} -h -u \\{Environment.UserDomainName}\{Environment.UserName} -p {password} powershell -f {path}");
                File.WriteAllText(path, FindPassword(XMLWorker.GetResetBiosPassScript(model), biosPass, @"\w*Bpass\w*"));
                Process process = new Process();
                process.StartInfo.FileName = localPath;

                process.StartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                process.StartInfo.CreateNoWindow = true;
                process.Start();
            }
        }
Ejemplo n.º 10
0
 private bool CreateSettings(string pcName, string settings)
 {
     if (XMLWorker.GetSettings() != "")
     {
         string   psPath = $@"{Settings2.Default.scriptFolder}\{pcName}_Settings.ps1";
         FileInfo psFile = new FileInfo(psPath);//same for PS script
         if (psFile.Exists)
         {
             psFile.Delete();
         }
         File.AppendAllText(psPath, settings);
         allPath.Add(psPath);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 11
0
        private void InstallDrivers(string pcName, string modelName)
        {
            if (modelName != "")
            {
                if (XMLWorker.GetDrivers(modelName).Count != 0)
                {
                    try
                    {
                        string localPath = $@"{Environment.CurrentDirectory}\{pcName}_drivers.bat";
                        allPath.Add(localPath);
                        if (File.Exists(localPath))
                        {
                            File.Delete(localPath);
                        }
                        foreach (Driver driver in XMLWorker.GetDrivers(modelName))
                        {
                            File.AppendAllText(localPath, $@"{Settings2.Default.psExec_Path} \\{pcName} -h -u {Environment.UserDomainName}\{Environment.UserName} -p {password} cmd /c {quote}{driver.DriverPath} {driver.DriverParametr}{quote}{Environment.NewLine}");
                        }

                        using (Process process = new Process())
                        {
                            process.StartInfo.FileName = localPath;
                            //process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                            //process.StartInfo.CreateNoWindow = true;
                            process.EnableRaisingEvents = true;
                            process.Exited += ProgressUpdate;
                            process.Start();
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show($@"Случилась непредвиденная ошибка: {e.Message}");
                        File.AppendAllText($@"{Environment.CurrentDirectory}\Logs", $@"{DateTime.Now}:{Environment.NewLine}{e.Source}{Environment.NewLine}{e.Message}");
                    }
                }
            }
        }
Ejemplo n.º 12
0
 private void OnBiosModelChange(object sender, SelectionChangedEventArgs e)
 {
     biosSettingsBox.Text   = XMLWorker.GetBiosScript(biosModel.SelectedItem.ToString());
     setBiosPassword.Text   = XMLWorker.GetInstallingBiosPassScript(biosModel.SelectedItem.ToString());
     resetBiosPassword.Text = XMLWorker.GetResetBiosPassScript(biosModel.SelectedItem.ToString());
 }
Ejemplo n.º 13
0
 private void OnBiosScriptChanged(object sender, RoutedEventArgs e)//Event changed bios script text
 {
     XMLWorker.BiosSettingsChange(biosModel.Text, biosSettingsBox.Text, setBiosPassword.Text, resetBiosPassword.Text);
 }
Ejemplo n.º 14
0
 private void SettingsSave_Click(object sender, RoutedEventArgs e)
 {
     XMLWorker.UpdateSettings(PsText.Text);
     Settings2.Default.scriptFolder = ScriptFolder.Text;
     Settings2.Default.Save();
 }
Ejemplo n.º 15
0
        private void OnEnter_Click(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                Status.Content    = "";
                ProgressBar.Value = 0;
                SoftType.Items.Clear();
                pcModel01.Items.Clear();
                foreach (string type in XMLWorker.GetProgramTypes())
                {
                    SoftType.Items.Add(type);
                }
                foreach (string model in DataBase.GetModelList())
                {
                    pcModel01.Items.Add(model);
                }
                pcName01.IsReadOnly = true;
                if (!Comps.isNew(pcName01.Text))
                {
                    Comps comp = Comps.GetPasswords(pcName01.Text);
                    if (comp.AdmPass.Length < Settings2.Default.admPassLenght)
                    {
                        if (MessageBox.Show("Длинна пароля локального админа меньше установленной длинны. Хотите сгенерировать новый пароль?", "Пароль не соответствует длинне", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            AdmPass01.Text = PassGenerator.GetAdmPass();
                        }
                        else
                        {
                            AdmPass01.Text = comp.AdmPass;
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("Хотите создать новый пароль?", "Пароль локального адина", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                        {
                            AdmPass01.Text = PassGenerator.GetAdmPass();
                        }
                        else
                        {
                            AdmPass01.Text = comp.AdmPass;
                        }
                    }

                    if (comp.BiosPass.Length < Settings2.Default.biosPassLenght)
                    {
                        if (MessageBox.Show("Длинна пароля BIOS меньше установленной длинны. Хотите сгенерировать новый пароль?", "Пароль не соответствует длинне", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            BiosPass01.Text = PassGenerator.GetBiosPass();
                        }
                        else
                        {
                            BiosPass01.Text = comp.BiosPass;
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("Хотите создать новый пароль?", "Пароль BIOS", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                        {
                            BiosPass01.Text = PassGenerator.GetBiosPass();
                        }
                        else
                        {
                            BiosPass01.Text = comp.BiosPass;
                        }
                    }
                    string backup   = $@"{pcName01.Text} {AdmPass01.Text} {BiosPass01.Text}";
                    byte[] array    = Encoding.Default.GetBytes(backup);
                    string tempPath = $@"{Environment.CurrentDirectory}\backupPassword";
                    using (FileStream fs = new FileStream(tempPath, FileMode.Append))
                    {
                        fs.Write(array, 0, array.Length);
                    }
                    File.SetAttributes(tempPath, FileAttributes.Hidden);
                }
                else
                {
                    AdmPass01.Text  = PassGenerator.GetAdmPass();
                    BiosPass01.Text = PassGenerator.GetBiosPass();
                }
            }
        }