public AutomationISEControl()
        {
            try
            {
                InitializeComponent();
                iseClient = new AutomationISEClient();
                backgroundWorkLock = new Object();
                progressSpinnerStoryboard = (Storyboard)FindResource("bigGearRotationStoryboard");
                progressSpinnerStoryboardReverse = (Storyboard)FindResource("bigGearRotationStoryboardReverse");
                miniProgressSpinnerStoryboard = (Storyboard)FindResource("smallGearRotationStoryboard");
                miniProgressSpinnerStoryboardReverse = (Storyboard)FindResource("smallGearRotationStoryboardReverse");

                /* Determine working directory */
                String localWorkspace = Properties.Settings.Default["localWorkspace"].ToString();
                if (localWorkspace == "")
                {
                    String systemDrive = Environment.GetEnvironmentVariable("SystemDrive") + "\\";
                    localWorkspace = System.IO.Path.Combine(systemDrive, "AutomationWorkspace");
                    Properties.Settings.Default["localWorkspace"] = localWorkspace;
                    Properties.Settings.Default.Save();
                }
                iseClient.baseWorkspace = localWorkspace;

                /* Update UI */
                workspaceTextBox.Text = iseClient.baseWorkspace;
                userNameTextBox.Text = Properties.Settings.Default["ADUserName"].ToString();
                subscriptionComboBox.IsEnabled = false;
                accountsComboBox.IsEnabled = false;

                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetVariable);
                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetCredential);
                //assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetCertificate);
                //assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetConnection);

                setRunbookAndAssetNonSelectionButtonState(false);
                setAssetSelectionButtonState(false);
                assetsComboBox.IsEnabled = false;
                setRunbookSelectionButtonState(false);

                // Generate self signed certificate for encrypting local assets in the current user store Cert:\CurrentUser\My\
                var certObj = new AutomationSelfSignedCertificate();
                certificateThumbprint = certObj.CreateSelfSignedCertificate();
                certificateTextBox.Text = certificateThumbprint;
                UpdateStatusBox(configurationStatusTextBox, "Thumbprint of certificate used to encrypt local assets: " + certificateThumbprint);

                // Load feedback and help page to increase load time before users clicks on these tabs
                surveyBrowserControl.Navigate(new Uri(Constants.feedbackURI));
                helpBrowserControl.Navigate(new Uri(Constants.helpURI));

                startContinualGet();
                startRefreshTokenTimer();
            }
            catch (Exception exception)
            {
                var detailsDialog = System.Windows.Forms.MessageBox.Show(exception.Message);
            }
        }
 public JobOutputWindow(String name, AutomationISEClient client)
 {
     InitializeComponent();
     this.Title = name + " Test Job";
     AdditionalInformation.Text = "Tip: not seeing Verbose output? Add the line \"$VerbosePreference='Continue'\" to your runbook.";
     runbookName = name;
     iseClient = client;
     Task t = checkTestJob(true);
     refreshTimer = new System.Timers.Timer();
     refreshTimer.Interval = 30000;
     refreshTimer.Elapsed += new ElapsedEventHandler(refresh);
 }
        public AutomationISEControl()
        {
            try
            {
                InitializeComponent();
                iseClient = new AutomationISEClient();
                fileTransferQueue = new BlockingCollection<RunbookTransferJob>(new ConcurrentQueue<RunbookTransferJob>(),50);
                fileTransferWorkerProgress = new Progress<RunbookTransferProgress>(updateUiWithTransferProgress);
                fileTransferWorker = Task.Factory.StartNew(() => processJobsFromQueue(fileTransferWorkerProgress), TaskCreationOptions.LongRunning);

                /* Determine working directory */
                String localWorkspace = Properties.Settings.Default["localWorkspace"].ToString();
                if (localWorkspace == "")
                {
                    String systemDrive = Environment.GetEnvironmentVariable("SystemDrive") + "\\";
                    localWorkspace = System.IO.Path.Combine(systemDrive, "AutomationWorkspace");
                    Properties.Settings.Default["localWorkspace"] = localWorkspace;
                    Properties.Settings.Default.Save();
                }
                iseClient.baseWorkspace = localWorkspace;

                /* Update UI */
                workspaceTextBox.Text = iseClient.baseWorkspace;
                userNameTextBox.Text = Properties.Settings.Default["ADUserName"].ToString();
                subscriptionComboBox.IsEnabled = false;
                accountsComboBox.IsEnabled = false;

                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetVariable);
                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetCredential);
                //assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetCertificate);
                //assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetConnection);

                setRunbookAndAssetNonSelectionButtonState(false);
                setAssetSelectionButtonState(false);
                setRunbookSelectionButtonState(false);

                // Generate self signed certificate for encrypting local assets in the current user store Cert:\CurrentUser\My\
                var certObj = new AutomationSelfSignedCertificate();
                String selfSignedThumbprint = certObj.CreateSelfSignedCertificate();
                certificateTextBox.Text = selfSignedThumbprint;
                UpdateStatusBox(configurationStatusTextBox, "Certificate to use for encrypting local assets is " + selfSignedThumbprint);

                // Load feedback page to increase load time before users clicks on feedback tab
                surveyBrowserControl.Navigate(new Uri(Constants.feedbackURI));

                startContinualGet();
            }
            catch (Exception exception)
            {
                var detailsDialog = System.Windows.Forms.MessageBox.Show(exception.Message);
            }
        }
 //TODO: refactor this to a different class with some inheritance structure
 public JobOutputWindow(String name, JobCreateResponse response, AutomationISEClient client)
 {
     InitializeComponent();
     StartJobButton.IsEnabled = false;
     StopJobButton.IsEnabled = false;
     this.Title = "Job: " + name;
     AdditionalInformation.Text = "This is a Global Runbook responsible for syncing your GitHub repo with your Automation Account. Neato!";
     runbookName = name;
     jobCreateResponse = response;
     iseClient = client;
     Task t = checkJob();
     refreshTimer = new System.Timers.Timer();
     refreshTimer.Interval = 30000;
     refreshTimer.Elapsed += new ElapsedEventHandler(refresh);
 }
        public AutomationISEControl()
        {
            try
            {
                InitializeComponent();
                iseClient = new AutomationISEClient();
                /* Spinner animation stuff */
                backgroundWorkLock = new Object();
                progressSpinnerStoryboard = (Storyboard)FindResource("bigGearRotationStoryboard");
                progressSpinnerStoryboardReverse = (Storyboard)FindResource("bigGearRotationStoryboardReverse");
                miniProgressSpinnerStoryboard = (Storyboard)FindResource("smallGearRotationStoryboard");
                miniProgressSpinnerStoryboardReverse = (Storyboard)FindResource("smallGearRotationStoryboardReverse");

                /* Determine working directory */
                String localWorkspace = Properties.Settings.Default["localWorkspace"].ToString();
                if (localWorkspace == "")
                {
                    String userProfile = Environment.GetEnvironmentVariable("USERPROFILE") + "\\";
                    localWorkspace = System.IO.Path.Combine(userProfile, "AutomationWorkspace");
                    Properties.Settings.Default["localWorkspace"] = localWorkspace;
                    Properties.Settings.Default.Save();
                }
                iseClient.baseWorkspace = localWorkspace;
                promptShortened = false;

                /* Initialize Timers */
                refreshAccountDataTimer = new System.Timers.Timer();
                refreshAccountDataTimer.Interval = 30000; //30 seconds
                refreshAccountDataTimer.Elapsed += new ElapsedEventHandler(refreshAccountData);

                refreshAuthTokenTimer = new System.Timers.Timer();
                refreshAuthTokenTimer.Interval = Constants.tokenRefreshInterval * 60000;
                refreshAuthTokenTimer.Elapsed += new ElapsedEventHandler(refreshAuthToken);

                /* Update UI */
                workspaceTextBox.Text = iseClient.baseWorkspace;
                userNameTextBox.Text = Properties.Settings.Default["ADUserName"].ToString();
                subscriptionComboBox.IsEnabled = false;
                accountsComboBox.IsEnabled = false;

                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetConnection);
                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetCredential);
                assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetVariable);
                //assetsComboBox.Items.Add(AutomationISE.Model.Constants.assetCertificate);

                setCreationButtonStatesTo(false);
                setAllAssetButtonStatesTo(false);
                assetsComboBox.IsEnabled = false;
                setAllRunbookButtonStatesTo(false);

                // Generate self-signed certificate for encrypting local assets in the current user store Cert:\CurrentUser\My\
                var certObj = new AutomationSelfSignedCertificate();
                certificateThumbprint = certObj.CreateSelfSignedCertificate();
                certificateTextBox.Text = certificateThumbprint;
                UpdateStatusBox(configurationStatusTextBox, "Thumbprint of certificate used to encrypt local assets: " + certificateThumbprint);

                // Load feedback and help page preemptively
                surveyBrowserControl.Navigate(new Uri(Constants.feedbackURI));
                helpBrowserControl.Navigate(new Uri(Constants.helpURI));
            }
            catch (Exception exception)
            {
                var detailsDialog = System.Windows.Forms.MessageBox.Show(exception.Message);
            }
        }