Ejemplo n.º 1
0
        public void Error(Exception ex)
        {
            messages_.Add(new ErrorInfo {
                ErrorMessage = ex.Message, ErrorDetails = ex.StackTrace, Source = ex.Source
            });

            // Does the user want to see a message?
            if (!CoreSettings.Value.DontShowErrors)
            {
                DialogResult res = DialogResult.None;
                try
                {
                    var dlg = new UnhandledExceptionDialog();

                    // Call ToString() to get the call stack. The Message property may not include that.
                    dlg.ExceptionTextBox.Text = ex.ToString();
                    res = dlg.ShowDialog();
                }
                finally
                {
                    if (res == DialogResult.No)
                    {
                        MainWindow.inst().Terminate(); // Terminating from the main window gives termination a chance to do its work
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate
     {
         UnhandledExceptionDialog.ShowModalDialog((Exception)e.ExceptionObject, AssemblyHelper.Version, AssemblyHelper.InstallationType.ToString(), AssemblyHelper.BuildType.ToString(), AssemblyHelper.ProductName);
     }, null);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the exception dialog that allows the user to choose whether or not to continue.
        /// If the user chooses not to continue, Environment.Exit(1) is called.</summary>
        /// <param name="exception">Exception raised</param>
        protected override void ShowExceptionDialog(Exception exception)
        {
            bool?result = null;

            try
            {
                var dlg = new UnhandledExceptionDialog();
                // Call ToString() to get the call stack. The Message property may not include that.
                dlg.DataContext = new UnhandledExceptionViewModel(exception.ToString());
                dlg.Owner       = Application.Current.MainWindow;
                result          = dlg.ShowDialog();

                if (UserFeedbackService != null)
                {
                    UserFeedbackService.ShowFeedbackForm();
                }
            }
            finally
            {
                if (result.HasValue && !result.Value)
                {
                    Environment.Exit(1);
                }
            }
        }
Ejemplo n.º 4
0
		public MainClass(string [] args)
		{
			isFirstRun = false;
			CheckDataFolders();
			BuildNlogConfig();
			logger.Info("Starting MonoTorrent");
					
			SetProcessName("monotorrent");
		
			userEngineSettings = new UserEngineSettings();
			portController = new ListenPortController(userEngineSettings);
			
			Application.Init ();
			Console.Out.WriteLine("IS FIRST RUN?!?! " + isFirstRun);
			mainWindow = new MainWindow (userEngineSettings, portController, isFirstRun);
			
			// This is so we can use IconEntry button
			// Use Gnome.Program instead of Gtk.Application?
			//Gnome.Program program = 
			new Gnome.Program("monotorrent", "0.1", Gnome.Modules.UI, args);
			
			try{
				Application.Run();
			} catch(Exception e){
				Console.Out.WriteLine(e.ToString());
				Application.Init();
				UnhandledExceptionDialog exDialog = new UnhandledExceptionDialog(e);
				exDialog.Run();
				mainWindow.Stop();
				exDialog.Destroy();
			}
			portController.Stop();
		}
Ejemplo n.º 5
0
 static void applicationThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     if (PlvsUtils.isConnectorException(e.Exception))
     {
         UnhandledExceptionDialog dlg = new UnhandledExceptionDialog(e.Exception);
         dlg.ShowDialog();
     }
 }
Ejemplo n.º 6
0
        static void HandleUnhandledException(Exception e, string source)
        {
            Log.Fatal("Unhandled exception", e);
            File.WriteAllText("error.log", $"Sentry GUID: {GlobalSettings.Instance.Guid}\nSource: {source}\nMessage: {e.Message}\n\nStack:\n{e.StackTrace}");
            var dlg = new UnhandledExceptionDialog(e);

            dlg.ShowDialog();
            Application.Exit();
        }
Ejemplo n.º 7
0
        private static void unhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = (Exception)e.ExceptionObject;

            if (PlvsUtils.isConnectorException(ex))
            {
                UnhandledExceptionDialog dlg = new UnhandledExceptionDialog(ex);
                dlg.ShowDialog();
            }
        }
Ejemplo n.º 8
0
        protected virtual bool?ShowExceptionDialog(Exception exception)
        {
            var dlg = new UnhandledExceptionDialog();

            dlg.DataContext = new UnhandledExceptionViewModel(exception.Message);
            if (Application.Current.MainWindow.IsVisible)
            {
                dlg.Owner = Application.Current.MainWindow;
            }
            return(dlg.ShowDialog());
        }
Ejemplo n.º 9
0
 public async Task ShowPrintUIAsync()
 {
     // Catch and print out any errors reported
     try
     {
         await PrintManager.ShowPrintUIAsync();
     }
     catch (Exception e)
     {
         UnhandledExceptionDialog.Show(e);
     }
 }
Ejemplo n.º 10
0
        public App()
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                UnhandledExceptionDialog dialog = new UnhandledExceptionDialog(args);
                dialog.ShowDialog();
            };
