示例#1
0
        public void Handle(MonitoringDisabledForEndpoint message)
        {
            // The user could be disabling an endpoint that had the heartbeats plugin, or not.
            // Check to see if the endpoint had associated heartbeat.
            var heartbeat = Session.Load <Heartbeat>(message.EndpointInstanceId);

            if (heartbeat != null)
            {
                if (heartbeat.Disabled)
                {
                    Logger.InfoFormat("Heartbeat monitoring for endpoint {0} is already disabled", message.EndpointInstanceId);
                    return;
                }
                heartbeat.Disabled = true;
                Session.Store(heartbeat);
            }
            else
            {
                Logger.InfoFormat("Heartbeat for endpoint {0} not found. Possible cause is that the endpoint may not have the plug in installed.", message.EndpointInstanceId);
            }

            StatusProvider.DisableMonitoring(message.Endpoint);
            Bus.Publish(new HeartbeatMonitoringDisabled
            {
                EndpointInstanceId = message.EndpointInstanceId
            });
        }
示例#2
0
        private async Task _AzureContextARM_AfterAzureSubscriptionChange(AzureContext sender)
        {
            ResetForm();

            if (sender.AzureSubscription != null)
            {
                //btnAzureContextARM.Enabled = true;

                TreeNode subscriptionNode = new TreeNode(sender.AzureSubscription.Name);
                treeSource.Nodes.Add(subscriptionNode);
                subscriptionNode.Expand();


                //    if (app.Default.SaveSelection)
                //    {
                //        lblStatus.Text = "BUSY: Reading saved selection";
                //        Application.DoEvents();
                //        _saveSelectionProvider.Read(Guid.Parse(subscriptionid),ref lvwVirtualNetworks, ref lvwStorageAccounts, ref lvwVirtualMachines);
                //    }

                treeSource.Enabled = true;
            }

            StatusProvider.UpdateStatus("Ready");
        }
示例#3
0
        private void btnExport_Click_1(object sender, EventArgs e)
        {
            if (splitContainer2.Panel1.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)splitContainer2.Panel1.Controls[0];

                if (migrator.TemplateGenerator.HasErrors)
                {
                    MessageBox.Show("There are still one or more error(s) with the template generation.  Please resolve all errors before exporting.");
                    return;
                }

                // We are refreshing both the MemoryStreams and the Output Tabs via this call, prior to writing to files
                btnRefreshOutput_Click(this, null);

                migrator.TemplateGenerator.OutputDirectory = txtDestinationFolder.Text;
                migrator.TemplateGenerator.Write();

                // post Telemetry Record to ASMtoARMToolAPI
                if (AppSettingsProvider.AllowTelemetry)
                {
                    StatusProvider.UpdateStatus("BUSY: saving telemetry information");
                    migrator.PostTelemetryRecord();
                }

                StatusProvider.UpdateStatus("Ready");

                var exportResults = new ExportResultsDialog(migrator.TemplateGenerator);
                exportResults.ShowDialog(this);
            }
        }
示例#4
0
        private async Task targetTreeView1_AfterTargetSelected(TargetTreeView targetTreeView, TreeNode selectedNode)
        {
            try
            {
                if (this.LogProvider != null)
                {
                    LogProvider.WriteLog("Control_AfterTargetSelected", "Start");
                }

                _EventSourceNode = selectedNode;
                await BindPropertyPanel(targetTreeView, selectedNode);

                _EventSourceNode = null;

                if (this.LogProvider != null)
                {
                    LogProvider.WriteLog("Control_AfterTargetSelected", "End");
                }

                if (this.StatusProvider != null)
                {
                    StatusProvider.UpdateStatus("Ready");
                }
            }
            catch (Exception exc)
            {
                UnhandledExceptionDialog unhandledExceptionDialog = new UnhandledExceptionDialog(this.LogProvider, exc);
                unhandledExceptionDialog.ShowDialog();
            }
        }
示例#5
0
        protected void GridView_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
        {
            StatusVM CloneItem = new StatusVM();

            if (bool.Parse(HttpContext.Current.Session["isCloneRow_Com"].ToString()) == true && GridView.FocusedRowIndex >= 0)
            {
                //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id);
                //CloneItem = StandardTypeProvider.GetSingleById(selectedIds.Last());

                CloneItem = Mapper.Map <StatusVM>(StatusProvider.GetSingleById(GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString()));


                HttpContext.Current.Session["isCloneRow_Com"] = false;

                PropertyInfo myFieldInfo;
                foreach (var myProperty in typeof(StatusVM).GetProperties())
                {
                    myFieldInfo = typeof(StatusVM).GetProperty(myProperty.Name);
                    if (myFieldInfo == null)
                    {
                        continue;
                    }
                    var ttt = myFieldInfo.GetValue(CloneItem);

                    e.NewValues[myProperty.Name] = myFieldInfo.GetValue(CloneItem);
                }
            }
        }
