コード例 #1
0
        internal static int GetNDependLocCount( DevelopmentInstallation installation, bool debug )
        {
            var servicesProvider = new NDependServicesProvider();
            var projectManager = servicesProvider.ProjectManager;
            var project =
                projectManager.CreateTemporaryProject(
                    getAssemblyPaths( installation, debug ).Select( i => Path.GetFullPath( i ).ToAbsoluteFilePath() ).ToArray(),
                    TemporaryProjectMode.Temporary );

            StatusStatics.SetStatus( "Performing NDepend analysis." );
            var analysisResult = project.RunAnalysis();
            StatusStatics.SetStatus( "Performed NDepend analysis." );

            var codeBase = analysisResult.CodeBase;
            var generatedCodeAttribute = codeBase.Types.WithFullName( "System.CodeDom.Compiler.GeneratedCodeAttribute" ).SingleOrDefault();
            var methods = from n in codeBase.Application.Namespaces
                          where !n.Name.StartsWith( EwlStatics.EwfFolderBaseNamespace )
                          from t in n.ChildTypes
                          where generatedCodeAttribute == null || !t.HasAttribute( generatedCodeAttribute )
                          from m in t.MethodsAndContructors
                          where generatedCodeAttribute == null || !m.HasAttribute( generatedCodeAttribute )
                          // We've considered excluding .designer.cs files here, but decided that they should remain part of the count since they still represent
                          // logic that must be maintained (in the designer).
                          where m.SourceFileDeclAvailable && m.SourceDecls.Any( s => s.SourceFile.FilePath.ParentDirectoryPath.DirectoryName != "Generated Code" )
                          select m;

            return methods.Where( i => i.NbLinesOfCode.HasValue ).Sum( i => Convert.ToInt32( i.NbLinesOfCode.Value ) );
        }
コード例 #2
0
 private static void writeNuGetPackageManifest(
     TextWriter writer, DevelopmentInstallation installation, string id, string projectName, Action <TextWriter> dependencyWriter, bool?prerelease,
     DateTime?localExportDateAndTime)
 {
     writer.WriteLine("<?xml version=\"1.0\"?>");
     writer.WriteLine("<package>");
     writer.WriteLine("<metadata>");
     writer.WriteLine("<id>" + id + "</id>");
     writer.WriteLine(
         "<version>" + EwlNuGetPackageSpecificationStatics.GetNuGetPackageVersionString(
             installation.CurrentMajorVersion,
             !prerelease.HasValue || prerelease.Value ? (int?)installation.NextBuildNumber : null,
             localExportDateAndTime: localExportDateAndTime) + "</version>");
     writer.WriteLine(
         "<title>" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + projectName.PrependDelimiter(" - ") + "</title>");
     writer.WriteLine("<authors>William Gross, Greg Smalter, Sam Rueby</authors>");
     writer.WriteLine(
         "<description>The {0} ({1}), together with its tailored infrastructure platform, is a highly opinionated foundation for web-based enterprise software.</description>"
         .FormatWith(EwlStatics.EwlName, EwlStatics.EwlInitialism));
     writer.WriteLine("<projectUrl>http://enterpriseweblibrary.org</projectUrl>");
     writer.WriteLine("<license type=\"expression\">MIT</license>");
     writer.WriteLine("<requireLicenseAcceptance>false</requireLicenseAcceptance>");
     writer.WriteLine("<dependencies>");
     dependencyWriter(writer);
     writer.WriteLine("</dependencies>");
     writer.WriteLine("<tags>C# ASP.NET DAL SQL-Server MySQL Oracle</tags>");
     writer.WriteLine("</metadata>");
     writer.WriteLine("</package>");
 }
コード例 #3
0
        internal static int GetNDependLocCount(DevelopmentInstallation installation, bool debug)
        {
            var servicesProvider = new NDependServicesProvider();
            var projectManager   = servicesProvider.ProjectManager;
            var project          =
                projectManager.CreateTemporaryProject(getAssemblyPaths(installation, debug).Select(i => Path.GetFullPath(i).ToAbsoluteFilePath()).ToArray(),
                                                      TemporaryProjectMode.Temporary);

            StatusStatics.SetStatus("Performing NDepend analysis.");
            var analysisResult = project.RunAnalysis();

            StatusStatics.SetStatus("Performed NDepend analysis.");

            var codeBase = analysisResult.CodeBase;
            var generatedCodeAttribute = codeBase.Types.WithFullName("System.CodeDom.Compiler.GeneratedCodeAttribute").SingleOrDefault();
            var methods = from n in codeBase.Application.Namespaces
                          where !n.Name.StartsWith(StandardLibraryMethods.EwfFolderBaseNamespace)
                          from t in n.ChildTypes
                          where generatedCodeAttribute == null || !t.HasAttribute(generatedCodeAttribute)
                          from m in t.MethodsAndContructors
                          where generatedCodeAttribute == null || !m.HasAttribute(generatedCodeAttribute)
                          where m.SourceFileDeclAvailable && m.SourceDecls.Any(s => s.SourceFile.FilePath.ParentDirectoryPath.DirectoryName != "Generated Code")
                          select m;

            return(methods.Where(i => i.NbLinesOfCode.HasValue).Sum(i => Convert.ToInt32(i.NbLinesOfCode.Value)));
        }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        private static void writeNuGetPackageManifest(DevelopmentInstallation installation, bool prerelease, DateTime localExportDateAndTime, TextWriter writer)
        {
            writer.WriteLine("<?xml version=\"1.0\"?>");
            writer.WriteLine("<package>");
            writer.WriteLine("<metadata>");
            writer.WriteLine(
                "<id>" + EwlNuGetPackageSpecificationStatics.GetNuGetPackageId(installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName) + "</id>");
            writer.WriteLine(
                "<version>" + EwlNuGetPackageSpecificationStatics.GetNuGetPackageVersionString(prerelease, localExportDateAndTime: localExportDateAndTime) +
                "</version>");
            writer.WriteLine("<title>" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + "</title>");
            writer.WriteLine("<authors>William Gross, Greg Smalter, Sam Rueby</authors>");
            writer.WriteLine(
                "<description>The Enterprise Web Library (EWL) is an extremely opinionated library for web applications that trades off performance, scalability, and development flexibility for an ease of maintenance you won't find anywhere else.</description>");
            writer.WriteLine("<projectUrl>http://enterpriseweblibrary.org</projectUrl>");
            writer.WriteLine("<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>");
            writer.WriteLine("<requireLicenseAcceptance>false</requireLicenseAcceptance>");
            writer.WriteLine("<dependencies>");

            var lines = from line in File.ReadAllLines(StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, @"Standard Library\packages.config"))
                        let trimmedLine = line.Trim()
                                          where trimmedLine.StartsWith("<package ")
                                          select trimmedLine;

            foreach (var line in lines)
            {
                writer.WriteLine(line.Replace("package", "dependency").Replace(" targetFramework=\"net451\"", ""));
            }

            writer.WriteLine("</dependencies>");
            writer.WriteLine("<tags>C# ASP.NET DAL SQL-Server MySQL Oracle</tags>");
            writer.WriteLine("</metadata>");
            writer.WriteLine("</package>");
        }
コード例 #6
0
        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);
                    }
                }
            }
        }
コード例 #7
0
        private void generateServerSideConsoleAppStatics(TextWriter writer, DevelopmentInstallation installation)
        {
            writer.WriteLine("namespace " + installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + " {");
            writer.WriteLine("public static class ServerSideConsoleAppStatics {");
            foreach (var project in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable)
            {
                writer.WriteLine(
                    "public static void Start" + project.Name.EnglishToPascal() +
                    "( IEnumerable<string> arguments, string input, string errorMessageIfAlreadyRunning = \"\" ) {");
                writer.WriteLine("if( errorMessageIfAlreadyRunning.Any() && Process.GetProcessesByName( \"" + project.NamespaceAndAssemblyName + "\" ).Any() )");
                writer.WriteLine("throw new DataModificationException( errorMessageIfAlreadyRunning );");

                var programPath = "EwlStatics.CombinePaths( ConfigurationStatics.InstallationPath, \"" + project.Name +
                                  "\", ConfigurationStatics.ServerSideConsoleAppRelativeFolderPath, \"" + project.NamespaceAndAssemblyName + "\" )";
                var runProgramExpression = "EwlStatics.RunProgram( " + programPath +
                                           ", \"\", Newtonsoft.Json.JsonConvert.SerializeObject( arguments, Newtonsoft.Json.Formatting.None ) + System.Environment.NewLine + input, false )";

                writer.WriteLine("if( EwfApp.Instance != null && AppRequestState.Instance != null )");
                writer.WriteLine("AppRequestState.AddNonTransactionalModificationMethod( () => " + runProgramExpression + " );");
                writer.WriteLine("else");
                writer.WriteLine(runProgramExpression + ";");

                writer.WriteLine("}");
            }
            writer.WriteLine("}");
            writer.WriteLine("}");
        }
