예제 #1
0
        private static void writeCreateForSingleRowUpdateMethod(
            DBConnection cn, string tableName, bool isRevisionHistoryTable, bool isRevisionHistoryClass, string methodNameSuffix)
        {
            // header
            CodeGenerationStatics.AddSummaryDocComment(
                writer,
                "Creates a modification object in single-row update mode with the specified current data. All column values in this object will have HasChanged = false, despite being initialized. This object can then be used to do a piecemeal update of the " +
                tableName + " table." );
            writer.Write(
                "public static " + GetClassName( cn, tableName, isRevisionHistoryTable, isRevisionHistoryClass ) + " CreateForSingleRowUpdate" + methodNameSuffix + "( " );
            writeColumnParameterDeclarations( columns.AllColumnsExceptRowVersion );
            writer.WriteLine( " ) {" );

            // body

            writer.WriteLine(
                "var mod = new " + GetClassName( cn, tableName, isRevisionHistoryTable, isRevisionHistoryClass ) + " { modType = ModificationType.Update };" );

            // Use the values of key columns as conditions.
            writer.WriteLine( "mod.conditions = new List<" + DataAccessStatics.GetTableConditionInterfaceName( cn, database, tableName ) + ">();" );
            foreach( var column in columns.KeyColumns ) {
                writer.WriteLine(
                    "mod.conditions.Add( new " + DataAccessStatics.GetEqualityConditionClassName( cn, database, tableName, column ) + "( " + "@" +
                    StandardLibraryMethods.GetCSharpIdentifierSimple( column.CamelCasedName ) + " ) );" );
            }

            writeColumnValueAssignmentsFromParameters( columns.AllColumnsExceptRowVersion, "mod" );
            writer.WriteLine( "mod.markColumnValuesUnchanged();" );
            writer.WriteLine( "return mod;" );
            writer.WriteLine( "}" );
        }
예제 #2
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))));
        }
 private void startWebSite(string webSiteName)
 {
     if (siteExistsInIis(webSiteName))
     {
         StandardLibraryMethods.RunProgram(appCmdPath, "Start Site \"" + webSiteName + "\"", "", true);
     }
 }
예제 #4
0
        void Database.ExportToFile(string filePath)
        {
            Directory.CreateDirectory(dataPumpFolderPath);
            try {
                executeMethodWithDbExceptionHandling(
                    delegate {
                    try {
                        // We pass an enter keystroke as input in an attempt to kill the program if it gets stuck on a username prompt because of a bad logon string.
                        StandardLibraryMethods.RunProgram(
                            "expdp",
                            getLogonString() + " DIRECTORY=" + dataPumpOracleDirectoryName + " DUMPFILE=\"\"\"" + getDumpFileName() + "\"\"\" NOLOGFILE=y VERSION=12.1",
                            Environment.NewLine,
                            true);
                    }
                    catch (Exception e) {
                        throwUserCorrectableExceptionIfNecessary(e);
                        throw DataAccessMethods.CreateDbConnectionException(info, "exporting (to file)", e);
                    }
                });

                IoMethods.ExecuteWithTempFolder(
                    folderPath => {
                    IoMethods.CopyFile(getDumpFilePath(), StandardLibraryMethods.CombinePaths(folderPath, databaseFileDumpFileName));
                    File.WriteAllText(StandardLibraryMethods.CombinePaths(folderPath, databaseFileSchemaNameFileName), info.UserAndSchema);
                    ZipOps.ZipFolderAsFile(folderPath, filePath);
                });
            }
            finally {
                IoMethods.DeleteFile(getDumpFilePath());
            }
        }
