protected String GenerateLinkTableForN2MLink(String entityName, EntityField currField) { String tableName = "n2m" + entityName + currField.LinkedEntityName; StringFileWriter FileWriter = new StringFileWriter(DataConfiguration.OutputPath, tableName, OutputFileType.SqlScript); FileWriter.WriteString("CREATE TABLE " + tableName + "("); FileWriter.WriteString(EmptyPrefix4 + "Id BIGINT IDENTITY(1,1) NOT NULL PRIMARY KEY,"); FileWriter.WriteString(EmptyPrefix4 + "[" + entityName + "]" + " BIGINT FOREIGN KEY REFERENCES tbl" + entityName + "(Id),"); FileWriter.WriteString(EmptyPrefix4 + "[" + currField.LinkedEntityName + "]" + " BIGINT FOREIGN KEY REFERENCES tbl" + currField.LinkedEntityName + "(Id),"); FileWriter.WriteString(");"); FileWriter.WriteString("GO"); FileWriter.Close(); String indexFileName = "idx" + entityName + currField.LinkedEntityName; FileWriter = new StringFileWriter(DataConfiguration.OutputPath, indexFileName, OutputFileType.SqlScript); FileWriter.WriteString("CREATE INDEX " + indexFileName + "_" + entityName + " "); FileWriter.WriteString(EmptyPrefix4 + "ON [" + tableName + "]([" + entityName + "]); "); FileWriter.WriteString("GO"); FileWriter.WriteString(""); FileWriter.WriteString("CREATE INDEX " + indexFileName + "_" + currField.LinkedEntityName + " "); FileWriter.WriteString(EmptyPrefix4 + "ON [" + tableName + "]([" + currField.LinkedEntityName + "]); "); FileWriter.WriteString("GO"); FileWriter.Close(); String result = EmptyPrefix4 + "-- see N2M link table n2m" + entityName + currField.LinkedEntityName; return(result); }
public void Generate() { // заполняем словарными данными tblDirectory ------------------------------------------------------------------------------------------------ StringFileWriter FileWriter_tblDirectory = new StringFileWriter(DataConfiguration.OutputPath, "fill_tblDirectory", OutputFileType.SqlScript); FileWriter_tblDirectory.WriteString(""); FileWriter_tblDirectory.WriteString("SET IDENTITY_INSERT tblDirectory ON;"); FileWriter_tblDirectory.WriteString(""); foreach (var currDirectory in DataConfiguration.DirectoryConfigurations.Values) { FillOneTblDirectoryRow(currDirectory, FileWriter_tblDirectory); } FileWriter_tblDirectory.WriteString(""); FileWriter_tblDirectory.WriteString("SET IDENTITY_INSERT tblDirectory OFF;"); FileWriter_tblDirectory.WriteString("GO"); FileWriter_tblDirectory.Close(); // заполняем словарными данными tblDirectoryValue ------------------------------------------------------------------------------------------- StringFileWriter FileWriter_tblDirectoryValue = new StringFileWriter(DataConfiguration.OutputPath, "fill_tblDirectoryValue", OutputFileType.SqlScript); FileWriter_tblDirectoryValue.WriteString(""); FileWriter_tblDirectoryValue.WriteString("SET IDENTITY_INSERT tblDirectoryValue ON;"); FileWriter_tblDirectoryValue.WriteString(""); foreach (var currDirectory in DataConfiguration.DirectoryConfigurations.Values) { foreach (var currDirectoryValue in currDirectory.Items.Values) { FillOneTblDirectoryValue(currDirectoryValue, FileWriter_tblDirectoryValue); } } FileWriter_tblDirectoryValue.WriteString(""); FileWriter_tblDirectoryValue.WriteString("SET IDENTITY_INSERT tblDirectoryValue OFF;"); FileWriter_tblDirectoryValue.WriteString("GO"); FileWriter_tblDirectoryValue.Close(); // заполняем словарными данными tblTranslatedString ----------------------------------------------------------------------------------------- StringFileWriter FileWriter_tblTranslatedString = new StringFileWriter(DataConfiguration.OutputPath, "fill_tblTranslatedString", OutputFileType.SqlScript); foreach (var currDirectory in DataConfiguration.DirectoryConfigurations.Values) { foreach (var currTranslatedString in currDirectory.TranslatedUINames) { FillOneTblTranslatedString(currTranslatedString, FileWriter_tblTranslatedString); } foreach (var currDirectoryValue in currDirectory.Items.Values) { foreach (var currTranslatedUIName in currDirectoryValue.TranslatedUINames) { FillOneTblTranslatedString(currTranslatedUIName, FileWriter_tblTranslatedString); } foreach (var currTranslatedUIComment in currDirectoryValue.TranslatedUIComments) { FillOneTblTranslatedString(currTranslatedUIComment, FileWriter_tblTranslatedString); } } } FileWriter_tblTranslatedString.Close(); }
public void Generate() { StringFileWriter FileWriter = new StringFileWriter(DataConfiguration.OutputPath, "fill_tblLanguage", OutputFileType.SqlScript); FileWriter.WriteString("SET IDENTITY_INSERT tblLanguage ON;"); foreach (var currLanguage in DataConfiguration.Languages.Values) { FillOneTableRow(currLanguage, FileWriter); } FileWriter.WriteString("SET IDENTITY_INSERT tblLanguage OFF;"); FileWriter.WriteString("GO"); FileWriter.Close(); }
private void CreateOneViewForComplexEntity(ComplexEntity complexEntity) { String viewName = "vw" + complexEntity.Name; StringFileWriter FileWriter = new StringFileWriter(DataConfiguration.OutputPath, viewName, OutputFileType.SqlScript); FileWriter.WriteString("CREATE VIEW " + viewName); FileWriter.WriteString("AS"); FileWriter.WriteString("SELECT "); List <String> allFields = new List <string>(); // получим все поля из основной сущности if (complexEntity.IsMainTableLink == false) { allFields.AddRange(GenerateEntityFields(complexEntity.MainEntityTableName, complexEntity.MainEntityShortName)); } // получим все поля из связанных сущностей allFields.AddRange(ProcessLinkFields(complexEntity)); // сегенрируем поля в скрипте с учетом отсутствия запятой после последнего for (int i = 0; i < allFields.Count; i++) { var currFieldStr = allFields[i]; FileWriter.Write(" " + currFieldStr); if (i < allFields.Count - 1) { FileWriter.WriteString(","); } else { FileWriter.WriteString(""); } } FileWriter.WriteString("FROM [" + complexEntity.MainEntityTableName + "] [" + complexEntity.MainEntityShortName + "] "); foreach (var currLink in complexEntity.Links) { GenerateJoinClause(currLink, FileWriter); } FileWriter.WriteString("GO"); FileWriter.Close(); }
public void GenerateFile(String entityName, List <EntityField> fields) { // write header FileWriter.WriteString("CREATE TABLE " + TableName + " ( "); // write rows corresponding to foreach (var currField in fields) { WriteTableDefinitionRow(entityName, currField); } // write tail FileWriter.WriteString(" ); "); FileWriter.WriteString("GO"); // close file FileWriter.Close(); FileWriter = null; }
public void GenerateFile(String entityName, List <EntityField> fields) { List <EntityField> fieldsWithIndexes = new List <EntityField>(); foreach (var currField in fields) { if (currField.FieldType == EntityFieldType.DirectoryItem || ( currField.FieldType == EntityFieldType.Link2TableOrVirtaulPart && currField.LinkType != LinkType.N2MTableOtherObject && currField.LinkType != LinkType.One2OneVirtualPartOfObject ) || currField.GridColumnIsSortingAllowed == true || currField.FieldFilterIsRequired == true ) { fieldsWithIndexes.Add(currField); } } foreach (var currField in fieldsWithIndexes) { String idxEntityName, idxFieldName; if (currField.IsFieldOfVirtualNestedEntity == true || currField.FieldType == EntityFieldType.DirectoryItem || currField.FieldType == EntityFieldType.Link2TableOrVirtaulPart) { idxEntityName = _rootEntityName; idxFieldName = currField.Name; } else { idxEntityName = currField.LinkedEntityName; idxFieldName = currField.LinkedFieldName; } _fileWriter.WriteString("CREATE INDEX " + _indexFileName + "_" + currField.Name + " "); _fileWriter.WriteString(EmptyPrefix4 + "ON [tbl" + idxEntityName + "]([" + idxFieldName + "]); "); _fileWriter.WriteString("GO"); _fileWriter.WriteString(""); } _fileWriter.Close(); }
private void FillOneFile(List <EnumItem> items, String itemName) { String enName = itemName; StringFileWriter FileWriter = new StringFileWriter( DataTransferObjectsConfiguration.OutputPath, enName, OutputFileType.CSharpSource); FileWriter.WriteString("namespace Common.DataTransferObjects.AppIdAndAuth.ApplicationId "); FileWriter.WriteString("{ "); FileWriter.WriteString(" using System;"); FileWriter.WriteString(""); FileWriter.WriteString(" public enum " + enName); FileWriter.WriteString(" { "); FillOneFileItems(items, FileWriter); FileWriter.WriteString(" } "); FileWriter.WriteString("} "); FileWriter.Close(); }