コード例 #8
0
        internal static int GetNDependLocCount(DevelopmentInstallation installation, bool debug)
        {
            var servicesProvider = new NDependServicesProvider();
            var projectManager   = servicesProvider.ProjectManager;
            var project          = projectManager.CreateTemporaryProject(
                getAssemblyPaths(installation, debug).Select(i => Path.GetFullPath(i).ToAbsoluteFilePath()).ToArray(),
                TemporaryProjectMode.Temporary);

            StatusStatics.SetStatus("Performing NDepend analysis.");
            var analysisResult = project.RunAnalysis();

            StatusStatics.SetStatus("Performed NDepend analysis.");

            var codeBase = analysisResult.CodeBase;
            var generatedCodeAttribute = codeBase.Types.WithFullName("System.CodeDom.Compiler.GeneratedCodeAttribute").SingleOrDefault();
            var methods = from n in codeBase.Application.Namespaces
                          from t in n.ChildTypes
                          where generatedCodeAttribute == null || !t.HasAttribute(generatedCodeAttribute)
                          from m in t.MethodsAndContructors
                          where generatedCodeAttribute == null || !m.HasAttribute(generatedCodeAttribute)
                          // We've considered excluding .designer.cs files here, but decided that they should remain part of the count since they still represent
                          // logic that must be maintained (in the designer).
                          where m.SourceFileDeclAvailable && m.SourceDecls.Any(s => s.SourceFile.FilePath.ParentDirectoryPath.DirectoryName != "Generated Code")
                          select m;

            return(methods.Where(i => i.NbLinesOfCode.HasValue).Sum(i => Convert.ToInt32(i.NbLinesOfCode.Value)));
        }
コード例 #9
0
        private void generateWebConfigAndCodeForWebProject(DevelopmentInstallation installation, WebProject project)
        {
            var application = installation.ExistingInstallationLogic.RuntimeConfiguration.WebApplications.Single(i => i.Name == project.name);

            // This must be done before web meta logic generation, which can be affected by the contents of Web.config files.
            WebConfigStatics.GenerateWebConfig(application, project);

            var webProjectGeneratedCodeFolderPath = EwlStatics.CombinePaths(application.Path, "Generated Code");

            Directory.CreateDirectory(webProjectGeneratedCodeFolderPath);
            var webProjectIsuFilePath = EwlStatics.CombinePaths(webProjectGeneratedCodeFolderPath, "ISU.cs");

            IoMethods.DeleteFile(webProjectIsuFilePath);
            using (TextWriter writer = new StreamWriter(webProjectIsuFilePath)) {
                writer.WriteLine("using System;");
                writer.WriteLine("using System.Collections.Generic;");
                writer.WriteLine("using System.Collections.ObjectModel;");
                writer.WriteLine("using System.Globalization;");
                writer.WriteLine("using System.Linq;");
                writer.WriteLine("using System.Reflection;");
                writer.WriteLine("using System.Runtime.InteropServices;");
                writer.WriteLine("using System.Web;");
                writer.WriteLine("using System.Web.UI;");
                writer.WriteLine("using System.Web.UI.WebControls;");
                writer.WriteLine("using EnterpriseWebLibrary;");
                writer.WriteLine("using EnterpriseWebLibrary.DataAccess;");
                writer.WriteLine("using EnterpriseWebLibrary.EnterpriseWebFramework;");
                writer.WriteLine("using EnterpriseWebLibrary.EnterpriseWebFramework.Controls;");
                writer.WriteLine("using EnterpriseWebLibrary.InputValidation;");
                writer.WriteLine();
                writeAssemblyInfo(writer, installation, project.name);
                writer.WriteLine();
                CodeGeneration.WebMetaLogic.WebMetaLogicStatics.Generate(writer, application.Path, project);
            }
        }
コード例 #10
0
 private static IEnumerable <string> getAssemblyPaths(DevelopmentInstallation installation, bool debug)
 {
     return(EwlStatics
            .CombinePaths(
                installation.DevelopmentInstallationLogic.LibraryPath,
                EwlStatics.GetProjectOutputFolderPath(debug),
                installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".dll")
            .ToCollection()
            .Concat(
                from i in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects ?? new WebProject[0]
                select EwlStatics.CombinePaths(installation.GeneralLogic.Path, i.name, "bin", i.NamespaceAndAssemblyName + ".dll"))
            .Concat(
                from i in installation.ExistingInstallationLogic.RuntimeConfiguration.WindowsServices
                select EwlStatics.CombinePaths(
                    installation.ExistingInstallationLogic.GetWindowsServiceFolderPath(i, debug),
                    i.NamespaceAndAssemblyName + ".exe"))
            .Concat(
                from i in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable
                select EwlStatics.CombinePaths(
                    installation.GeneralLogic.Path,
                    i.Name,
                    EwlStatics.GetProjectOutputFolderPath(debug),
                    i.NamespaceAndAssemblyName + ".exe"))
            .Concat(
                installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject != null
                                         ? EwlStatics.CombinePaths(
                    installation.GeneralLogic.Path,
                    installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name,
                    EwlStatics.GetProjectOutputFolderPath(debug),
                    installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.assemblyName + ".exe")
                .ToCollection()
                                         : new string[0]));
 }
コード例 #11
0
        internal static byte[] CreateEwlNuGetPackage(DevelopmentInstallation installation, bool useDebugAssembly, string outputFolderPath, bool?prerelease)
        {
            var localExportDateAndTime = prerelease.HasValue ? null as DateTime? : DateTime.Now;

            IoMethods.ExecuteWithTempFolder(folderPath => {
                var ewlOutputFolderPath = StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                                                              "Standard Library",
                                                                              StandardLibraryMethods.GetProjectOutputFolderPath(useDebugAssembly));
                var libFolderPath = StandardLibraryMethods.CombinePaths(folderPath, @"lib\net451-full");
                foreach (var fileName in new[] { "dll", "pdb", "xml" }.Select(i => "EnterpriseWebLibrary." + i))
                {
                    IoMethods.CopyFile(StandardLibraryMethods.CombinePaths(ewlOutputFolderPath, fileName), StandardLibraryMethods.CombinePaths(libFolderPath, fileName));
                }

                IoMethods.CopyFile(StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, @"Development Utility\Package Manager Console Commands.ps1"),
                                   StandardLibraryMethods.CombinePaths(folderPath, @"tools\init.ps1"));

                var webSitePath = StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, "Web Site");
                var webProjectFilesFolderPath = StandardLibraryMethods.CombinePaths(folderPath, AppStatics.WebProjectFilesFolderName);
                IoMethods.CopyFolder(StandardLibraryMethods.CombinePaths(webSitePath, AppStatics.EwfFolderName),
                                     StandardLibraryMethods.CombinePaths(webProjectFilesFolderPath, AppStatics.EwfFolderName),
                                     false);
                IoMethods.CopyFile(StandardLibraryMethods.CombinePaths(webSitePath, AppStatics.StandardLibraryFilesFileName),
                                   StandardLibraryMethods.CombinePaths(webProjectFilesFolderPath, AppStatics.StandardLibraryFilesFileName));

                const string duProjectAndFolderName = "Development Utility";
                IoMethods.CopyFolder(
                    StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                                        duProjectAndFolderName,
                                                        StandardLibraryMethods.GetProjectOutputFolderPath(useDebugAssembly)),
                    StandardLibraryMethods.CombinePaths(folderPath, duProjectAndFolderName),
                    false);
                packageGeneralFiles(installation, folderPath, false);
                IoMethods.CopyFolder(
                    StandardLibraryMethods.CombinePaths(installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath,
                                                        InstallationConfiguration.InstallationConfigurationFolderName,
                                                        InstallationConfiguration.InstallationsFolderName,
                                                        (!prerelease.HasValue || prerelease.Value ? "Testing" : "Live")),
                    StandardLibraryMethods.CombinePaths(folderPath,
                                                        InstallationConfiguration.ConfigurationFolderName,
                                                        InstallationConfiguration.InstallationConfigurationFolderName),
                    false);

                var manifestPath = StandardLibraryMethods.CombinePaths(folderPath, "Package.nuspec");
                using (var writer = IoMethods.GetTextWriterForWrite(manifestPath))
                    writeNuGetPackageManifest(installation, prerelease, localExportDateAndTime, writer);

                StatusStatics.SetStatus(StandardLibraryMethods.RunProgram(StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, @"Solution Files\nuget"),
                                                                          "pack \"" + manifestPath + "\" -OutputDirectory \"" + outputFolderPath + "\"",
                                                                          "",
                                                                          true));
            });

            return
                (File.ReadAllBytes(StandardLibraryMethods.CombinePaths(outputFolderPath,
                                                                       EwlNuGetPackageSpecificationStatics.GetNuGetPackageFileName(installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName,
                                                                                                                                   installation.CurrentMajorVersion,
                                                                                                                                   !prerelease.HasValue || prerelease.Value ? installation.NextBuildNumber as int? : null,
                                                                                                                                   localExportDateAndTime: localExportDateAndTime))));
        }