예제 #5
0
        private static void writeInequalityConditionClasses(DBConnection cn, TextWriter writer, string table)
        {
            // NOTE: This kind of sucks. It seems like we could use generics to not have to write N of these methods into ISU.cs.
            writer.WriteLine("public static class " + StandardLibraryMethods.GetCSharpSafeClassName(table.TableNameToPascal(cn)) + "TableInequalityConditions {");
            foreach (var column in new TableColumns(cn, table, false).AllColumnsExceptRowVersion)
            {
                CodeGenerationStatics.AddSummaryDocComment(writer, "A condition that narrows the scope of a command.");
                writer.WriteLine("public class " + GetConditionClassName(column) + ": " + GetTableConditionInterfaceName(cn, table) + " {");
                writer.WriteLine("private readonly InequalityCondition.Operator op; ");
                writer.WriteLine("private readonly " + column.DataTypeName + " value;");

                CodeGenerationStatics.AddSummaryDocComment(
                    writer,
                    "Creates a condition to narrow the scope of a command. Expression will read 'valueInDatabase op yourValue'. So new InequalityCondition( Operator.GreaterThan, value ) will turn into 'columnName > @value'.");
                writer.WriteLine("public " + GetConditionClassName(column) + "( InequalityCondition.Operator op, " + column.DataTypeName + " value ) {");
                writer.WriteLine("this.op = op;");
                writer.WriteLine("this.value = value;");
                writer.WriteLine("}");

                var colVal = column.GetCommandColumnValueExpression("value");
                writer.WriteLine("InlineDbCommandCondition TableCondition.CommandCondition { get { return new InequalityCondition( op, " + colVal + " ); } }");
                writer.WriteLine("}");
            }
            writer.WriteLine("}");               // class
        }
        internal static void GenerateWebConfig(WebProject webProject, string webProjectPath)
        {
            var sections = new XmlDocument {
                PreserveWhitespace = true
            };

            using (var reader = new StringReader(getSectionString(webProject)))
                sections.Load(reader);

            if (!File.Exists(StandardLibraryMethods.CombinePaths(webProjectPath, "Web.config")))
            {
                throw new UserCorrectableException("The Web.config file is missing.");
            }
            var webConfig = new XmlDocument {
                PreserveWhitespace = true
            };

            webConfig.Load(StandardLibraryMethods.CombinePaths(webProjectPath, "Web.config"));

            replaceSection(sections, webConfig, "appSettings");
            replaceSection(sections, webConfig, "system.web");
            replaceSection(sections, webConfig, "system.webServer");

            try {
                webConfig.Save(StandardLibraryMethods.CombinePaths(webProjectPath, "Web.config"));
            }
            catch (Exception e) {
                const string message = "Failed to write web configuration file.";
                if (e is UnauthorizedAccessException)
                {
                    throw new UserCorrectableException(message, e);
                }
                throw new ApplicationException(message, e);
            }
        }
예제 #7
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>");
        }
        private void tick(object state)
        {
            AppTools.ExecuteBlockWithStandardExceptionHandling(
                () => {
                // We need to schedule the next tick even if there is an exception thrown in this one. Use try-finally instead of CallEveryMethod so we don't lose
                // exception stack traces.
                try {
                    var now = DateTime.Now;
                    if (AppTools.IsLiveInstallation && !ConfigurationStatics.MachineIsStandbyServer &&
                        new[] { lastHealthCheckDateAndTime, now }.Any(dt => dt.Date.IsBetweenDateTimes(lastHealthCheckDateAndTime, now)))
                    {
                        StandardLibraryMethods.SendHealthCheckEmail(WindowsServiceMethods.GetServiceInstalledName(service));
                    }
                    lastHealthCheckDateAndTime = now;

                    service.Tick();
                }
                finally {
                    try {
                        timer.Change(tickInterval, Timeout.Infinite);
                    }
                    catch (ObjectDisposedException) {
                        // This should not be necessary with the Timer.Dispose overload we are using, but see http://stackoverflow.com/q/12354883/35349.
                    }
                }
            });
        }
 private static IEnumerable <string> getAssemblyPaths(DevelopmentInstallation installation, bool debug)
 {
     return(StandardLibraryMethods.CombinePaths(installation.DevelopmentInstallationLogic.LibraryPath,
                                                StandardLibraryMethods.GetProjectOutputFolderPath(debug),
                                                installation.DevelopmentInstallationLogic.DevelopmentConfiguration.LibraryNamespaceAndAssemblyName + ".dll")
            .ToSingleElementArray()
            .Concat(from i in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.webProjects ?? new WebProject[0]
                    select StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, i.name, "bin", i.NamespaceAndAssemblyName + ".dll"))
            .Concat(from i in installation.ExistingInstallationLogic.RuntimeConfiguration.WindowsServices
                    select
                    StandardLibraryMethods.CombinePaths(installation.ExistingInstallationLogic.GetWindowsServiceFolderPath(i, debug),
                                                        i.NamespaceAndAssemblyName + ".exe"))
            .Concat(from i in installation.DevelopmentInstallationLogic.DevelopmentConfiguration.ServerSideConsoleProjectsNonNullable
                    select
                    StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                                        i.Name,
                                                        StandardLibraryMethods.GetProjectOutputFolderPath(debug),
                                                        i.NamespaceAndAssemblyName + ".exe"))
            .Concat(installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject != null
                                          ? StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path,
                                                                                installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name,
                                                                                StandardLibraryMethods.GetProjectOutputFolderPath(debug),
                                                                                installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.assemblyName + ".exe").ToSingleElementArray()
                                          : new string[0]));
 }
