Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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");
            }
        }
Exemplo n.º 4
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}");
                    }
                }
            }
        }