コード例 #12
0
 private void copyServerSideProject(DevelopmentInstallation installation, string serverSideLogicFolderPath, string project)
 {
     IoMethods.CopyFolder(
         EwlStatics.CombinePaths(installation.GeneralLogic.Path, project, EwlStatics.GetProjectOutputFolderPath(false)),
         EwlStatics.CombinePaths(serverSideLogicFolderPath, project),
         false);
 }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        private InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build.NuGetPackagesType packageEwl(
            DevelopmentInstallation installation, string logicPackagesFolderPath)
        {
            var buildMessageNuGetPackages = new InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build.NuGetPackagesType();

            buildMessageNuGetPackages.Prerelease = CreateEwlNuGetPackage(installation, false, logicPackagesFolderPath, true);
            buildMessageNuGetPackages.Stable     = CreateEwlNuGetPackage(installation, false, logicPackagesFolderPath, false);
            return(buildMessageNuGetPackages);
        }
コード例 #15
0
 private void generateGeneralProvider(TextWriter writer, DevelopmentInstallation installation)
 {
     writer.WriteLine(
         "namespace " + installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".Configuration.Providers {");
     writer.WriteLine("internal partial class General: SystemGeneralProvider {");
     ConfigurationLogic.SystemProvider.WriteGeneralProviderMembers(writer);
     writer.WriteLine("}");
     writer.WriteLine("}");
 }
コード例 #16
0
 private void packageClientSideApp(DevelopmentInstallation installation, string clientSideAppFolder)
 {
     IoMethods.CopyFolder(
         StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                             installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name,
                                             StandardLibraryMethods.GetProjectOutputFolderPath(false)),
         StandardLibraryMethods.CombinePaths(clientSideAppFolder, installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name),
         false);
 }
コード例 #17
0
 private void packageWindowsServices(DevelopmentInstallation installation, string serverSideLogicFolderPath)
 {
     foreach (var service in installation.ExistingInstallationLogic.RuntimeConfiguration.WindowsServices)
     {
         IoMethods.CopyFolder(installation.ExistingInstallationLogic.GetWindowsServiceFolderPath(service, false),
                              StandardLibraryMethods.CombinePaths(serverSideLogicFolderPath, service.Name),
                              false);
     }
 }
コード例 #18
0
 private void writeAssemblyInfo(TextWriter writer, DevelopmentInstallation installation, string projectName)
 {
     writeAssemblyAttribute(
         writer,
         "AssemblyTitle",
         "\"" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + projectName.PrependDelimiter(" - ") + "\"");
     writeAssemblyAttribute(writer, "AssemblyProduct", "\"" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + "\"");
     writeAssemblyAttribute(writer, "ComVisible", "false");
     writeAssemblyAttribute(writer, "AssemblyVersion", "\"" + installation.CurrentMajorVersion + ".0." + installation.NextBuildNumber + ".0\"");
 }
コード例 #19
0
        private void generateWindowsServiceCode(DevelopmentInstallation installation, WindowsService service)
        {
            var serviceProjectGeneratedCodeFolderPath = EwlStatics.CombinePaths(installation.GeneralLogic.Path, service.Name, generatedCodeFolderName);

            Directory.CreateDirectory(serviceProjectGeneratedCodeFolderPath);
            var isuFilePath = EwlStatics.CombinePaths(serviceProjectGeneratedCodeFolderPath, "ISU.cs");

            IoMethods.DeleteFile(isuFilePath);
            using (TextWriter writer = new StreamWriter(isuFilePath)) {
                writer.WriteLine("using System;");
                writer.WriteLine("using System.ComponentModel;");
                writer.WriteLine("using System.Reflection;");
                writer.WriteLine("using System.Runtime.InteropServices;");
                writer.WriteLine("using System.ServiceProcess;");
                writer.WriteLine("using System.Threading;");
                writer.WriteLine("using EnterpriseWebLibrary;");
                writer.WriteLine("using EnterpriseWebLibrary.DataAccess;");
                writer.WriteLine("using EnterpriseWebLibrary.WindowsServiceFramework;");
                writer.WriteLine();
                writeAssemblyInfo(writer, installation, service.Name);
                writer.WriteLine();
                writer.WriteLine("namespace " + service.NamespaceAndAssemblyName + " {");

                writer.WriteLine("internal static partial class Program {");

                writer.WriteLine("[ MTAThread ]");
                writer.WriteLine("private static void Main() {");
                writer.WriteLine("SystemInitializer globalInitializer = null;");
                writer.WriteLine("initGlobalInitializer( ref globalInitializer );");
                writer.WriteLine("var dataAccessState = new ThreadLocal<DataAccessState>( () => new DataAccessState() );");
                writer.WriteLine(
                    "GlobalInitializationOps.InitStatics( globalInitializer, \"{0}\", false, mainDataAccessStateGetter: () => dataAccessState.Value, useLongDatabaseTimeouts: true );"
                    .FormatWith(service.Name));
                writer.WriteLine("try {");
                writer.WriteLine(
                    "TelemetryStatics.ExecuteBlockWithStandardExceptionHandling( () => ServiceBase.Run( new ServiceBaseAdapter( new " + service.Name.EnglishToPascal() +
                    "() ) ) );");
                writer.WriteLine("}");
                writer.WriteLine("finally {");
                writer.WriteLine("GlobalInitializationOps.CleanUpStatics();");
                writer.WriteLine("}");
                writer.WriteLine("}");

                writer.WriteLine("static partial void initGlobalInitializer( ref SystemInitializer globalInitializer );");

                writer.WriteLine("}");

                writer.WriteLine("internal partial class " + service.Name.EnglishToPascal() + ": WindowsServiceBase {");
                writer.WriteLine("internal " + service.Name.EnglishToPascal() + "() {}");
                writer.WriteLine("string WindowsServiceBase.Name { get { return \"" + service.Name + "\"; } }");
                writer.WriteLine("}");

                writer.WriteLine("}");
            }
        }
コード例 #20
0
 private IEnumerable <InstallationSupportUtility.SystemManagerInterface.Messages.BuildMessage.NuGetPackage> packageEwl(
     DevelopmentInstallation installation, PackagingConfiguration packagingConfiguration, string logicPackagesFolderPath) =>
 CreateEwlNuGetPackages(installation, packagingConfiguration, false, logicPackagesFolderPath, new bool?[] { true, false })
 .Select(
     i => {
     var package        = new InstallationSupportUtility.SystemManagerInterface.Messages.BuildMessage.NuGetPackage();
     package.Id         = i.id;
     package.Prerelease = i.packages[0];
     package.Stable     = i.packages[1];
     return(package);
 });
コード例 #21
0
        private void generateCodeForProject(DevelopmentInstallation installation, string projectName, Action <TextWriter> codeWriter)
        {
            var generatedCodeFolderPath = EwlStatics.CombinePaths(installation.GeneralLogic.Path, projectName, "Generated Code");

            Directory.CreateDirectory(generatedCodeFolderPath);
            var isuFilePath = EwlStatics.CombinePaths(generatedCodeFolderPath, "ISU.cs");

            IoMethods.DeleteFile(isuFilePath);
            using (TextWriter writer = new StreamWriter(isuFilePath))
                codeWriter(writer);
        }
コード例 #22
0
        private void generateServerSideConsoleProjectCode(DevelopmentInstallation installation, ServerSideConsoleProject project)
        {
            var projectGeneratedCodeFolderPath = EwlStatics.CombinePaths(installation.GeneralLogic.Path, project.Name, "Generated Code");

            Directory.CreateDirectory(projectGeneratedCodeFolderPath);
            var isuFilePath = EwlStatics.CombinePaths(projectGeneratedCodeFolderPath, "ISU.cs");

            IoMethods.DeleteFile(isuFilePath);
            using (TextWriter writer = new StreamWriter(isuFilePath)) {
                writer.WriteLine("using System;");
                writer.WriteLine("using System.Collections.Generic;");
                writer.WriteLine("using System.Collections.Immutable;");
                writer.WriteLine("using System.IO;");
                writer.WriteLine("using System.Reflection;");
                writer.WriteLine("using System.Runtime.InteropServices;");
                writer.WriteLine("using System.Threading;");
                writer.WriteLine("using EnterpriseWebLibrary;");
                writer.WriteLine("using EnterpriseWebLibrary.DataAccess;");
                writer.WriteLine();
                writeAssemblyInfo(writer, installation, project.Name);
                writer.WriteLine();
                writer.WriteLine("namespace " + project.NamespaceAndAssemblyName + " {");
                writer.WriteLine("internal static partial class Program {");

                writer.WriteLine("[ MTAThread ]");
                writer.WriteLine("private static int Main( string[] args ) {");
                writer.WriteLine("SystemInitializer globalInitializer = null;");
                writer.WriteLine("initGlobalInitializer( ref globalInitializer );");
                writer.WriteLine("var dataAccessState = new ThreadLocal<DataAccessState>( () => new DataAccessState() );");
                writer.WriteLine(
                    "GlobalInitializationOps.InitStatics( globalInitializer, \"" + project.Name +
                    "\", false, mainDataAccessStateGetter: () => dataAccessState.Value );");
                writer.WriteLine("try {");
                writer.WriteLine("return GlobalInitializationOps.ExecuteAppWithStandardExceptionHandling( () => {");

                // See https://stackoverflow.com/a/44135529/35349.
                writer.WriteLine("Console.SetIn( new StreamReader( Console.OpenStandardInput(), Console.InputEncoding, false, 4096 ) );");

                writer.WriteLine("ewlMain( Newtonsoft.Json.JsonConvert.DeserializeObject<ImmutableArray<string>>( Console.ReadLine() ) );");
                writer.WriteLine("} );");
                writer.WriteLine("}");
                writer.WriteLine("finally {");
                writer.WriteLine("GlobalInitializationOps.CleanUpStatics();");
                writer.WriteLine("}");
                writer.WriteLine("}");

                writer.WriteLine("static partial void initGlobalInitializer( ref SystemInitializer globalInitializer );");
                writer.WriteLine("static partial void ewlMain( IReadOnlyList<string> arguments );");

                writer.WriteLine("}");
                writer.WriteLine("}");
            }
        }