示例#6
0
        // Cách tạo lỗi Exception
        // NotImplementedException innerException = new NotImplementedException("NoReport");
        // throw new NotImplementedException("This message has been generated for a GetCallbackErrorMessage() method demonstration.", innerException);

        //protected override void InitializeCulture()
        //{
        //    if (!string.IsNullOrEmpty(GetDXCurrentLanguageValue()))
        //    {
        //        //for regional server standards
        //        Culture = GetDXCurrentLanguageValue();
        //        //for DevExpress localizable strings
        //        UICulture = GetDXCurrentLanguageValue();
        //    }
        //}
        protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.Session["Log"] == null)
            {
                HttpContext.Current.Session["Log"] = "";
            }

            ASPxWebControl.RegisterBaseScript(this);
            GridViewFeaturesHelper.SetupGlobalGridViewBehavior(GridView);

            DemoHelper.Instance.ControlAreaMaxWidth = Unit.Pixel(1300);
            UpdatePageToolbarEnable();

            if (!IsPostBack)
            {
                HttpContext.Current.Session["isActBloChanged_Com"] = true;
                HttpContext.Current.Session["isCloneRow_Com"]      = false;
                HttpContext.Current.Session["isDetailRow_Com"]     = false;

                List <MenuInfo> menuItems = StatusProvider.GetMenuList("Request", "Tình trạng HS");
                //FiltersNavBar.BuildNavBarItems(menuItems);
            }
            if (IsCallback)
            {
            }
        }
示例#7
0
        private void btnExport_Click_1(object sender, EventArgs e)
        {
            if (splitContainer2.Panel1.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)splitContainer2.Panel1.Controls[0];

                if (migrator.TemplateGenerator.HasErrors)
                {
                    tabMigAzMonitoring.SelectTab("tabMessages");
                    MessageBox.Show("There are still one or more error(s) with the template generation.  Please resolve all errors before exporting.");
                    return;
                }

                migrator.TemplateGenerator.OutputDirectory = txtDestinationFolder.Text;

                // We are refreshing both the MemoryStreams and the Output Tabs via this call, prior to writing to files
                btnRefreshOutput_Click(this, null);

                migrator.TemplateGenerator.Write();

                StatusProvider.UpdateStatus("Ready");

                var exportResults = new ExportResultsDialog(migrator.TemplateGenerator);
                exportResults.ShowDialog(this);
            }
        }
示例#8
0
 public Scanner(string host)
 {
     this.esclClient           = new EsclClient();
     this.Host                 = host;
     this.statusProvider       = new StatusProvider(esclClient, host);
     this.capabilitiesProvider = new CapabilitiesProvider(esclClient, host);
     this.requestGenerator     = new EsclScanRequestGenerator();
     this.jobCreator           = new EsclJobCreator(esclClient, host, requestGenerator);
 }
示例#9
0
        private async void treeTargetARM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LogProvider.WriteLog("treeARM_AfterSelect", "Start");

            _PropertyPanel.Bind(e.Node);

            LogProvider.WriteLog("treeARM_AfterSelect", "End");
            StatusProvider.UpdateStatus("Ready");
        }
示例#10
0
        public void CallLibgit_RetrieveStatus()
        {
            var            repository     = NSubstitute.Substitute.For <IRepository>();
            StatusProvider statusProvider = new StatusProvider(repository);
            var            filePath       = "somePath";

            statusProvider.Get(filePath);

            repository.Received().RetrieveStatus(filePath);
        }
示例#11
0
 public ConsulClientV1(Polymath polymath)
 {
     ACL         = new ACLProvider(polymath);
     Agent       = new AgentProvider(polymath);
     Event       = new EventProvider(polymath);
     KeyValue    = new KeyValueProvider(polymath);
     Session     = new SessionProvider(polymath);
     Snapshot    = new SnapshotProvider(polymath);
     Status      = new StatusProvider(polymath);
     Transaction = new TransactionProvider(polymath);
 }
示例#12
0
        private async Task ReadSubscriptionSettings(AzureSubscription azureSubscription)
        {
            // If save selection option is enabled
            if (app.Default.SaveSelection)
            {
                StatusProvider.UpdateStatus("BUSY: Reading saved selection");
                await _saveSelectionProvider.Read(azureSubscription.SubscriptionId, _AzureContextSourceASM.AzureRetriever, AzureContextTargetARM.AzureRetriever, treeSourceASM);

                UpdateExportItemsCount();
            }
        }
示例#13
0
 public WorkItem(
     WaitCallback callback,
     object state,
     TimeSpan executionTimeTreshold,
     StatusProvider statusProvider = null)
 {
     this.callback = callback;
     this.State    = state;
     this.executionTimeTreshold = executionTimeTreshold;
     this.statusProvider        = statusProvider ?? NoOpStatusProvider;
     this.enqueueTime           = DateTime.UtcNow;
 }
