Ejemplo n.º 1
0
        static string GenSPParameters_Batch(Table pTable, MethodActionType pMethodActionType)
        {
            StringBuilder wParams        = new StringBuilder();
            int           i              = 0;
            bool          appendProperty = true;
            Column        primaryKey     = FwkGeneratorHelper.GetPrimaryKey(pTable);

            foreach (Column c in pTable.Columns)
            {
                i++;

                if (pMethodActionType == MethodActionType.Insert ||
                    pMethodActionType == MethodActionType.Update)
                {
                    if (primaryKey != null)
                    {
                        appendProperty = !(primaryKey == c && pMethodActionType == MethodActionType.Insert);
                    }

                    if (appendProperty)
                    {
                        //i == pTable.Columns.Count --> Fin de la coleccion
                        wParams.Append(Get_Property_Batch(c, (i == pTable.Columns.Count)));
                    }
                }
            }
            return(wParams.ToString());
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Genera comentarios sobre los parámetros de un método.
        /// </summary>
        /// <param name="pMethodInfo">información sobre el método a generar.</param>
        /// <returns>Comentarios sobre los parámetros.</returns>
        /// <author>Marcelo Oviedo</author>
        static string GenParametersSummary(MethodActionType pMethodActionType, Table pTable)
        {
            StringBuilder wBuilder = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("ParameterSummary").Content);



            switch (pMethodActionType)
            {
            case MethodActionType.Insert:
            case MethodActionType.Update:
            case MethodActionType.GetByParam:
            case MethodActionType.SearchByParam:

                wBuilder.Replace("[MethodParameterName]", pTable.Name);
                wBuilder.Replace("[ParameterName]", pTable.Name);
                break;

            case MethodActionType.Delete:
                Column pPK = FwkGeneratorHelper.GetPrimaryKey(pTable);
                if (pPK != null)
                {
                    wBuilder.Replace("[MethodParameterName]", pPK.Name);
                }
                else
                {
                    wBuilder.Replace("[MethodParameterName]", "pId");
                }
                wBuilder.Replace("[ParameterName]", string.Concat("Id por el cual realizar la busqueda de registros a eliminar de tabla ", pTable.Name));
                break;
            }
            return(wBuilder.ToString());
        }
Ejemplo n.º 4
0
        private static string GenMethodReturn(TableViewBase pTable, CodeGeneratorCommon.MethodActionType t)
        {
            StringBuilder wBuilderReturn = null;

            switch (t)
            {
            case CodeGeneratorCommon.MethodActionType.Insert:
            {
                Column pPK = FwkGeneratorHelper.GetPrimaryKey(pTable);
                if (pPK != null)
                {
                    wBuilderReturn = new StringBuilder("  cmd.ExecuteNonQuery();");
                    wBuilderReturn.AppendLine(FwkGeneratorHelper.TemplateDocument.GetTemplate("InsertReturn").Content);
                    wBuilderReturn.Replace(CodeGeneratorCommon.CommonConstants.CONST_ENTITY_PROPERTY_NAME, pPK.Name);
                    wBuilderReturn.Replace(CodeGeneratorCommon.CommonConstants.CONST_TYPENAME, FwkGeneratorHelper.GetCSharpType(pPK));

                    return(wBuilderReturn.ToString());
                }
                else
                {
                    return("  cmd.ExecuteNonQuery();");
                }
            }

            case CodeGeneratorCommon.MethodActionType.Update:
                return("  cmd.ExecuteNonQuery();");

            case CodeGeneratorCommon.MethodActionType.SearchByParam:

                wBuilderReturn = new StringBuilder(FwkGeneratorHelper.TemplateDocument.GetTemplate("SearchReturn").Content);

                return(wBuilderReturn.ToString());

            case CodeGeneratorCommon.MethodActionType.Delete:
                return("  cmd.ExecuteNonQuery();");
            }

            return(string.Empty);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Retorno del metodo
        /// </summary>
        /// <param name="pTable"></param>
        /// <param name="pMethodActionType"></param>
        /// <returns></returns>
        static string GetRetType(Table pTable, MethodActionType pMethodActionType)
        {
            String wBuilder = string.Empty;
            Column c        = FwkGeneratorHelper.GetPrimaryKey(pTable);

            switch (pMethodActionType)
            {
            case MethodActionType.Insert:

            case MethodActionType.Update:
            case MethodActionType.Delete:
                wBuilder = "void";
                break;

            case MethodActionType.SearchByParam:
                wBuilder = string.Concat(pTable.Name, "List");
                break;

            case MethodActionType.GetByParam:
                wBuilder = pTable.Name;
                break;
            }
            return(wBuilder);
        }
Ejemplo n.º 6
0
        static string GenSPParameters(Table pTable, MethodActionType pMethodActionType)
        {
            StringBuilder wParams = new StringBuilder();



            switch (pMethodActionType)
            {
            case MethodActionType.Insert:
                foreach (Column c in pTable.Columns)
                {
                    if (!FwkGeneratorHelper.NotSupportTypes_ToIncludeInBackEnd.Contains(c.DataType.SqlDataType.ToString().ToLower()))
                    {
                        if (c.InPrimaryKey)
                        {
                            wParams.Append(GetOutParameter(pTable, c));
                        }
                        else
                        {
                            wParams.Append(GetInParameter(pTable, c));
                        }
                    }
                }
                break;

            case MethodActionType.Update:
                foreach (Column c in pTable.Columns)
                {
                    if (!FwkGeneratorHelper.NotSupportTypes_ToIncludeInBackEnd.Contains(c.DataType.SqlDataType.ToString().ToLower()))
                    {
                        wParams.Append(GetInParameter(pTable, c));
                    }
                }
                break;

            case MethodActionType.Delete:

                Column cPK = FwkGeneratorHelper.GetPrimaryKey(pTable);
                if (cPK != null)
                {
                    wParams.Append(GetInParameter(cPK.Name, FwkGeneratorHelper.GetDBType(cPK)));
                }
                else
                {
                    wParams.Append(GetInParameter("Id", "System.Data.DbType.Int32"));
                }

                break;

            case MethodActionType.SearchByParam:

                foreach (Column c in pTable.Columns)
                {
                    if (FwkGeneratorHelper.GeColumnFindeable(c))
                    {
                        wParams.Append(GetInParameter(pTable, c));
                    }
                }
                break;

            case MethodActionType.Get:
                wParams.Append(string.Empty);
                break;
            }
            return(wParams.ToString());
        }