コード例 #23
0
        private void generateWebConfigAndCodeForWebProject(DevelopmentInstallation installation, WebProject project)
        {
            var application = installation.ExistingInstallationLogic.RuntimeConfiguration.WebApplications.Single(i => i.Name == project.name);

            // This must be done before web meta logic generation, which can be affected by the contents of Web.config files.
            WebConfigStatics.GenerateWebConfig(application, project);

            Directory.CreateDirectory(EwlStatics.CombinePaths(application.Path, StaticFile.AppStaticFilesFolderName));

            var webProjectGeneratedCodeFolderPath = EwlStatics.CombinePaths(application.Path, generatedCodeFolderName);

            Directory.CreateDirectory(webProjectGeneratedCodeFolderPath);
            var webProjectIsuFilePath = EwlStatics.CombinePaths(webProjectGeneratedCodeFolderPath, "ISU.cs");

            IoMethods.DeleteFile(webProjectIsuFilePath);
            using (TextWriter writer = new StreamWriter(webProjectIsuFilePath)) {
                writer.WriteLine("using System;");
                writer.WriteLine("using System.Collections.Generic;");
                writer.WriteLine("using System.Collections.ObjectModel;");
                writer.WriteLine("using System.Globalization;");
                writer.WriteLine("using System.Linq;");
                writer.WriteLine("using System.Reflection;");
                writer.WriteLine("using System.Runtime.InteropServices;");
                writer.WriteLine("using System.Threading;");
                writer.WriteLine("using EnterpriseWebLibrary;");
                writer.WriteLine("using EnterpriseWebLibrary.DataAccess;");
                writer.WriteLine("using EnterpriseWebLibrary.EnterpriseWebFramework;");
                writer.WriteLine("using NodaTime;");
                writer.WriteLine("using Tewl.InputValidation;");
                writer.WriteLine("using Tewl.Tools;");
                writer.WriteLine();
                writeAssemblyInfo(writer, installation, project.name);
                writer.WriteLine();
                writer.WriteLine("namespace {0}.Providers {{".FormatWith(project.NamespaceAndAssemblyName));
                writer.WriteLine("internal partial class RequestDispatching: AppRequestDispatchingProvider {");
                writer.WriteLine(
                    "protected override UrlPattern GetStaticFilesFolderUrlPattern( string urlSegment ) => StaticFiles.FolderSetup.UrlPatterns.Literal( urlSegment );");
                writer.WriteLine("}");
                writer.WriteLine("}");
                writer.WriteLine();
                CodeGeneration.WebFramework.WebFrameworkStatics.Generate(
                    writer,
                    application.Path,
                    project.NamespaceAndAssemblyName,
                    false,
                    generatedCodeFolderName.ToCollection(),
                    StaticFile.AppStaticFilesFolderName,
                    "RequestDispatchingStatics.AppProvider.GetFrameworkUrlParent()");
            }
        }
コード例 #24
0
        private void generateXmlSchemaLogicForInstallationConfigurationFile(DevelopmentInstallation installation, string schemaFileName)
        {
            var schemaPathInProject = EwlStatics.CombinePaths(@"Configuration\Installation", schemaFileName + FileExtensions.Xsd);

            if (File.Exists(EwlStatics.CombinePaths(installation.DevelopmentInstallationLogic.LibraryPath, schemaPathInProject)))
            {
                generateXmlSchemaLogic(
                    installation.DevelopmentInstallationLogic.LibraryPath,
                    schemaPathInProject,
                    installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".Configuration.Installation",
                    $"Installation {schemaFileName} Configuration.cs",
                    true);
            }
        }
コード例 #25
0
        private void generateXmlSchemaLogicForCustomInstallationConfigurationXsd(DevelopmentInstallation installation)
        {
            const string customInstallationConfigSchemaPathInProject = @"Configuration\Installation\Custom.xsd";

            if (File.Exists(EwlStatics.CombinePaths(installation.DevelopmentInstallationLogic.LibraryPath, customInstallationConfigSchemaPathInProject)))
            {
                generateXmlSchemaLogic(
                    installation.DevelopmentInstallationLogic.LibraryPath,
                    customInstallationConfigSchemaPathInProject,
                    installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".Configuration.Installation",
                    "Installation Custom Configuration.cs",
                    true);
            }
        }
コード例 #26
0
 private void generateXmlSchemaLogicForOtherXsdFiles(DevelopmentInstallation installation)
 {
     if (installation.DevelopmentInstallationLogic.DevelopmentConfiguration.xmlSchemas != null)
     {
         foreach (var xmlSchema in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.xmlSchemas)
         {
             generateXmlSchemaLogic(
                 EwlStatics.CombinePaths(installation.GeneralLogic.Path, xmlSchema.project),
                 xmlSchema.pathInProject,
                 xmlSchema.@namespace,
                 xmlSchema.codeFileName,
                 xmlSchema.useSvcUtil);
         }
     }
 }
コード例 #27
0
        private void packageServerSideConsoleApps(DevelopmentInstallation installation, string serverSideLogicFolderPath)
        {
            foreach (var project in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable)
            {
                copyServerSideProject(installation, serverSideLogicFolderPath, project.Name);
            }

            // Always copy special projects.
            var testRunnerFolder = EwlStatics.CombinePaths(installation.GeneralLogic.Path, EwlStatics.TestRunnerProjectName);

            if (Directory.Exists(testRunnerFolder))
            {
                copyServerSideProject(installation, serverSideLogicFolderPath, EwlStatics.TestRunnerProjectName);
            }
        }
コード例 #28
0
        internal static PackagingConfiguration GetPackagingConfiguration(DevelopmentInstallation installation)
        {
            var filePath = EwlStatics.CombinePaths(
                installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath,
                InstallationConfiguration.InstallationConfigurationFolderName,
                InstallationConfiguration.InstallationsFolderName,
                "Packaging" + FileExtensions.Xml);

            return(File.Exists(filePath)
                                       ? XmlOps.DeserializeFromFile <PackagingConfiguration>(filePath, false)
                                       : new PackagingConfiguration
            {
                SystemName = installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName,
                SystemShortName = installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName
            });
        }
コード例 #29
0
        private void packageWebApps(DevelopmentInstallation installation, string serverSideLogicFolderPath)
        {
            // NOTE: When packaging web apps, try to find a way to exclude data files. Apparently web deployment projects include these in their output even though
            // they aren't part of the source web projects. NOTE ON NOTE: We don't use WDPs anymore, so maybe we can eliminate this note.
            foreach (var webProject in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects ?? new WebProject[0])
            {
                var webAppPath = EwlStatics.CombinePaths(serverSideLogicFolderPath, webProject.name);

                // Pre-compile the web project.
                try {
                    EwlStatics.RunProgram(
                        EwlStatics.CombinePaths(RuntimeEnvironment.GetRuntimeDirectory(), "aspnet_compiler"),
                        "-v \"/" + webProject.name + ".csproj\" -p \"" + EwlStatics.CombinePaths(installation.GeneralLogic.Path, webProject.name) + "\" " +
                        (webProject.IsUpdateableWhenInstalledSpecified && webProject.IsUpdateableWhenInstalled ? "-u " : "") + "-f \"" + webAppPath + "\"",
                        "",
                        true);
                }
                catch (Exception e) {
                    throw new UserCorrectableException("ASP.NET pre-compilation failed for web project " + webProject.name + ".", e);
                }
                try {
                    EwlStatics.RunProgram(
                        EwlStatics.CombinePaths(AppStatics.DotNetToolsFolderPath, "aspnet_merge"),
                        "\"" + webAppPath + "\" -o " + webProject.NamespaceAndAssemblyName + ".Package -a -copyattrs",
                        "",
                        true);
                }
                catch (Exception e) {
                    throw new UserCorrectableException("ASP.NET Merge Tool failed for web project " + webProject.name + ".", e);
                }

                // Delete files and folders that aren't necessary for installed installations.
                IoMethods.DeleteFolder(EwlStatics.CombinePaths(webAppPath, "Generated Code"));
                IoMethods.DeleteFolder(EwlStatics.CombinePaths(webAppPath, "obj"));
                IoMethods.DeleteFile(EwlStatics.CombinePaths(webAppPath, webProject.name + ".csproj"));
                IoMethods.DeleteFile(EwlStatics.CombinePaths(webAppPath, webProject.name + ".csproj.user"));
                IoMethods.DeleteFile(EwlStatics.CombinePaths(webAppPath, webProject.name + ".csproj.vspscc"));
                IoMethods.DeleteFile(EwlStatics.CombinePaths(webAppPath, AppStatics.StandardLibraryFilesFileName));

                var webConfigPath = EwlStatics.CombinePaths(webAppPath, WebApplication.WebConfigFileName);
                File.WriteAllText(
                    webConfigPath,
                    File.ReadAllText(webConfigPath)
                    .Replace("debug=\"true\"", "debug=\"false\"")
                    .Replace("<!--<add name=\"HttpCacheModule\" />-->", "<add name=\"HttpCacheModule\" />"));
            }
        }