예제 #10
0
        private void copyInWebProjectFiles(Installation installation, WebProject webProject)
        {
            var webProjectFilesFolderPath = StandardLibraryMethods.CombinePaths(AppTools.InstallationPath, AppStatics.WebProjectFilesFolderName);
            var webProjectPath            = StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, webProject.name);

            // Copy Ewf folder and customize namespaces in .aspx, .ascx, .master, and .cs files.
            var webProjectEwfFolderPath = StandardLibraryMethods.CombinePaths(webProjectPath, StaticFileHandler.EwfFolderName);

            IoMethods.DeleteFolder(webProjectEwfFolderPath);
            IoMethods.CopyFolder(StandardLibraryMethods.CombinePaths(webProjectFilesFolderPath, StaticFileHandler.EwfFolderName), webProjectEwfFolderPath, false);
            IoMethods.RecursivelyRemoveReadOnlyAttributeFromItem(webProjectEwfFolderPath);
            var matchingFiles = new List <string>();

            matchingFiles.AddRange(Directory.GetFiles(webProjectEwfFolderPath, "*.aspx", SearchOption.AllDirectories));
            matchingFiles.AddRange(Directory.GetFiles(webProjectEwfFolderPath, "*.ascx", SearchOption.AllDirectories));
            matchingFiles.AddRange(Directory.GetFiles(webProjectEwfFolderPath, "*.master", SearchOption.AllDirectories));
            matchingFiles.AddRange(Directory.GetFiles(webProjectEwfFolderPath, "*.cs", SearchOption.AllDirectories));
            foreach (var filePath in matchingFiles)
            {
                File.WriteAllText(filePath, customizeNamespace(File.ReadAllText(filePath), webProject));
            }

            IoMethods.CopyFile(
                StandardLibraryMethods.CombinePaths(webProjectFilesFolderPath, AppStatics.StandardLibraryFilesFileName),
                StandardLibraryMethods.CombinePaths(webProjectPath, AppStatics.StandardLibraryFilesFileName));
            IoMethods.RecursivelyRemoveReadOnlyAttributeFromItem(StandardLibraryMethods.CombinePaths(webProjectPath, AppStatics.StandardLibraryFilesFileName));
        }
