示例#1
0
        static string GenSPParameters_Batch(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {
            StringBuilder wParams        = new StringBuilder();
            int           i              = 0;
            bool          appendProperty = true;
            Column        primaryKey     = FwkGenerator.GetPrimaryKey(pTable);

            foreach (Column c in pTable.Columns)
            {
                i++;
                if (pMethodActionType == CodeGeneratorCommon.MethodActionType.Insert ||
                    pMethodActionType == CodeGeneratorCommon.MethodActionType.Update)
                {
                    if (primaryKey != null)
                    {
                        appendProperty = !(primaryKey == c && pMethodActionType == CodeGeneratorCommon.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());
        }
示例#2
0
        /// <summary>
        /// Genera código de parámetros de llamado a un método.
        /// </summary>
        /// <param name="CodeGeneratorCommon.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(CodeGeneratorCommon.MethodActionType pMethodActionType, TableViewBase pTable)
        {
            String wBuilder = string.Empty;

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

                wBuilder = string.Concat(pTable.Name, " p", pTable.Name);
                break;

            case CodeGeneratorCommon.MethodActionType.Delete:
                Column pPK = FwkGenerator.GetPrimaryKey(pTable);
                if (pPK != null)
                {
                    FwkGenerator.GetCSharpType(pPK);
                    wBuilder = String.Concat(FwkGenerator.GetCSharpType(pPK), " p", pPK.Name);
                }
                else
                {
                    wBuilder = String.Concat("int pId");
                }

                break;
            }
            return(wBuilder);
        }
示例#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(CodeGeneratorCommon.MethodActionType pMethodActionType, TableViewBase pTable)
        {
            StringBuilder wBuilder = new StringBuilder(FwkGenerator.TemplateDocument.GetTemplate("ParameterSummary").Content);



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

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

            case CodeGeneratorCommon.MethodActionType.Delete:
                Column pPK = FwkGenerator.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());
        }
示例#4
0
        private static string GenMethodReturn(TableViewBase pTable, CodeGeneratorCommon.MethodActionType t)
        {
            StringBuilder wBuilderReturn = null;

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

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

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

            case CodeGeneratorCommon.MethodActionType.SearchByParam:

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

                return(wBuilderReturn.ToString());

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

            return(string.Empty);
        }
示例#5
0
        /// <summary>
        /// Retorno del metodo
        /// </summary>
        /// <param name="pTable"></param>
        /// <param name="pMethodActionType"></param>
        /// <returns></returns>
        static string GetRetType(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {
            String wBuilder = string.Empty;
            Column c        = FwkGenerator.GetPrimaryKey(pTable);

            switch (pMethodActionType)
            {
            case CodeGeneratorCommon.MethodActionType.Insert:

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

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

            case CodeGeneratorCommon.MethodActionType.GetByParam:
                wBuilder = pTable.Name;
                break;
            }
            return(wBuilder);
        }
示例#6
0
        static string GenSPParameters(TableViewBase pTable, CodeGeneratorCommon.MethodActionType pMethodActionType)
        {
            StringBuilder wParams = new StringBuilder();



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

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

            case CodeGeneratorCommon.MethodActionType.Delete:

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

                break;

            case CodeGeneratorCommon.MethodActionType.SearchByParam:

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

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