コード例 #30
0
        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);
                    }
                }
            }
        }
コード例 #31
0
        private void generateServerSideConsoleProjectCode(DevelopmentInstallation installation, ServerSideConsoleProject project)
        {
            var projectGeneratedCodeFolderPath = EwlStatics.CombinePaths(installation.GeneralLogic.Path, project.Name, "Generated Code");

            Directory.CreateDirectory(projectGeneratedCodeFolderPath);
            var isuFilePath = EwlStatics.CombinePaths(projectGeneratedCodeFolderPath, "ISU.cs");

            IoMethods.DeleteFile(isuFilePath);
            using (TextWriter writer = new StreamWriter(isuFilePath)) {
                writer.WriteLine("using System;");
                writer.WriteLine("using System.Reflection;");
                writer.WriteLine("using System.Runtime.InteropServices;");
                writer.WriteLine("using System.Threading;");
                writer.WriteLine("using EnterpriseWebLibrary;");
                writer.WriteLine("using EnterpriseWebLibrary.DataAccess;");
                writer.WriteLine();
                writeAssemblyInfo(writer, installation, project.Name);
                writer.WriteLine();
                writer.WriteLine("namespace " + project.NamespaceAndAssemblyName + " {");
                writer.WriteLine("internal static partial class Program {");

                writer.WriteLine("[ MTAThread ]");
                writer.WriteLine("private static int Main( string[] args ) {");
                writer.WriteLine("SystemInitializer globalInitializer = null;");
                writer.WriteLine("initGlobalInitializer( ref globalInitializer );");
                writer.WriteLine("var dataAccessState = new ThreadLocal<DataAccessState>( () => new DataAccessState() );");
                writer.WriteLine(
                    "GlobalInitializationOps.InitStatics( globalInitializer, \"" + project.Name + "\", false, mainDataAccessStateGetter: () => dataAccessState.Value );");
                writer.WriteLine("try {");
                writer.WriteLine("return GlobalInitializationOps.ExecuteAppWithStandardExceptionHandling( () => ewlMain( args ) );");
                writer.WriteLine("}");
                writer.WriteLine("finally {");
                writer.WriteLine("GlobalInitializationOps.CleanUpStatics();");
                writer.WriteLine("}");
                writer.WriteLine("}");

                writer.WriteLine("static partial void initGlobalInitializer( ref SystemInitializer globalInitializer );");
                writer.WriteLine("static partial void ewlMain( string[] args );");

                writer.WriteLine("}");
                writer.WriteLine("}");
            }
        }
コード例 #32
0
 private void generateDataAccessCode( TextWriter writer, DevelopmentInstallation installation )
 {
     var baseNamespace = installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".DataAccess";
     foreach( var database in installation.DevelopmentInstallationLogic.DatabasesForCodeGeneration ) {
         try {
             generateDataAccessCodeForDatabase(
                 database,
                 installation.DevelopmentInstallationLogic.LibraryPath,
                 writer,
                 baseNamespace,
                 database.SecondaryDatabaseName.Length == 0
                     ? installation.DevelopmentInstallationLogic.DevelopmentConfiguration.database
                     : installation.DevelopmentInstallationLogic.DevelopmentConfiguration.secondaryDatabases.Single( sd => sd.name == database.SecondaryDatabaseName ) );
         }
         catch( Exception e ) {
             throw UserCorrectableException.CreateSecondaryException(
                 "An exception occurred while generating data access logic for the " +
                 ( database.SecondaryDatabaseName.Length == 0 ? "primary" : database.SecondaryDatabaseName + " secondary" ) + " database.",
                 e );
         }
     }
     if( installation.DevelopmentInstallationLogic.DatabasesForCodeGeneration.Any( d => d.SecondaryDatabaseName.Length > 0 ) ) {
         writer.WriteLine();
         writer.WriteLine( "namespace " + baseNamespace + " {" );
         writer.WriteLine( "public class SecondaryDatabaseNames {" );
         foreach( var secondaryDatabase in installation.DevelopmentInstallationLogic.DatabasesForCodeGeneration.Where( d => d.SecondaryDatabaseName.Length > 0 ) )
             writer.WriteLine( "public const string " + secondaryDatabase.SecondaryDatabaseName + " = \"" + secondaryDatabase.SecondaryDatabaseName + "\";" );
         writer.WriteLine( "}" );
         writer.WriteLine( "}" );
     }
 }
コード例 #33
0
 private void generateCodeForProject( DevelopmentInstallation installation, string projectName, Action<TextWriter> codeWriter )
 {
     var generatedCodeFolderPath = EwlStatics.CombinePaths( installation.GeneralLogic.Path, projectName, "Generated Code" );
     Directory.CreateDirectory( generatedCodeFolderPath );
     var isuFilePath = EwlStatics.CombinePaths( generatedCodeFolderPath, "ISU.cs" );
     IoMethods.DeleteFile( isuFilePath );
     using( TextWriter writer = new StreamWriter( isuFilePath ) )
         codeWriter( writer );
 }
コード例 #34
0
        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 ) {
                    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 );
                }
            }
        }
コード例 #35
0
 private void generateXmlSchemaLogicForCustomInstallationConfigurationXsd( DevelopmentInstallation installation )
 {
     const string customInstallationConfigSchemaPathInProject = @"Configuration\Installation\Custom.xsd";
     if( File.Exists( EwlStatics.CombinePaths( installation.DevelopmentInstallationLogic.LibraryPath, customInstallationConfigSchemaPathInProject ) ) ) {
         generateXmlSchemaLogic(
             installation.DevelopmentInstallationLogic.LibraryPath,
             customInstallationConfigSchemaPathInProject,
             installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".Configuration.Installation",
             "Installation Custom Configuration.cs",
             true );
     }
 }
コード例 #36
0
        private void generateWebConfigAndCodeForWebProject( DevelopmentInstallation installation, WebProject project )
        {
            var application = installation.ExistingInstallationLogic.RuntimeConfiguration.WebApplications.Single( i => i.Name == project.name );

            // This must be done before web meta logic generation, which can be affected by the contents of Web.config files.
            WebConfigStatics.GenerateWebConfig( application, project );

            var webProjectGeneratedCodeFolderPath = EwlStatics.CombinePaths( application.Path, "Generated Code" );
            Directory.CreateDirectory( webProjectGeneratedCodeFolderPath );
            var webProjectIsuFilePath = EwlStatics.CombinePaths( webProjectGeneratedCodeFolderPath, "ISU.cs" );
            IoMethods.DeleteFile( webProjectIsuFilePath );
            using( TextWriter writer = new StreamWriter( webProjectIsuFilePath ) ) {
                writer.WriteLine( "using System;" );
                writer.WriteLine( "using System.Collections.Generic;" );
                writer.WriteLine( "using System.Collections.ObjectModel;" );
                writer.WriteLine( "using System.Globalization;" );
                writer.WriteLine( "using System.Linq;" );
                writer.WriteLine( "using System.Reflection;" );
                writer.WriteLine( "using System.Runtime.InteropServices;" );
                writer.WriteLine( "using System.Web;" );
                writer.WriteLine( "using System.Web.UI;" );
                writer.WriteLine( "using System.Web.UI.WebControls;" );
                writer.WriteLine( "using EnterpriseWebLibrary;" );
                writer.WriteLine( "using EnterpriseWebLibrary.DataAccess;" );
                writer.WriteLine( "using EnterpriseWebLibrary.EnterpriseWebFramework;" );
                writer.WriteLine( "using EnterpriseWebLibrary.EnterpriseWebFramework.Controls;" );
                writer.WriteLine( "using EnterpriseWebLibrary.InputValidation;" );
                writer.WriteLine();
                writeAssemblyInfo( writer, installation, project.name );
                writer.WriteLine();
                CodeGeneration.WebMetaLogic.WebMetaLogicStatics.Generate( writer, application.Path, project );
            }
        }
