Exemplo n.º 1
0
        private void SavaData()
        {
            SetDefault();
            if (Names.Contains(textBoxImageName.Text) && path != "")
            {
                SetErrorMessage(labelImageName, "'Image Name': " + textBoxImageName.Text + " exists");
                return;
            }
            if (textBoxImageName.Text.IndexOfAny(new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }) != -1)
            {
                SetErrorMessage(labelImageName, "'Image Name' cannot contains \\ / : * ? \" < > |");
                return;
            }
            if (textBoxSourcePath.Text == "")
            {
                SetErrorMessage(labelSourcePath, "'Source Path' cannot be an empty string");
                return;
            }
            if (textBoxBootLabel.Text == "")
            {
                SetErrorMessage(labelBootLabel, "'Boot Label' cannot be an empty string");
                return;
            }
            if (textBoxBootLabel.Text.IndexOfAny(new char[] { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }) != -1)
            {
                SetErrorMessage(labelBootLabel, "'Boot Label' cannot contains \\ / : * ? \" < > |");
                return;
            }
            if (baseImage)
            {
                if (checkBoxVHDResize.IsChecked.Value && sliderPartitionDSize.Value < sliderVHDResizeSize.Value + 50)
                {
                    SetErrorMessage(checkBoxVHDResize, "Partition D size is too small, must be greater than " + (sliderVHDResizeSize.Value + 50));
                    return;
                }
                if (listBoxVHDNames.Items.Count == 0)
                {
                    SetErrorMessage(labelVHDName, "'VHD Name' cannot be an empty string");
                    return;
                }
                if (listBoxOSAbbrivations.Items.Count == 0)
                {
                    SetErrorMessage(labelOSAbrivations, "'OS Abrivations' cannot be an empty string");
                    return;
                }
                imageData.PartitionSize = (int)sliderPartitionDSize.Value;
                imageData.VHDResize     = checkBoxVHDResize.IsChecked.Value;
                imageData.VHDResizeSize = (int)sliderVHDResizeSize.Value;
                imageData.VHDNames.Clear();
                foreach (string VHDName in listBoxVHDNames.Items)
                {
                    imageData.VHDNames.Add(VHDName);
                }
                imageData.OSAbrivations.Clear();
                foreach (string OSAbrivation in listBoxOSAbbrivations.Items)
                {
                    imageData.OSAbrivations.Add(OSAbrivation);
                }
            }
            imageData.SourcePath = textBoxSourcePath.Text;
            imageData.BoolLabel  = textBoxBootLabel.Text;

            if (imageData.Name != textBoxImageName.Text && imageData.Name != "")
            {
                var createRenameDialog = new CreateRenameCancel();
                createRenameDialog.lblNewName.Content = textBoxImageName.Text;
                createRenameDialog.lblOldName.Content = imageData.Name;
                createRenameDialog.ShowDialog();
                if (createRenameDialog.renameOld)
                {
                    if (File.Exists(nodePath + "\\" + imageData.Name + ".my"))
                    {
                        File.Delete(nodePath + "\\" + imageData.Name + ".my");
                    }
                    imageData.Name = textBoxImageName.Text;
                    FileHandler.Save <ImageData>(imageData, nodePath + "\\" + imageData.Name + ".my");
                    this.Close();
                }
                if (createRenameDialog.createNew)
                {
                    imageData.Name = textBoxImageName.Text;
                    FileHandler.Save <ImageData>(imageData, nodePath + "\\" + imageData.Name + ".my");
                    this.Close();
                }
            }
            else
            {
                imageData.Name = textBoxImageName.Text;
                FileHandler.Save <ImageData>(imageData, nodePath + "\\" + imageData.Name + ".my");
                this.Close();
            }
        }
Exemplo n.º 2
0
 private bool Save()
 {
     if (SaveControl())
     {
         try {
             taskData.MachineGroup = labelMachineGroupContent.Content.ToString();
             LoadDataToList(listBoxTargetComputers, taskData.TargetComputers);
             taskData.BaseImageSourcePath         = textBoxBaseImage.Text;
             taskData.DestinationDirectoryInOS    = textBoxDestinationFolderInOS.Text;
             taskData.DestinationDirectoryInWINPE = textBoxDestinationFolderInWINPE.Text;
             taskData.DriveEImageSourcePath       = textBoxDriveEImage.Text;
             taskData.WakeOnLan                   = checkBoxWakeOnLan.IsChecked.Value;
             taskData.Configuration               = checkBoxConfiguration.IsChecked.Value;
             taskData.Cloning                     = checkBoxCloning.IsChecked.Value;
             taskData.ForceInstall                = checkBoxForceInstall.IsChecked.Value;
             taskData.ShutDown                    = checkBoxShutdown.IsChecked.Value;
             taskData.SoftwareAndFileAction       = checkBoxSOFA.IsChecked.Value;
             taskData.SoftwareAndFileAction_WINPE = checkBoxSOFAWinpe.IsChecked.Value;
             taskData.WithoutVHD                  = checkBoxWithoutVHD.IsChecked.Value;
             taskData.SendWarningMails            = checkBoxSendWarningMails.IsChecked.Value;
             taskData.InfinityWaitingTime         = checkBoxInfinityWaitingTime.IsChecked.Value;
             string[] commandsOS = StringFromRichTextBox(richTextBoxCommandsInOS).Split(new[] { Environment.NewLine }
                                                                                        , StringSplitOptions.RemoveEmptyEntries);
             taskData.CommandsInOS = new List <string>();
             taskData.CommandsInOS = new List <string>(commandsOS);
             LoadDataToList(listBoxCopyFilesInOS, taskData.CopyFilesInOS);
             LoadDataToList(listBoxCopyFilesInWINPE, taskData.CopyFilesInWINPE);
             string[] commandsWINPE = StringFromRichTextBox(richTextBoxCommandsInWINPE).Split(new[] { Environment.NewLine }
                                                                                              , StringSplitOptions.RemoveEmptyEntries);
             taskData.CommandsInWINPE = new List <string>(commandsWINPE);
             taskData.WaitingTime     = (int)slider.Value;
             if (taskData.Name != textBoxTaskName.Text && taskData.Name != "")
             {
                 var createRenameDialog = new CreateRenameCancel();
                 createRenameDialog.lblNewName.Content = textBoxTaskName.Text;
                 createRenameDialog.lblOldName.Content = taskData.Name;
                 createRenameDialog.ShowDialog();
                 if (createRenameDialog.renameOld)
                 {
                     if (File.Exists(nodePath + "\\" + taskData.Name + ".my"))
                     {
                         File.Delete(nodePath + "\\" + taskData.Name + ".my");
                     }
                     taskData.Name = textBoxTaskName.Text;
                     FileHandler.Save <TaskData>(taskData, nodePath + "\\" + taskData.Name + ".my");
                     return(true);
                 }
                 if (createRenameDialog.createNew)
                 {
                     taskData.Name = textBoxTaskName.Text;
                     FileHandler.Save <TaskData>(taskData, nodePath + "\\" + taskData.Name + ".my");
                     return(true);
                 }
             }
             else
             {
                 taskData.Name = textBoxTaskName.Text;
                 FileHandler.Save <TaskData>(taskData, nodePath + "\\" + taskData.Name + ".my");
                 return(true);
             }
             return(true);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
     return(false);
 }