This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathMainForm.cs
147 lines (124 loc) · 5.11 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Copyright (c) Microsoft Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using CompatCheckAndMigrate.Controls;
using CompatCheckAndMigrate.Helpers;
using CompatCheckAndMigrate.ObjectModel;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace CompatCheckAndMigrate
{
public partial class MainForm : Form
{
private Control _previousControl = null;
private Dictionary<WizardSteps, IWizardStep> _steps = new Dictionary<WizardSteps, IWizardStep>()
{
{WizardSteps.FeedbackPage, new SendFeedbackControl()},
{ WizardSteps.MigrationCandidates, new MigrationCandidatesControl() },
{ WizardSteps.ReadinessReport, new ReadinessReportControl() },
{ WizardSteps.SaveReadinessReport, new SaveReadinessReportControl() },
{ WizardSteps.Confirmation, new ConfirmationControl() },
{WizardSteps.ContentAndDbMigration, new ContentAndDbMigrationControl()},
{WizardSteps.SiteStep,new MigrationSite()},
{WizardSteps.InstallWebDeploy, new InstallerControl()},
{WizardSteps.SiteNotMigrated, new SiteStatusControl()},
{WizardSteps.RemoteComputerInfo, new RemoteServerControl()},
{WizardSteps.AddRemoteServers, new AddRemoteServers()},
{WizardSteps.PickPublishSettings, new PickPublishSettingsControl()},
};
private void InitializeTrace()
{
TraceHelper.Tracer = new Tracer();
}
public MainForm()
{
InitializeComponent();
InitializeTrace();
CheckAndSetBrowserEmulation();
this.WindowState = FormWindowState.Maximized;
}
public static void WriteTrace(string format, params object[] args)
{
TraceHelper.Tracer.WriteTrace(format, args);
}
private static void CheckAndSetBrowserEmulation()
{
// Get highest iE installed
var ieVersion = Helper.InstalledIEVersion;
if (ieVersion < 8 || ieVersion > 13)
{
Helper.ShowErrorMessageAndExit("The application needs IE 8 or higher installed. Please install the latest IE supported for this system and restart the application. The application will now exit");
}
Helper.SetEmulationVersion(ieVersion);
}
static MainForm()
{
ServicePointManager.ServerCertificateValidationCallback += ServerCertificateValidationCallback;
}
private static bool ServerCertificateValidationCallback(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
private void MainForm_Load(object sender, System.EventArgs e)
{
InitializeWizardSteps();
}
private void InitializeWizardSteps()
{
// Subscribe to wizard steps notifications
foreach (var step in _steps)
{
step.Value.GoTo += OnGoToStep;
}
if (Helper.IsWebDeployInstalled && !Helper.IsIISComponentNeeded)
{
// Go to first step
GoToStep(WizardSteps.RemoteComputerInfo, null);
}
else
{
var result = MessageBox.Show("Web Deploy is needed for migrating your site content and database to azure. Would you like to install it?",
"Web Deploy For Publish",
MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
GoToStep(WizardSteps.InstallWebDeploy, null);
}
else
{
GoToStep(WizardSteps.RemoteComputerInfo, null);
}
}
}
private void OnGoToStep(object sender, GoToWizardStepEventArgs e)
{
GoToStep(e.GoTo, e.State, e.IsNavigatingBack);
}
private void GoToStep(WizardSteps step, object state, bool isNavigatingBack = false)
{
this.SuspendLayout();
if (_previousControl != null)
{
this.contentPanel.Controls.Remove(_previousControl);
}
IWizardStep wizardStep = _steps[step];
wizardStep.SetState(state, isNavigatingBack);
Control wizardStepControl = (Control)wizardStep;
wizardStepControl.Dock = DockStyle.Fill;
this.contentPanel.Controls.Add(wizardStepControl);
this.contentPanel.ResumeLayout(false);
this.contentPanel.PerformLayout();
this.ResumeLayout(false);
_previousControl = wizardStepControl;
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
}
}
}