#endif

            SetupJitCache();
            StartBackgroundInitialization();
        }
Ejemplo n.º 11
0
        private async Task _AzureContext_AfterAzureSubscriptionChange(AzureContext sender)
        {
            try
            {
                ResetForm();

                if (sender.AzureSubscription != null)
                {
                    switch (cmbAzureResourceTypeSource.SelectedItem.ToString())
                    {
                    case "Azure Service Management (ASM / Classic)":
                        await BindAsmResources(sender, _TargetSettings);

                        break;

                    case "Azure Resource Manager (ARM)":
                        treeViewSourceResourceManager1.Enabled = true;
                        treeViewSourceResourceManager1.Visible = true;
                        await sender.AzureSubscription.InitializeChildrenAsync();

                        await sender.AzureSubscription.BindArmResources(_TargetSettings);

                        await treeViewSourceResourceManager1.BindArmResources(sender, sender.AzureSubscription, _TargetSettings);

                        break;

                    default:
                        throw new ArgumentException("Unexpected Source Resource Tab: " + cmbAzureResourceTypeSource.SelectedValue);
                    }

                    _AzureContextSource.AzureRetriever.SaveRestCache();
                }
            }
            catch (Exception exc)
            {
                UnhandledExceptionDialog unhandledException = new UnhandledExceptionDialog(_AzureContextSource.LogProvider, exc);
                unhandledException.ShowDialog();
            }

            _AzureContextSource.StatusProvider.UpdateStatus("Ready");

            AfterAzureSubscriptionChange?.Invoke(sender);
        }
Ejemplo n.º 12
0
        public App()
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                UnhandledExceptionDialog dialog = new UnhandledExceptionDialog(args);
                dialog.ShowDialog();
            };
#endif

            SetupJitCache();
            StartBackgroundInitialization();
            SetupAggregateCatalogs();

            // initialize preferences
            if (Preferences.Instance != null)
            {
                Logging.Logger.Log(LogLevel.Error, "Failed to load preferences");
            }
        }
        public static System.Threading.Thread createThread(ThreadStart threadStart)
        {
            ThreadStart ts = delegate {
                try {
                    threadStart.Invoke();
                } catch (Exception e) {
                    if (isConnectorException(e))
                    {
                        UnhandledExceptionDialog dlg = new UnhandledExceptionDialog(e);
                        dlg.ShowDialog();
                    }
                    else
                    {
                        throw;
                    }
                }
            };

            System.Threading.Thread t = new System.Threading.Thread(ts);
            return(t);
        }
Ejemplo n.º 14
0
 private void OnUnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
 {
     if (e.ExceptionObject is NodeNotFoundException)
     {
         ((MainPage)RootVisual).Loader.Visibility = Visibility.Collapsed;
         SuperMessageBoxService.Show(
             "Load Map Failed",
             "Sorry, unfortunately we can’t find the map you’re looking for",
             "Select a new map",
             "Cancel",
             MessageBoxType.Error,
             () => ((MainPage)RootVisual).HomeScreen()
             );
     }
     else if (e.ExceptionObject.InnerException != null)
     {
         if (e.ExceptionObject.InnerException is TimeoutException)
         {
             ((MainPage)RootVisual).Loader.Visibility = Visibility.Collapsed;
             SuperMessageBoxService.Show(
                 "Communication Failed",
                 "Unfortunately it seems your internet connection is not working",
                 "Refresh",
                 "Cancel",
                 MessageBoxType.Error,
                 () => HtmlPage.Document.Submit()
                 );
         }
     }
     else
     {
         var unhandledExceptionDialog = new UnhandledExceptionDialog();
         unhandledExceptionDialog.UnhandledException = e.ExceptionObject;
         unhandledExceptionDialog.Show();
     }
 }
Ejemplo n.º 15
0
 private void SynchronizationContext_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     e.Handled = true;
     UnhandledExceptionDialog.Show(e.Exception);
 }
Ejemplo n.º 16
0
 private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     UnhandledExceptionDialog.ShowModalDialog(e.Exception, AssemblyHelper.Version, AssemblyHelper.InstallationType.ToString(), AssemblyHelper.BuildType.ToString(), AssemblyHelper.ProductName);
 }
Ejemplo n.º 17
0
 private void OnUnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
 {
     e.Handled = true;
     UnhandledExceptionDialog.Show(e.Exception);
 }