예제 #11
0
 private void executeWithBasicExceptionHandling(Action handler, bool setErrorInRequestState, bool set500StatusCode)
 {
     try {
         handler();
     }
     catch (Exception e) {
         // Suppress all exceptions since there is no way to report them and in some cases they could wreck the control flow for the request.
         try {
             StandardLibraryMethods.CallEveryMethod(
                 delegate {
                 const string prefix = "An exception occurred that could not be handled by the main exception handler:";
                 if (setErrorInRequestState)
                 {
                     RequestState.SetError(prefix, e);
                 }
                 else
                 {
                     AppTools.EmailAndLogError(prefix, e);
                 }
             },
                 delegate {
                 if (set500StatusCode)
                 {
                     this.set500StatusCode("Exception");
                 }
             });
         }
         catch {}
     }
 }
        private static void writeFormItemGetterWithoutValueParams(
            TextWriter writer, string controlType, ModificationField field, string controlTypeForName, bool includeValidationParams,
            IEnumerable <CSharpParameter> requiredControlParams, IEnumerable <CSharpParameter> requiredValidationParams, IEnumerable <CSharpParameter> optionalControlParams,
            IEnumerable <CSharpParameter> optionalValidationParams, IEnumerable <string> additionalSummarySentences)
        {
            // NOTE: The "out" parameter logic is a hack. We need to improve CSharpParameter.
            var body = "return " + StandardLibraryMethods.GetCSharpIdentifierSimple("Get" + field.PascalCasedName + controlTypeForName + "FormItem") + "( false, " +
                       requiredControlParams.Concat(requiredValidationParams)
                       .Select(i => (i.MethodSignatureDeclaration.StartsWith("out ") ? "out " : "") + i.Name)
                       .GetCommaDelimitedStringFromCollection()
                       .AppendDelimiter(", ") + "labelAndSubject: labelAndSubject, labelOverride: labelOverride, " +
                       optionalControlParams.Select(i => i.Name + ": " + i.Name).GetCommaDelimitedStringFromCollection().AppendDelimiter(", ") +
                       "cellSpan: cellSpan, textAlignment: textAlignment" + (includeValidationParams ? ", validationPredicate: validationPredicate" : "") +
                       optionalValidationParams.Select(i => i.Name + ": " + i.Name).GetCommaDelimitedStringFromCollection().PrependDelimiter(", ") +
                       (includeValidationParams
                                             ? ", validationErrorNotifier: validationErrorNotifier, additionalValidationMethod: additionalValidationMethod, validationList: validationList"
                                             : "") + " );";

            writeFormItemGetter(
                writer,
                controlType,
                field,
                controlTypeForName,
                "",
                requiredControlParams,
                requiredValidationParams,
                "",
                optionalControlParams,
                includeValidationParams,
                optionalValidationParams,
                body,
                additionalSummarySentences);
        }
        internal static void Generate(DBConnection cn, TextWriter writer, string baseNamespace, Database database)
        {
            writer.WriteLine("namespace " + baseNamespace + "." + database.SecondaryDatabaseName + "TableConstants {");
            foreach (var table in DatabaseOps.GetDatabaseTables(database))
            {
                CodeGenerationStatics.AddSummaryDocComment(writer, "This object represents the constants of the " + table + " table.");
                writer.WriteLine("public class " + StandardLibraryMethods.GetCSharpSafeClassName(table.TableNameToPascal(cn)) + "Table {");

                CodeGenerationStatics.AddSummaryDocComment(writer, "The name of this table.");
                writer.WriteLine("public const string Name = \"" + table + "\";");

                foreach (var column in new TableColumns(cn, table, false).AllColumnsExceptRowVersion)
                {
                    CodeGenerationStatics.AddSummaryDocComment(writer, "Contains schema information about this column.");
                    writer.WriteLine("public class " + StandardLibraryMethods.GetCSharpSafeClassName(column.PascalCasedNameExceptForOracle) + "Column {");

                    CodeGenerationStatics.AddSummaryDocComment(writer, "The name of this column.");
                    writer.WriteLine("public const string Name = \"" + column.Name + "\";");

                    CodeGenerationStatics.AddSummaryDocComment(
                        writer,
                        "The size of this column. For varchars, this is the length of the biggest string that can be stored in this column.");
                    writer.WriteLine("public const int Size = " + column.Size + ";");

                    writer.WriteLine("}");
                }

                writer.WriteLine("}");
            }
            writer.WriteLine("}");
        }