示例#14
0
        private void cmbRegion_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbRegion.Enabled == true)
            {
                //Load the Region Items
                // TODO Load_Items();
            }

            // If save selection option is enabled
            if (app.Default.SaveSelection)
            {
                StatusProvider.UpdateStatus("BUSY: Reading saved selection");
                _saveSelectionProvider.Read(cmbRegion.Text, ref lvwVirtualNetworks, ref lvwVirtualMachines);
            }
        }
示例#15
0
        public async Task successful_response_with_idle_status()
        {
            var responseXml = new XmlDocument();

            responseXml.LoadXml(FULL_RESPONSE_BODY);
            var client = A.Fake <IEsclClient>();

            A.CallTo(() => client.GetAsync("http://192.168.0.151/eSCL/ScannerStatus"))
            .Returns(Task.FromResult <IEsclResponse>(new EsclResponse(content: responseXml)));

            var statusProvider = new StatusProvider(client, "192.168.0.151");
            var status         = await statusProvider.GetStatus();

            Assert.Equal("Idle", status.State);
            Assert.Equal("2.63", status.Version);
        }
示例#16
0
        private async void btnExport_Click_1Async(object sender, EventArgs e)
        {
            // We are refreshing both the MemoryStreams and the Output Tabs via this call, prior to writing to files
            if (await RefreshOutput())
            {
                if (this.AzureGenerator != null)
                {
                    this.AzureGenerator.OutputDirectory = txtDestinationFolder.Text;

                    this.AzureGenerator.Write();

                    StatusProvider.UpdateStatus("Ready");

                    var exportResults = new ExportResultsDialog(this.AzureGenerator);
                    exportResults.ShowDialog(this);
                }
            }
        }
示例#17
0
        private void Load_Items()
        {
            LogProvider.WriteLog("Load_Items", "Start");

            treeSourceAWS.Nodes.Clear();
            treeTargetARM.Nodes.Clear();

            TreeNode subscriptionNode = new TreeNode("AWS Subscription");

            treeSourceAWS.Nodes.Add(subscriptionNode);

            AWSRetriever awsRetriever = new AWSRetriever(this.LogProvider, this.StatusProvider);

            awsRetriever.toname(accessKeyTextBox.Text.Trim(), secretKeyTextBox.Text.Trim(), subscriptionNode);

            subscriptionNode.ExpandAll();

            StatusProvider.UpdateStatus("Ready");
        }
示例#18
0
        private async void TargetTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (this.LogProvider != null)
            {
                LogProvider.WriteLog("treeARM_AfterSelect", "Start");
            }

            _EventSourceNode = e.Node;
            await _PropertyPanel.Bind(e.Node);

            _EventSourceNode = null;

            if (this.LogProvider != null)
            {
                LogProvider.WriteLog("treeARM_AfterSelect", "End");
            }

            if (this.StatusProvider != null)
            {
                StatusProvider.UpdateStatus("Ready");
            }
        }
示例#19
0
        private void UpdateNavBarName()
        {
            List <bool> ActivedList = new List <bool>();
            List <bool> BlockedList = new List <bool>();

            for (int i = 0; i < GridView.VisibleRowCount; i++)
            {
                ActivedList.Add((bool)GridView.GetRowValues(i, "Actived"));
                BlockedList.Add((bool)GridView.GetRowValues(i, "Blocked"));
            }
            GridView.JSProperties["cpActived"] = ActivedList;
            GridView.JSProperties["cpBlocked"] = BlockedList;


            HttpContext.Current.Session["isActBloChanged_Com"] = false;

            GridView.JSProperties["cpAllCount"] = StatusProvider.Count(x => true);
            GridView.JSProperties["cpInActivedUnBlockedCount"] = StatusProvider.Count(x => x.Actived == false && x.Blocked == false);
            GridView.JSProperties["cpActivedBlockedCount"]     = StatusProvider.Count(x => x.Actived == true && x.Blocked == true);
            GridView.JSProperties["cpInactivedBlockedCount"]   = StatusProvider.Count(x => x.Actived == false && x.Blocked == true);
            GridView.JSProperties["cpActivedUnBlockedCount"]   = StatusProvider.Count(x => x.Actived == true && x.Blocked == false);
            GridView.JSProperties["cpUpdatedByCount"]          = StatusProvider.Count(x => x.CreatedBy == User.Identity.Name || x.UpdatedBy == User.Identity.Name);
        }
