Example #1
0
        private bool SaveControl()
        {
            SetDefaultColors();
            if (textBoxTaskName.Text == "")
            {
                SetErrorMessage(labelTaskName, "'Task Name' cannot be an empty string\n");
                return(false);
            }
            if (textBoxTaskName.Text.IndexOfAny(new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }) != -1)
            {
                SetErrorMessage(labelTaskName, "'Task Name' cannot contains \\ / : * ? \" < > | \n");
                return(false);
            }
            if (Names.Contains(textBoxTaskName.Text))
            {
                SetErrorMessage(labelTaskName, "'Task Name': " + textBoxTaskName.Text + " exists\n");
                return(false);
            }
            List <string> LockComputers = Directory.GetFiles(@".\Machine Groups\Lock\", "*.my", SearchOption.AllDirectories).ToList();

            foreach (string LockComputer in LockComputers)
            {
                foreach (string computerName in listBoxTargetComputers.Items)
                {
                    if (LockComputer.Contains(computerName + ".my"))
                    {
                        SetErrorMessage(labelMachineGroup, "Computer: " + computerName + " is locked\n");
                        return(false);
                    }
                }
            }
            if (checkBoxCloning.IsChecked.Value && textBoxBaseImage.Text == "" && textBoxDriveEImage.Text == "")
            {
                tabItemGeneral.IsSelected = true;
                labelError.Content       += "Cloning is not properly set up\n";
                return(false);
            }
            return(true);
        }
Example #2
0
 private bool SaveControl()
 {
     try
     {
         SetDefaultColors();
         if (textBoxTaskName.Text == "")
         {
             SetErrorMessage(labelTaskName, "'Task Name' cannot be an empty string\n");
             return(false);
         }
         if (textBoxTaskName.Text.IndexOfAny(new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }) != -1)
         {
             SetErrorMessage(labelTaskName, "'Task Name' cannot contains \\ / : * ? \" < > | \n");
             return(false);
         }
         if (Names.Contains(textBoxTaskName.Text))
         {
             SetErrorMessage(labelTaskName, "'Task Name': " + textBoxTaskName.Text + " exists\n");
             return(false);
         }
         List <string> LockComputers = Directory.GetFiles(@".\Machine Groups\Lock\", "*.my", SearchOption.AllDirectories).ToList();
         foreach (string LockComputer in LockComputers)
         {
             foreach (ComputerDetailsData computer in listBoxTargetComputers.Items)
             {
                 if (LockComputer.Contains(computer.Name + ".my"))
                 {
                     SetErrorMessage(labelMachineGroup, "Computer: " + computer.Name + " is locked\n");
                     return(false);
                 }
             }
         }
         if (checkBoxCloning.IsChecked.Value && textBoxBaseImage.Text == "" && textBoxDriveEImage.Text == "")
         {
             tabItemGeneral.IsSelected = true;
             labelError.Content       += "Cloning is not properly set up\n";
             return(false);
         }
         if (checkBoxCloning.IsChecked.Value)
         {
             if (textBoxBaseImage.Text != "")
             {
                 if (!File.Exists(textBoxBaseImage.Text + ".my"))
                 {
                     labelError.Content += "Base image settings does not exist\n";
                     return(false);
                 }
                 else
                 {
                     taskData.BaseImageData = FileHandler.Load <ImageData>(textBoxBaseImage.Text + ".my");
                     if (!File.Exists(taskData.BaseImageData.SourcePath))
                     {
                         labelError.Content += "Source path of Base wim file does not exist\n";
                         return(false);
                     }
                 }
             }
             if (textBoxDriveEImage.Text != "")
             {
                 if (!File.Exists(textBoxDriveEImage.Text + ".my"))
                 {
                     labelError.Content += "DriveE image settings does not exist\n";
                     return(false);
                 }
                 else
                 {
                     taskData.DriveEImageData = FileHandler.Load <ImageData>(textBoxDriveEImage.Text + ".my");
                     if (!File.Exists(taskData.DriveEImageData.SourcePath))
                     {
                         labelError.Content += "Source path of DriveE wim file does not exist\n";
                         return(false);
                     }
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         return(false);
     }
 }