コード例 #37
0
        private void generateServerSideConsoleAppStatics( TextWriter writer, DevelopmentInstallation installation )
        {
            writer.WriteLine( "namespace " + installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + " {" );
            writer.WriteLine( "public static class ServerSideConsoleAppStatics {" );
            foreach( var project in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable ) {
                writer.WriteLine(
                    "public static void Start" + project.Name.EnglishToPascal() + "( string arguments, string input, string errorMessageIfAlreadyRunning = \"\" ) {" );
                writer.WriteLine( "if( errorMessageIfAlreadyRunning.Any() && Process.GetProcessesByName( \"" + project.NamespaceAndAssemblyName + "\" ).Any() )" );
                writer.WriteLine( "throw new DataModificationException( errorMessageIfAlreadyRunning );" );

                var programPath = "EwlStatics.CombinePaths( ConfigurationStatics.InstallationPath, \"" + project.Name +
                                  "\", ConfigurationStatics.ServerSideConsoleAppRelativeFolderPath, \"" + project.NamespaceAndAssemblyName + "\" )";
                var runProgramExpression = "EwlStatics.RunProgram( " + programPath + ", arguments, input, false )";

                writer.WriteLine( "if( EwfApp.Instance != null && AppRequestState.Instance != null )" );
                writer.WriteLine( "AppRequestState.AddNonTransactionalModificationMethod( () => " + runProgramExpression + " );" );
                writer.WriteLine( "else" );
                writer.WriteLine( runProgramExpression + ";" );

                writer.WriteLine( "}" );
            }
            writer.WriteLine( "}" );
            writer.WriteLine( "}" );
        }
コード例 #38
0
 private void packageClientSideApp( DevelopmentInstallation installation, string clientSideAppFolder )
 {
     IoMethods.CopyFolder(
         EwlStatics.CombinePaths(
             installation.GeneralLogic.Path,
             installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name,
             EwlStatics.GetProjectOutputFolderPath( false ) ),
         EwlStatics.CombinePaths( clientSideAppFolder, installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name ),
         false );
 }
コード例 #39
0
 private InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build.NuGetPackagesType packageEwl(
     DevelopmentInstallation installation, string logicPackagesFolderPath)
 {
     var buildMessageNuGetPackages = new InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build.NuGetPackagesType();
     buildMessageNuGetPackages.Prerelease = CreateEwlNuGetPackage( installation, false, logicPackagesFolderPath, true );
     buildMessageNuGetPackages.Stable = CreateEwlNuGetPackage( installation, false, logicPackagesFolderPath, false );
     return buildMessageNuGetPackages;
 }
コード例 #40
0
        private void packageServerSideConsoleApps( DevelopmentInstallation installation, string serverSideLogicFolderPath )
        {
            foreach( var project in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable )
                copyServerSideProject( installation, serverSideLogicFolderPath, project.Name );

            // Always copy special projects.
            var testRunnerFolder = EwlStatics.CombinePaths( installation.GeneralLogic.Path, EwlStatics.TestRunnerProjectName );
            if( Directory.Exists( testRunnerFolder ) )
                copyServerSideProject( installation, serverSideLogicFolderPath, EwlStatics.TestRunnerProjectName );
        }
コード例 #41
0
        private void packageWebApps( DevelopmentInstallation installation, string serverSideLogicFolderPath )
        {
            // NOTE: When packaging web apps, try to find a way to exclude data files. Apparently web deployment projects include these in their output even though
            // they aren't part of the source web projects. NOTE ON NOTE: We don't use WDPs anymore, so maybe we can eliminate this note.
            foreach( var webProject in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects ?? new WebProject[ 0 ] ) {
                var webAppPath = EwlStatics.CombinePaths( serverSideLogicFolderPath, webProject.name );

                // Pre-compile the web project.
                try {
                    EwlStatics.RunProgram(
                        EwlStatics.CombinePaths( RuntimeEnvironment.GetRuntimeDirectory(), "aspnet_compiler" ),
                        "-v \"/" + webProject.name + ".csproj\" -p \"" + EwlStatics.CombinePaths( installation.GeneralLogic.Path, webProject.name ) + "\" " +
                        ( webProject.IsUpdateableWhenInstalledSpecified && webProject.IsUpdateableWhenInstalled ? "-u " : "" ) + "-f \"" + webAppPath + "\"",
                        "",
                        true );
                }
                catch( Exception e ) {
                    throw new UserCorrectableException( "ASP.NET pre-compilation failed for web project " + webProject.name + ".", e );
                }
                try {
                    EwlStatics.RunProgram(
                        EwlStatics.CombinePaths( AppStatics.DotNetToolsFolderPath, "aspnet_merge" ),
                        "\"" + webAppPath + "\" -o " + webProject.NamespaceAndAssemblyName + ".Package -a -copyattrs",
                        "",
                        true );
                }
                catch( Exception e ) {
                    throw new UserCorrectableException( "ASP.NET Merge Tool failed for web project " + webProject.name + ".", e );
                }

                // Delete files and folders that aren't necessary for installed installations.
                IoMethods.DeleteFolder( EwlStatics.CombinePaths( webAppPath, "Generated Code" ) );
                IoMethods.DeleteFolder( EwlStatics.CombinePaths( webAppPath, "obj" ) );
                IoMethods.DeleteFile( EwlStatics.CombinePaths( webAppPath, webProject.name + ".csproj" ) );
                IoMethods.DeleteFile( EwlStatics.CombinePaths( webAppPath, webProject.name + ".csproj.user" ) );
                IoMethods.DeleteFile( EwlStatics.CombinePaths( webAppPath, webProject.name + ".csproj.vspscc" ) );
                IoMethods.DeleteFile( EwlStatics.CombinePaths( webAppPath, AppStatics.StandardLibraryFilesFileName ) );

                var webConfigPath = EwlStatics.CombinePaths( webAppPath, "Web.config" );
                File.WriteAllText(
                    webConfigPath,
                    File.ReadAllText( webConfigPath )
                        .Replace( "debug=\"true\"", "debug=\"false\"" )
                        .Replace( "<!--<add name=\"HttpCacheModule\" />-->", "<add name=\"HttpCacheModule\" />" ) );
            }
        }
コード例 #42
0
 private void packageWindowsServices( DevelopmentInstallation installation, string serverSideLogicFolderPath )
 {
     foreach( var service in installation.ExistingInstallationLogic.RuntimeConfiguration.WindowsServices ) {
         IoMethods.CopyFolder(
             installation.ExistingInstallationLogic.GetWindowsServiceFolderPath( service, false ),
             EwlStatics.CombinePaths( serverSideLogicFolderPath, service.Name ),
             false );
     }
 }
コード例 #43
0
        private void updateMercurialIgnoreFile( DevelopmentInstallation installation )
        {
            var filePath = EwlStatics.CombinePaths( installation.GeneralLogic.Path, ".hgignore" );
            var lines = File.Exists( filePath ) ? File.ReadAllLines( filePath ) : new string[ 0 ];
            IoMethods.DeleteFile( filePath );
            using( TextWriter writer = new StreamWriter( filePath ) ) {
                const string regionBegin = "# EWL-REGION";
                const string regionEnd = "# END-EWL-REGION";

                writer.WriteLine( regionBegin );
                writer.WriteLine( "syntax: glob" );
                writer.WriteLine();
                writer.WriteLine( installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + ".v12.suo" );
                writer.WriteLine( "packages/" );
                writer.WriteLine( installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + ".sln.DotSettings.user" );
                writer.WriteLine( "Error Log.txt" );
                writer.WriteLine( "*.csproj.user" );
                writer.WriteLine( "*" + CodeGeneration.DataAccess.DataAccessStatics.CSharpTemplateFileExtension );
                writer.WriteLine();
                writer.WriteLine( "Solution Files/bin/" );
                writer.WriteLine( "Solution Files/obj/" );
                writer.WriteLine();
                writer.WriteLine( "Library/bin/" );
                writer.WriteLine( "Library/obj/" );
                writer.WriteLine( "Library/Generated Code/" );
                writer.WriteLine( "Library/" + InstallationFileStatics.FilesFolderName + "/" + asposeLicenseFileName );

                foreach( var webProject in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects ?? new WebProject[ 0 ] ) {
                    writer.WriteLine();
                    writer.WriteLine( webProject.name + "/bin/" );
                    writer.WriteLine( webProject.name + "/obj/" );
                    writer.WriteLine( webProject.name + "/" + StaticFileHandler.EwfFolderName + "/" );
                    writer.WriteLine( webProject.name + "/" + AppStatics.StandardLibraryFilesFileName );
                    writer.WriteLine( webProject.name + "/Generated Code/" );
                }

                foreach( var service in installation.ExistingInstallationLogic.RuntimeConfiguration.WindowsServices ) {
                    writer.WriteLine();
                    writer.WriteLine( service.Name + "/bin/" );
                    writer.WriteLine( service.Name + "/obj/" );
                    writer.WriteLine( service.Name + "/Generated Code/" );
                }

                foreach( var project in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable ) {
                    writer.WriteLine();
                    writer.WriteLine( project.Name + "/bin/" );
                    writer.WriteLine( project.Name + "/obj/" );
                    writer.WriteLine( project.Name + "/Generated Code/" );
                }

                if( installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject != null ) {
                    writer.WriteLine();
                    writer.WriteLine( installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name + "/bin/" );
                    writer.WriteLine( installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name + "/obj/" );
                    writer.WriteLine( installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name + "/Generated Code/" );
                }

                writer.WriteLine();
                writer.WriteLine( regionEnd );

                var skipping = false;
                foreach( var line in lines ) {
                    if( line == regionBegin )
                        skipping = true;
                    if( !skipping )
                        writer.WriteLine( line );
                    if( line == regionEnd )
                        skipping = false;
                }
            }
        }
