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(); }
private void FillOneFileItems(List <EnumItem> items, StringFileWriter fileWriter) { foreach (var currEnumItem in items) { FillOneString(currEnumItem, fileWriter); } }
private void FillOneTableRow(LanguageItem currLangItem, StringFileWriter fileWriter) { fileWriter.WriteString(""); fileWriter.WriteString("IF NOT EXISTS( SELECT * FROM tblLanguage WHERE Id=" + currLangItem.Id.ToString() + " )"); fileWriter.WriteString("BEGIN"); fileWriter.WriteString(" INSERT INTO tblLanguage "); fileWriter.WriteString(" ( Id, EnumName, UIName )"); fileWriter.WriteString(" VALUES"); fileWriter.WriteString(" ( " + currLangItem.Id.ToString() + ", \'" + currLangItem.EnumName + "\', \'" + currLangItem.UIName + "\' );"); fileWriter.WriteString("END"); }
private void FillOneTblTranslatedString(TranslatedString transStr, StringFileWriter fileWriter) { fileWriter.WriteString(""); fileWriter.WriteString("IF NOT EXISTS( SELECT * FROM tblTranslatedString"); fileWriter.WriteString(" WHERE Language=" + transStr.Language.ToString() + " AND Type=" + ((int)transStr.Type).ToString() + " AND "); fileWriter.WriteString(" ReferencedItemId=" + transStr.ReferencedItemId.ToString() + " AND Value=\'" + transStr.Value.ToString() + "\' )"); fileWriter.WriteString("BEGIN"); fileWriter.WriteString(" INSERT INTO tblTranslatedString "); fileWriter.WriteString(" ( Language, Type, ReferencedItemId, Value )"); fileWriter.WriteString(" VALUES"); fileWriter.WriteString(" ( " + transStr.Language.ToString() + ", " + ((int)transStr.Type).ToString() + ", " + transStr.ReferencedItemId.ToString() + ", \'" + transStr.Value.ToString() + "\' );"); fileWriter.WriteString("END"); }
private void FillOneTblDirectoryRow(Directory dirItem, StringFileWriter fileWriter) { fileWriter.WriteString(""); fileWriter.WriteString("IF NOT EXISTS( SELECT * FROM tblDirectory WHERE Id=" + dirItem.Id.ToString() + " )"); fileWriter.WriteString("BEGIN"); fileWriter.WriteString(" INSERT INTO tblDirectory "); fileWriter.WriteString(" ( Id, EnumName, IsReadOnly )"); fileWriter.WriteString(" VALUES"); String IsReadOnlyStr = dirItem.IsReadOnly == true ? "1" : "0"; fileWriter.WriteString(" ( " + dirItem.Id.ToString() + ", \'" + dirItem.EnumName + "\', " + IsReadOnlyStr + " );"); fileWriter.WriteString("END"); }
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; }
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(); }
private void GenerateJoinClause(ComplexEntityLink link, StringFileWriter FileWriter) { String joinStr = ""; switch (link.Type) { case ComplexEntityLinkType.Inner: joinStr = "INNER JOIN"; break; case ComplexEntityLinkType.Left: joinStr = "LEFT JOIN"; break; case ComplexEntityLinkType.Right: joinStr = "RIGHT JOIN"; break; } FileWriter.WriteString(joinStr + " [" + link.RightTableName + "] [" + link.RightShortTableName + "] ON [" + link.LeftShortTableName + "].[" + link.LeftFieldName + "]=[" + link.RightShortTableName + "].[" + link.RightFieldName + "]"); }
public TableCreator(String filePath, String entityName) { TableName = "tbl" + entityName; FileWriter = new StringFileWriter(filePath, TableName, OutputFileType.SqlScript); }
public Indexes4TableCreator(String filePath, String entityName) { _rootEntityName = entityName; _indexFileName = "idx" + entityName; _fileWriter = new StringFileWriter(filePath, _indexFileName, OutputFileType.SqlScript); }
private void FillOneString(EnumItem currEnumItem, StringFileWriter fileWriter) { fileWriter.WriteString(currEnumItem.GetEnumRow()); }
public SyncStringFileSubmitter(StringFileWriter fileWriter) { m_fileWriter = fileWriter; }