public virtual void init(UpdateProc updateProc, Quaternion rot, _Action3 act) { update = updateProc; owner = act; rotation = rot; time = 0.0f; barrelFactor = 1.0f; }
private string GenerateScripts() { string tablePluralName = (this.Name.EndsWith("y") ? $"{this.Name.TrimEnd('y')}ies" : $"{this.Name}s"); string tableTypeName = $"[{this.Owner}].[tt_{this.Name}]"; string selectProcName = $"[{this.Owner}].[usp_Select_{this.Name}]"; string selectAllProcName = $"[{this.Owner}].[usp_SelectAll_{tablePluralName}]"; string insertProcName = $"[{this.Owner}].[usp_Insert_{this.Name}]"; string updateProcName = $"[{this.Owner}].[usp_Update_{this.Name}]"; string hardDeleteProcName = null; string softDeleteProcName = null; StringBuilder scriptBuilder = new StringBuilder(); StringBuilder dropScriptBuilder = new StringBuilder(); var tableType = new TableType() { TableTypeName = tableTypeName, AllColumnAndTypeList = this.allColumnAndTypeList }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(tableType); if (!string.IsNullOrEmpty(this.KeyColumnCategory) && this.KeyColumnCategory.Equals("primary")) { var selectProc = new SelectProc() { FullTableName = this.fullTableName, SelectProcName = selectProcName, AllColumnList = this.allColumnList, keyColumnAndTypeList = this.keyColumnAndTypeList, WhereClause = this.whereClause }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(selectProc); dropScriptBuilder.Append(new DropProc() { ProcName = selectProcName }.TransformText().TrimStart('\r', '\n')); var selectAllProc = new SelectAllProc() { FullTableName = this.fullTableName, SelectAllProcName = selectAllProcName, AllColumnList = this.allColumnList, DeleteFlagWhereClause = this.deleteFlagWhereClause }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(selectAllProc); dropScriptBuilder.Append(new DropProc() { ProcName = selectAllProcName }.TransformText().TrimStart('\r', '\n')); var updateProc = new UpdateProc() { TableName = this.Name, FullTableName = this.fullTableName, UpdateProcName = updateProcName, UpdateColumnList = this.updateColumnList, OnClause = this.onClause }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(updateProc); dropScriptBuilder.Append(new DropProc() { ProcName = updateProcName }.TransformText().TrimStart('\r', '\n')); if (idNameColumnList != null) { var selectIdNamePairsProcName = $"[{this.Owner}].[usp_Select_{this.Name}_IdNamePairs]"; var selectIdNamePairsProc = new SelectIdNamePairsProc() { FullTableName = this.fullTableName, SelectIdNamePairsProcName = selectIdNamePairsProcName, IdNameColumnList = this.idNameColumnList, DeleteFlagWhereClause = this.deleteFlagWhereClause }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(selectIdNamePairsProc); dropScriptBuilder.Append(new DropProc() { ProcName = selectIdNamePairsProcName }.TransformText().TrimStart('\r', '\n')); } } var insertProc = new InsertProc() { TableName = this.Name, FullTableName = this.fullTableName, InsertProcName = insertProcName, InsertIntoColumnList = this.insertIntoColumnList, InsertSelectColumnList = this.insertSelectColumnList, IdentityColumn = this.IdentityColumn, HasCreatedDateColumn = this.hasCreatedDateColumn, IsKeyColumnGuidColumn = (this.keyColumn != null && this.keyColumn.Type.Equals("uniqueidentifier")) }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(insertProc); dropScriptBuilder.Append(new DropProc() { ProcName = insertProcName }.TransformText().TrimStart('\r', '\n')); if (this.softDeleteStatement != null) { softDeleteProcName = $"[{this.Owner}].[usp_Delete_{this.Name}]"; var deleteProc = new DeleteProc() { DeleteProcName = softDeleteProcName, keyColumnAndTypeList = this.keyColumnAndTypeList, DeleteStatement = this.softDeleteStatement }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(deleteProc); dropScriptBuilder.Append(new DropProc() { ProcName = softDeleteProcName }.TransformText().TrimStart('\r', '\n')); hardDeleteProcName = $"[{this.Owner}].[usp_HardDelete_{this.Name}]"; } else { hardDeleteProcName = $"[{this.Owner}].[usp_Delete_{this.Name}]"; } if (this.hardDeleteStatement != null) { var deleteProc = new DeleteProc() { DeleteProcName = hardDeleteProcName, keyColumnAndTypeList = this.keyColumnAndTypeList, DeleteStatement = this.hardDeleteStatement }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(deleteProc); dropScriptBuilder.Append(new DropProc() { ProcName = hardDeleteProcName }.TransformText().TrimStart('\r', '\n')); } if (this.fkColumns.Count > 0 && this.hasIdColumn) { foreach (var c in this.fkColumns) { var procName = $"[{this.Owner}].[usp_Select_{this.Name}Ids_By_{c.ReferencingColumnName}]"; var proc = new SelectPKColumnByFKColumnProc() { FullTableName = this.fullTableName, ProcName = procName, VariablesList = $"@{c.ReferencingColumnName} {c.Type}", ColumnList = string.Join(",", this.keyColumnList), WhereClause = $"[{c.Name}] = @{c.ReferencingColumnName}" + (this.deleteFlagWhereClause == null ? "" : $" AND {this.deleteFlagWhereClause}") }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(proc); dropScriptBuilder.Append(new DropProc() { ProcName = procName }.TransformText().TrimStart('\r', '\n')); procName = $"[{this.Owner}].[usp_Select_{tablePluralName}_By_{c.ReferencingColumnName}]"; proc = new SelectPKColumnByFKColumnProc() { FullTableName = this.fullTableName, ProcName = procName, VariablesList = $"@{c.ReferencingColumnName} {c.Type}", ColumnList = this.allColumnList, WhereClause = $"[{c.Name}] = @{c.ReferencingColumnName}" + (this.deleteFlagWhereClause == null ? "" : $" AND {this.deleteFlagWhereClause}") }.TransformText().TrimStart('\r', '\n'); scriptBuilder.Append(proc); dropScriptBuilder.Append(new DropProc() { ProcName = procName }.TransformText().TrimStart('\r', '\n')); } } dropScriptBuilder.Append(new DropType() { TableName = this.Name, TypeName = tableTypeName }.TransformText().TrimStart('\r', '\n')); scriptBuilder.Insert(0, dropScriptBuilder.ToString()); var script = scriptBuilder.ToString(); var solutionRootFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../"); var dbProjectPath = Path.Combine(solutionRootFolder, "DatabaseScriptsGenerator/DatabaseScriptsGenerator.csproj"); var dbScriptPath = Path.Combine(solutionRootFolder, $"DatabaseScriptsGenerator/Tables/{this.Name}.sql"); CommonFunctions.WriteFileToProject("Content", dbScriptPath, dbProjectPath, script); var entity = new Entity() { TableName = this.Name, Columns = allColumns }.TransformText().TrimStart('\r', '\n'); var apiProjectPath = Path.Combine(solutionRootFolder, "AddAppAPI/AddAppAPI.csproj"); var entityPath = Path.Combine(solutionRootFolder, $"AddAppAPI/Models/{this.Name}.cs"); CommonFunctions.WriteFileToProject("Compile", entityPath, apiProjectPath, entity); var lowerCaseTableName = this.Name[0].ToString().ToLower() + this.Name.Substring(1); var entityController = new EntityController() { EntityName = this.Name, PluralEntityName = tablePluralName, LowerCaseEntityName = lowerCaseTableName, PluralEntityVariableName = lowerCaseTableName.EndsWith("y") ? (lowerCaseTableName.TrimEnd('y') + "ies") : (lowerCaseTableName + "s"), KeyColumnType = this.keyColumn.DotNetType, KeyColumnCategory = this.KeyColumnCategory, HasNameColumn = this.nameColumns.Count > 0, KeyColumns = this.primaryOrUniqueKeyColumns, KeyColumnAndDotNetTypeList = this.keyColumnAndDotNetTypeList, KeyColumnDotNetVariableNameList = this.keyColumnDotNetVariableNameList, FkColumns = this.fkColumns, HasIdColumn = this.hasIdColumn }.TransformText().TrimStart('\r', '\n'); var entityControllerPath = Path.Combine(solutionRootFolder, $"AddAppAPI/Controllers/{this.Name}Controller.cs"); CommonFunctions.WriteFileToProject("Compile", entityControllerPath, apiProjectPath, entityController); return(script); }
public virtual void cleanup() { owner = null; update = null; }