private static void packageGeneralFiles(DevelopmentInstallation installation, string folderPath, bool includeDatabaseUpdates) { // configuration files var configurationFolderPath = EwlStatics.CombinePaths(folderPath, InstallationConfiguration.ConfigurationFolderName); IoMethods.CopyFolder(installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath, configurationFolderPath, false); IoMethods.RecursivelyRemoveReadOnlyAttributeFromItem(configurationFolderPath); IoMethods.DeleteFolder(EwlStatics.CombinePaths(configurationFolderPath, InstallationConfiguration.InstallationConfigurationFolderName)); IoMethods.DeleteFolder(EwlStatics.CombinePaths(configurationFolderPath, ConfigurationStatics.ProvidersFolderAndNamespaceName)); if (!includeDatabaseUpdates) { IoMethods.DeleteFile(EwlStatics.CombinePaths(configurationFolderPath, ExistingInstallationLogic.SystemDatabaseUpdatesFileName)); } IoMethods.DeleteFile(EwlStatics.CombinePaths(configurationFolderPath, InstallationConfiguration.SystemDevelopmentConfigurationFileName)); IoMethods.DeleteFolder(EwlStatics.CombinePaths(configurationFolderPath, ".hg")); // EWL uses a nested repository for configuration. IoMethods.DeleteFile(EwlStatics.CombinePaths(configurationFolderPath, "Update All Dependent Logic.bat")); // EWL has this file. // other files var filesFolderInInstallationPath = EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true), InstallationFileStatics.FilesFolderName); if (Directory.Exists(filesFolderInInstallationPath)) { IoMethods.CopyFolder(filesFolderInInstallationPath, EwlStatics.CombinePaths(folderPath, InstallationFileStatics.FilesFolderName), false); } }
private void copyInEwlFiles(DevelopmentInstallation installation) { if (installation is RecognizedDevelopmentInstallation recognizedInstallation) { recognizedInstallation.KnownSystemLogic.DownloadAsposeLicenses(installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath); } if (installation.DevelopmentInstallationLogic.SystemIsEwl) { foreach (var fileName in GlobalStatics.ConfigurationXsdFileNames) { IoMethods.CopyFile( EwlStatics.CombinePaths(installation.GeneralLogic.Path, AppStatics.CoreProjectName, "Configuration", fileName + FileExtensions.Xsd), EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true), InstallationFileStatics.FilesFolderName, fileName + FileExtensions.Xsd)); } } else { // If web projects exist for this installation, copy appropriate files into them. if (installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects != null) { foreach (var webProject in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects) { copyInWebProjectFiles(installation, webProject); } } } }
private void copyInEwlFiles(DevelopmentInstallation installation) { if (installation is RecognizedDevelopmentInstallation recognizedInstallation) { recognizedInstallation.KnownSystemLogic.DownloadAsposeLicenses(installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath); } if (installation.DevelopmentInstallationLogic.SystemIsEwl) { foreach (var fileName in GlobalStatics.ConfigurationXsdFileNames) { IoMethods.CopyFile( EwlStatics.CombinePaths(installation.GeneralLogic.Path, EwlStatics.CoreProjectName, "Configuration", fileName + FileExtensions.Xsd), EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true), InstallationFileStatics.FilesFolderName, fileName + FileExtensions.Xsd)); } } else { // If web projects exist for this installation, copy in web-framework static files. if (installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects != null) { var webFrameworkStaticFilesFolderPath = EwlStatics.CombinePaths( installation.GeneralLogic.Path, InstallationFileStatics.WebFrameworkStaticFilesFolderName); IoMethods.DeleteFolder(webFrameworkStaticFilesFolderPath); IoMethods.CopyFolder( EwlStatics.CombinePaths(ConfigurationStatics.InstallationPath, InstallationFileStatics.WebFrameworkStaticFilesFolderName), webFrameworkStaticFilesFolderPath, false); } } }
private void copyInEwlFiles(DevelopmentInstallation installation) { if (installation.DevelopmentInstallationLogic.SystemIsEwl) { foreach (var fileName in GlobalStatics.ConfigurationXsdFileNames) { IoMethods.CopyFile( EwlStatics.CombinePaths(installation.GeneralLogic.Path, AppStatics.CoreProjectName, "Configuration", fileName + FileExtensions.Xsd), EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true), InstallationFileStatics.FilesFolderName, fileName + FileExtensions.Xsd)); } } else { var recognizedInstallation = installation as RecognizedDevelopmentInstallation; if (recognizedInstallation == null || !recognizedInstallation.SystemIsEwlCacheCoordinator) { foreach (var asposeLicenseFileName in asposeLicenseFileNames) { var asposeLicenseFilePath = EwlStatics.CombinePaths(ConfigurationStatics.ConfigurationFolderPath, asposeLicenseFileName); if (File.Exists(asposeLicenseFilePath)) { IoMethods.CopyFile( asposeLicenseFilePath, EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true), InstallationFileStatics.FilesFolderName, asposeLicenseFileName)); } } } // If web projects exist for this installation, copy appropriate files into them. if (installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects != null) { foreach (var webProject in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects) { copyInWebProjectFiles(installation, webProject); } } } }
/// <summary> /// Creates a new installation configuration. /// </summary> public InstallationConfiguration(bool machineIsStandbyServer, string installationPath, bool isDevelopmentInstallation) { this.installationPath = installationPath; // The EWL configuration folder is not inside any particular app's folder the way that Web.config and app.config are. This is for two reasons. First, EWL // configuration is system-wide (technically installation-wide) and not app-specific like Web.config and app.config. Second, it could be disastrous to // have EWL configuration files inside a web app's folder since then these files, which often contain database passwords and other sensitive information, // could potentially be served up to users. configurationFolderPath = StandardLibraryMethods.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installationPath, isDevelopmentInstallation), ConfigurationFolderName); // Do not perform schema validation for non-development installations because the schema files may not be available. For development installations, also // do not perform schema validation since the schema files may not match this version of the library. This can happen, for example, when you are trying to // run a system using an unreleased version of the library that contains schema changes. // system general configuration var systemGeneralConfigurationFilePath = StandardLibraryMethods.CombinePaths(ConfigurationFolderPath, "General.xml"); systemGeneralConfiguration = XmlOps.DeserializeFromFile <SystemGeneralConfiguration>(systemGeneralConfigurationFilePath, false); // system development configuration if (isDevelopmentInstallation) { systemDevelopmentConfiguration = XmlOps.DeserializeFromFile <SystemDevelopment.SystemDevelopmentConfiguration>( StandardLibraryMethods.CombinePaths(configurationFolderPath, SystemDevelopmentConfigurationFileName), false); } var installationConfigurationFolderPath = isDevelopmentInstallation ? StandardLibraryMethods.CombinePaths( ConfigurationFolderPath, InstallationConfigurationFolderName, InstallationsFolderName, DevelopmentInstallationFolderName) : StandardLibraryMethods.CombinePaths(ConfigurationFolderPath, InstallationConfigurationFolderName); // installation standard configuration var installationStandardConfigurationFilePath = StandardLibraryMethods.CombinePaths( installationConfigurationFolderPath, InstallationStandardConfigurationFileName); installationStandardConfiguration = XmlOps.DeserializeFromFile <InstallationStandardConfiguration>(installationStandardConfigurationFilePath, false); var systemWebApplicationElements = systemGeneralConfiguration.WebApplications ?? new SystemGeneralConfigurationApplication[0]; webApplications = from systemElement in systemWebApplicationElements let name = systemElement.Name let supportsSecureConnections = systemElement.SupportsSecureConnections select isDevelopmentInstallation ? new WebApplication( name, supportsSecureConnections, installationPath, SystemShortName, systemWebApplicationElements.Skip(1).Any(), systemDevelopmentConfiguration.webProjects.Single(i => i.name == name)) : InstallationType == InstallationType.Live ? new WebApplication( name, supportsSecureConnections, machineIsStandbyServer, LiveInstallationConfiguration.WebApplications.Single(i => i.Name == name)) : new WebApplication( name, supportsSecureConnections, IntermediateInstallationConfiguration.WebApplications.Single(i => i.Name == name)); webApplications = webApplications.ToArray(); // installation custom configuration installationCustomConfigurationFilePath = StandardLibraryMethods.CombinePaths(installationConfigurationFolderPath, "Custom.xml"); }
private void generateLibraryCode(DevelopmentInstallation installation) { var libraryGeneratedCodeFolderPath = EwlStatics.CombinePaths(installation.DevelopmentInstallationLogic.LibraryPath, "Generated Code"); Directory.CreateDirectory(libraryGeneratedCodeFolderPath); var isuFilePath = EwlStatics.CombinePaths(libraryGeneratedCodeFolderPath, "ISU.cs"); IoMethods.DeleteFile(isuFilePath); using (TextWriter writer = new StreamWriter(isuFilePath)) { // Don't add "using System" here. It will create a huge number of ReSharper warnings in the generated code file. writer.WriteLine("using System.Collections.Generic;"); writer.WriteLine("using System.Data;"); // Necessary for stored procedure logic writer.WriteLine("using System.Data.Common;"); writer.WriteLine("using System.Diagnostics;"); // Necessary for ServerSideConsoleAppStatics writer.WriteLine("using System.Linq;"); writer.WriteLine("using System.Reflection;"); writer.WriteLine("using System.Runtime.InteropServices;"); writer.WriteLine("using System.Web.UI;"); writer.WriteLine("using System.Web.UI.WebControls;"); writer.WriteLine("using EnterpriseWebLibrary;"); writer.WriteLine("using EnterpriseWebLibrary.Caching;"); writer.WriteLine("using EnterpriseWebLibrary.Collections;"); // Necessary for row constants writer.WriteLine("using EnterpriseWebLibrary.Configuration;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.CommandWriting;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.CommandWriting.Commands;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.CommandWriting.InlineConditionAbstraction;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.CommandWriting.InlineConditionAbstraction.Conditions;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.RetrievalCaching;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.RevisionHistory;"); writer.WriteLine("using EnterpriseWebLibrary.DataAccess.StandardModification;"); writer.WriteLine("using EnterpriseWebLibrary.Email;"); writer.WriteLine("using EnterpriseWebLibrary.EnterpriseWebFramework;"); writer.WriteLine("using EnterpriseWebLibrary.EnterpriseWebFramework.Controls;"); writer.WriteLine("using EnterpriseWebLibrary.InputValidation;"); writer.WriteLine(); writeAssemblyInfo(writer, installation, "Library"); writer.WriteLine(); var recognizedInstallation = installation as RecognizedDevelopmentInstallation; if (ConfigurationLogic.SystemProviderExists && !installation.DevelopmentInstallationLogic.SystemIsEwl && (recognizedInstallation == null || !recognizedInstallation.SystemIsEwlCacheCoordinator)) { generateGeneralProvider(writer, installation); } if (installation.ExistingInstallationLogic.RuntimeConfiguration.WebApplications.Any()) { writer.WriteLine(); writer.WriteLine("namespace " + installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + " {"); writer.WriteLine("public static class WebApplicationNames {"); foreach (var i in installation.ExistingInstallationLogic.RuntimeConfiguration.WebApplications) { writer.WriteLine("public const string {0} = \"{1}\";".FormatWith(EwlStatics.GetCSharpIdentifier(i.Name.EnglishToPascal()), i.Name)); } writer.WriteLine("}"); writer.WriteLine("}"); } writer.WriteLine(); TypedCssClassStatics.Generate( installation.GeneralLogic.Path, installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName, writer); writer.WriteLine(); generateServerSideConsoleAppStatics(writer, installation); generateDataAccessCode(writer, installation); var emailTemplateFolderPath = EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true), InstallationFileStatics.FilesFolderName, EmailTemplate.TemplateFolderName); if (Directory.Exists(emailTemplateFolderPath)) { writer.WriteLine(); writer.WriteLine("namespace " + installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + " {"); writer.WriteLine("public static class EmailTemplates {"); foreach (var i in IoMethods.GetFileNamesInFolder(emailTemplateFolderPath, searchPattern: "*.html")) { writer.WriteLine( "public static readonly EmailTemplateName {0} = new EmailTemplateName( \"{1}\" );".FormatWith( EwlStatics.GetCSharpIdentifier(Path.GetFileNameWithoutExtension(i).EnglishToPascal()), i)); } writer.WriteLine("}"); writer.WriteLine("}"); } } }
private static string getInstallationsFolderPath(string installationPath, bool useTemplate) => EwlStatics.CombinePaths( InstallationFileStatics.GetGeneralFilesFolderPath(installationPath, true), InstallationConfiguration.ConfigurationFolderName, InstallationConfiguration.InstallationConfigurationFolderName, useTemplate ? "{0} Template".FormatWith(InstallationConfiguration.InstallationsFolderName) : InstallationConfiguration.InstallationsFolderName);