예제 #14
0
        void Database.DeleteAndReCreateFromFile(string filePath, bool keepDbInStandbyMode)
        {
            using (var sw = new StringWriter()) {
                sw.WriteLine("DROP DATABASE IF EXISTS {0};".FormatWith(info.Database));
                sw.WriteLine("CREATE DATABASE {0};".FormatWith(info.Database));
                sw.WriteLine("use {0}".FormatWith(info.Database));
                sw.Write(File.ReadAllText(filePath));
                sw.WriteLine("quit");

                executeMethodWithDbExceptionHandling(
                    delegate {
                    try {
                        StandardLibraryMethods.RunProgram(
                            StandardLibraryMethods.CombinePaths(binFolderPath, "mysql"),
                            getHostAndAuthenticationArguments() + " --disable-reconnect --batch --disable-auto-rehash",
                            sw.ToString(),
                            true);
                    }
                    catch (Exception e) {
                        if (e.Message.Contains("ERROR") && e.Message.Contains("at line"))
                        {
                            throw new UserCorrectableException("Failed to create database from file. Please try the operation again after obtaining a new database file.", e);
                        }
                        throw DataAccessMethods.CreateDbConnectionException(info, "re-creating (from file)", e);
                    }
                });
            }
        }
예제 #15
0
        private void generateWebConfigAndCodeForWebProject(DevelopmentInstallation installation, WebProject webProject)
        {
            var webProjectPath = StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, webProject.name);

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

            var webProjectGeneratedCodeFolderPath = StandardLibraryMethods.CombinePaths(webProjectPath, "Generated Code");

            Directory.CreateDirectory(webProjectGeneratedCodeFolderPath);
            var webProjectIsuFilePath = StandardLibraryMethods.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 RedStapler.StandardLibrary;");
                writer.WriteLine("using RedStapler.StandardLibrary.DataAccess;");
                writer.WriteLine("using RedStapler.StandardLibrary.EnterpriseWebFramework;");
                writer.WriteLine("using RedStapler.StandardLibrary.EnterpriseWebFramework.Controls;");
                writer.WriteLine("using RedStapler.StandardLibrary.Validation;");
                writer.WriteLine();
                writeAssemblyInfo(writer, installation, webProject.name);
                writer.WriteLine();
                CodeGeneration.WebMetaLogic.WebMetaLogicStatics.Generate(writer, webProjectPath, webProject);
            }
        }
예제 #16
0
        private static void packageGeneralFiles(DevelopmentInstallation installation, string folderPath, bool includeDatabaseUpdates)
        {
            // configuration files
            var configurationFolderPath = StandardLibraryMethods.CombinePaths(folderPath, InstallationConfiguration.ConfigurationFolderName);

            IoMethods.CopyFolder(installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath, configurationFolderPath, false);
            IoMethods.RecursivelyRemoveReadOnlyAttributeFromItem(configurationFolderPath);
            IoMethods.DeleteFolder(StandardLibraryMethods.CombinePaths(configurationFolderPath, InstallationConfiguration.InstallationConfigurationFolderName));
            IoMethods.DeleteFolder(StandardLibraryMethods.CombinePaths(configurationFolderPath, ConfigurationStatics.ProvidersFolderAndNamespaceName));
            if (!includeDatabaseUpdates)
            {
                IoMethods.DeleteFile(StandardLibraryMethods.CombinePaths(configurationFolderPath, ExistingInstallationLogic.SystemDatabaseUpdatesFileName));
            }
            IoMethods.DeleteFile(StandardLibraryMethods.CombinePaths(configurationFolderPath, InstallationConfiguration.SystemDevelopmentConfigurationFileName));
            IoMethods.DeleteFolder(StandardLibraryMethods.CombinePaths(configurationFolderPath, ".hg"));                          // EWL uses a nested repository for configuration.
            IoMethods.DeleteFile(StandardLibraryMethods.CombinePaths(configurationFolderPath, "Update All Dependent Logic.bat")); // EWL has this file.

            // other files
            var filesFolderInInstallationPath =
                StandardLibraryMethods.CombinePaths(
                    InstallationFileStatics.GetGeneralFilesFolderPath(installation.GeneralLogic.Path, true),
                    InstallationFileStatics.FilesFolderName);

            if (Directory.Exists(filesFolderInInstallationPath))
            {
                IoMethods.CopyFolder(filesFolderInInstallationPath, StandardLibraryMethods.CombinePaths(folderPath, InstallationFileStatics.FilesFolderName), false);
            }
        }
        public bool Equals(InlineDbCommandCondition other)
        {
            var otherInequalityCondition = other as InequalityCondition;

            return(otherInequalityCondition != null && op == otherInequalityCondition.op &&
                   StandardLibraryMethods.AreEqual(columnValue, otherInequalityCondition.columnValue));
        }