Ejemplo n.º 18
0
        private async Task _AzureContextSourceASM_AfterAzureSubscriptionChange(AzureContext sender)
        {
            ResetForm();

            try
            {
                if (sender.AzureSubscription != null)
                {
                    if (_AzureContextTargetARM.AzureSubscription == null)
                    {
                        await _AzureContextTargetARM.SetSubscriptionContext(_AzureContextSourceASM.AzureSubscription);
                    }

                    azureLoginContextViewerARM.Enabled = true;

                    this.TemplateGenerator.SourceSubscription = _AzureContextSourceASM.AzureSubscription;
                    this.TemplateGenerator.TargetSubscription = _AzureContextTargetARM.AzureSubscription;

                    #region Bind Source ASM Objects

                    TreeNode subscriptionNodeASM = new TreeNode(sender.AzureSubscription.Name);
                    treeSourceASM.Nodes.Add(subscriptionNodeASM);
                    subscriptionNodeASM.Expand();

                    List <Azure.Asm.VirtualNetwork> asmVirtualNetworks = await _AzureContextSourceASM.AzureRetriever.GetAzureAsmVirtualNetworks();

                    foreach (Azure.Asm.VirtualNetwork asmVirtualNetwork in asmVirtualNetworks)
                    {
                        if (asmVirtualNetwork.HasNonGatewaySubnet)
                        {
                            TreeNode parentNode       = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeASM, asmVirtualNetwork.Location, "Virtual Networks");
                            TreeNode tnVirtualNetwork = new TreeNode(asmVirtualNetwork.Name);
                            tnVirtualNetwork.Name = asmVirtualNetwork.Name;
                            tnVirtualNetwork.Tag  = asmVirtualNetwork;
                            parentNode.Nodes.Add(tnVirtualNetwork);
                            parentNode.Expand();
                        }
                    }

                    foreach (Azure.Asm.StorageAccount asmStorageAccount in await _AzureContextSourceASM.AzureRetriever.GetAzureAsmStorageAccounts())
                    {
                        TreeNode parentNode       = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeASM, asmStorageAccount.GeoPrimaryRegion, "Storage Accounts");
                        TreeNode tnStorageAccount = new TreeNode(asmStorageAccount.Name);
                        tnStorageAccount.Name = tnStorageAccount.Text;
                        tnStorageAccount.Tag  = asmStorageAccount;
                        parentNode.Nodes.Add(tnStorageAccount);
                        parentNode.Expand();
                    }

                    List <CloudService> asmCloudServices = await _AzureContextSourceASM.AzureRetriever.GetAzureAsmCloudServices();

                    foreach (CloudService asmCloudService in asmCloudServices)
                    {
                        foreach (Azure.Asm.VirtualMachine asmVirtualMachine in asmCloudService.VirtualMachines)
                        {
                            TreeNode   parentNode             = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeASM, asmCloudService.Location, "Cloud Services");
                            TreeNode[] cloudServiceNodeSearch = parentNode.Nodes.Find(asmCloudService.ServiceName, false);
                            TreeNode   cloudServiceNode       = null;
                            if (cloudServiceNodeSearch.Count() == 1)
                            {
                                cloudServiceNode = cloudServiceNodeSearch[0];
                            }

                            if (cloudServiceNode == null)
                            {
                                cloudServiceNode      = new TreeNode(asmCloudService.ServiceName);
                                cloudServiceNode.Name = asmCloudService.ServiceName;
                                cloudServiceNode.Tag  = asmCloudService;
                                parentNode.Nodes.Add(cloudServiceNode);
                                parentNode.Expand();
                            }

                            TreeNode virtualMachineNode = new TreeNode(asmVirtualMachine.RoleName);
                            virtualMachineNode.Name = asmVirtualMachine.RoleName;
                            virtualMachineNode.Tag  = asmVirtualMachine;
                            cloudServiceNode.Nodes.Add(virtualMachineNode);
                            cloudServiceNode.Expand();
                        }
                    }

                    foreach (Azure.Asm.NetworkSecurityGroup asmNetworkSecurityGroup in await _AzureContextSourceASM.AzureRetriever.GetAzureAsmNetworkSecurityGroups())
                    {
                        TreeNode parentNode       = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeASM, asmNetworkSecurityGroup.Location, "Network Security Groups");
                        TreeNode tnStorageAccount = new TreeNode(asmNetworkSecurityGroup.Name);
                        tnStorageAccount.Name = tnStorageAccount.Text;
                        tnStorageAccount.Tag  = asmNetworkSecurityGroup;
                        parentNode.Nodes.Add(tnStorageAccount);
                        parentNode.Expand();
                    }

                    subscriptionNodeASM.ExpandAll();

                    #endregion

                    #region Bind Source ARM Objects

                    TreeNode subscriptionNodeARM = new TreeNode("ARM Resources Coming Soon!!");