示例#20
0
        private async void btnRefreshOutput_Click(object sender, EventArgs e)
        {
            SplitterPanel parent = (SplitterPanel)splitContainer2.Panel1;

            if (parent.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)parent.Controls[0];

                if (migrator.TemplateGenerator.HasErrors)
                {
                    tabMigAzMonitoring.SelectTab("tabMessages");
                    MessageBox.Show("There are still one or more error(s) with the template generation.  Please resolve all errors before exporting.");
                    return;
                }

                await migrator.TemplateGenerator.GenerateStreams();

                await migrator.TemplateGenerator.SerializeStreams();

                foreach (TabPage tabPage in tabOutputResults.TabPages)
                {
                    if (!migrator.TemplateGenerator.TemplateStreams.ContainsKey(tabPage.Name))
                    {
                        tabOutputResults.TabPages.Remove(tabPage);
                    }
                }

                foreach (var templateStream in migrator.TemplateGenerator.TemplateStreams)
                {
                    TabPage tabPage = null;
                    if (!tabOutputResults.TabPages.ContainsKey(templateStream.Key))
                    {
                        tabPage      = new TabPage(templateStream.Key);
                        tabPage.Name = templateStream.Key;
                        tabOutputResults.TabPages.Add(tabPage);

                        if (templateStream.Key.EndsWith(".html"))
                        {
                            WebBrowser webBrowser = new WebBrowser();
                            webBrowser.Width             = tabOutputResults.Width - 15;
                            webBrowser.Height            = tabOutputResults.Height - 30;
                            webBrowser.AllowNavigation   = false;
                            webBrowser.ScrollBarsEnabled = true;
                            tabPage.Controls.Add(webBrowser);
                        }
                        else if (templateStream.Key.EndsWith(".json") || templateStream.Key.EndsWith(".ps1"))
                        {
                            TextBox textBox = new TextBox();
                            textBox.Width      = tabOutputResults.Width - 15;
                            textBox.Height     = tabOutputResults.Height - 30;
                            textBox.ReadOnly   = true;
                            textBox.Multiline  = true;
                            textBox.WordWrap   = false;
                            textBox.ScrollBars = ScrollBars.Both;
                            tabPage.Controls.Add(textBox);
                        }
                    }
                    else
                    {
                        tabPage = tabOutputResults.TabPages[templateStream.Key];
                    }

                    if (tabPage.Controls[0].GetType() == typeof(TextBox))
                    {
                        TextBox textBox = (TextBox)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        textBox.Text = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                    else if (tabPage.Controls[0].GetType() == typeof(WebBrowser))
                    {
                        WebBrowser webBrowser = (WebBrowser)tabPage.Controls[0];
                        templateStream.Value.Position = 0;

                        if (webBrowser.Document == null)
                        {
                            webBrowser.DocumentText = new StreamReader(templateStream.Value).ReadToEnd();
                        }
                        else
                        {
                            webBrowser.Document.OpenNew(true);
                            webBrowser.Document.Write(new StreamReader(templateStream.Value).ReadToEnd());
                        }
                    }
                }

                if (tabOutputResults.TabPages.Count != migrator.TemplateGenerator.TemplateStreams.Count)
                {
                    throw new ArgumentException("Count mismatch between tabOutputResults TabPages and Migrator TemplateStreams.  Counts should match after addition/removal above.  tabOutputResults. TabPages Count: " + tabOutputResults.TabPages.Count + "  Migration TemplateStream Count: " + migrator.TemplateGenerator.TemplateStreams.Count);
                }

                // Ensure Tabs are in same order as output streams
                int streamIndex = 0;
                foreach (string templateStreamKey in migrator.TemplateGenerator.TemplateStreams.Keys)
                {
                    int rotationCounter = 0;

                    // This while loop is to bubble the tab to the end, as to rotate the tab sequence to ensure they match the order returned from the stream outputs
                    // The addition/removal of Streams may result in order of existing tabPages being "out of order" to the streams generated, so we may need to consider reordering
                    while (tabOutputResults.TabPages[streamIndex].Name != templateStreamKey)
                    {
                        TabPage currentTabpage = tabOutputResults.TabPages[streamIndex];
                        tabOutputResults.TabPages.Remove(currentTabpage);
                        tabOutputResults.TabPages.Add(currentTabpage);

                        rotationCounter++;

                        if (rotationCounter > migrator.TemplateGenerator.TemplateStreams.Count)
                        {
                            throw new ArgumentException("Rotated through all tabs, unabled to locate tab '" + templateStreamKey + "' while ensuring tab order/sequencing.");
                        }
                    }

                    streamIndex++;
                }


                lblLastOutputRefresh.Text = "Last Refresh Completed: " + DateTime.Now.ToString();
                btnRefreshOutput.Enabled  = false;

                // post Telemetry Record to ASMtoARMToolAPI
                if (AppSettingsProvider.AllowTelemetry)
                {
                    StatusProvider.UpdateStatus("BUSY: saving telemetry information");
                    migrator.PostTelemetryRecord();
                }
            }
        }
示例#21
0
        public void ThrowAnException_WhenSuppliedPath_IsInvalid(string path)
        {
            StatusProvider statusProvider = new StatusProvider(null);

            Assert.Throws <ArgumentException>(() => statusProvider.Get(path));
        }