예제 #18
0
 private static void writeColumnParameterDeclarations( IEnumerable<Column> columns )
 {
     writer.Write(
         StringTools.ConcatenateWithDelimiter(
             ", ",
             columns.Select( i => i.DataTypeName + " @" + StandardLibraryMethods.GetCSharpIdentifierSimple( i.CamelCasedName ) ).ToArray() ) );
 }
예제 #19
0
 private void copyServerSideProject(DevelopmentInstallation installation, string serverSideLogicFolderPath, string project)
 {
     IoMethods.CopyFolder(
         StandardLibraryMethods.CombinePaths(installation.GeneralLogic.Path, project, StandardLibraryMethods.GetProjectOutputFolderPath(false)),
         StandardLibraryMethods.CombinePaths(serverSideLogicFolderPath, project),
         false);
 }
예제 #20
0
        private static void writeFieldsAndPropertiesForColumn( Column column )
        {
            var columnIsReadOnly = !columns.DataColumns.Contains( column );

            writer.WriteLine(
                "private readonly DataValue<" + column.DataTypeName + "> " + getColumnFieldName( column ) + " = new DataValue<" + column.DataTypeName + ">();" );
            CodeGenerationStatics.AddSummaryDocComment(
                writer,
                "Gets " + ( columnIsReadOnly ? "" : "or sets " ) + "the value for the " + column.Name +
                " column. Throws an exception if the value has not been initialized. " + getComment( column ) );
            var propertyDeclarationBeginning = "public " + column.DataTypeName + " " +
                                               StandardLibraryMethods.GetCSharpIdentifierSimple( column.PascalCasedNameExceptForOracle ) + " { get { return " +
                                               getColumnFieldName( column ) + ".Value; } ";
            if( columnIsReadOnly )
                writer.WriteLine( propertyDeclarationBeginning + "}" );
            else {
                writer.WriteLine( propertyDeclarationBeginning + "set { " + getColumnFieldName( column ) + ".Value = value; } }" );

                CodeGenerationStatics.AddSummaryDocComment(
                    writer,
                    "Indicates whether or not the value for the " + column.Name + " has been set since object creation or the last call to Execute, whichever was latest." );
                writer.WriteLine(
                    "public bool " + StandardLibraryMethods.GetCSharpIdentifierSimple( column.PascalCasedNameExceptForOracle ) + "HasChanged { get { return " +
                    getColumnFieldName( column ) + ".Changed; } }" );
            }
        }
        internal WebItemGeneralData(string webProjectPath, string pathRelativeToProject, bool includeFileExtensionInClassName, WebProject webProjectConfiguration)
        {
            this.pathRelativeToProject = pathRelativeToProject;

            // Get the URL for this item. "Plain old class" entity setups do not have URLs.
            urlRelativeToProject = pathRelativeToProject.EndsWith(".cs") ? "" : pathRelativeToProject.Replace(System.IO.Path.DirectorySeparatorChar, '/');

            // Load this item's code if it exists.
            path = StandardLibraryMethods.CombinePaths(webProjectPath, pathRelativeToProject);
            var codePath = path.EndsWith(".cs") ? path : path + ".cs";

            code = File.Exists(codePath) ? File.ReadAllText(codePath) : "";

            // Attempt to get the namespace from the code. If this fails, use a namespace based on the item's path in the project.
            foreach (Match match in Regex.Matches(code, @"namespace\s(?<namespace>.*)\s{"))
            {
                itemNamespace = match.Groups["namespace"].Value;
            }
            if (itemNamespace == null)
            {
                itemNamespace = getNamespaceFromFilePath(webProjectConfiguration.NamespaceAndAssemblyName, pathRelativeToProject);
            }

            className =
                StandardLibraryMethods.GetCSharpIdentifier(
                    System.IO.Path.GetFileNameWithoutExtension(path) + (includeFileExtensionInClassName ? System.IO.Path.GetExtension(path).CapitalizeString() : ""));
            this.webProjectConfiguration = webProjectConfiguration;
        }