//                    TreeNode subscriptionNodeARM = new TreeNode(sender.AzureSubscription.Name);
                    treeSourceARM.Nodes.Add(subscriptionNodeARM);
                    subscriptionNodeARM.Expand();

                    //foreach (ResourceGroup armResourceGroup in await _AzureContextSourceASM.AzureRetriever.GetAzureARMResourceGroups())
                    //{

                    //}

                    //foreach (Azure.Arm.AvailabilitySet armAvailabilitySet in await _AzureContextSourceASM.AzureRetriever.GetAzureARMAvailabilitySets())
                    //{

                    //}

                    //List<Azure.Arm.VirtualNetwork> armVirtualNetworks = await _AzureContextSourceASM.AzureRetriever.GetAzureARMVirtualNetworks();
                    //foreach (Azure.Arm.VirtualNetwork armVirtualNetwork in armVirtualNetworks)
                    //{
                    //    if (armVirtualNetwork.HasNonGatewaySubnet)
                    //    {
                    //        TreeNode parentNode = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeARM, armVirtualNetwork.Location, "Virtual Networks");
                    //        TreeNode tnVirtualNetwork = new TreeNode(armVirtualNetwork.Name);
                    //        tnVirtualNetwork.Name = armVirtualNetwork.Name;
                    //        tnVirtualNetwork.Tag = armVirtualNetwork;
                    //        parentNode.Nodes.Add(tnVirtualNetwork);
                    //        parentNode.Expand();
                    //    }
                    //}

                    //foreach (Azure.Arm.StorageAccount armStorageAccount in await _AzureContextSourceASM.AzureRetriever.GetAzureARMStorageAccounts())
                    //{
                    //    TreeNode parentNode = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeARM, armStorageAccount.PrimaryLocation, "Storage Accounts");
                    //    TreeNode tnStorageAccount = new TreeNode(armStorageAccount.Name);
                    //    tnStorageAccount.Name = tnStorageAccount.Text;
                    //    tnStorageAccount.Tag = armStorageAccount;
                    //    parentNode.Nodes.Add(tnStorageAccount);
                    //    parentNode.Expand();
                    //}

                    //foreach (Azure.Arm.VirtualMachine armVirtualMachine in await _AzureContextSourceASM.AzureRetriever.GetAzureArmVirtualMachines())
                    //{
                    //    TreeNode parentNode = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNodeARM, armVirtualMachine.Location, "Virtual Machines");
                    //    TreeNode tnVirtualMachine = new TreeNode(armVirtualMachine.Name);
                    //    tnVirtualMachine.Name = tnVirtualMachine.Text;
                    //    tnVirtualMachine.Tag = armVirtualMachine;
                    //    parentNode.Nodes.Add(tnVirtualMachine);
                    //    parentNode.Expand();
                    //}

                    subscriptionNodeARM.ExpandAll();

                    #endregion

                    await ReadSubscriptionSettings(sender.AzureSubscription);

                    treeSourceASM.Enabled = true;
                    //treeSourceARM.Enabled = true;
                    treeTargetARM.Enabled = true;
                }
            }
            catch (Exception exc)
            {
                UnhandledExceptionDialog unhandledException = new UnhandledExceptionDialog(LogProvider, exc);
                unhandledException.ShowDialog();
            }

            StatusProvider.UpdateStatus("Ready");
        }