示例#22
0
        private async Task <bool> RefreshOutput()
        {
            if (AssertHasTargetErrors())
            {
                return(false);
            }

            IMigrationSourceUserControl migrationSourceControl = this.MigrationSourceControl;

            if (migrationSourceControl == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL MigrationSourceControl Context");
            }

            if (targetAzureContextViewer.ExistingContext == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL Target Existing Azure Context");
            }

            if (targetAzureContextViewer.ExistingContext.AzureSubscription == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL Target Existing Azure Context");
            }

            if (this.AzureGenerator == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL TemplateGenerator");
            }

            if (this.targetAzureContextViewer == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL TargetAzureContextViewer");
            }

            if (this.targetAzureContextViewer.SelectedAzureContext == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL SelectedAzureContext on TargetAzureContextViewer");
            }

            if (this.targetAzureContextViewer.SelectedAzureContext.TokenProvider == null)
            {
                throw new ArgumentException("Unable to Refresh Output:  NULL TokenProvider on SelectedAzureContext");
            }

            if (this.AzureGenerator != null)
            {
                this.AzureGenerator.AccessSASTokenLifetimeSeconds = app.Default.AccessSASTokenLifetimeSeconds;
                this.AzureGenerator.ExportArtifacts          = this.targetTreeView1.ExportArtifacts;
                this.AzureGenerator.OutputDirectory          = this.txtDestinationFolder.Text;
                this.AzureGenerator.TargetAzureTokenProvider = (AzureTokenProvider)this.targetAzureContextViewer.SelectedAzureContext.TokenProvider;

                await this.AzureGenerator.GenerateStreams();

                foreach (TabPage tabPage in tabOutputResults.TabPages)
                {
                    if (!this.AzureGenerator.TemplateStreams.ContainsKey(tabPage.Name))
                    {
                        tabOutputResults.TabPages.Remove(tabPage);
                    }
                }

                foreach (var templateStream in this.AzureGenerator.TemplateStreams)
                {
                    TabPage tabPage = null;
                    if (!tabOutputResults.TabPages.ContainsKey(templateStream.Key))
                    {
                        tabPage      = new TabPage(templateStream.Key);
                        tabPage.Name = templateStream.Key;
                        tabOutputResults.TabPages.Add(tabPage);

                        if (templateStream.Key.EndsWith(".html"))
                        {
                            WebBrowser webBrowser = new WebBrowser();
                            webBrowser.Width             = tabOutputResults.Width - 15;
                            webBrowser.Height            = tabOutputResults.Height - 30;
                            webBrowser.AllowNavigation   = false;
                            webBrowser.ScrollBarsEnabled = true;
                            tabPage.Controls.Add(webBrowser);
                        }
                        else if (templateStream.Key.EndsWith(".json") || templateStream.Key.EndsWith(".ps1"))
                        {
                            TextBox textBox = new TextBox();
                            textBox.Width      = tabOutputResults.Width - 15;
                            textBox.Height     = tabOutputResults.Height - 30;
                            textBox.ReadOnly   = true;
                            textBox.Multiline  = true;
                            textBox.WordWrap   = false;
                            textBox.ScrollBars = ScrollBars.Both;
                            tabPage.Controls.Add(textBox);
                        }
                    }
                    else
                    {
                        tabPage = tabOutputResults.TabPages[templateStream.Key];
                    }

                    if (tabPage.Controls[0].GetType() == typeof(TextBox))
                    {
                        TextBox textBox = (TextBox)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        textBox.Text = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                    else if (tabPage.Controls[0].GetType() == typeof(WebBrowser))
                    {
                        WebBrowser webBrowser = (WebBrowser)tabPage.Controls[0];
                        templateStream.Value.Position = 0;

                        if (webBrowser.Document == null)
                        {
                            webBrowser.DocumentText = new StreamReader(templateStream.Value).ReadToEnd();
                        }
                        else
                        {
                            webBrowser.Document.OpenNew(true);
                            webBrowser.Document.Write(new StreamReader(templateStream.Value).ReadToEnd());
                        }
                    }
                }

                if (tabOutputResults.TabPages.Count != this.AzureGenerator.TemplateStreams.Count)
                {
                    throw new ArgumentException("Count mismatch between tabOutputResults TabPages and Migrator TemplateStreams.  Counts should match after addition/removal above.  tabOutputResults. TabPages Count: " + tabOutputResults.TabPages.Count + "  Migration TemplateStream Count: " + this.AzureGenerator.TemplateStreams.Count);
                }

                // Ensure Tabs are in same order as output streams
                int streamIndex = 0;
                foreach (string templateStreamKey in this.AzureGenerator.TemplateStreams.Keys)
                {
                    int rotationCounter = 0;

                    // This while loop is to bubble the tab to the end, as to rotate the tab sequence to ensure they match the order returned from the stream outputs
                    // The addition/removal of Streams may result in order of existing tabPages being "out of order" to the streams generated, so we may need to consider reordering
                    while (tabOutputResults.TabPages[streamIndex].Name != templateStreamKey)
                    {
                        TabPage currentTabpage = tabOutputResults.TabPages[streamIndex];
                        tabOutputResults.TabPages.Remove(currentTabpage);
                        tabOutputResults.TabPages.Add(currentTabpage);

                        rotationCounter++;

                        if (rotationCounter > this.AzureGenerator.TemplateStreams.Count)
                        {
                            throw new ArgumentException("Rotated through all tabs, unabled to locate tab '" + templateStreamKey + "' while ensuring tab order/sequencing.");
                        }
                    }

                    streamIndex++;
                }


                lblLastOutputRefresh.Text = "Last Refresh Completed: " + DateTime.Now.ToString();
                btnRefreshOutput.Enabled  = false;

                // post Telemetry Record to ASMtoARMToolAPI
                if (AppSettingsProvider.AllowTelemetry)
                {
                    StatusProvider.UpdateStatus("BUSY: saving telemetry information");
                    _telemetryProvider.PostTelemetryRecord(_AppSessionGuid, this.MigrationSourceControl.MigrationSourceType, targetAzureContextViewer.ExistingContext.AzureSubscription, this.AzureGenerator);
                }
            }

            StatusProvider.UpdateStatus("Ready");
            return(true);
        }
 public void register_status_provider(string uid, StatusProvider provider)
 {
     _appService.RegisterStatusProvider(uid, () => provider());
 }
示例#24
0
        private void btnRefreshOutput_Click(object sender, EventArgs e)
        {
            SplitterPanel parent = (SplitterPanel)splitContainer2.Panel1;

            if (parent.Controls.Count == 1)
            {
                IMigratorUserControl migrator = (IMigratorUserControl)parent.Controls[0];

                if (migrator.TemplateGenerator.HasErrors)
                {
                    tabMigAzMonitoring.SelectTab("tabMessages");
                    MessageBox.Show("There are still one or more error(s) with the template generation.  Please resolve all errors before exporting.");
                    return;
                }

                migrator.TemplateGenerator.SerializeStreams();

                foreach (TabPage tabPage in tabOutputResults.TabPages)
                {
                    if (!migrator.TemplateGenerator.TemplateStreams.ContainsKey(tabPage.Name))
                    {
                        tabOutputResults.TabPages.Remove(tabPage);
                    }
                }

                foreach (var templateStream in migrator.TemplateGenerator.TemplateStreams)
                {
                    TabPage tabPage = null;
                    if (!tabOutputResults.TabPages.ContainsKey(templateStream.Key))
                    {
                        tabPage      = new TabPage(templateStream.Key);
                        tabPage.Name = templateStream.Key;
                        tabOutputResults.TabPages.Add(tabPage);

                        if (templateStream.Key.EndsWith(".html"))
                        {
                            WebBrowser webBrowser = new WebBrowser();
                            webBrowser.Width             = tabOutputResults.Width - 15;
                            webBrowser.Height            = tabOutputResults.Height - 30;
                            webBrowser.AllowNavigation   = false;
                            webBrowser.ScrollBarsEnabled = true;
                            tabPage.Controls.Add(webBrowser);
                        }
                        else if (templateStream.Key.EndsWith(".json"))
                        {
                            TextBox textBox = new TextBox();
                            textBox.Width      = tabOutputResults.Width - 15;
                            textBox.Height     = tabOutputResults.Height - 30;
                            textBox.ReadOnly   = true;
                            textBox.Multiline  = true;
                            textBox.WordWrap   = false;
                            textBox.ScrollBars = ScrollBars.Both;
                            tabPage.Controls.Add(textBox);
                        }
                    }
                    else
                    {
                        tabPage = tabOutputResults.TabPages[templateStream.Key];
                    }

                    if (tabPage.Controls[0].GetType() == typeof(TextBox))
                    {
                        TextBox textBox = (TextBox)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        textBox.Text = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                    else if (tabPage.Controls[0].GetType() == typeof(WebBrowser))
                    {
                        WebBrowser webBrowser = (WebBrowser)tabPage.Controls[0];
                        templateStream.Value.Position = 0;
                        webBrowser.DocumentText       = new StreamReader(templateStream.Value).ReadToEnd();
                    }
                }

                lblLastOutputRefresh.Text = "Last Refresh Completed: " + DateTime.Now.ToString();
                btnRefreshOutput.Enabled  = false;

                // post Telemetry Record to ASMtoARMToolAPI
                if (AppSettingsProvider.AllowTelemetry)
                {
                    StatusProvider.UpdateStatus("BUSY: saving telemetry information");
                    migrator.PostTelemetryRecord();
                }
            }
        }
示例#25
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");
        }
 /// <summary>
 /// Creates an instance of this command, passing the logger to write messages to.
 /// </summary>
 /// <param name="logger">The logger which messages should be written to.</param>
 public GetByStatusProvider(ILogger logger, StatusProvider statusProvider)
     : base(logger)
 {
     StatusProvider = statusProvider;
 }
示例#27
0
        protected void GridView_CustomCallback(object sender, DevExpress.Web.ASPxGridViewCustomCallbackEventArgs e)
        {
            switch (e.Parameters)
            {
            case "CloneRow":
                HttpContext.Current.Session["isCloneRow_Com"] = true;
                GridView.JSProperties["cpMessage"]            = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "DetailRow":
                HttpContext.Current.Session["isDetailRow_Com"] = true;
                GridView.JSProperties["cpMessage"]             = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "Actived":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.SetActived(itemID, true);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "InActived":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.SetActived(itemID, false);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "Blocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.SetBlocked(itemID, true, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "UnBlocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.SetBlocked(itemID, false, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "InActivedBlocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.SetActivedBlocked(itemID, false, true, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "ActivedUnBlocked":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.SetActivedBlocked(itemID, true, false, User.Identity.Name);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

            case "Delete":
                if (GridView.FocusedRowIndex >= 0)
                {
                    var itemID = GridView.GetRowValues(GridView.FocusedRowIndex, "Id").ToString();
                    StatusProvider.Delete(itemID);
                    //StandardTypeProvider.Delete(itemID);
                    GridView.DataBind();
                    UpdateNavBarName();
                }
                GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                break;

                //case "Delete":
                //List<int> selectedIds = GridView.GetSelectedFieldValues("Id").ConvertAll(id => (int)id);
                //foreach (var item in selectedIds)
                //{
                //    StandardTypeProvider.DeleteSuit(item, false);
                //    HttpContext.Current.Session["isActBloChanged_Com"] = true;
                //}
                //GridView.DataBind();
                //GridView.JSProperties["cpMessage"] = string.Format("OrderDate {0} is later than {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString());
                //break;
            }
            GridView.JSProperties["cpParameters"] = e.Parameters;
        }
示例#28
0
        private async void treeARM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LogProvider.WriteLog("treeARM_AfterSelect", "Start");
            _SourceArmNode = e.Node;

            _PropertyPanel.Clear();
            _PropertyPanel.ResourceText = String.Empty;
            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.GetType() == typeof(TreeNode))
                {
                    TreeNode asmTreeNode = (TreeNode)e.Node.Tag;

                    if (asmTreeNode.Tag != null)
                    {
                        _PropertyPanel.ResourceText = e.Node.Text;

                        if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.VirtualNetwork) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.VirtualNetwork))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["VirtualNetwork"];

                            VirtualNetworkProperties properties = new VirtualNetworkProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(e.Node);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.StorageAccount) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.StorageAccount))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["StorageAccount"];

                            StorageAccountProperties properties = new StorageAccountProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(this._AzureContextTargetARM, e.Node);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.VirtualMachine) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.VirtualMachine))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["VirtualMachine"];

                            VirtualMachineProperties properties = new VirtualMachineProperties();
                            properties.LogProvider       = LogProvider;
                            properties.AllowManangedDisk = (await _AzureContextSourceASM.AzureRetriever.GetAzureARMManagedDisks() != null);
                            properties.PropertyChanged  += Properties_PropertyChanged;
                            await properties.Bind(e.Node, this);

                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.NetworkSecurityGroup) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.NetworkSecurityGroup))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["NetworkSecurityGroup"];

                            NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(e.Node, this);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                    }
                }
                if (e.Node.Tag.GetType() == typeof(Azure.Asm.Subnet) || e.Node.Tag.GetType() == typeof(Azure.Arm.Subnet))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["VirtualNetwork"];

                    SubnetProperties properties = new SubnetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(Azure.Asm.Disk) || e.Node.Tag.GetType() == typeof(Azure.Arm.Disk))
                {
                    Azure.Asm.Disk asmDisk = (Azure.Asm.Disk)e.Node.Tag;

                    this._PropertyPanel.ResourceImage = imageList1.Images["Disk"];

                    DiskProperties properties = new DiskProperties();
                    properties.LogProvider       = this.LogProvider;
                    properties.AllowManangedDisk = (await _AzureContextSourceASM.AzureRetriever.GetAzureARMManagedDisks() != null);
                    properties.PropertyChanged  += Properties_PropertyChanged;
                    properties.Bind(this, e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(Azure.Asm.AvailabilitySet))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["AvailabilitySet"];

                    AvailabilitySetProperties properties = new AvailabilitySetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(ResourceGroup))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["ResourceGroup"];

                    ResourceGroupProperties properties = new ResourceGroupProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    await properties.Bind(this, e.Node);

                    _PropertyPanel.PropertyDetailControl = properties;
                }
            }

            _SourceArmNode = null;
            LogProvider.WriteLog("treeARM_AfterSelect", "End");
            StatusProvider.UpdateStatus("Ready");
        }