コード例 #44
0
 private void generateGeneralProvider( TextWriter writer, DevelopmentInstallation installation )
 {
     writer.WriteLine(
         "namespace " + installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".Configuration.Providers {" );
     writer.WriteLine( "internal partial class General: SystemGeneralProvider {" );
     ConfigurationLogic.SystemProvider.WriteGeneralProviderMembers( writer );
     writer.WriteLine( "}" );
     writer.WriteLine( "}" );
 }
コード例 #45
0
        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.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.GetCSharpIdentifierSimple( 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 );
            }
        }
コード例 #46
0
 private void copyServerSideProject( DevelopmentInstallation installation, string serverSideLogicFolderPath, string project )
 {
     IoMethods.CopyFolder(
         EwlStatics.CombinePaths( installation.GeneralLogic.Path, project, EwlStatics.GetProjectOutputFolderPath( false ) ),
         EwlStatics.CombinePaths( serverSideLogicFolderPath, project ),
         false );
 }
コード例 #47
0
        private void generateServerSideConsoleProjectCode( DevelopmentInstallation installation, ServerSideConsoleProject project )
        {
            var projectGeneratedCodeFolderPath = EwlStatics.CombinePaths( installation.GeneralLogic.Path, project.Name, "Generated Code" );
            Directory.CreateDirectory( projectGeneratedCodeFolderPath );
            var isuFilePath = EwlStatics.CombinePaths( projectGeneratedCodeFolderPath, "ISU.cs" );
            IoMethods.DeleteFile( isuFilePath );
            using( TextWriter writer = new StreamWriter( isuFilePath ) ) {
                writer.WriteLine( "using System;" );
                writer.WriteLine( "using System.Reflection;" );
                writer.WriteLine( "using System.Runtime.InteropServices;" );
                writer.WriteLine( "using System.Threading;" );
                writer.WriteLine( "using EnterpriseWebLibrary;" );
                writer.WriteLine( "using EnterpriseWebLibrary.DataAccess;" );
                writer.WriteLine();
                writeAssemblyInfo( writer, installation, project.Name );
                writer.WriteLine();
                writer.WriteLine( "namespace " + project.NamespaceAndAssemblyName + " {" );
                writer.WriteLine( "internal static partial class Program {" );

                writer.WriteLine( "[ MTAThread ]" );
                writer.WriteLine( "private static int Main( string[] args ) {" );
                writer.WriteLine( "SystemInitializer globalInitializer = null;" );
                writer.WriteLine( "initGlobalInitializer( ref globalInitializer );" );
                writer.WriteLine( "var dataAccessState = new ThreadLocal<DataAccessState>( () => new DataAccessState() );" );
                writer.WriteLine(
                    "GlobalInitializationOps.InitStatics( globalInitializer, \"" + project.Name + "\", false, mainDataAccessStateGetter: () => dataAccessState.Value );" );
                writer.WriteLine( "try {" );
                writer.WriteLine( "return GlobalInitializationOps.ExecuteAppWithStandardExceptionHandling( () => ewlMain( args ) );" );
                writer.WriteLine( "}" );
                writer.WriteLine( "finally {" );
                writer.WriteLine( "GlobalInitializationOps.CleanUpStatics();" );
                writer.WriteLine( "}" );
                writer.WriteLine( "}" );

                writer.WriteLine( "static partial void initGlobalInitializer( ref SystemInitializer globalInitializer );" );
                writer.WriteLine( "static partial void ewlMain( string[] args );" );

                writer.WriteLine( "}" );
                writer.WriteLine( "}" );
            }
        }
コード例 #48
0
        private static void writeNuGetPackageManifest( DevelopmentInstallation installation, bool? prerelease, DateTime? localExportDateAndTime, TextWriter writer )
        {
            writer.WriteLine( "<?xml version=\"1.0\"?>" );
            writer.WriteLine( "<package>" );
            writer.WriteLine( "<metadata>" );
            writer.WriteLine(
                "<id>" + EwlNuGetPackageSpecificationStatics.GetNuGetPackageId( installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName ) + "</id>" );
            writer.WriteLine(
                "<version>" +
                EwlNuGetPackageSpecificationStatics.GetNuGetPackageVersionString(
                    installation.CurrentMajorVersion,
                    !prerelease.HasValue || prerelease.Value ? installation.NextBuildNumber as int? : null,
                    localExportDateAndTime: localExportDateAndTime ) + "</version>" );
            writer.WriteLine( "<title>" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + "</title>" );
            writer.WriteLine( "<authors>William Gross, Greg Smalter, Sam Rueby</authors>" );
            writer.WriteLine(
                "<description>The {0} ({1}) is an extremely opinionated library for web applications that trades off performance, scalability, and development flexibility for an ease of maintenance you won't find anywhere else.</description>"
                    .FormatWith( EwlStatics.EwlName, EwlStatics.EwlInitialism ) );
            writer.WriteLine( "<projectUrl>http://enterpriseweblibrary.org</projectUrl>" );
            writer.WriteLine( "<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>" );
            writer.WriteLine( "<requireLicenseAcceptance>false</requireLicenseAcceptance>" );
            writer.WriteLine( "<dependencies>" );

            var lines = from line in File.ReadAllLines( EwlStatics.CombinePaths( installation.GeneralLogic.Path, AppStatics.CoreProjectName, "packages.config" ) )
                        let trimmedLine = line.Trim()
                        where trimmedLine.StartsWith( "<package " )
                        select trimmedLine;
            foreach( var line in lines )
                writer.WriteLine( line.Replace( "package", "dependency" ).Replace( " targetFramework=\"net451\"", "" ) );

            writer.WriteLine( "</dependencies>" );
            writer.WriteLine( "<tags>C# ASP.NET DAL SQL-Server MySQL Oracle</tags>" );
            writer.WriteLine( "</metadata>" );
            writer.WriteLine( "</package>" );
        }
コード例 #49
0
        private void generateWindowsServiceCode( DevelopmentInstallation installation, WindowsService service )
        {
            var serviceProjectGeneratedCodeFolderPath = EwlStatics.CombinePaths( installation.GeneralLogic.Path, service.Name, "Generated Code" );
            Directory.CreateDirectory( serviceProjectGeneratedCodeFolderPath );
            var isuFilePath = EwlStatics.CombinePaths( serviceProjectGeneratedCodeFolderPath, "ISU.cs" );
            IoMethods.DeleteFile( isuFilePath );
            using( TextWriter writer = new StreamWriter( isuFilePath ) ) {
                writer.WriteLine( "using System;" );
                writer.WriteLine( "using System.ComponentModel;" );
                writer.WriteLine( "using System.Reflection;" );
                writer.WriteLine( "using System.Runtime.InteropServices;" );
                writer.WriteLine( "using System.ServiceProcess;" );
                writer.WriteLine( "using System.Threading;" );
                writer.WriteLine( "using EnterpriseWebLibrary;" );
                writer.WriteLine( "using EnterpriseWebLibrary.DataAccess;" );
                writer.WriteLine( "using EnterpriseWebLibrary.WindowsServiceFramework;" );
                writer.WriteLine();
                writeAssemblyInfo( writer, installation, service.Name );
                writer.WriteLine();
                writer.WriteLine( "namespace " + service.NamespaceAndAssemblyName + " {" );

                writer.WriteLine( "internal static partial class Program {" );

                writer.WriteLine( "[ MTAThread ]" );
                writer.WriteLine( "private static void Main() {" );
                writer.WriteLine( "InitStatics();" );
                writer.WriteLine( "try {" );
                writer.WriteLine(
                    "TelemetryStatics.ExecuteBlockWithStandardExceptionHandling( () => ServiceBase.Run( new ServiceBaseAdapter( new " + service.Name.EnglishToPascal() +
                    "() ) ) );" );
                writer.WriteLine( "}" );
                writer.WriteLine( "finally {" );
                writer.WriteLine( "GlobalInitializationOps.CleanUpStatics();" );
                writer.WriteLine( "}" );
                writer.WriteLine( "}" );

                writer.WriteLine( "internal static void InitStatics() {" );
                writer.WriteLine( "SystemInitializer globalInitializer = null;" );
                writer.WriteLine( "initGlobalInitializer( ref globalInitializer );" );
                writer.WriteLine( "var dataAccessState = new ThreadLocal<DataAccessState>( () => new DataAccessState() );" );
                writer.WriteLine(
                    "GlobalInitializationOps.InitStatics( globalInitializer, \"" + service.Name +
                    "\" + \" Executable\", false, mainDataAccessStateGetter: () => dataAccessState.Value );" );
                writer.WriteLine( "}" );

                writer.WriteLine( "static partial void initGlobalInitializer( ref SystemInitializer globalInitializer );" );

                writer.WriteLine( "}" );

                writer.WriteLine( "[ RunInstaller( true ) ]" );
                writer.WriteLine( "public class Installer: System.Configuration.Install.Installer {" );

                writer.WriteLine( "public Installer() {" );
                writer.WriteLine( "Program.InitStatics();" );
                writer.WriteLine( "try {" );
                writer.WriteLine( "var code = GlobalInitializationOps.ExecuteAppWithStandardExceptionHandling( delegate {" );
                writer.WriteLine( "Installers.Add( WindowsServiceMethods.CreateServiceProcessInstaller() );" );
                writer.WriteLine( "Installers.Add( WindowsServiceMethods.CreateServiceInstaller( new " + service.Name.EnglishToPascal() + "() ) );" );
                writer.WriteLine( "} );" );
                writer.WriteLine( "if( code != 0 )" );
                writer.WriteLine(
                    "throw new ApplicationException( \"Service installer objects could not be created. More information should be available in a separate error email from the service executable.\" );" );
                writer.WriteLine( "}" );
                writer.WriteLine( "finally {" );
                writer.WriteLine( "GlobalInitializationOps.CleanUpStatics();" );
                writer.WriteLine( "}" );
                writer.WriteLine( "}" );

                writer.WriteLine( "}" );

                writer.WriteLine( "internal partial class " + service.Name.EnglishToPascal() + ": WindowsServiceBase {" );
                writer.WriteLine( "internal " + service.Name.EnglishToPascal() + "() {}" );
                writer.WriteLine( "string WindowsServiceBase.Name { get { return \"" + service.Name + "\"; } }" );
                writer.WriteLine( "}" );

                writer.WriteLine( "}" );
            }
        }