Ejemplo n.º 19
0
        public async Task BindArmResources(AzureContext azureContext, AzureSubscription azureSubscription, TargetSettings targetSettings)
        {
            treeAzureARM.Nodes.Clear();

            try
            {
                if (azureSubscription != null)
                {
                    await azureSubscription.BindArmResources(targetSettings);

                    if (azureSubscription != null)
                    {
                        TreeNode subscriptionNodeARM = new TreeNode(azureSubscription.Name);
                        subscriptionNodeARM.ImageKey         = "Subscription";
                        subscriptionNodeARM.SelectedImageKey = "Subscription";
                        treeAzureARM.Nodes.Add(subscriptionNodeARM);
                        subscriptionNodeARM.Expand();

                        foreach (MigrationTarget.NetworkSecurityGroup targetNetworkSecurityGroup in azureSubscription.ArmTargetNetworkSecurityGroups)
                        {
                            TreeNode networkSecurityGroupParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.NetworkSecurityGroup)targetNetworkSecurityGroup.SourceNetworkSecurityGroup).ResourceGroup);

                            TreeNode tnNetworkSecurityGroup = new TreeNode(targetNetworkSecurityGroup.SourceName);
                            tnNetworkSecurityGroup.Name             = targetNetworkSecurityGroup.SourceName;
                            tnNetworkSecurityGroup.Tag              = targetNetworkSecurityGroup;
                            tnNetworkSecurityGroup.ImageKey         = targetNetworkSecurityGroup.ImageKey;
                            tnNetworkSecurityGroup.SelectedImageKey = targetNetworkSecurityGroup.ImageKey;
                            networkSecurityGroupParentNode.Nodes.Add(tnNetworkSecurityGroup);
                        }

                        foreach (MigrationTarget.PublicIp targetPublicIP in azureSubscription.ArmTargetPublicIPs)
                        {
                            TreeNode publicIpParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.PublicIP)targetPublicIP.Source).ResourceGroup);;

                            TreeNode tnPublicIP = new TreeNode(targetPublicIP.SourceName);
                            tnPublicIP.Name             = targetPublicIP.SourceName;
                            tnPublicIP.Tag              = targetPublicIP;
                            tnPublicIP.ImageKey         = targetPublicIP.ImageKey;
                            tnPublicIP.SelectedImageKey = targetPublicIP.ImageKey;
                            publicIpParentNode.Nodes.Add(tnPublicIP);
                        }

                        foreach (MigrationTarget.RouteTable targetRouteTable in azureSubscription.ArmTargetRouteTables)
                        {
                            TreeNode routeTableParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.RouteTable)targetRouteTable.Source).ResourceGroup);

                            TreeNode tnRouteTable = new TreeNode(targetRouteTable.SourceName);
                            tnRouteTable.Name             = targetRouteTable.SourceName;
                            tnRouteTable.Tag              = targetRouteTable;
                            tnRouteTable.ImageKey         = targetRouteTable.ImageKey;
                            tnRouteTable.SelectedImageKey = targetRouteTable.ImageKey;
                            routeTableParentNode.Nodes.Add(tnRouteTable);
                        }

                        foreach (MigrationTarget.VirtualNetwork targetVirtualNetwork in azureSubscription.ArmTargetVirtualNetworks)
                        {
                            TreeNode virtualNetworkParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualNetwork)targetVirtualNetwork.SourceVirtualNetwork).ResourceGroup);

                            TreeNode tnVirtualNetwork = new TreeNode(targetVirtualNetwork.SourceName);
                            tnVirtualNetwork.Name             = targetVirtualNetwork.SourceName;
                            tnVirtualNetwork.Tag              = targetVirtualNetwork;
                            tnVirtualNetwork.ImageKey         = targetVirtualNetwork.ImageKey;
                            tnVirtualNetwork.SelectedImageKey = targetVirtualNetwork.ImageKey;
                            virtualNetworkParentNode.Nodes.Add(tnVirtualNetwork);
                        }

                        foreach (MigrationTarget.VirtualNetworkGateway targetVirtualNetworkGateway in azureSubscription.ArmTargetVirtualNetworkGateways)
                        {
                            TreeNode virtualNetworkGatewayParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualNetworkGateway)targetVirtualNetworkGateway.SourceVirtualNetworkGateway).ResourceGroup);

                            TreeNode tnVirtualNetworkGateway = new TreeNode(targetVirtualNetworkGateway.SourceName);
                            tnVirtualNetworkGateway.Name             = targetVirtualNetworkGateway.SourceName;
                            tnVirtualNetworkGateway.Tag              = targetVirtualNetworkGateway;
                            tnVirtualNetworkGateway.ImageKey         = targetVirtualNetworkGateway.ImageKey;
                            tnVirtualNetworkGateway.SelectedImageKey = targetVirtualNetworkGateway.ImageKey;
                            virtualNetworkGatewayParentNode.Nodes.Add(tnVirtualNetworkGateway);
                        }

                        foreach (MigrationTarget.LocalNetworkGateway targetLocalNetworkGateway in azureSubscription.ArmTargetLocalNetworkGateways)
                        {
                            TreeNode localNetworkGatewayParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.LocalNetworkGateway)targetLocalNetworkGateway.SourceLocalNetworkGateway).ResourceGroup);

                            TreeNode tnLocalNetworkGateway = new TreeNode(targetLocalNetworkGateway.SourceName);
                            tnLocalNetworkGateway.Name             = targetLocalNetworkGateway.SourceName;
                            tnLocalNetworkGateway.Tag              = targetLocalNetworkGateway;
                            tnLocalNetworkGateway.ImageKey         = targetLocalNetworkGateway.ImageKey;
                            tnLocalNetworkGateway.SelectedImageKey = targetLocalNetworkGateway.ImageKey;
                            localNetworkGatewayParentNode.Nodes.Add(tnLocalNetworkGateway);
                        }

                        foreach (MigrationTarget.VirtualNetworkGatewayConnection targetConnection in azureSubscription.ArmTargetConnections)
                        {
                            TreeNode connectionParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualNetworkGatewayConnection)targetConnection.SourceConnection).ResourceGroup);

                            TreeNode tnConnection = new TreeNode(targetConnection.SourceName);
                            tnConnection.Name             = targetConnection.SourceName;
                            tnConnection.Tag              = targetConnection;
                            tnConnection.ImageKey         = targetConnection.ImageKey;
                            tnConnection.SelectedImageKey = targetConnection.ImageKey;
                            connectionParentNode.Nodes.Add(tnConnection);
                        }

                        foreach (MigrationTarget.StorageAccount targetStorageAccount in azureSubscription.ArmTargetStorageAccounts)
                        {
                            TreeNode storageAccountParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.StorageAccount)targetStorageAccount.SourceAccount).ResourceGroup);

                            TreeNode tnStorageAccount = new TreeNode(targetStorageAccount.SourceName);
                            tnStorageAccount.Name             = targetStorageAccount.SourceName;
                            tnStorageAccount.Tag              = targetStorageAccount;
                            tnStorageAccount.ImageKey         = targetStorageAccount.ImageKey;
                            tnStorageAccount.SelectedImageKey = targetStorageAccount.ImageKey;
                            storageAccountParentNode.Nodes.Add(tnStorageAccount);
                        }

                        foreach (MigrationTarget.Disk targetManagedDisk in azureSubscription.ArmTargetManagedDisks)
                        {
                            Azure.Arm.ManagedDisk armManagedDisk = (Azure.Arm.ManagedDisk)targetManagedDisk.SourceDisk;
                            TreeNode managedDiskParentNode       = GetResourceGroupTreeNode(subscriptionNodeARM, armManagedDisk.ResourceGroup);

                            TreeNode tnDisk = new TreeNode(targetManagedDisk.SourceName);
                            tnDisk.Name             = targetManagedDisk.SourceName;
                            tnDisk.Tag              = targetManagedDisk;
                            tnDisk.ImageKey         = targetManagedDisk.ImageKey;
                            tnDisk.SelectedImageKey = targetManagedDisk.ImageKey;
                            managedDiskParentNode.Nodes.Add(tnDisk);
                        }

                        foreach (MigrationTarget.AvailabilitySet targetAvailabilitySet in azureSubscription.ArmTargetAvailabilitySets)
                        {
                            TreeNode availabilitySetParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.AvailabilitySet)targetAvailabilitySet.SourceAvailabilitySet).ResourceGroup);

                            TreeNode tnAvailabilitySet = new TreeNode(targetAvailabilitySet.SourceName);
                            tnAvailabilitySet.Name             = targetAvailabilitySet.SourceName;
                            tnAvailabilitySet.Tag              = targetAvailabilitySet;
                            tnAvailabilitySet.ImageKey         = targetAvailabilitySet.ImageKey;
                            tnAvailabilitySet.SelectedImageKey = targetAvailabilitySet.ImageKey;
                            availabilitySetParentNode.Nodes.Add(tnAvailabilitySet);
                        }

                        foreach (MigrationTarget.NetworkInterface targetNetworkInterface in azureSubscription.ArmTargetNetworkInterfaces)
                        {
                            TreeNode tnResourceGroup = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.NetworkInterface)targetNetworkInterface.SourceNetworkInterface).ResourceGroup);

                            TreeNode txNetworkInterface = new TreeNode(targetNetworkInterface.SourceName);
                            txNetworkInterface.Name             = targetNetworkInterface.SourceName;
                            txNetworkInterface.Tag              = targetNetworkInterface;
                            txNetworkInterface.ImageKey         = targetNetworkInterface.ImageKey;
                            txNetworkInterface.SelectedImageKey = targetNetworkInterface.ImageKey;
                            tnResourceGroup.Nodes.Add(txNetworkInterface);
                        }

                        foreach (MigrationTarget.VirtualMachine targetVirtualMachine in azureSubscription.ArmTargetVirtualMachines)
                        {
                            TreeNode tnResourceGroup = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualMachine)targetVirtualMachine.Source).ResourceGroup);

                            TreeNode tnVirtualMachine = new TreeNode(targetVirtualMachine.SourceName);
                            tnVirtualMachine.Name             = targetVirtualMachine.SourceName;
                            tnVirtualMachine.Tag              = targetVirtualMachine;
                            tnVirtualMachine.ImageKey         = targetVirtualMachine.ImageKey;
                            tnVirtualMachine.SelectedImageKey = targetVirtualMachine.ImageKey;
                            tnResourceGroup.Nodes.Add(tnVirtualMachine);
                        }

                        foreach (MigrationTarget.LoadBalancer targetLoadBalancer in azureSubscription.ArmTargetLoadBalancers)
                        {
                            TreeNode networkSecurityGroupParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.LoadBalancer)targetLoadBalancer.Source).ResourceGroup);

                            TreeNode tnNetworkSecurityGroup = new TreeNode(targetLoadBalancer.SourceName);
                            tnNetworkSecurityGroup.Name             = targetLoadBalancer.SourceName;
                            tnNetworkSecurityGroup.Tag              = targetLoadBalancer;
                            tnNetworkSecurityGroup.ImageKey         = targetLoadBalancer.ImageKey;
                            tnNetworkSecurityGroup.SelectedImageKey = targetLoadBalancer.ImageKey;
                            networkSecurityGroupParentNode.Nodes.Add(tnNetworkSecurityGroup);
                        }

                        //foreach (MigrationTarget.VirtualMachineImage targetVirtualMachineImage in _AzureContextSource.AzureSubscription.ArmTargetVirtualMachineImages)
                        //{
                        //    TreeNode virtualMachineImageParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualMachineImage)targetVirtualMachineImage.Source).ResourceGroup);

                        //    TreeNode tnVirtualMachineImage = new TreeNode(targetVirtualMachineImage.SourceName);
                        //    tnVirtualMachineImage.Name = targetVirtualMachineImage.SourceName;
                        //    tnVirtualMachineImage.Tag = targetVirtualMachineImage;
                        //    tnVirtualMachineImage.ImageKey = "VirtualMachineImage";
                        //    tnVirtualMachineImage.SelectedImageKey = "VirtualMachineImage";
                        //    virtualMachineImageParentNode.Nodes.Add(tnVirtualMachineImage);
                        //}

                        subscriptionNodeARM.Expand();
                        treeAzureARM.Sort();
                        treeAzureARM.Enabled = true;
                    }
                }
            }
            catch (Exception exc)
            {
                UnhandledExceptionDialog exceptionDialog = new UnhandledExceptionDialog(_LogProvider, exc);
                exceptionDialog.ShowDialog();
            }

            _StatusProvider.UpdateStatus("Ready");
        }