示例#29
0
        private async Task AutoSelectDependencies(TreeNode selectedNode)
        {
            if ((app.Default.AutoSelectDependencies) && (selectedNode.Checked) && (selectedNode.Tag != null))
            {
                if (selectedNode.Tag.GetType() == typeof(Azure.Asm.VirtualMachine))
                {
                    Azure.Asm.VirtualMachine asmVirtualMachine = (Azure.Asm.VirtualMachine)selectedNode.Tag;

                    #region process virtual network
                    if (asmVirtualMachine.VirtualNetworkName != string.Empty)
                    {
                        foreach (TreeNode treeNode in treeSourceASM.Nodes.Find(asmVirtualMachine.VirtualNetworkName, true))
                        {
                            if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.Asm.VirtualNetwork)))
                            {
                                if (!treeNode.Checked)
                                {
                                    treeNode.Checked = true;
                                }
                            }
                        }
                    }

                    #endregion

                    #region OS Disk Storage Account

                    foreach (TreeNode treeNode in treeSourceASM.Nodes.Find(asmVirtualMachine.OSVirtualHardDisk.StorageAccountName, true))
                    {
                        if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.Asm.StorageAccount)))
                        {
                            if (!treeNode.Checked)
                            {
                                treeNode.Checked = true;
                            }
                        }
                    }

                    #endregion

                    #region Data Disk(s) Storage Account(s)

                    foreach (Azure.Asm.Disk dataDisk in asmVirtualMachine.DataDisks)
                    {
                        foreach (TreeNode treeNode in treeSourceASM.Nodes.Find(dataDisk.StorageAccountName, true))
                        {
                            if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.Asm.StorageAccount)))
                            {
                                if (!treeNode.Checked)
                                {
                                    treeNode.Checked = true;
                                }
                            }
                        }
                    }

                    #endregion

                    #region Network Security Group

                    if (asmVirtualMachine.NetworkSecurityGroup != null)
                    {
                        foreach (TreeNode treeNode in treeSourceASM.Nodes.Find(asmVirtualMachine.NetworkSecurityGroup.Name, true))
                        {
                            if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.Asm.NetworkSecurityGroup)))
                            {
                                if (!treeNode.Checked)
                                {
                                    treeNode.Checked = true;
                                }
                            }
                        }
                    }

                    #endregion
                }

                else if (selectedNode.Tag.GetType() == typeof(Azure.Asm.VirtualNetwork))
                {
                    Azure.Asm.VirtualNetwork asmVirtualNetwork = (Azure.Asm.VirtualNetwork)selectedNode.Tag;

                    foreach (Azure.Asm.Subnet asmSubnet in asmVirtualNetwork.Subnets)
                    {
                        if (asmSubnet.NetworkSecurityGroup != null)
                        {
                            foreach (TreeNode treeNode in treeSourceASM.Nodes.Find(asmSubnet.NetworkSecurityGroup.Name, true))
                            {
                                if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.Asm.NetworkSecurityGroup)))
                                {
                                    if (!treeNode.Checked)
                                    {
                                        treeNode.Checked = true;
                                    }
                                }
                            }
                        }
                    }
                }

                StatusProvider.UpdateStatus("Ready");
            }
        }