コード例 #50
0
        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 );
        }
コード例 #51
0
 private void generateXmlSchemaLogicForOtherXsdFiles( DevelopmentInstallation installation )
 {
     if( installation.DevelopmentInstallationLogic.DevelopmentConfiguration.xmlSchemas != null ) {
         foreach( var xmlSchema in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.xmlSchemas ) {
             generateXmlSchemaLogic(
                 EwlStatics.CombinePaths( installation.GeneralLogic.Path, xmlSchema.project ),
                 xmlSchema.pathInProject,
                 xmlSchema.@namespace,
                 xmlSchema.codeFileName,
                 xmlSchema.useSvcUtil );
         }
     }
 }
コード例 #52
0
        internal static byte[] CreateEwlNuGetPackage( DevelopmentInstallation installation, bool useDebugAssembly, string outputFolderPath, bool? prerelease )
        {
            var localExportDateAndTime = prerelease.HasValue ? null as DateTime? : DateTime.Now;

            IoMethods.ExecuteWithTempFolder(
                folderPath => {
                    var ewlOutputFolderPath = EwlStatics.CombinePaths(
                        installation.GeneralLogic.Path,
                        AppStatics.CoreProjectName,
                        EwlStatics.GetProjectOutputFolderPath( useDebugAssembly ) );
                    var libFolderPath = EwlStatics.CombinePaths( folderPath, @"lib\net451-full" );
                    foreach( var fileName in new[] { "dll", "pdb", "xml" }.Select( i => "EnterpriseWebLibrary." + i ) )
                        IoMethods.CopyFile( EwlStatics.CombinePaths( ewlOutputFolderPath, fileName ), EwlStatics.CombinePaths( libFolderPath, fileName ) );

                    IoMethods.CopyFile(
                        EwlStatics.CombinePaths( installation.GeneralLogic.Path, @"Development Utility\Package Manager Console Commands.ps1" ),
                        EwlStatics.CombinePaths( folderPath, @"tools\init.ps1" ) );

                    var webSitePath = EwlStatics.CombinePaths( installation.GeneralLogic.Path, "Web Site" );
                    var webProjectFilesFolderPath = EwlStatics.CombinePaths( folderPath, AppStatics.WebProjectFilesFolderName );
                    IoMethods.CopyFolder(
                        EwlStatics.CombinePaths( webSitePath, StaticFileHandler.EwfFolderName ),
                        EwlStatics.CombinePaths( webProjectFilesFolderPath, StaticFileHandler.EwfFolderName ),
                        false );
                    IoMethods.CopyFile(
                        EwlStatics.CombinePaths( webSitePath, AppStatics.StandardLibraryFilesFileName ),
                        EwlStatics.CombinePaths( webProjectFilesFolderPath, AppStatics.StandardLibraryFilesFileName ) );

                    const string duProjectAndFolderName = "Development Utility";
                    IoMethods.CopyFolder(
                        EwlStatics.CombinePaths( installation.GeneralLogic.Path, duProjectAndFolderName, EwlStatics.GetProjectOutputFolderPath( useDebugAssembly ) ),
                        EwlStatics.CombinePaths( folderPath, duProjectAndFolderName ),
                        false );
                    packageGeneralFiles( installation, folderPath, false );
                    IoMethods.CopyFolder(
                        EwlStatics.CombinePaths(
                            installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath,
                            InstallationConfiguration.InstallationConfigurationFolderName,
                            InstallationConfiguration.InstallationsFolderName,
                            ( !prerelease.HasValue || prerelease.Value ? "Testing" : "Live" ) ),
                        EwlStatics.CombinePaths( folderPath, InstallationConfiguration.ConfigurationFolderName, InstallationConfiguration.InstallationConfigurationFolderName ),
                        false );

                    var manifestPath = EwlStatics.CombinePaths( folderPath, "Package.nuspec" );
                    using( var writer = IoMethods.GetTextWriterForWrite( manifestPath ) )
                        writeNuGetPackageManifest( installation, prerelease, localExportDateAndTime, writer );

                    StatusStatics.SetStatus(
                        EwlStatics.RunProgram(
                            EwlStatics.CombinePaths( installation.GeneralLogic.Path, @"Solution Files\nuget" ),
                            "pack \"" + manifestPath + "\" -OutputDirectory \"" + outputFolderPath + "\"",
                            "",
                            true ) );
                } );

            return
                File.ReadAllBytes(
                    EwlStatics.CombinePaths(
                        outputFolderPath,
                        EwlNuGetPackageSpecificationStatics.GetNuGetPackageFileName(
                            installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName,
                            installation.CurrentMajorVersion,
                            !prerelease.HasValue || prerelease.Value ? installation.NextBuildNumber as int? : null,
                            localExportDateAndTime: localExportDateAndTime ) ) );
        }
コード例 #53
0
 private void writeAssemblyInfo( TextWriter writer, DevelopmentInstallation installation, string projectName )
 {
     writeAssemblyAttribute(
         writer,
         "AssemblyTitle",
         "\"" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + projectName.PrependDelimiter( " - " ) + "\"" );
     writeAssemblyAttribute( writer, "AssemblyProduct", "\"" + installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName + "\"" );
     writeAssemblyAttribute( writer, "ComVisible", "false" );
     writeAssemblyAttribute( writer, "AssemblyVersion", "\"" + installation.CurrentMajorVersion + ".0." + installation.NextBuildNumber + ".0\"" );
 }
コード例 #54
0
 private static IEnumerable<string> getAssemblyPaths( DevelopmentInstallation installation, bool debug )
 {
     return EwlStatics.CombinePaths(
         installation.DevelopmentInstallationLogic.LibraryPath,
         EwlStatics.GetProjectOutputFolderPath( debug ),
         installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".dll" )
         .ToSingleElementArray()
         .Concat(
             from i in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects ?? new WebProject[ 0 ]
             select EwlStatics.CombinePaths( installation.GeneralLogic.Path, i.name, "bin", i.NamespaceAndAssemblyName + ".dll" ) )
         .Concat(
             from i in installation.ExistingInstallationLogic.RuntimeConfiguration.WindowsServices
             select EwlStatics.CombinePaths( installation.ExistingInstallationLogic.GetWindowsServiceFolderPath( i, debug ), i.NamespaceAndAssemblyName + ".exe" ) )
         .Concat(
             from i in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable
             select
                 EwlStatics.CombinePaths( installation.GeneralLogic.Path, i.Name, EwlStatics.GetProjectOutputFolderPath( debug ), i.NamespaceAndAssemblyName + ".exe" ) )
         .Concat(
             installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject != null
                 ? EwlStatics.CombinePaths(
                     installation.GeneralLogic.Path,
                     installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name,
                     EwlStatics.GetProjectOutputFolderPath( debug ),
                     installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.assemblyName + ".exe" ).ToSingleElementArray()
                 : new string[ 0 ] );
 }