aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Azure/Tango.AzureUtils
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-02-03 19:57:18 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-02-03 19:57:18 +0200
commit384ef8966066b6c2ee973b906ff78418f533f174 (patch)
treed8c568a722e2ff113ca3176013d80593fdd64cd2 /Software/Visual_Studio/Azure/Tango.AzureUtils
parent45e7cad9ca890376374b9485bac7818ccbc4d70e (diff)
downloadTango-384ef8966066b6c2ee973b906ff78418f533f174.tar.gz
Tango-384ef8966066b6c2ee973b906ff78418f533f174.zip
Working on Azure Utils.
Diffstat (limited to 'Software/Visual_Studio/Azure/Tango.AzureUtils')
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs484
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentProgressEventArgs.cs17
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentStage.cs16
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs18
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/UpgradeConfiguration.cs15
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj32
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/app.config14
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config2
8 files changed, 563 insertions, 35 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs
index e9ae6e97b..8a3b6ad7b 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentManager.cs
@@ -1,4 +1,5 @@
-using Microsoft.Azure.Management.AppService.Fluent;
+using FluentFTP;
+using Microsoft.Azure.Management.AppService.Fluent;
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
@@ -6,27 +7,70 @@ using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Blob;
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Data.Entity;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Xml;
+using System.Xml.Linq;
+using Tango.BL;
+using Tango.BL.Entities;
+using Tango.Core;
+using Tango.Core.Helpers;
namespace Tango.AzureUtils.Deployment
{
- public class DeploymentManager
+ public class DeploymentManager : ExtendedObject
{
private AzureUtilsCredentials _credentials;
private IAzure _azure;
+ private IProgress<FtpProgress> _ftpDownloadProgress;
+ private IProgress<FtpProgress> _ftpUploadProgress;
+
+ //TODO: Embedded TFP injection to current package!
+
+ #region Events
+
+ public event EventHandler<DeploymentProgressEventArgs> DeploymentProgress;
+
+ #endregion
+
+ #region Properties
+
+ private UpgradeConfiguration _upgradeConfiguration;
+ public UpgradeConfiguration UpgradeConfiguration
+ {
+ get { return _upgradeConfiguration; }
+ set { _upgradeConfiguration = value; RaisePropertyChangedAuto(); }
+ }
+
+ #endregion
+
+ #region Constructors
public DeploymentManager(AzureUtilsCredentials credentials)
{
+ UpgradeConfiguration = new UpgradeConfiguration();
+
_credentials = credentials;
+
+ _ftpDownloadProgress = new Progress<FtpProgress>((p) =>
+ {
+ OnProgress(DeploymentStage.DownloadingFTP, $"Downloading {p.RemotePath}...", p.Progress, 100, false);
+ });
+
+ _ftpUploadProgress = new Progress<FtpProgress>((p) =>
+ {
+ OnProgress(DeploymentStage.UploadingFTP, $"Uploading {p.LocalPath}...", p.Progress, 100, false);
+ });
}
- private static string app_id = "be33437c-5052-449f-ab9d-a88d008eae24";
- private static string client_secret = "bf67fb6f-4d06-4893-988c-6b347aff23d6";
- private static string tenant_id = "2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4";
- private static string subscription_id = "10c8aa60-3b15-4e0d-b412-6aeef90e5e91";
+ #endregion
+
+ #region Authenticate
private IAzure GetOrCreateAzure()
{
@@ -44,56 +88,430 @@ namespace Tango.AzureUtils.Deployment
return _azure;
}
- public List<IWebApp> GetAllWebApps()
+ #endregion
+
+ #region Helpers
+
+ public async Task<List<IWebApp>> GetAllWebAppsAsync()
+ {
+ return (await GetOrCreateAzure().WebApps.ListAsync()).ToList();
+ }
+
+ #endregion
+
+ #region Init
+
+ public void Init()
+ {
+ GetOrCreateAzure();
+ }
+
+ #endregion
+
+ #region Full Upgrade
+
+ public async Task PerformFullUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ await ValidateUpgrade(sourceApp, targetApp);
+
+ await UpgradeStorage(sourceApp, targetApp);
+ await UpgradeVersions(sourceApp, targetApp);
+
+ if (UpgradeConfiguration.UpgradeMachineService)
+ {
+ await UpgradeMachineService(sourceApp, targetApp);
+ }
+ }
+
+ #endregion
+
+ #region SQLExaminer
+
+ public async Task OpenSQLExaminerSchema(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ String projectFile = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "Deployment", "GENERAL_ENV_UPGRADE.seproj");
+
+ using (Stream stream = GetFileStream(projectFile))
+ {
+ XElement projectXml = XElement.Load(stream);
+ var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync();
+ var targetSettings = await targetApp.GetMachineServiceSettingsAsync();
+ ApplyDatabaseSettingsToProjectXml(projectXml, sourceSettings, targetSettings);
+
+ var tempFile = TemporaryManager.CreateImaginaryFile(".seproj");
+ tempFile.Persist = true;
+
+ File.WriteAllText(tempFile, projectXml.ToString());
+
+ Process.Start(tempFile);
+ }
+ }
+
+ public async Task OpenSQLExaminerData(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ String projectFile = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "Deployment", "GENERAL_ENV_UPGRADE.sdeproj");
+
+ using (Stream stream = GetFileStream(projectFile))
+ {
+ XElement projectXml = XElement.Load(stream);
+ var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync();
+ var targetSettings = await targetApp.GetMachineServiceSettingsAsync();
+ ApplyDatabaseSettingsToProjectXml(projectXml, sourceSettings, targetSettings);
+
+ var tempFile = TemporaryManager.CreateImaginaryFile(".sdeproj");
+ tempFile.Persist = true;
+
+ File.WriteAllText(tempFile, projectXml.ToString());
+
+ Process.Start(tempFile);
+ }
+ }
+
+ private Stream GetFileStream(String projectFile)
+ {
+ byte[] projectBytes = File.ReadAllBytes(projectFile);
+ MemoryStream stream = new MemoryStream(projectBytes);
+ return stream;
+ }
+
+ private void ApplyDatabaseSettingsToProjectXml(XElement projectXml, MachineServiceSettings sourceSettings, MachineServiceSettings targetSettings)
+ {
+ var sourceElement = projectXml.Elements().SelectMany(x => x.Descendants()).SingleOrDefault(x => x.Name == "Source" && x.Attributes().SingleOrDefault(y => y.Name == "id").Value == "1");
+ var targetElement = projectXml.Elements().SelectMany(x => x.Descendants()).SingleOrDefault(x => x.Name == "Source" && x.Attributes().SingleOrDefault(y => y.Name == "id").Value == "2");
+
+ ApplyDatabaseSettingsToSourceElement(sourceElement, sourceSettings);
+ ApplyDatabaseSettingsToSourceElement(targetElement, targetSettings);
+ }
+
+ private void ApplyDatabaseSettingsToSourceElement(XElement sourceElement, MachineServiceSettings settings)
+ {
+ sourceElement.Element("ServerName").SetValue(settings.DB_ADDRESS);
+ sourceElement.Element("Database").SetValue(settings.DB_CATALOG);
+ sourceElement.Element("Login").SetValue(settings.DB_USER_NAME);
+ sourceElement.Element("Password").SetValue(settings.DB_PASSWORD);
+ }
+
+ #endregion
+
+ #region FTP
+
+ private async Task<List<FtpResult>> DownloadWebAppFiles(IWebAppBase app, String targetFolder)
+ {
+ var profile = await app.GetPublishingProfileAsync();
+
+ using (var ftp = new FtpClient(profile.FtpUrl, profile.FtpUsername, profile.FtpPassword))
+ {
+ var downloadResults = await ftp.DownloadDirectoryAsync(targetFolder, "/site/wwwroot", progress: _ftpDownloadProgress);
+
+ foreach (var downloadResult in downloadResults)
+ {
+ if (downloadResult.IsFailed)
+ {
+ throw downloadResult.Exception;
+ }
+ }
+
+ return downloadResults;
+ }
+ }
+
+ private async Task<List<FtpResult>> UploadWebAppFiles(IWebAppBase app, String sourceFolder)
+ {
+ var profile = await app.GetPublishingProfileAsync();
+
+ using (var ftp = new FtpClient(profile.FtpUrl, profile.FtpUsername, profile.FtpPassword))
+ {
+ var uploadResults = await ftp.UploadDirectoryAsync(sourceFolder, "/site/wwwroot", existsMode: FtpRemoteExists.Overwrite, progress: _ftpUploadProgress);
+
+ foreach (var uploadResult in uploadResults)
+ {
+ if (uploadResult.IsFailed)
+ {
+ throw uploadResult.Exception;
+ }
+ }
+
+ return uploadResults;
+ }
+ }
+
+ #endregion
+
+ #region Machine Service
+
+ public async Task UpgradeMachineService(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ var webAppFilesTempFolder = TemporaryManager.CreateFolder();
+ var downloadResults = await DownloadWebAppFiles(sourceApp, webAppFilesTempFolder);
+ var uploadResults = await UploadWebAppFiles(targetApp, webAppFilesTempFolder + "\\wwwroot");
+ }
+
+ #endregion
+
+ #region Applications Versions & Storage Blobs
+
+ public async Task<MachineStudioVersion> GetLatestMachineStudioVersion(IWebAppBase app)
+ {
+ MachineServiceSettings settings = null;
+
+ try
+ {
+ settings = await app.GetMachineServiceSettingsAsync();
+ }
+ catch (Exception ex)
+ {
+ throw new ArgumentException("Could not fetch machine service settings. Please check that all settings are available.");
+ }
+
+ try
+ {
+ DataSource dataSource = settings.ToDataSource();
+
+ using (var db = ObservablesContext.CreateDefault(dataSource))
+ {
+ var versions = await db.MachineStudioVersions.ToListAsync();
+ var latest_machine_version = versions.OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault();
+ return latest_machine_version;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidDataException("Could not retrieve latest Machine Studio version from database.", ex);
+ }
+ }
+
+ public async Task<TangoVersion> GetLatestPPCVersion(IWebAppBase app)
{
- return GetOrCreateAzure().WebApps.List().ToList();
+ MachineServiceSettings settings = null;
+
+ try
+ {
+ settings = await app.GetMachineServiceSettingsAsync();
+ }
+ catch (Exception ex)
+ {
+ throw new ArgumentException("Could not fetch machine service settings. Please check that all settings are available.", ex);
+ }
+
+ try
+ {
+ DataSource dataSource = settings.ToDataSource();
+
+ using (var db = ObservablesContext.CreateDefault(dataSource))
+ {
+ var versions = await db.TangoVersions.ToListAsync();
+ var latest_machine_version = versions.OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault();
+ return latest_machine_version;
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidDataException("Could not retrieve latest PPC version from database.", ex);
+ }
}
- public void UpdateSlot(IDeploymentSlot slot)
+ public async Task UpgradeStorage(IWebAppBase sourceApp, IWebAppBase targetApp)
{
-
+ await ValidateUpgrade(sourceApp, targetApp);
+
+ var latestMachineStudioVersion = await GetLatestMachineStudioVersion(sourceApp);
+ var latestPPCVersion = await GetLatestPPCVersion(sourceApp);
+
+ var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync();
+ var targetSettings = await targetApp.GetMachineServiceSettingsAsync();
+
+ var sourceAccount = CloudStorageAccount.Parse(sourceSettings.STORAGE_ACCOUNT);
+ var sourceClient = sourceAccount.CreateCloudBlobClient();
+
+ var targetAccount = CloudStorageAccount.Parse(targetSettings.STORAGE_ACCOUNT);
+ var targetClient = targetAccount.CreateCloudBlobClient();
+
+ var sourceMachineStudioContainer = sourceClient.GetContainerReference(sourceSettings.MACHINE_STUDIO_VERSIONS_CONTAINER);
+ var targetMachineStudioContainer = targetClient.GetContainerReference(targetSettings.MACHINE_STUDIO_VERSIONS_CONTAINER);
+
+ var sourcePPCContainer = sourceClient.GetContainerReference(sourceSettings.TANGO_VERSIONS_CONTAINER);
+ var targetPPCContainer = targetClient.GetContainerReference(targetSettings.TANGO_VERSIONS_CONTAINER);
+
+ var sourceMachineStudioBlob = sourceMachineStudioContainer.GetBlockBlobReference(latestMachineStudioVersion.BlobName);
+ var sourceMachineStudioInstallerBlob = sourceMachineStudioContainer.GetBlockBlobReference(latestMachineStudioVersion.InstallerBlobName);
+
+ var targetMachineStudioBlob = CreateEmptyBlob(targetMachineStudioContainer, sourceMachineStudioBlob.Name);
+ var targetMachineStudioInstallerBlob = CreateEmptyBlob(targetMachineStudioContainer, sourceMachineStudioInstallerBlob.Name);
+
+ await Task.Factory.StartNew(() =>
+ {
+ targetMachineStudioBlob.StartCopy(sourceMachineStudioBlob);
+ targetMachineStudioInstallerBlob.StartCopy(sourceMachineStudioInstallerBlob);
+ });
}
- public void Deploy()
+ public async Task UpgradeVersions(IWebAppBase sourceApp, IWebAppBase targetApp)
{
- var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
- app_id,
- client_secret,
- tenant_id,
- AzureEnvironment.AzureGlobalCloud);
+ await ValidateUpgrade(sourceApp, targetApp);
+
+ if (UpgradeConfiguration.UpgradeMachineStudio)
+ {
+ await UpgradeMachineStudioVersion(sourceApp, targetApp);
+ }
- var azure = Azure.Authenticate(credentials).WithSubscription(subscription_id);
- var webApps = azure.WebApps.List();
+ if (UpgradeConfiguration.UpgradePPC)
+ {
+ await UpgradePPCVersion(sourceApp, targetApp);
+ }
+ }
- var machineService = webApps.SingleOrDefault(x => x.Name == "MachineService");
- var devSlot = machineService.DeploymentSlots.GetByName("MachineService-DEV");
- var devProfile = devSlot.GetPublishingProfile();
+ private async Task UpgradeMachineStudioVersion(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ var latestMachineStudioVersion = await GetLatestMachineStudioVersion(sourceApp);
- String ftpAddress = devProfile.FtpUrl;
- String ftpUser = devProfile.FtpUsername;
- String ftpPassword = devProfile.FtpPassword;
+ var targetDataSource = (await targetApp.GetMachineServiceSettingsAsync()).ToDataSource();
- foreach (var ds in machineService.DeploymentSlots.List())
+ using (var db = ObservablesContext.CreateDefault(targetDataSource))
{
- Console.WriteLine(ds.Name);
+ db.MachineStudioVersions.Add(latestMachineStudioVersion);
+ await db.SaveChangesAsync();
}
+ }
- CloudStorageAccount sourceAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=tangostorage;AccountKey=S4z/D+Yg6mwMis+bs/VpcDLA9yE1iZaYq23shQlRIi2KmM9E7JY8zdZjeAPOPdG3gONHoNDEpsgH6D4cqQ/bsA==;EndpointSuffix=core.windows.net");
- CloudBlobClient sourceClient = sourceAccount.CreateCloudBlobClient();
+ private async Task UpgradePPCVersion(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ var latestPPCVersion = await GetLatestPPCVersion(sourceApp);
- var sourceContainer = sourceClient.GetContainerReference("machine-studio-versions-test");
- var sourceBlob = sourceContainer.GetBlockBlobReference("Machine Studio v4.0.34.0.zip");
+ var targetDataSource = (await targetApp.GetMachineServiceSettingsAsync()).ToDataSource();
- var targetContainer = sourceClient.GetContainerReference("machine-studio-versions-dev");
+ using (var db = ObservablesContext.CreateDefault(targetDataSource))
+ {
+ db.TangoVersions.Add(latestPPCVersion);
+ await db.SaveChangesAsync();
+ }
+ }
- CloudBlockBlob targetBlob = targetContainer.GetBlockBlobReference(sourceBlob.Name);
+ private CloudBlockBlob CreateEmptyBlob(CloudBlobContainer container, String name)
+ {
+ CloudBlockBlob targetBlob = container.GetBlockBlobReference(name);
using (MemoryStream ms = new MemoryStream())
{
targetBlob.UploadFromStream(ms);//Empty memory stream. Will create an empty blob.
}
- targetBlob.StartCopy(sourceBlob);
+ return targetBlob;
+ }
+
+ #endregion
+
+ #region Validation
+
+ public async Task ValidateUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ if (UpgradeConfiguration.UpgradeMachineStudio)
+ {
+ await ValidateMachineStudioUpgrade(sourceApp, targetApp);
+ }
+
+ if (UpgradeConfiguration.UpgradePPC)
+ {
+ await ValidatePPCUpgrade(sourceApp, targetApp);
+ }
+ }
+
+ private async Task ValidateMachineStudioUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync();
+ var targetSettings = await targetApp.GetMachineServiceSettingsAsync();
+
+ var latestSourceMachineStudioVersion = await GetLatestMachineStudioVersion(sourceApp);
+
+ //Check if there is any source machine studio version.
+ if (latestSourceMachineStudioVersion == null)
+ {
+ throw new ValidationException("Could not locate a Machine Studio version entry on the source database.");
+ }
+
+ var latestTargetMachineStudioVersion = await GetLatestMachineStudioVersion(targetApp);
+
+ //Check target latest machine studio version is older if there is any.
+ if (latestTargetMachineStudioVersion != null && Version.Parse(latestSourceMachineStudioVersion.Version) <= Version.Parse(latestTargetMachineStudioVersion.Version))
+ {
+ throw new ValidationException($"Machine Studio source version is '{latestSourceMachineStudioVersion.Version}' while target version is '{latestTargetMachineStudioVersion.Version}'.");
+ }
+
+ var targetAccount = CloudStorageAccount.Parse(targetSettings.STORAGE_ACCOUNT);
+ var targetClient = targetAccount.CreateCloudBlobClient();
+
+ var targetMachineStudioContainer = targetClient.GetContainerReference(targetSettings.MACHINE_STUDIO_VERSIONS_CONTAINER);
+
+ //Check machine studio binaries blob not exists on the target.
+ var targetMachineStudioBlob = targetMachineStudioContainer.GetBlockBlobReference(latestSourceMachineStudioVersion.BlobName);
+ if (await targetMachineStudioBlob.ExistsAsync())
+ {
+ throw new ValidationException($"Machine Studio Block blob '{latestSourceMachineStudioVersion.BlobName}' already exists on the target storage.");
+ }
+
+ //Check machine studio installer blob not exists on the target.
+ var targetMachineStudioInstallerBlob = targetMachineStudioContainer.GetBlockBlobReference(latestSourceMachineStudioVersion.InstallerBlobName);
+ if (await targetMachineStudioInstallerBlob.ExistsAsync())
+ {
+ throw new ValidationException($"Machine Studio Block blob '{latestSourceMachineStudioVersion.InstallerBlobName}' already exists on the target storage.");
+ }
+ }
+
+ private async Task ValidatePPCUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp)
+ {
+ var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync();
+ var targetSettings = await targetApp.GetMachineServiceSettingsAsync();
+
+ var latestSourcePPCVersion = await GetLatestPPCVersion(sourceApp);
+
+ //Check if there is any source PPC version.
+ if (latestSourcePPCVersion == null)
+ {
+ throw new ValidationException("Could not locate a PPC version entry on the source database.");
+ }
+
+ var latestTargetPPCVersion = await GetLatestPPCVersion(targetApp);
+
+ //Check target latest PPC version is older if there is any.
+ if (latestTargetPPCVersion != null && Version.Parse(latestSourcePPCVersion.Version) <= Version.Parse(latestTargetPPCVersion.Version))
+ {
+ throw new ValidationException($"PPC source version is '{latestSourcePPCVersion.Version}' while target version is '{latestTargetPPCVersion.Version}'.");
+ }
+
+ var targetAccount = CloudStorageAccount.Parse(targetSettings.STORAGE_ACCOUNT);
+ var targetClient = targetAccount.CreateCloudBlobClient();
+
+ var targetPPCContainer = targetClient.GetContainerReference(targetSettings.TANGO_VERSIONS_CONTAINER);
+
+ //Check PPC binaries blob not exists on the target.
+ var targetPPCBlob = targetPPCContainer.GetBlockBlobReference(latestSourcePPCVersion.BlobName);
+ if (await targetPPCBlob.ExistsAsync())
+ {
+ throw new ValidationException($"PPC Block blob '{latestSourcePPCVersion.BlobName}' already exists on the target storage.");
+ }
+
+ //Check PPC installer blob not exists on the target.
+ var targetPPCInstallerBlob = targetPPCContainer.GetBlockBlobReference(latestSourcePPCVersion.InstallerBlobName);
+ if (await targetPPCInstallerBlob.ExistsAsync())
+ {
+ throw new ValidationException($"PPC Block blob '{latestSourcePPCVersion.InstallerBlobName}' already exists on the target storage.");
+ }
+ }
+
+ #endregion
+
+ #region Virtual Methods
+
+ protected virtual void OnProgress(DeploymentStage stage, String message = null, double progress = 0, double maximum = 100, bool indeterminate = true)
+ {
+ DeploymentProgress?.Invoke(this, new DeploymentProgressEventArgs()
+ {
+ Stage = stage,
+ Message = message,
+ Progress = progress,
+ Maximum = maximum,
+ IsIndeterminate = indeterminate,
+ });
}
+ #endregion
}
}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentProgressEventArgs.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentProgressEventArgs.cs
new file mode 100644
index 000000000..5fe166464
--- /dev/null
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentProgressEventArgs.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.AzureUtils.Deployment
+{
+ public class DeploymentProgressEventArgs : EventArgs
+ {
+ public DeploymentStage Stage { get; set; }
+ public double Progress { get; set; }
+ public double Maximum { get; set; }
+ public bool IsIndeterminate { get; set; }
+ public String Message { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentStage.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentStage.cs
new file mode 100644
index 000000000..531a1ed8c
--- /dev/null
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/DeploymentStage.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.AzureUtils.Deployment
+{
+ public enum DeploymentStage
+ {
+ Ready,
+ Initializing,
+ DownloadingFTP,
+ UploadingFTP,
+ }
+}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs
index 6b57ce53a..b9437e49e 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/ExtensionMethods.cs
@@ -5,14 +5,15 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.AzureUtils.Deployment;
+using Tango.Core;
public static class ExtensionMethods
{
- public static MachineServiceSettings GetMachineServiceSettings(this IWebAppBase app)
+ public static async Task<MachineServiceSettings> GetMachineServiceSettingsAsync(this IWebAppBase app)
{
MachineServiceSettings settings = new MachineServiceSettings();
- var s = app.GetAppSettings();
+ var s = await app.GetAppSettingsAsync();
settings.DB_ADDRESS = s[nameof(MachineServiceSettings.DB_ADDRESS)].Value;
settings.DB_CATALOG = s[nameof(MachineServiceSettings.DB_CATALOG)].Value;
@@ -24,4 +25,17 @@ public static class ExtensionMethods
return settings;
}
+
+ public static DataSource ToDataSource(this MachineServiceSettings settings)
+ {
+ DataSource dataSource = new DataSource();
+ dataSource.Type = DataSourceType.SQLServer;
+ dataSource.Address = settings.DB_ADDRESS;
+ dataSource.Catalog = settings.DB_CATALOG;
+ dataSource.UserName = settings.DB_USER_NAME;
+ dataSource.Password = settings.DB_PASSWORD;
+ dataSource.IntegratedSecurity = false;
+
+ return dataSource;
+ }
}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/UpgradeConfiguration.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/UpgradeConfiguration.cs
new file mode 100644
index 000000000..233034d0d
--- /dev/null
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Deployment/UpgradeConfiguration.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.AzureUtils.Deployment
+{
+ public class UpgradeConfiguration
+ {
+ public bool UpgradeMachineService { get; set; }
+ public bool UpgradeMachineStudio { get; set; }
+ public bool UpgradePPC { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj b/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj
index 7643f389c..d3dc6a69f 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Tango.AzureUtils.csproj
@@ -31,6 +31,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+ </Reference>
+ <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+ </Reference>
+ <Reference Include="FluentFTP, Version=30.0.0.0, Culture=neutral, PublicKeyToken=f4af092b1d8df44f, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\FluentFTP.30.0.0\lib\net45\FluentFTP.dll</HintPath>
+ </Reference>
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Hyak.Common.1.2.2\lib\net452\Hyak.Common.dll</HintPath>
</Reference>
@@ -155,6 +164,7 @@
<HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel" />
@@ -163,6 +173,7 @@
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
+ <Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -174,13 +185,34 @@
<ItemGroup>
<Compile Include="AzureUtilsCredentials.cs" />
<Compile Include="Deployment\DeploymentManager.cs" />
+ <Compile Include="Deployment\DeploymentProgressEventArgs.cs" />
+ <Compile Include="Deployment\DeploymentStage.cs" />
<Compile Include="Deployment\ExtensionMethods.cs" />
<Compile Include="Deployment\MachineServiceSettings.cs" />
+ <Compile Include="Deployment\UpgradeConfiguration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <Content Include="..\..\..\DB\SQLExaminer Projects\GENERAL_ENV_UPGRADE.sdeproj">
+ <Link>Deployment\GENERAL_ENV_UPGRADE.sdeproj</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="..\..\..\DB\SQLExaminer Projects\GENERAL_ENV_UPGRADE.seproj">
+ <Link>Deployment\GENERAL_ENV_UPGRADE.seproj</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj">
+ <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project>
+ <Name>Tango.BL</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj">
+ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
+ <Name>Tango.Core</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config b/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config
index dde2c3cc6..0c152335c 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/app.config
@@ -1,11 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
+ <configSections>
+ <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ </configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
+ <entityFramework>
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+ <providers>
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+ </providers>
+ </entityFramework>
</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config b/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config
index 9f49cc92c..9d0723d02 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/packages.config
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="EntityFramework" version="6.2.0" targetFramework="net461" />
+ <package id="FluentFTP" version="30.0.0" targetFramework="net461" />
<package id="Hyak.Common" version="1.2.2" targetFramework="net461" />
<package id="Microsoft.Azure.Common" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.Azure.KeyVault" version="3.0.1" targetFramework="net461" />