예제 #22
0
 internal static string GetClassName( DBConnection cn, string table, bool isRevisionHistoryTable, bool isRevisionHistoryClass )
 {
     return
         StandardLibraryMethods.GetCSharpSafeClassName(
             isRevisionHistoryTable && !isRevisionHistoryClass
                 ? "Direct" + table.TableNameToPascal( cn ) + "ModificationWithRevisionBypass"
                 : table.TableNameToPascal( cn ) + "Modification" );
 }
 // NOTE: We do have the power to add and remove web sites here, and we can list just the stopped or just the started sites.
 // NOTE: When we add web sites with the ISU, we should NOT support host headers since WCF services have some restrictions with these. See http://stackoverflow.com/questions/561823/wcf-error-this-collection-already-contains-an-address-with-scheme-http
 private bool siteExistsInIis(string webSiteName)
 {
     if (!File.Exists(appCmdPath))
     {
         return(false);
     }
     return(StandardLibraryMethods.RunProgram(appCmdPath, "list sites", "", true).Contains("\"" + webSiteName + "\""));
 }
 private static void writeToIdDictionaryMethod(TextWriter writer, TableColumns tableColumns)
 {
     writer.WriteLine("public static Dictionary<" + tableColumns.KeyColumns.Single().DataTypeName + ", Row> ToIdDictionary( this IEnumerable<Row> rows ) {");
     writer.WriteLine(
         "return rows.ToDictionary( i => i." + StandardLibraryMethods.GetCSharpIdentifierSimple(tableColumns.KeyColumns.Single().PascalCasedNameExceptForOracle) +
         " );");
     writer.WriteLine("}");
 }
예제 #25
0
 /// <summary>
 /// Internal and Red Stapler Information System use only.
 /// </summary>
 public static string GetGeneralFilesFolderPath(string installationPath, bool isDevelopmentInstallation)
 {
     if (isDevelopmentInstallation)
     {
         return(StandardLibraryMethods.CombinePaths(installationPath, "Library"));
     }
     return(installationPath);
 }
예제 #26
0
 protected override void init()
 {
     FilePath = StandardLibraryMethods.CombinePaths(AppTools.FilesFolderPath, FileName + FileExtensions.Xsd);
     if (!File.Exists(FilePath))
     {
         throw new ApplicationException("File does not exist.");
     }
 }
예제 #27
0
 public static string GetBuildFilePath(int systemId)
 {
     return(StandardLibraryMethods.CombinePaths(
                DataPackageRepositoryPath
                /*NOTE: Make this the generic web-site-accessible folder and change this and DataPackageRepositoryPath to be a subfolder of that.*/,
                "Latest Builds",
                systemId.ToString()));
 }
예제 #28
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);
     }
 }
예제 #29
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);
 }
 private static void writeColumnProperty(TextWriter writer, Column column)
 {
     CodeGenerationStatics.AddSummaryDocComment(
         writer,
         "This object will " + (column.AllowsNull && !column.NullValueExpression.Any() ? "sometimes" : "never") + " be null.");
     writer.WriteLine(
         "public " + column.DataTypeName + " " + StandardLibraryMethods.GetCSharpIdentifierSimple(column.PascalCasedNameExceptForOracle) +
         " { get { return __basicRow." + StandardLibraryMethods.GetCSharpIdentifierSimple(column.PascalCasedName) + "; } }");
 }