示例#30
0
        private async Task _AzureContextARM_AfterAzureSubscriptionChange(AzureContext sender)
        {
            ResetForm();

            if (sender.AzureSubscription != null)
            {
                //btnAzureContextARM.Enabled = true;

                TreeNode subscriptionNode = new TreeNode(sender.AzureSubscription.Name);
                treeSource.Nodes.Add(subscriptionNode);
                subscriptionNode.Expand();

                foreach (ResourceGroup armResourceGroup in await _AzureContextARM.AzureRetriever.GetAzureARMResourceGroups())
                {
                }

                List <VirtualNetwork> armVirtualNetworks = await _AzureContextARM.AzureRetriever.GetAzureARMVirtualNetworks();

                foreach (VirtualNetwork armVirtualNetwork in armVirtualNetworks)
                {
                    if (armVirtualNetwork.HasNonGatewaySubnet)
                    {
                        TreeNode parentNode       = MigAzTreeView.GetDataCenterTreeViewNode(subscriptionNode, armVirtualNetwork.Location, "Virtual Networks");
                        TreeNode tnVirtualNetwork = new TreeNode(armVirtualNetwork.Name);
                        tnVirtualNetwork.Name = armVirtualNetwork.Name;
                        tnVirtualNetwork.Tag  = armVirtualNetwork;
                        parentNode.Nodes.Add(tnVirtualNetwork);
                        parentNode.Expand();
                    }
                }

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

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

                subscriptionNode.ExpandAll();

                //    if (app.Default.SaveSelection)
                //    {
                //        lblStatus.Text = "BUSY: Reading saved selection";
                //        Application.DoEvents();
                //        _saveSelectionProvider.Read(Guid.Parse(subscriptionid),ref lvwVirtualNetworks, ref lvwStorageAccounts, ref lvwVirtualMachines);
                //    }

                treeSource.Enabled = true;
            }

            StatusProvider.UpdateStatus("Ready");
        }