/// <summary> /// Genera código de parámetros de llamado a un método. /// </summary> /// <param name="MethodActionType">información sobre el método a generar.</param> /// <param name="pTable">tabla.</param> /// <returns>Código que representa los parámetros para ejecutar el método.</returns> /// <author>Marcelo Oviedo</author> static string GenMethodParameters(MethodActionType pMethodActionType, Table pTable) { String wBuilder = string.Empty; switch (pMethodActionType) { case MethodActionType.Insert: case MethodActionType.Update: case MethodActionType.GetByParam: case MethodActionType.SearchByParam: wBuilder = string.Concat(pTable.Name, " p", pTable.Name); break; case MethodActionType.Delete: Column pPK = FwkGeneratorHelper.GetPrimaryKey(pTable); if (pPK != null) { FwkGeneratorHelper.GetCSharpType(pPK); wBuilder = String.Concat(FwkGeneratorHelper.GetCSharpType(pPK), " p", pPK.Name); } else { wBuilder = String.Concat("int pId"); } break; } return(wBuilder); }
/// <summary> /// Obtiene el seteo de parametro que se envia a un store procedure para Aplication Block, /// en forma de batch.- /// /// </summary> /// <param name="pTableName">Nombre de tabla</param> /// <param name="pColumnName">Nombre de columna</param> /// <param name="pType">Tipo de SQL Server</param> ///<example> /// <code> /// /// #region [[Property_Name]] /// public [TYPENAME] [Property_Name] /// { /// get { return _[Property_Name]; } /// set { _[Property_Name] = value; } /// } /// #endregion /// /// </code> /// </example> /// <returns>string</returns> internal static string GetCsharpProperty(Column pColumn) { string wTypeName = pColumn.DataType.Name.ToUpper(); if (pColumn.DataType.SqlDataType.ToString().Equals("UserDefinedDataType")) { wTypeName = UserDefinedTypes.GetUserDefinedType(pColumn.DataType.Name).SystemType.ToUpper(); } System.Text.StringBuilder str = new System.Text.StringBuilder(_Entity_Property_tt); switch (wTypeName) { case "IMAGE": case "VARBINARY": case "BINARY": str = new System.Text.StringBuilder(_Entity_Property_TemplateBinary_tt); //str.Replace(CommonConstants.CONST_TYPENAME, "Byte[]"); break; } str.Replace(CommonConstants.CONST_TYPENAME, FwkGeneratorHelper.GetCSharpType(pColumn)); str.Replace("[NullToken]", GetNullableToken(pColumn)); str.Replace(CommonConstants.CONST_ENTITY_PROPERTY_NAME, pColumn.Name); str.AppendLine(Environment.NewLine); return(str.ToString()); }
private static string GenMethodReturn(Table pTable, MethodActionType t) { StringBuilder wBuilderReturn = null; switch (t) { case MethodActionType.Insert: { Column pPK = FwkGeneratorHelper.GetPrimaryKey(pTable); if (pPK != null) { wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("InsertReturn").Content); wBuilderReturn.Replace(CommonConstants.CONST_ENTITY_PROPERTY_NAME, pPK.Name); wBuilderReturn.Replace(CommonConstants.CONST_TYPENAME, FwkGeneratorHelper.GetCSharpType(pPK)); return(wBuilderReturn.ToString()); } else { return(" wDataBase.ExecuteNonQuery(wCmd);"); } } case MethodActionType.Update: return(" wDataBase.ExecuteNonQuery(wCmd);"); case MethodActionType.SearchByParam: wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("SearchReturn").Content); return(wBuilderReturn.ToString()); case MethodActionType.Delete: return(" wDataBase.ExecuteNonQuery(wCmd);"); } return(string.Empty); }
/// <summary> /// Obtiene el seteo de parametro que se envia a un store procedure para Aplication Block, /// en forma de batch.- /// /// </summary> /// <param name="pTableName">Nombre de tabla</param> /// <param name="pColumnName">Nombre de columna</param> /// <param name="pType">Tipo de SQL Server</param> /// <param name="pLastField">indica si es el ultimo parametro</param> ///<example> /// <code> /// /// BatchCommandText.Append("@[Property_Name] = "); /// if (w[NamePattern].[Property_Name] != null) /// { /// BatchCommandText.Append(w[NamePattern].[Property_Name] == true ? "1":"0"); /// } /// else { BatchCommandText.Append("NULL"); } /// BatchCommandText.Append( ","); /// /// </code> /// </example> /// <returns>string</returns> static string Get_Property_Batch(Column c, bool pLastField) { System.Text.StringBuilder str = new System.Text.StringBuilder(); switch (c.DataType.ToString().ToUpper()) { case "BIT": str.Append(FwkGeneratorHelper.TemplateDocument.GetTemplate("SPParameterBatchBit").Content); break; case "REAL": case "NUMERIC": case "BIGINT": case "SMALLINT": case "INT": case "TINYINT": str.Append(FwkGeneratorHelper.TemplateDocument.GetTemplate("SPParameterBatchInteger").Content); break; case "MONEY": case "SMALLMONEY": case "DECIMAL": case "FLOAT": str.Append(FwkGeneratorHelper.TemplateDocument.GetTemplate("SPParameterBatchDecimal").Content); break; case "SMALLDATETIME": case "DATETIME": str.Append(FwkGeneratorHelper.TemplateDocument.GetTemplate("SPParameterBatchDateTime").Content); break; case "TEXT": case "CHAR": case "NCHAR": case "VARCHAR": case "NVARCHAR": str.Append(FwkGeneratorHelper.TemplateDocument.GetTemplate("SPParameterBatchString").Content); break; ///TODO:Ver paso de binarios por batch case "IMAGE": case "VARBINARY": case "BINARY": str.Append(FwkGeneratorHelper.TemplateDocument.GetTemplate("SPParameterBatchString").Content); break; } if (!c.Nullable) { str.Replace("[Batch_NULL_Question]", String.Empty); } else { if (FwkGeneratorHelper.GetCSharpType(c).Contains("string")) { str.Replace("[Batch_NULL_Question_string]", FwkGeneratorHelper.TemplateDocument.GetTemplate("Batch_NULL_Question").Content); } else { str.Replace("[Batch_NULL_Question]", FwkGeneratorHelper.TemplateDocument.GetTemplate("Batch_NULL_Question").Content); } } str.Replace(CommonConstants.CONST_ENTITY_PROPERTY_NAME, c.Name); if (pLastField) { str.Replace("wBatchCommandText.Append( \",\");", "wBatchCommandText.Append( \";\");"); } return(str.ToString()); }