Exemplo n.º 1
0
        private void ButtonUploadRunbook_Click(object sender, RoutedEventArgs e)
        {
            AutomationRunbook selectedRunbook = (AutomationRunbook)RunbooksListView.SelectedItem;

            if (selectedRunbook == null)
            {
                MessageBox.Show("No runbook selected.");
                return;
            }
            ButtonUploadRunbook.IsEnabled = false;
            if (fileTransferQueue.TryAdd(new RunbookTransferJob(selectedRunbook, RunbookTransferJob.TransferOperation.Upload))) //TryAdd() immediately returns false if queue is at capacity
            {
                JobsRemainingLabel.Text = "(" + fileTransferQueue.Count + " tasks remaining)";
            }
            else
            {
                MessageBox.Show("Too many runbooks are waiting to be downloaded/uploaded right now. Hold your horses!");
            }
            /* Make sure the worker is alive, start a new one if not */
            if (fileTransferWorker == null || fileTransferWorker.Status == TaskStatus.Canceled || fileTransferWorker.Status == TaskStatus.Faulted)
            {
                fileTransferWorker = Task.Factory.StartNew(() => processJobsFromQueue(fileTransferWorkerProgress), TaskCreationOptions.LongRunning);
            }
            ButtonUploadRunbook.IsEnabled = true;
        }
Exemplo n.º 2
0
        private async void ButtonPublishRunbook_Click(object sender, RoutedEventArgs e)
        {
            AutomationRunbook selectedRunbook = (AutomationRunbook)RunbooksListView.SelectedItem;

            if (selectedRunbook == null)
            {
                MessageBox.Show("No runbook selected.");
                return;
            }
            try
            {
                /* Update UI */
                ButtonPublishRunbook.IsEnabled  = false;
                ButtonDownloadRunbook.IsEnabled = false;
                ButtonUploadRunbook.IsEnabled   = false;
                ButtonPublishRunbook.Content    = "Publishing...";
                /* Do the uploading */
                await AutomationRunbookManager.PublishRunbook(selectedRunbook, iseClient.automationManagementClient,
                                                              iseClient.accountResourceGroups[iseClient.currAccount].Name, iseClient.currAccount.Name);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The runbook could not be published.\r\nDetails: " + ex.Message, "Error");
            }
            finally
            {
                /* Update UI */
                RunbooksListView.Items.Refresh();
                ButtonPublishRunbook.IsEnabled  = true;
                ButtonDownloadRunbook.IsEnabled = true;
                ButtonUploadRunbook.IsEnabled   = true;
                ButtonPublishRunbook.Content    = "Publish Draft";
            }
        }
        public JobOutputWindow(AutomationRunbook runbook, AutomationISEClient client, int refreshTimerValue)
        {
            InitializeComponent();
            StartJobButton.IsEnabled = true;
            StopJobButton.IsEnabled  = false;
            this.Title = runbook.Name + " Test Job";
            AdditionalInformation.Text = "Tip: not seeing Verbose output? Add the line \"$VerbosePreference='Continue'\" to your runbook.";
            runbookName    = runbook.Name;
            runbookType    = runbook.RunbookType;
            iseClient      = client;
            jobParams.Time = DateTime.UtcNow.AddDays(-30).ToString("o");
            Task t = checkTestJob(true);

            refreshTimer          = new System.Timers.Timer();
            refreshTimer.Interval = refreshTimerValue;
            refreshTimer.Elapsed += new ElapsedEventHandler(refresh);
        }
Exemplo n.º 4
0
        private void ButtonOpenRunbook_Click(object sender, RoutedEventArgs e)
        {
            AutomationRunbook selectedRunbook = (AutomationRunbook)RunbooksListView.SelectedItem;

            if (selectedRunbook == null)
            {
                MessageBox.Show("No runbook selected.");
                return;
            }
            try
            {
                HostObject.CurrentPowerShellTab.Files.Add(selectedRunbook.localFileInfo.FullName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The runbook could not be opened.\r\nError details: " + ex.Message, "Error");
            }
        }
Exemplo n.º 5
0
        private void ButtonTestRunbook_Click(object sender, RoutedEventArgs e)
        {
            AutomationRunbook selectedRunbook = (AutomationRunbook)RunbooksListView.SelectedItem;

            if (selectedRunbook == null)
            {
                MessageBox.Show("No runbook selected.");
                return;
            }
            try
            {
                JobOutputWindow jobWindow = new JobOutputWindow(selectedRunbook.Name, iseClient);
                jobWindow.Show();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error");
            }
        }
Exemplo n.º 6
0
        private void RunbooksListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            AutomationRunbook selectedRunbook = (AutomationRunbook)RunbooksListView.SelectedItem;

            if (selectedRunbook == null)
            {
                setRunbookSelectionButtonState(false);
                return;
            }
            /* Set Download button status */
            if (selectedRunbook.SyncStatus == AutomationRunbook.Constants.SyncStatus.LocalOnly)
            {
                ButtonDownloadRunbook.IsEnabled = false;
            }
            else
            {
                ButtonDownloadRunbook.IsEnabled = true;
            }
            /* Set Open and Upload button status */
            if (selectedRunbook.localFileInfo != null && File.Exists(selectedRunbook.localFileInfo.FullName))
            {
                ButtonOpenRunbook.IsEnabled   = true;
                ButtonUploadRunbook.IsEnabled = true;
            }
            else
            {
                ButtonOpenRunbook.IsEnabled   = false;
                ButtonUploadRunbook.IsEnabled = false;
            }
            /* Set Test and Publish button status */
            if (selectedRunbook.AuthoringState == AutomationRunbook.AuthoringStates.Published || selectedRunbook.SyncStatus == AutomationRunbook.Constants.SyncStatus.LocalOnly)
            {
                ButtonTestRunbook.IsEnabled    = false;
                ButtonPublishRunbook.IsEnabled = false;
            }
            else
            {
                ButtonTestRunbook.IsEnabled    = true;
                ButtonPublishRunbook.IsEnabled = true;
            }
        }