Ejemplo n.º 20
0
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            UnhandledExceptionDialog exceptionDialog = new UnhandledExceptionDialog(programForm.LogProvider, e.Exception);

            exceptionDialog.ShowDialog();
        }
Ejemplo n.º 21
0
        private async Task BindAsmResources(AzureContext azureContext, TargetSettings targetSettings)
        {
            treeAzureASM.Nodes.Clear();

            try
            {
                if (_AzureContextSource != null && _AzureContextSource.AzureSubscription != null)
                {
                    await _AzureContextSource.AzureSubscription.BindAsmResources(targetSettings);

                    if (_AzureContextSource != null && _AzureContextSource.AzureSubscription != null)
                    {
                        TreeNode subscriptionNodeASM = new TreeNode(_AzureContextSource.AzureSubscription.Name);
                        treeAzureASM.Nodes.Add(subscriptionNodeASM);
                        subscriptionNodeASM.Expand();

                        foreach (Azure.MigrationTarget.NetworkSecurityGroup targetNetworkSecurityGroup in _AzureContextSource.AzureSubscription.AsmTargetNetworkSecurityGroups)
                        {
                            Azure.Asm.NetworkSecurityGroup asmNetworkSecurityGroup = (Azure.Asm.NetworkSecurityGroup)targetNetworkSecurityGroup.SourceNetworkSecurityGroup;
                            TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, asmNetworkSecurityGroup.Location, "Network Security Groups");

                            TreeNode tnNetworkSecurityGroup = new TreeNode(targetNetworkSecurityGroup.SourceName);
                            tnNetworkSecurityGroup.Name = targetNetworkSecurityGroup.SourceName;
                            tnNetworkSecurityGroup.Tag  = targetNetworkSecurityGroup;
                            parentNode.Nodes.Add(tnNetworkSecurityGroup);
                            parentNode.Expand();
                        }

                        foreach (Azure.MigrationTarget.VirtualNetwork targetVirtualNetwork in _AzureContextSource.AzureSubscription.AsmTargetVirtualNetworks)
                        {
                            Azure.Asm.VirtualNetwork asmVirtualNetwork = (Azure.Asm.VirtualNetwork)targetVirtualNetwork.SourceVirtualNetwork;
                            TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, asmVirtualNetwork.Location, "Virtual Networks");

                            TreeNode tnVirtualNetwork = new TreeNode(targetVirtualNetwork.SourceName);
                            tnVirtualNetwork.Name = targetVirtualNetwork.SourceName;
                            tnVirtualNetwork.Text = targetVirtualNetwork.SourceName;
                            tnVirtualNetwork.Tag  = targetVirtualNetwork;
                            parentNode.Nodes.Add(tnVirtualNetwork);
                            parentNode.Expand();
                        }

                        foreach (Azure.MigrationTarget.StorageAccount targetStorageAccount in _AzureContextSource.AzureSubscription.AsmTargetStorageAccounts)
                        {
                            TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, targetStorageAccount.SourceAccount.PrimaryLocation, "Storage Accounts");

                            TreeNode tnStorageAccount = new TreeNode(targetStorageAccount.SourceName);
                            tnStorageAccount.Name = targetStorageAccount.SourceName;
                            tnStorageAccount.Tag  = targetStorageAccount;
                            parentNode.Nodes.Add(tnStorageAccount);
                            parentNode.Expand();
                        }

                        foreach (Azure.MigrationTarget.VirtualMachine targetVirtualMachine in _AzureContextSource.AzureSubscription.AsmTargetVirtualMachines)
                        {
                            Azure.Asm.VirtualMachine asmVirtualMachine = (Azure.Asm.VirtualMachine)targetVirtualMachine.Source;
                            TreeNode   parentNode             = GetDataCenterTreeViewNode(subscriptionNodeASM, asmVirtualMachine.Location, "Cloud Services");
                            TreeNode[] cloudServiceNodeSearch = parentNode.Nodes.Find(targetVirtualMachine.TargetAvailabilitySet.TargetName, false);
                            TreeNode   cloudServiceNode       = null;
                            if (cloudServiceNodeSearch.Count() == 1)
                            {
                                cloudServiceNode = cloudServiceNodeSearch[0];
                            }

                            cloudServiceNode      = new TreeNode(targetVirtualMachine.TargetAvailabilitySet.TargetName);
                            cloudServiceNode.Name = targetVirtualMachine.TargetAvailabilitySet.TargetName;
                            cloudServiceNode.Tag  = targetVirtualMachine.TargetAvailabilitySet;
                            parentNode.Nodes.Add(cloudServiceNode);
                            parentNode.Expand();

                            TreeNode virtualMachineNode = new TreeNode(targetVirtualMachine.SourceName);
                            virtualMachineNode.Name = targetVirtualMachine.SourceName;
                            virtualMachineNode.Tag  = targetVirtualMachine;
                            cloudServiceNode.Nodes.Add(virtualMachineNode);
                            cloudServiceNode.Expand();

                            foreach (Azure.MigrationTarget.NetworkInterface targetNetworkInterface in targetVirtualMachine.NetworkInterfaces)
                            {
                                if (targetNetworkInterface.BackEndAddressPool != null && targetNetworkInterface.BackEndAddressPool.LoadBalancer != null)
                                {
                                    TreeNode loadBalancerNode = new TreeNode(targetNetworkInterface.BackEndAddressPool.LoadBalancer.SourceName);
                                    loadBalancerNode.Name = targetNetworkInterface.BackEndAddressPool.LoadBalancer.SourceName;
                                    loadBalancerNode.Tag  = targetNetworkInterface.BackEndAddressPool.LoadBalancer;
                                    cloudServiceNode.Nodes.Add(loadBalancerNode);
                                    cloudServiceNode.Expand();

                                    foreach (Azure.MigrationTarget.FrontEndIpConfiguration frontEnd in targetNetworkInterface.BackEndAddressPool.LoadBalancer.FrontEndIpConfigurations)
                                    {
                                        if (frontEnd.PublicIp != null) // if external load balancer
                                        {
                                            TreeNode publicIPAddressNode = new TreeNode(frontEnd.PublicIp.SourceName);
                                            publicIPAddressNode.Name = frontEnd.PublicIp.SourceName;
                                            publicIPAddressNode.Tag  = frontEnd.PublicIp;
                                            cloudServiceNode.Nodes.Add(publicIPAddressNode);
                                            cloudServiceNode.Expand();
                                        }
                                    }
                                }
                            }
                        }

                        subscriptionNodeASM.Expand();
                        treeAzureASM.Enabled = true;
                    }
                }
            }
            catch (Exception exc)
            {
                if (exc.GetType() == typeof(System.Net.WebException))
                {
                    System.Net.WebException webException = (System.Net.WebException)exc;
                    if (webException.Response != null)
                    {
                        HttpWebResponse exceptionResponse = (HttpWebResponse)webException.Response;
                        if (exceptionResponse.StatusCode == HttpStatusCode.Forbidden)
                        {
                            ASM403ForbiddenExceptionDialog forbiddenDialog = new ASM403ForbiddenExceptionDialog(_AzureContextSource.LogProvider, exc);
                            return;
                        }
                    }
                }

                UnhandledExceptionDialog exceptionDialog = new UnhandledExceptionDialog(_AzureContextSource.LogProvider, exc);
                exceptionDialog.ShowDialog();
            }

            _AzureContextSource.StatusProvider.UpdateStatus("Ready");
        }